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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c02aea9db26430300b8826b8bb7d0865ac82d8f7 | junyanl-code/Luminary-Micro-Library | boards/ek-lm3s9d90/usb_dev_chidcdc/usb_dev_mouse.c | [
"BSD-3-Clause"
] | C | MouseHandler | null | unsigned long
MouseHandler(void *pvCBData, unsigned long ulEvent,
unsigned long ulMsgData, void *pvMsgData)
{
switch(ulEvent)
{
//
// The USB host has connected to and configured the device.
//
case USB_EVENT_CONNECTED:
{
g_eMouseState = MOUSE_STATE_IDLE;
HWREGBITW(&g_ulFlags, FLAG_CONNECTED) = 1;
break;
}
//
// The USB host has disconnected from the device.
//
case USB_EVENT_DISCONNECTED:
{
HWREGBITW(&g_ulFlags, FLAG_CONNECTED) = 0;
g_eMouseState = MOUSE_STATE_UNCONFIGURED;
break;
}
//
// A report was sent to the host. We are not free to send another.
//
case USB_EVENT_TX_COMPLETE:
{
g_eMouseState = MOUSE_STATE_IDLE;
break;
}
}
return(0);
} | //****************************************************************************
//
// This function handles notification messages from the mouse device driver.
//
//****************************************************************************
| This function handles notification messages from the mouse device driver. | [
"This",
"function",
"handles",
"notification",
"messages",
"from",
"the",
"mouse",
"device",
"driver",
"."
] | unsigned long
MouseHandler(void *pvCBData, unsigned long ulEvent,
unsigned long ulMsgData, void *pvMsgData)
{
switch(ulEvent)
{
case USB_EVENT_CONNECTED:
{
g_eMouseState = MOUSE_STATE_IDLE;
HWREGBITW(&g_ulFlags, FLAG_CONNECTED) = 1;
break;
}
case USB_EVENT_DISCONNECTED:
{
HWREGBITW(&g_ulFlags, FLAG_CONNECTED) = 0;
g_eMouseState = MOUSE_STATE_UNCONFIGURED;
break;
}
case USB_EVENT_TX_COMPLETE:
{
g_eMouseState = MOUSE_STATE_IDLE;
break;
}
}
return(0);
} | [
"unsigned",
"long",
"MouseHandler",
"(",
"void",
"*",
"pvCBData",
",",
"unsigned",
"long",
"ulEvent",
",",
"unsigned",
"long",
"ulMsgData",
",",
"void",
"*",
"pvMsgData",
")",
"{",
"switch",
"(",
"ulEvent",
")",
"{",
"case",
"USB_EVENT_CONNECTED",
":",
"{",
"g_eMouseState",
"=",
"MOUSE_STATE_IDLE",
";",
"HWREGBITW",
"(",
"&",
"g_ulFlags",
",",
"FLAG_CONNECTED",
")",
"=",
"1",
";",
"break",
";",
"}",
"case",
"USB_EVENT_DISCONNECTED",
":",
"{",
"HWREGBITW",
"(",
"&",
"g_ulFlags",
",",
"FLAG_CONNECTED",
")",
"=",
"0",
";",
"g_eMouseState",
"=",
"MOUSE_STATE_UNCONFIGURED",
";",
"break",
";",
"}",
"case",
"USB_EVENT_TX_COMPLETE",
":",
"{",
"g_eMouseState",
"=",
"MOUSE_STATE_IDLE",
";",
"break",
";",
"}",
"}",
"return",
"(",
"0",
")",
";",
"}"
] | This function handles notification messages from the mouse device driver. | [
"This",
"function",
"handles",
"notification",
"messages",
"from",
"the",
"mouse",
"device",
"driver",
"."
] | [
"//\r",
"// The USB host has connected to and configured the device.\r",
"//\r",
"//\r",
"// The USB host has disconnected from the device.\r",
"//\r",
"//\r",
"// A report was sent to the host. We are not free to send another.\r",
"//\r"
] | [
{
"param": "pvCBData",
"type": "void"
},
{
"param": "ulEvent",
"type": "unsigned long"
},
{
"param": "ulMsgData",
"type": "unsigned long"
},
{
"param": "pvMsgData",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pvCBData",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ulEvent",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ulMsgData",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pvMsgData",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c02aea9db26430300b8826b8bb7d0865ac82d8f7 | junyanl-code/Luminary-Micro-Library | boards/ek-lm3s9d90/usb_dev_chidcdc/usb_dev_mouse.c | [
"BSD-3-Clause"
] | C | WaitForSendIdle | tBoolean | tBoolean
WaitForSendIdle(unsigned long ulTimeoutTicks)
{
unsigned long ulStart;
unsigned long ulNow;
unsigned long ulElapsed;
ulStart = g_ulSysTickCount;
ulElapsed = 0;
while(ulElapsed < ulTimeoutTicks)
{
//
// Is the mouse is idle, return immediately.
//
if(g_eMouseState == MOUSE_STATE_IDLE)
{
return(true);
}
//
// Determine how much time has elapsed since we started waiting. This
// should be safe across a wrap of g_ulSysTickCount.
//
ulNow = g_ulSysTickCount;
ulElapsed = ((ulStart < ulNow) ? (ulNow - ulStart) :
(((unsigned long)0xFFFFFFFF - ulStart) + ulNow + 1));
}
//
// If we get here, we timed out so return a bad return code to let the
// caller know.
//
return(false);
} | //***************************************************************************
//
// Wait for a period of time for the state to become idle.
//
// \param ulTimeoutTick is the number of system ticks to wait before
// declaring a timeout and returning \b false.
//
// This function polls the current keyboard state for ulTimeoutTicks system
// ticks waiting for it to become idle. If the state becomes idle, the
// function returns true. If it ulTimeoutTicks occur prior to the state
// becoming idle, false is returned to indicate a timeout.
//
// \return Returns \b true on success or \b false on timeout.
//
//***************************************************************************
| Wait for a period of time for the state to become idle.
\param ulTimeoutTick is the number of system ticks to wait before
declaring a timeout and returning \b false.
This function polls the current keyboard state for ulTimeoutTicks system
ticks waiting for it to become idle. If the state becomes idle, the
function returns true. If it ulTimeoutTicks occur prior to the state
becoming idle, false is returned to indicate a timeout.
\return Returns \b true on success or \b false on timeout. | [
"Wait",
"for",
"a",
"period",
"of",
"time",
"for",
"the",
"state",
"to",
"become",
"idle",
".",
"\\",
"param",
"ulTimeoutTick",
"is",
"the",
"number",
"of",
"system",
"ticks",
"to",
"wait",
"before",
"declaring",
"a",
"timeout",
"and",
"returning",
"\\",
"b",
"false",
".",
"This",
"function",
"polls",
"the",
"current",
"keyboard",
"state",
"for",
"ulTimeoutTicks",
"system",
"ticks",
"waiting",
"for",
"it",
"to",
"become",
"idle",
".",
"If",
"the",
"state",
"becomes",
"idle",
"the",
"function",
"returns",
"true",
".",
"If",
"it",
"ulTimeoutTicks",
"occur",
"prior",
"to",
"the",
"state",
"becoming",
"idle",
"false",
"is",
"returned",
"to",
"indicate",
"a",
"timeout",
".",
"\\",
"return",
"Returns",
"\\",
"b",
"true",
"on",
"success",
"or",
"\\",
"b",
"false",
"on",
"timeout",
"."
] | tBoolean
WaitForSendIdle(unsigned long ulTimeoutTicks)
{
unsigned long ulStart;
unsigned long ulNow;
unsigned long ulElapsed;
ulStart = g_ulSysTickCount;
ulElapsed = 0;
while(ulElapsed < ulTimeoutTicks)
{
if(g_eMouseState == MOUSE_STATE_IDLE)
{
return(true);
}
ulNow = g_ulSysTickCount;
ulElapsed = ((ulStart < ulNow) ? (ulNow - ulStart) :
(((unsigned long)0xFFFFFFFF - ulStart) + ulNow + 1));
}
return(false);
} | [
"tBoolean",
"WaitForSendIdle",
"(",
"unsigned",
"long",
"ulTimeoutTicks",
")",
"{",
"unsigned",
"long",
"ulStart",
";",
"unsigned",
"long",
"ulNow",
";",
"unsigned",
"long",
"ulElapsed",
";",
"ulStart",
"=",
"g_ulSysTickCount",
";",
"ulElapsed",
"=",
"0",
";",
"while",
"(",
"ulElapsed",
"<",
"ulTimeoutTicks",
")",
"{",
"if",
"(",
"g_eMouseState",
"==",
"MOUSE_STATE_IDLE",
")",
"{",
"return",
"(",
"true",
")",
";",
"}",
"ulNow",
"=",
"g_ulSysTickCount",
";",
"ulElapsed",
"=",
"(",
"(",
"ulStart",
"<",
"ulNow",
")",
"?",
"(",
"ulNow",
"-",
"ulStart",
")",
":",
"(",
"(",
"(",
"unsigned",
"long",
")",
"0xFFFFFFFF",
"-",
"ulStart",
")",
"+",
"ulNow",
"+",
"1",
")",
")",
";",
"}",
"return",
"(",
"false",
")",
";",
"}"
] | Wait for a period of time for the state to become idle. | [
"Wait",
"for",
"a",
"period",
"of",
"time",
"for",
"the",
"state",
"to",
"become",
"idle",
"."
] | [
"//\r",
"// Is the mouse is idle, return immediately.\r",
"//\r",
"//\r",
"// Determine how much time has elapsed since we started waiting. This\r",
"// should be safe across a wrap of g_ulSysTickCount.\r",
"//\r",
"//\r",
"// If we get here, we timed out so return a bad return code to let the\r",
"// caller know.\r",
"//\r"
] | [
{
"param": "ulTimeoutTicks",
"type": "unsigned long"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ulTimeoutTicks",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c02aea9db26430300b8826b8bb7d0865ac82d8f7 | junyanl-code/Luminary-Micro-Library | boards/ek-lm3s9d90/usb_dev_chidcdc/usb_dev_mouse.c | [
"BSD-3-Clause"
] | C | MoveHandler | void | void
MoveHandler(void)
{
unsigned long ulRetcode;
char cDeltaX, cDeltaY;
//
// Allow the mouse to be still if requested.
//
if(HWREGBITW(&g_ulFlags, FLAG_MOVE_MOUSE) == 0)
{
return;
}
//
// Determine the direction to move the mouse.
//
ulRetcode = g_ulSysTickCount % (4 * SYSTICKS_PER_SECOND);
if(ulRetcode < SYSTICKS_PER_SECOND)
{
cDeltaX = MOUSE_MOVE_INC;
cDeltaY = 0;
}
else if(ulRetcode < (2 * SYSTICKS_PER_SECOND))
{
cDeltaX = 0;
cDeltaY = MOUSE_MOVE_INC;
}
else if(ulRetcode < (3 * SYSTICKS_PER_SECOND))
{
cDeltaX = (char)MOUSE_MOVE_DEC;
cDeltaY = 0;
}
else
{
cDeltaX = 0;
cDeltaY = (char)MOUSE_MOVE_DEC;
}
//
// Tell the HID driver to send this new report.
//
g_eMouseState = MOUSE_STATE_SENDING;
ulRetcode = USBDHIDMouseStateChange((void *)&g_sMouseDevice, cDeltaX,
cDeltaY, 0);
//
// Did we schedule the report for transmission?
//
if(ulRetcode == MOUSE_SUCCESS)
{
//
// Wait for the host to acknowledge the transmission if all went well.
//
if(!WaitForSendIdle(MAX_SEND_DELAY))
{
//
// The transmission failed, so assume the host disconnected and go
// back to waiting for a new connection.
//
HWREGBITW(&g_ulFlags, FLAG_CONNECTED) = 0;
}
}
} | //****************************************************************************
//
// This function provides simulated movements of the mouse.
//
//****************************************************************************
| This function provides simulated movements of the mouse. | [
"This",
"function",
"provides",
"simulated",
"movements",
"of",
"the",
"mouse",
"."
] | void
MoveHandler(void)
{
unsigned long ulRetcode;
char cDeltaX, cDeltaY;
if(HWREGBITW(&g_ulFlags, FLAG_MOVE_MOUSE) == 0)
{
return;
}
ulRetcode = g_ulSysTickCount % (4 * SYSTICKS_PER_SECOND);
if(ulRetcode < SYSTICKS_PER_SECOND)
{
cDeltaX = MOUSE_MOVE_INC;
cDeltaY = 0;
}
else if(ulRetcode < (2 * SYSTICKS_PER_SECOND))
{
cDeltaX = 0;
cDeltaY = MOUSE_MOVE_INC;
}
else if(ulRetcode < (3 * SYSTICKS_PER_SECOND))
{
cDeltaX = (char)MOUSE_MOVE_DEC;
cDeltaY = 0;
}
else
{
cDeltaX = 0;
cDeltaY = (char)MOUSE_MOVE_DEC;
}
g_eMouseState = MOUSE_STATE_SENDING;
ulRetcode = USBDHIDMouseStateChange((void *)&g_sMouseDevice, cDeltaX,
cDeltaY, 0);
if(ulRetcode == MOUSE_SUCCESS)
{
if(!WaitForSendIdle(MAX_SEND_DELAY))
{
HWREGBITW(&g_ulFlags, FLAG_CONNECTED) = 0;
}
}
} | [
"void",
"MoveHandler",
"(",
"void",
")",
"{",
"unsigned",
"long",
"ulRetcode",
";",
"char",
"cDeltaX",
",",
"cDeltaY",
";",
"if",
"(",
"HWREGBITW",
"(",
"&",
"g_ulFlags",
",",
"FLAG_MOVE_MOUSE",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"ulRetcode",
"=",
"g_ulSysTickCount",
"%",
"(",
"4",
"*",
"SYSTICKS_PER_SECOND",
")",
";",
"if",
"(",
"ulRetcode",
"<",
"SYSTICKS_PER_SECOND",
")",
"{",
"cDeltaX",
"=",
"MOUSE_MOVE_INC",
";",
"cDeltaY",
"=",
"0",
";",
"}",
"else",
"if",
"(",
"ulRetcode",
"<",
"(",
"2",
"*",
"SYSTICKS_PER_SECOND",
")",
")",
"{",
"cDeltaX",
"=",
"0",
";",
"cDeltaY",
"=",
"MOUSE_MOVE_INC",
";",
"}",
"else",
"if",
"(",
"ulRetcode",
"<",
"(",
"3",
"*",
"SYSTICKS_PER_SECOND",
")",
")",
"{",
"cDeltaX",
"=",
"(",
"char",
")",
"MOUSE_MOVE_DEC",
";",
"cDeltaY",
"=",
"0",
";",
"}",
"else",
"{",
"cDeltaX",
"=",
"0",
";",
"cDeltaY",
"=",
"(",
"char",
")",
"MOUSE_MOVE_DEC",
";",
"}",
"g_eMouseState",
"=",
"MOUSE_STATE_SENDING",
";",
"ulRetcode",
"=",
"USBDHIDMouseStateChange",
"(",
"(",
"void",
"*",
")",
"&",
"g_sMouseDevice",
",",
"cDeltaX",
",",
"cDeltaY",
",",
"0",
")",
";",
"if",
"(",
"ulRetcode",
"==",
"MOUSE_SUCCESS",
")",
"{",
"if",
"(",
"!",
"WaitForSendIdle",
"(",
"MAX_SEND_DELAY",
")",
")",
"{",
"HWREGBITW",
"(",
"&",
"g_ulFlags",
",",
"FLAG_CONNECTED",
")",
"=",
"0",
";",
"}",
"}",
"}"
] | This function provides simulated movements of the mouse. | [
"This",
"function",
"provides",
"simulated",
"movements",
"of",
"the",
"mouse",
"."
] | [
"//\r",
"// Allow the mouse to be still if requested.\r",
"//\r",
"//\r",
"// Determine the direction to move the mouse.\r",
"//\r",
"//\r",
"// Tell the HID driver to send this new report.\r",
"//\r",
"//\r",
"// Did we schedule the report for transmission?\r",
"//\r",
"//\r",
"// Wait for the host to acknowledge the transmission if all went well.\r",
"//\r",
"//\r",
"// The transmission failed, so assume the host disconnected and go\r",
"// back to waiting for a new connection.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
c02aea9db26430300b8826b8bb7d0865ac82d8f7 | junyanl-code/Luminary-Micro-Library | boards/ek-lm3s9d90/usb_dev_chidcdc/usb_dev_mouse.c | [
"BSD-3-Clause"
] | C | MouseMain | void | void
MouseMain(void)
{
//
// Now keep processing the mouse as long as the host is connected.
//
if(HWREGBITW(&g_ulFlags, FLAG_CONNECTED) == 1)
{
//
// If it is time to move the mouse then do so.
//
if(HWREGBITW(&g_ulFlags, FLAG_MOVE_UPDATE) == 1)
{
HWREGBITW(&g_ulFlags, FLAG_MOVE_UPDATE) = 0;
MoveHandler();
}
}
} | //****************************************************************************
//
// This is the main loop that runs the application.
//
//****************************************************************************
| This is the main loop that runs the application. | [
"This",
"is",
"the",
"main",
"loop",
"that",
"runs",
"the",
"application",
"."
] | void
MouseMain(void)
{
if(HWREGBITW(&g_ulFlags, FLAG_CONNECTED) == 1)
{
if(HWREGBITW(&g_ulFlags, FLAG_MOVE_UPDATE) == 1)
{
HWREGBITW(&g_ulFlags, FLAG_MOVE_UPDATE) = 0;
MoveHandler();
}
}
} | [
"void",
"MouseMain",
"(",
"void",
")",
"{",
"if",
"(",
"HWREGBITW",
"(",
"&",
"g_ulFlags",
",",
"FLAG_CONNECTED",
")",
"==",
"1",
")",
"{",
"if",
"(",
"HWREGBITW",
"(",
"&",
"g_ulFlags",
",",
"FLAG_MOVE_UPDATE",
")",
"==",
"1",
")",
"{",
"HWREGBITW",
"(",
"&",
"g_ulFlags",
",",
"FLAG_MOVE_UPDATE",
")",
"=",
"0",
";",
"MoveHandler",
"(",
")",
";",
"}",
"}",
"}"
] | This is the main loop that runs the application. | [
"This",
"is",
"the",
"main",
"loop",
"that",
"runs",
"the",
"application",
"."
] | [
"//\r",
"// Now keep processing the mouse as long as the host is connected.\r",
"//\r",
"//\r",
"// If it is time to move the mouse then do so.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0e8a3973131d932a2ecb9701c37e512ee9fb8731 | junyanl-code/Luminary-Micro-Library | boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bt_a2dp.c | [
"BSD-3-Clause"
] | C | ToggleLED | void | static void
ToggleLED(unsigned long ulLEDPin)
{
ROM_GPIOPinWrite(LED_PORT, ulLEDPin, ~ROM_GPIOPinRead(LED_PORT, ulLEDPin));
} | //*****************************************************************************
//
// The following function toggles the state of specified LED.
//
//*****************************************************************************
| The following function toggles the state of specified LED. | [
"The",
"following",
"function",
"toggles",
"the",
"state",
"of",
"specified",
"LED",
"."
] | static void
ToggleLED(unsigned long ulLEDPin)
{
ROM_GPIOPinWrite(LED_PORT, ulLEDPin, ~ROM_GPIOPinRead(LED_PORT, ulLEDPin));
} | [
"static",
"void",
"ToggleLED",
"(",
"unsigned",
"long",
"ulLEDPin",
")",
"{",
"ROM_GPIOPinWrite",
"(",
"LED_PORT",
",",
"ulLEDPin",
",",
"~",
"ROM_GPIOPinRead",
"(",
"LED_PORT",
",",
"ulLEDPin",
")",
")",
";",
"}"
] | The following function toggles the state of specified LED. | [
"The",
"following",
"function",
"toggles",
"the",
"state",
"of",
"specified",
"LED",
"."
] | [] | [
{
"param": "ulLEDPin",
"type": "unsigned long"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ulLEDPin",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0e8a3973131d932a2ecb9701c37e512ee9fb8731 | junyanl-code/Luminary-Micro-Library | boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bt_a2dp.c | [
"BSD-3-Clause"
] | C | UserSwitchPressed | tBoolean | static tBoolean
UserSwitchPressed(void)
{
//
// Button GPIO reads as 0 when pressed so invert the logic sense when
// returning the value.
//
return(!ROM_GPIOPinRead(USER_BUTTON_PORT, USER_BUTTON_PIN));
} | //*****************************************************************************
//
// The following function is used to check the state of the User Button. The
// function returns TRUE if the button is depressed and FALSE if it is
// released.
//
//*****************************************************************************
| The following function is used to check the state of the User Button. The
function returns TRUE if the button is depressed and FALSE if it is
released. | [
"The",
"following",
"function",
"is",
"used",
"to",
"check",
"the",
"state",
"of",
"the",
"User",
"Button",
".",
"The",
"function",
"returns",
"TRUE",
"if",
"the",
"button",
"is",
"depressed",
"and",
"FALSE",
"if",
"it",
"is",
"released",
"."
] | static tBoolean
UserSwitchPressed(void)
{
return(!ROM_GPIOPinRead(USER_BUTTON_PORT, USER_BUTTON_PIN));
} | [
"static",
"tBoolean",
"UserSwitchPressed",
"(",
"void",
")",
"{",
"return",
"(",
"!",
"ROM_GPIOPinRead",
"(",
"USER_BUTTON_PORT",
",",
"USER_BUTTON_PIN",
")",
")",
";",
"}"
] | The following function is used to check the state of the User Button. | [
"The",
"following",
"function",
"is",
"used",
"to",
"check",
"the",
"state",
"of",
"the",
"User",
"Button",
"."
] | [
"//\r",
"// Button GPIO reads as 0 when pressed so invert the logic sense when\r",
"// returning the value.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0e8a3973131d932a2ecb9701c37e512ee9fb8731 | junyanl-code/Luminary-Micro-Library | boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bt_a2dp.c | [
"BSD-3-Clause"
] | C | BD_ADDRToStr | void | static void
BD_ADDRToStr(unsigned char *pucBoard_Address, char *pcBoardStr)
{
unsigned int uIdx;
usprintf(pcBoardStr, "0x");
for(uIdx = 0; uIdx < 6; uIdx++)
{
pcBoardStr += 2;
usprintf(pcBoardStr, "%02X", pucBoard_Address[uIdx]);
}
} | //*****************************************************************************
//
// Function to format the BD_ADDR as a string.
//
//*****************************************************************************
| Function to format the BD_ADDR as a string. | [
"Function",
"to",
"format",
"the",
"BD_ADDR",
"as",
"a",
"string",
"."
] | static void
BD_ADDRToStr(unsigned char *pucBoard_Address, char *pcBoardStr)
{
unsigned int uIdx;
usprintf(pcBoardStr, "0x");
for(uIdx = 0; uIdx < 6; uIdx++)
{
pcBoardStr += 2;
usprintf(pcBoardStr, "%02X", pucBoard_Address[uIdx]);
}
} | [
"static",
"void",
"BD_ADDRToStr",
"(",
"unsigned",
"char",
"*",
"pucBoard_Address",
",",
"char",
"*",
"pcBoardStr",
")",
"{",
"unsigned",
"int",
"uIdx",
";",
"usprintf",
"(",
"pcBoardStr",
",",
"\"",
"\"",
")",
";",
"for",
"(",
"uIdx",
"=",
"0",
";",
"uIdx",
"<",
"6",
";",
"uIdx",
"++",
")",
"{",
"pcBoardStr",
"+=",
"2",
";",
"usprintf",
"(",
"pcBoardStr",
",",
"\"",
"\"",
",",
"pucBoard_Address",
"[",
"uIdx",
"]",
")",
";",
"}",
"}"
] | Function to format the BD_ADDR as a string. | [
"Function",
"to",
"format",
"the",
"BD_ADDR",
"as",
"a",
"string",
"."
] | [] | [
{
"param": "pucBoard_Address",
"type": "unsigned char"
},
{
"param": "pcBoardStr",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pucBoard_Address",
"type": "unsigned char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pcBoardStr",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0e8a3973131d932a2ecb9701c37e512ee9fb8731 | junyanl-code/Luminary-Micro-Library | boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bt_a2dp.c | [
"BSD-3-Clause"
] | C | BluetoothCallbackFunction | void | static void
BluetoothCallbackFunction(tCallbackEventData *pCallbackData,
void *pCallbackParameter)
{
//
// Verify that the parameters pass in appear valid.
//
if(pCallbackData)
{
//
// Process each Callback Event.
//
switch(pCallbackData->sEvent)
{
//
// Handle PIN code request
//
case cePinCodeRequest:
{
Display(("cePinCodeRequest\r\n"));
PinCodeResponse(pCallbackData->ucRemoteDevice, 4,
DEFAULT_PIN_CODE);
break;
}
//
// Handle completion of authentication
//
case ceAuthenticationComplete:
{
Display(("ceAuthenticationComplete\r\n"));
break;
}
//
// Handle failure of authentication
//
case ceAuthenticationFailure:
{
Display(("ceAuthenticationFailure\r\n"));
break;
}
//
// Handle opening of endpoint. Notify user of connection.
//
case ceAudioEndpointOpen:
{
Display(("ceAudioEndpointOpen\r\n"));
//
// Flag that we are now connected.
//
g_bAudioConnected = true;
//
// Flag that the Audio is not currently playing.
//
g_bStreamStarted = false;
//
// Set the Audio State to indicate that we need to prepare to
// receive audio data.
//
UpdateStatusBox("Connected... Paused");
break;
}
//
// Handle closing of endpoint. Notify user there is no more
// connection.
//
case ceAudioEndpointClose:
{
Display(("ceAudioEndpointClose\r\n"));
//
// Flag that we are no longer connected.
//
g_bAudioConnected = false;
//
// Flag that the Audio is NOT currently playing.
//
g_bStreamStarted = false;
//
// Set the audio State back to Stopping. This will allow any
// queued audio data to be consumed.
//
UpdateStatusBox("Waiting for Connection...");
break;
}
//
// Handle start of audio stream. Notify user that a stream is
// playing.
//
case ceAudioStreamStart:
{
Display(("ceAudioStreamStart\r\n"));
//
// Flag that the Audio is currently playing.
//
g_bStreamStarted = true;
UpdateStatusBox("Connected... Playing");
break;
}
//
// Handle suspension of audio stream. Notify user that the stream
// is paused.
//
case ceAudioStreamSuspend:
{
Display(("ceAudioStreamSuspend\r\n"));
//
// Flag that the Audio is NOT currently playing.
//
g_bStreamStarted = false;
UpdateStatusBox("Connected... Paused");
break;
}
//
// Handle opening of control connection.
//
case ceRemoteControlConnectionOpen:
{
Display(("ceRemoteControlConnectionOpen\r\n"));
//
// Flag that the Remote is connected.
//
g_bRemoteConnected = true;
break;
}
//
// Handle closing of control connection.
//
case ceRemoteControlConnectionClose:
{
Display(("ceRemoteControlConnectionClose\r\n"));
//
// Flag that the Remote is no longer connected.
//
g_bRemoteConnected = false;
break;
}
}
}
} | //*****************************************************************************
//
// The following function is called when various Bluetooth Events occur. The
// function passes a Callback Event Data Structure and a Callback Parameter.
// The Callback parameter is a user definable value that was passed to the
// InitializeBluetooth function. For this application, this value is not used.
//
//*****************************************************************************
| The following function is called when various Bluetooth Events occur. The
function passes a Callback Event Data Structure and a Callback Parameter.
The Callback parameter is a user definable value that was passed to the
InitializeBluetooth function. For this application, this value is not used. | [
"The",
"following",
"function",
"is",
"called",
"when",
"various",
"Bluetooth",
"Events",
"occur",
".",
"The",
"function",
"passes",
"a",
"Callback",
"Event",
"Data",
"Structure",
"and",
"a",
"Callback",
"Parameter",
".",
"The",
"Callback",
"parameter",
"is",
"a",
"user",
"definable",
"value",
"that",
"was",
"passed",
"to",
"the",
"InitializeBluetooth",
"function",
".",
"For",
"this",
"application",
"this",
"value",
"is",
"not",
"used",
"."
] | static void
BluetoothCallbackFunction(tCallbackEventData *pCallbackData,
void *pCallbackParameter)
{
if(pCallbackData)
{
switch(pCallbackData->sEvent)
{
case cePinCodeRequest:
{
Display(("cePinCodeRequest\r\n"));
PinCodeResponse(pCallbackData->ucRemoteDevice, 4,
DEFAULT_PIN_CODE);
break;
}
case ceAuthenticationComplete:
{
Display(("ceAuthenticationComplete\r\n"));
break;
}
case ceAuthenticationFailure:
{
Display(("ceAuthenticationFailure\r\n"));
break;
}
case ceAudioEndpointOpen:
{
Display(("ceAudioEndpointOpen\r\n"));
g_bAudioConnected = true;
g_bStreamStarted = false;
UpdateStatusBox("Connected... Paused");
break;
}
case ceAudioEndpointClose:
{
Display(("ceAudioEndpointClose\r\n"));
g_bAudioConnected = false;
g_bStreamStarted = false;
UpdateStatusBox("Waiting for Connection...");
break;
}
case ceAudioStreamStart:
{
Display(("ceAudioStreamStart\r\n"));
g_bStreamStarted = true;
UpdateStatusBox("Connected... Playing");
break;
}
case ceAudioStreamSuspend:
{
Display(("ceAudioStreamSuspend\r\n"));
g_bStreamStarted = false;
UpdateStatusBox("Connected... Paused");
break;
}
case ceRemoteControlConnectionOpen:
{
Display(("ceRemoteControlConnectionOpen\r\n"));
g_bRemoteConnected = true;
break;
}
case ceRemoteControlConnectionClose:
{
Display(("ceRemoteControlConnectionClose\r\n"));
g_bRemoteConnected = false;
break;
}
}
}
} | [
"static",
"void",
"BluetoothCallbackFunction",
"(",
"tCallbackEventData",
"*",
"pCallbackData",
",",
"void",
"*",
"pCallbackParameter",
")",
"{",
"if",
"(",
"pCallbackData",
")",
"{",
"switch",
"(",
"pCallbackData",
"->",
"sEvent",
")",
"{",
"case",
"cePinCodeRequest",
":",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
")",
";",
"PinCodeResponse",
"(",
"pCallbackData",
"->",
"ucRemoteDevice",
",",
"4",
",",
"DEFAULT_PIN_CODE",
")",
";",
"break",
";",
"}",
"case",
"ceAuthenticationComplete",
":",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
")",
";",
"break",
";",
"}",
"case",
"ceAuthenticationFailure",
":",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
")",
";",
"break",
";",
"}",
"case",
"ceAudioEndpointOpen",
":",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
")",
";",
"g_bAudioConnected",
"=",
"true",
";",
"g_bStreamStarted",
"=",
"false",
";",
"UpdateStatusBox",
"(",
"\"",
"\"",
")",
";",
"break",
";",
"}",
"case",
"ceAudioEndpointClose",
":",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
")",
";",
"g_bAudioConnected",
"=",
"false",
";",
"g_bStreamStarted",
"=",
"false",
";",
"UpdateStatusBox",
"(",
"\"",
"\"",
")",
";",
"break",
";",
"}",
"case",
"ceAudioStreamStart",
":",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
")",
";",
"g_bStreamStarted",
"=",
"true",
";",
"UpdateStatusBox",
"(",
"\"",
"\"",
")",
";",
"break",
";",
"}",
"case",
"ceAudioStreamSuspend",
":",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
")",
";",
"g_bStreamStarted",
"=",
"false",
";",
"UpdateStatusBox",
"(",
"\"",
"\"",
")",
";",
"break",
";",
"}",
"case",
"ceRemoteControlConnectionOpen",
":",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
")",
";",
"g_bRemoteConnected",
"=",
"true",
";",
"break",
";",
"}",
"case",
"ceRemoteControlConnectionClose",
":",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
")",
";",
"g_bRemoteConnected",
"=",
"false",
";",
"break",
";",
"}",
"}",
"}",
"}"
] | The following function is called when various Bluetooth Events occur. | [
"The",
"following",
"function",
"is",
"called",
"when",
"various",
"Bluetooth",
"Events",
"occur",
"."
] | [
"//\r",
"// Verify that the parameters pass in appear valid.\r",
"//\r",
"//\r",
"// Process each Callback Event.\r",
"//\r",
"//\r",
"// Handle PIN code request\r",
"//\r",
"//\r",
"// Handle completion of authentication\r",
"//\r",
"//\r",
"// Handle failure of authentication\r",
"//\r",
"//\r",
"// Handle opening of endpoint. Notify user of connection.\r",
"//\r",
"//\r",
"// Flag that we are now connected.\r",
"//\r",
"//\r",
"// Flag that the Audio is not currently playing.\r",
"//\r",
"//\r",
"// Set the Audio State to indicate that we need to prepare to\r",
"// receive audio data.\r",
"//\r",
"//\r",
"// Handle closing of endpoint. Notify user there is no more\r",
"// connection.\r",
"//\r",
"//\r",
"// Flag that we are no longer connected.\r",
"//\r",
"//\r",
"// Flag that the Audio is NOT currently playing.\r",
"//\r",
"//\r",
"// Set the audio State back to Stopping. This will allow any\r",
"// queued audio data to be consumed.\r",
"//\r",
"//\r",
"// Handle start of audio stream. Notify user that a stream is\r",
"// playing.\r",
"//\r",
"//\r",
"// Flag that the Audio is currently playing.\r",
"//\r",
"//\r",
"// Handle suspension of audio stream. Notify user that the stream\r",
"// is paused.\r",
"//\r",
"//\r",
"// Flag that the Audio is NOT currently playing.\r",
"//\r",
"//\r",
"// Handle opening of control connection.\r",
"//\r",
"//\r",
"// Flag that the Remote is connected.\r",
"//\r",
"//\r",
"// Handle closing of control connection.\r",
"//\r",
"//\r",
"// Flag that the Remote is no longer connected.\r",
"//\r"
] | [
{
"param": "pCallbackData",
"type": "tCallbackEventData"
},
{
"param": "pCallbackParameter",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pCallbackData",
"type": "tCallbackEventData",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pCallbackParameter",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0e8a3973131d932a2ecb9701c37e512ee9fb8731 | junyanl-code/Luminary-Micro-Library | boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bt_a2dp.c | [
"BSD-3-Clause"
] | C | ButtonPressCallback | void | static void
ButtonPressCallback(unsigned int ButtonPress)
{
//
// Only process if the Audio Endpoint AND the Remote is
// connected.
//
if(g_bAudioConnected && g_bRemoteConnected)
{
//
// Both connected, process the Button press.
//
switch(ButtonPress)
{
case BUTTON_PRESS_PLAY:
{
Display(("Play Pressed\r\n"));
//
// Determine if we are currently playing or are
// paused.
//
if(!g_bStreamStarted)
{
if(!SendRemoteControlCommand(rcPlay))
{
UpdateStatusBox("Connected... Playing");
g_bStreamStarted = true;
}
}
break;
}
case BUTTON_PRESS_PAUSE:
{
Display(("Pause Pressed\r\n"));
//
// Determine if we are currently playing or are
// paused.
//
if(g_bStreamStarted)
{
if(!SendRemoteControlCommand(rcPause))
{
UpdateStatusBox("Connected... Playing");
g_bStreamStarted = false;
}
}
break;
}
case BUTTON_PRESS_NEXT:
{
Display(("Next Pressed\r\n"));
SendRemoteControlCommand(rcNext);
break;
}
case BUTTON_PRESS_BACK:
{
Display(("Back Pressed\r\n"));
SendRemoteControlCommand(rcBack);
break;
}
default:
{
//
// Unknown/Unhandled button press.
//
break;
}
}
}
} | //*****************************************************************************
//
// The following is the callback function that is registered with the
// graphics module (during the InitializeGraphics() call). This function
// is called by the Graphics module when a button press occurs.
//
//*****************************************************************************
| The following is the callback function that is registered with the
graphics module (during the InitializeGraphics() call). This function
is called by the Graphics module when a button press occurs. | [
"The",
"following",
"is",
"the",
"callback",
"function",
"that",
"is",
"registered",
"with",
"the",
"graphics",
"module",
"(",
"during",
"the",
"InitializeGraphics",
"()",
"call",
")",
".",
"This",
"function",
"is",
"called",
"by",
"the",
"Graphics",
"module",
"when",
"a",
"button",
"press",
"occurs",
"."
] | static void
ButtonPressCallback(unsigned int ButtonPress)
{
if(g_bAudioConnected && g_bRemoteConnected)
{
switch(ButtonPress)
{
case BUTTON_PRESS_PLAY:
{
Display(("Play Pressed\r\n"));
if(!g_bStreamStarted)
{
if(!SendRemoteControlCommand(rcPlay))
{
UpdateStatusBox("Connected... Playing");
g_bStreamStarted = true;
}
}
break;
}
case BUTTON_PRESS_PAUSE:
{
Display(("Pause Pressed\r\n"));
if(g_bStreamStarted)
{
if(!SendRemoteControlCommand(rcPause))
{
UpdateStatusBox("Connected... Playing");
g_bStreamStarted = false;
}
}
break;
}
case BUTTON_PRESS_NEXT:
{
Display(("Next Pressed\r\n"));
SendRemoteControlCommand(rcNext);
break;
}
case BUTTON_PRESS_BACK:
{
Display(("Back Pressed\r\n"));
SendRemoteControlCommand(rcBack);
break;
}
default:
{
break;
}
}
}
} | [
"static",
"void",
"ButtonPressCallback",
"(",
"unsigned",
"int",
"ButtonPress",
")",
"{",
"if",
"(",
"g_bAudioConnected",
"&&",
"g_bRemoteConnected",
")",
"{",
"switch",
"(",
"ButtonPress",
")",
"{",
"case",
"BUTTON_PRESS_PLAY",
":",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
")",
";",
"if",
"(",
"!",
"g_bStreamStarted",
")",
"{",
"if",
"(",
"!",
"SendRemoteControlCommand",
"(",
"rcPlay",
")",
")",
"{",
"UpdateStatusBox",
"(",
"\"",
"\"",
")",
";",
"g_bStreamStarted",
"=",
"true",
";",
"}",
"}",
"break",
";",
"}",
"case",
"BUTTON_PRESS_PAUSE",
":",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
")",
";",
"if",
"(",
"g_bStreamStarted",
")",
"{",
"if",
"(",
"!",
"SendRemoteControlCommand",
"(",
"rcPause",
")",
")",
"{",
"UpdateStatusBox",
"(",
"\"",
"\"",
")",
";",
"g_bStreamStarted",
"=",
"false",
";",
"}",
"}",
"break",
";",
"}",
"case",
"BUTTON_PRESS_NEXT",
":",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
")",
";",
"SendRemoteControlCommand",
"(",
"rcNext",
")",
";",
"break",
";",
"}",
"case",
"BUTTON_PRESS_BACK",
":",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
")",
";",
"SendRemoteControlCommand",
"(",
"rcBack",
")",
";",
"break",
";",
"}",
"default",
":",
"{",
"break",
";",
"}",
"}",
"}",
"}"
] | The following is the callback function that is registered with the
graphics module (during the InitializeGraphics() call). | [
"The",
"following",
"is",
"the",
"callback",
"function",
"that",
"is",
"registered",
"with",
"the",
"graphics",
"module",
"(",
"during",
"the",
"InitializeGraphics",
"()",
"call",
")",
"."
] | [
"//\r",
"// Only process if the Audio Endpoint AND the Remote is\r",
"// connected.\r",
"//\r",
"//\r",
"// Both connected, process the Button press.\r",
"//\r",
"//\r",
"// Determine if we are currently playing or are\r",
"// paused.\r",
"//\r",
"//\r",
"// Determine if we are currently playing or are\r",
"// paused.\r",
"//\r",
"//\r",
"// Unknown/Unhandled button press.\r",
"//\r"
] | [
{
"param": "ButtonPress",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ButtonPress",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0e8a3973131d932a2ecb9701c37e512ee9fb8731 | junyanl-code/Luminary-Micro-Library | boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bt_a2dp.c | [
"BSD-3-Clause"
] | C | MainApp | void | static void
MainApp(void *pThreadParameter)
{
int iPressCount;
int iTick;
int iVolume;
int iRetVal;
tDeviceInfo sDeviceInfo;
BTPS_Initialization_t sBTPSInitialization;
//
// Set the callback function the stack can use for printing to the
// console.
//
#ifdef DEBUG_ENABLED
sBTPSInitialization.MessageOutputCallback = MessageOutputCallback;
#else
sBTPSInitialization.MessageOutputCallback = NULL;
#endif
//
// Initialize the Bluetooth stack, using no callback parameters (NULL).
//
iRetVal = InitializeBluetooth(BluetoothCallbackFunction, NULL,
&sBTPSInitialization);
//
// Initialize the Graphics Module.
//
InitializeGraphics(ButtonPressCallback);
//
// Proceed with application if there was no Bluetooth init error.
//
if(!iRetVal)
{
//
// Make the device Connectable and Discoverable and enabled Secured
// Simple Pairing.
//
SetLocalDeviceMode(CONNECTABLE_MODE | DISCOVERABLE_MODE |
PAIRABLE_SSP_MODE);
//
// Get information about our local device.
//
iRetVal = GetLocalDeviceInformation(&sDeviceInfo);
if(!iRetVal)
{
//
// Format the board address into a string, and display it on
// the console.
//
BD_ADDRToStr(sDeviceInfo.ucBDAddr, g_cBoardAddress);
Display(("Local BD_ADDR: %s\r\n", g_cBoardAddress));
//
// Display additional info about the device to the console
//
Display(("HCI Version : %s\r\n",
g_pcHCIVersionStrings[sDeviceInfo.ucHCIVersion]));
Display(("Connectable : %s\r\n",
((sDeviceInfo.sMode & CONNECTABLE_MODE) ? "Yes" : "No")));
Display(("Discoverable : %s\r\n",
((sDeviceInfo.sMode & DISCOVERABLE_MODE) ? "Yes" : "No")));
if(sDeviceInfo.sMode & (PAIRABLE_NON_SSP_MODE | PAIRABLE_SSP_MODE))
{
Display(("Pairable : Yes\r\n"));
Display(("SSP Enabled : %s\r\n",
((sDeviceInfo.sMode & PAIRABLE_SSP_MODE) ?
"Yes" : "No")));
}
else
{
Display(("Pairable : No\r\n"));
}
//
// Show message to user on the screen
//
UpdateStatusBox("Waiting for Connection...");
//
// Bluetooth should be running now. Enter a forever loop to run
// the user interface on the board screen display and process
// button presses.
//
iTick = ONE_SEC_COUNT;
iVolume = DEFAULT_POWERUP_VOLUME;
iPressCount = 0;
while(1)
{
//
// Update the screen.
//
ProcessGraphics();
//
// Wait 1/10 second.
//
BTPS_Delay(TENTH_SEC_COUNT);
//
// If one second has elapsed, toggle the LED
//
if(!(--iTick))
{
iTick = ONE_SEC_COUNT;
ToggleLED(LED_PIN);
}
//
// Check to see if the User Switch was pressed.
//
if(UserSwitchPressed())
{
//
// Count the amount of time that the button has been
// pressed.
//
iPressCount++;
}
//
// Else the user switch is not pressed
//
else
{
//
// If the button was just released, then adjust the volume.
// Decrease the volume by 10% for each button press. At
// zero, then reset it to 100%.
//
if(iPressCount)
{
iVolume = (iVolume == 0) ? 100 : iVolume - 10;
//
// Set the new volume, and display a message on the
// console
//
SoundVolumeSet(iVolume);
Display(("Press Count %d Volume %d\r\n", iPressCount,
iVolume));
iPressCount = 0;
}
}
}
}
}
//
// There was an error initializing Bluetooth
//
else
{
//
// Print an error message to the console and show a message on
// the screen
//
Display(("Bluetooth Failed to initialize: Error %d\r\n", iRetVal));
UpdateStatusBox("Failed to Initialize Bluetooth.");
//
// Enter a forever loop. Continue to update the screen, and rapidly
// blink the LED as an indication of the error state.
//
while(1)
{
ProcessGraphics();
BTPS_Delay(500);
ToggleLED(LED_PIN);
}
}
} | //*****************************************************************************
//
// The following is the Main Application Thread. It will Initialize the
// Bluetooth Stack and all used profiles.
//
//*****************************************************************************
| The following is the Main Application Thread. It will Initialize the
Bluetooth Stack and all used profiles. | [
"The",
"following",
"is",
"the",
"Main",
"Application",
"Thread",
".",
"It",
"will",
"Initialize",
"the",
"Bluetooth",
"Stack",
"and",
"all",
"used",
"profiles",
"."
] | static void
MainApp(void *pThreadParameter)
{
int iPressCount;
int iTick;
int iVolume;
int iRetVal;
tDeviceInfo sDeviceInfo;
BTPS_Initialization_t sBTPSInitialization;
#ifdef DEBUG_ENABLED
sBTPSInitialization.MessageOutputCallback = MessageOutputCallback;
#else
sBTPSInitialization.MessageOutputCallback = NULL;
#endif
iRetVal = InitializeBluetooth(BluetoothCallbackFunction, NULL,
&sBTPSInitialization);
InitializeGraphics(ButtonPressCallback);
if(!iRetVal)
{
SetLocalDeviceMode(CONNECTABLE_MODE | DISCOVERABLE_MODE |
PAIRABLE_SSP_MODE);
iRetVal = GetLocalDeviceInformation(&sDeviceInfo);
if(!iRetVal)
{
BD_ADDRToStr(sDeviceInfo.ucBDAddr, g_cBoardAddress);
Display(("Local BD_ADDR: %s\r\n", g_cBoardAddress));
Display(("HCI Version : %s\r\n",
g_pcHCIVersionStrings[sDeviceInfo.ucHCIVersion]));
Display(("Connectable : %s\r\n",
((sDeviceInfo.sMode & CONNECTABLE_MODE) ? "Yes" : "No")));
Display(("Discoverable : %s\r\n",
((sDeviceInfo.sMode & DISCOVERABLE_MODE) ? "Yes" : "No")));
if(sDeviceInfo.sMode & (PAIRABLE_NON_SSP_MODE | PAIRABLE_SSP_MODE))
{
Display(("Pairable : Yes\r\n"));
Display(("SSP Enabled : %s\r\n",
((sDeviceInfo.sMode & PAIRABLE_SSP_MODE) ?
"Yes" : "No")));
}
else
{
Display(("Pairable : No\r\n"));
}
UpdateStatusBox("Waiting for Connection...");
iTick = ONE_SEC_COUNT;
iVolume = DEFAULT_POWERUP_VOLUME;
iPressCount = 0;
while(1)
{
ProcessGraphics();
BTPS_Delay(TENTH_SEC_COUNT);
if(!(--iTick))
{
iTick = ONE_SEC_COUNT;
ToggleLED(LED_PIN);
}
if(UserSwitchPressed())
{
iPressCount++;
}
else
{
if(iPressCount)
{
iVolume = (iVolume == 0) ? 100 : iVolume - 10;
SoundVolumeSet(iVolume);
Display(("Press Count %d Volume %d\r\n", iPressCount,
iVolume));
iPressCount = 0;
}
}
}
}
}
else
{
Display(("Bluetooth Failed to initialize: Error %d\r\n", iRetVal));
UpdateStatusBox("Failed to Initialize Bluetooth.");
while(1)
{
ProcessGraphics();
BTPS_Delay(500);
ToggleLED(LED_PIN);
}
}
} | [
"static",
"void",
"MainApp",
"(",
"void",
"*",
"pThreadParameter",
")",
"{",
"int",
"iPressCount",
";",
"int",
"iTick",
";",
"int",
"iVolume",
";",
"int",
"iRetVal",
";",
"tDeviceInfo",
"sDeviceInfo",
";",
"BTPS_Initialization_t",
"sBTPSInitialization",
";",
"#ifdef",
"DEBUG_ENABLED",
"sBTPSInitialization",
".",
"MessageOutputCallback",
"=",
"MessageOutputCallback",
";",
"#else",
"sBTPSInitialization",
".",
"MessageOutputCallback",
"=",
"NULL",
";",
"#endif",
"iRetVal",
"=",
"InitializeBluetooth",
"(",
"BluetoothCallbackFunction",
",",
"NULL",
",",
"&",
"sBTPSInitialization",
")",
";",
"InitializeGraphics",
"(",
"ButtonPressCallback",
")",
";",
"if",
"(",
"!",
"iRetVal",
")",
"{",
"SetLocalDeviceMode",
"(",
"CONNECTABLE_MODE",
"|",
"DISCOVERABLE_MODE",
"|",
"PAIRABLE_SSP_MODE",
")",
";",
"iRetVal",
"=",
"GetLocalDeviceInformation",
"(",
"&",
"sDeviceInfo",
")",
";",
"if",
"(",
"!",
"iRetVal",
")",
"{",
"BD_ADDRToStr",
"(",
"sDeviceInfo",
".",
"ucBDAddr",
",",
"g_cBoardAddress",
")",
";",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"g_cBoardAddress",
")",
")",
";",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"g_pcHCIVersionStrings",
"[",
"sDeviceInfo",
".",
"ucHCIVersion",
"]",
")",
")",
";",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"(",
"(",
"sDeviceInfo",
".",
"sMode",
"&",
"CONNECTABLE_MODE",
")",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
")",
")",
";",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"(",
"(",
"sDeviceInfo",
".",
"sMode",
"&",
"DISCOVERABLE_MODE",
")",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
")",
")",
";",
"if",
"(",
"sDeviceInfo",
".",
"sMode",
"&",
"(",
"PAIRABLE_NON_SSP_MODE",
"|",
"PAIRABLE_SSP_MODE",
")",
")",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
")",
";",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"(",
"(",
"sDeviceInfo",
".",
"sMode",
"&",
"PAIRABLE_SSP_MODE",
")",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
")",
")",
";",
"}",
"else",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
")",
")",
";",
"}",
"UpdateStatusBox",
"(",
"\"",
"\"",
")",
";",
"iTick",
"=",
"ONE_SEC_COUNT",
";",
"iVolume",
"=",
"DEFAULT_POWERUP_VOLUME",
";",
"iPressCount",
"=",
"0",
";",
"while",
"(",
"1",
")",
"{",
"ProcessGraphics",
"(",
")",
";",
"BTPS_Delay",
"(",
"TENTH_SEC_COUNT",
")",
";",
"if",
"(",
"!",
"(",
"--",
"iTick",
")",
")",
"{",
"iTick",
"=",
"ONE_SEC_COUNT",
";",
"ToggleLED",
"(",
"LED_PIN",
")",
";",
"}",
"if",
"(",
"UserSwitchPressed",
"(",
")",
")",
"{",
"iPressCount",
"++",
";",
"}",
"else",
"{",
"if",
"(",
"iPressCount",
")",
"{",
"iVolume",
"=",
"(",
"iVolume",
"==",
"0",
")",
"?",
"100",
":",
"iVolume",
"-",
"10",
";",
"SoundVolumeSet",
"(",
"iVolume",
")",
";",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"iPressCount",
",",
"iVolume",
")",
")",
";",
"iPressCount",
"=",
"0",
";",
"}",
"}",
"}",
"}",
"}",
"else",
"{",
"Display",
"(",
"(",
"\"",
"\\r",
"\\n",
"\"",
",",
"iRetVal",
")",
")",
";",
"UpdateStatusBox",
"(",
"\"",
"\"",
")",
";",
"while",
"(",
"1",
")",
"{",
"ProcessGraphics",
"(",
")",
";",
"BTPS_Delay",
"(",
"500",
")",
";",
"ToggleLED",
"(",
"LED_PIN",
")",
";",
"}",
"}",
"}"
] | The following is the Main Application Thread. | [
"The",
"following",
"is",
"the",
"Main",
"Application",
"Thread",
"."
] | [
"//\r",
"// Set the callback function the stack can use for printing to the\r",
"// console.\r",
"//\r",
"//\r",
"// Initialize the Bluetooth stack, using no callback parameters (NULL).\r",
"//\r",
"//\r",
"// Initialize the Graphics Module.\r",
"//\r",
"//\r",
"// Proceed with application if there was no Bluetooth init error.\r",
"//\r",
"//\r",
"// Make the device Connectable and Discoverable and enabled Secured\r",
"// Simple Pairing.\r",
"//\r",
"//\r",
"// Get information about our local device.\r",
"//\r",
"//\r",
"// Format the board address into a string, and display it on\r",
"// the console.\r",
"//\r",
"//\r",
"// Display additional info about the device to the console\r",
"//\r",
"//\r",
"// Show message to user on the screen\r",
"//\r",
"//\r",
"// Bluetooth should be running now. Enter a forever loop to run\r",
"// the user interface on the board screen display and process\r",
"// button presses.\r",
"//\r",
"//\r",
"// Update the screen.\r",
"//\r",
"//\r",
"// Wait 1/10 second.\r",
"//\r",
"//\r",
"// If one second has elapsed, toggle the LED\r",
"//\r",
"//\r",
"// Check to see if the User Switch was pressed.\r",
"//\r",
"//\r",
"// Count the amount of time that the button has been\r",
"// pressed.\r",
"//\r",
"//\r",
"// Else the user switch is not pressed\r",
"//\r",
"//\r",
"// If the button was just released, then adjust the volume.\r",
"// Decrease the volume by 10% for each button press. At\r",
"// zero, then reset it to 100%.\r",
"//\r",
"//\r",
"// Set the new volume, and display a message on the\r",
"// console\r",
"//\r",
"//\r",
"// There was an error initializing Bluetooth\r",
"//\r",
"//\r",
"// Print an error message to the console and show a message on\r",
"// the screen\r",
"//\r",
"//\r",
"// Enter a forever loop. Continue to update the screen, and rapidly\r",
"// blink the LED as an indication of the error state.\r",
"//\r"
] | [
{
"param": "pThreadParameter",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pThreadParameter",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0e8a3973131d932a2ecb9701c37e512ee9fb8731 | junyanl-code/Luminary-Micro-Library | boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bt_a2dp.c | [
"BSD-3-Clause"
] | C | ApplicationErrorHook | void | static void
ApplicationErrorHook(xTaskHandle xCurrentTask,
signed portCHAR *pcErrorString,
portBASE_TYPE ErrorCode)
{
while(1);
} | //*****************************************************************************
//
// The following is the function that is registered with SafeRTOS to be
// called back when an error occurs.
//
//*****************************************************************************
| The following is the function that is registered with SafeRTOS to be
called back when an error occurs. | [
"The",
"following",
"is",
"the",
"function",
"that",
"is",
"registered",
"with",
"SafeRTOS",
"to",
"be",
"called",
"back",
"when",
"an",
"error",
"occurs",
"."
] | static void
ApplicationErrorHook(xTaskHandle xCurrentTask,
signed portCHAR *pcErrorString,
portBASE_TYPE ErrorCode)
{
while(1);
} | [
"static",
"void",
"ApplicationErrorHook",
"(",
"xTaskHandle",
"xCurrentTask",
",",
"signed",
"portCHAR",
"*",
"pcErrorString",
",",
"portBASE_TYPE",
"ErrorCode",
")",
"{",
"while",
"(",
"1",
")",
";",
"}"
] | The following is the function that is registered with SafeRTOS to be
called back when an error occurs. | [
"The",
"following",
"is",
"the",
"function",
"that",
"is",
"registered",
"with",
"SafeRTOS",
"to",
"be",
"called",
"back",
"when",
"an",
"error",
"occurs",
"."
] | [] | [
{
"param": "xCurrentTask",
"type": "xTaskHandle"
},
{
"param": "pcErrorString",
"type": "signed portCHAR"
},
{
"param": "ErrorCode",
"type": "portBASE_TYPE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "xCurrentTask",
"type": "xTaskHandle",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pcErrorString",
"type": "signed portCHAR",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ErrorCode",
"type": "portBASE_TYPE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0e8a3973131d932a2ecb9701c37e512ee9fb8731 | junyanl-code/Luminary-Micro-Library | boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bt_a2dp.c | [
"BSD-3-Clause"
] | C | ApplicationIdleHook | void | static void
ApplicationIdleHook(void)
{
//
// Simply call into the Bluetooth sub-system Application Idle Hook.
//
BTPS_ApplicationIdleHook();
} | //*****************************************************************************
//
// The following is the function that is registered with SafeRTOS to be
// called the SafeRTOS scheduler is Idle.
//
//*****************************************************************************
| The following is the function that is registered with SafeRTOS to be
called the SafeRTOS scheduler is Idle. | [
"The",
"following",
"is",
"the",
"function",
"that",
"is",
"registered",
"with",
"SafeRTOS",
"to",
"be",
"called",
"the",
"SafeRTOS",
"scheduler",
"is",
"Idle",
"."
] | static void
ApplicationIdleHook(void)
{
BTPS_ApplicationIdleHook();
} | [
"static",
"void",
"ApplicationIdleHook",
"(",
"void",
")",
"{",
"BTPS_ApplicationIdleHook",
"(",
")",
";",
"}"
] | The following is the function that is registered with SafeRTOS to be
called the SafeRTOS scheduler is Idle. | [
"The",
"following",
"is",
"the",
"function",
"that",
"is",
"registered",
"with",
"SafeRTOS",
"to",
"be",
"called",
"the",
"SafeRTOS",
"scheduler",
"is",
"Idle",
"."
] | [
"//\r",
"// Simply call into the Bluetooth sub-system Application Idle Hook.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0e8a3973131d932a2ecb9701c37e512ee9fb8731 | junyanl-code/Luminary-Micro-Library | boards/dk-lm3s9b96-em2-cc2560-bluetopia/bt_a2dp_safertos/bt_a2dp.c | [
"BSD-3-Clause"
] | C | ConfigureHardware | void | static void
ConfigureHardware(void)
{
//
// Set the system clock for 50 MHz.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// Enable all the GPIO ports that are used for peripherals
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
//
// Configure the pin functions for each GPIO port
//
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinConfigure(GPIO_PA2_SSI0CLK);
GPIOPinConfigure(GPIO_PA3_SSI0FSS);
GPIOPinConfigure(GPIO_PA4_SSI0RX);
GPIOPinConfigure(GPIO_PA5_SSI0TX);
GPIOPinConfigure(GPIO_PA6_USB0EPEN);
GPIOPinConfigure(GPIO_PA7_USB0PFLT);
GPIOPinConfigure(GPIO_PB2_I2C0SCL);
GPIOPinConfigure(GPIO_PB3_I2C0SDA);
GPIOPinConfigure(GPIO_PB6_I2S0TXSCK);
GPIOPinConfigure(GPIO_PB7_NMI);
GPIOPinConfigure(GPIO_PC6_U1RX);
GPIOPinConfigure(GPIO_PC7_U1TX);
GPIOPinConfigure(GPIO_PD0_I2S0RXSCK);
GPIOPinConfigure(GPIO_PD1_I2S0RXWS);
GPIOPinConfigure(GPIO_PD4_I2S0RXSD);
GPIOPinConfigure(GPIO_PD5_I2S0RXMCLK);
GPIOPinConfigure(GPIO_PE1_SSI1FSS);
GPIOPinConfigure(GPIO_PE4_I2S0TXWS);
GPIOPinConfigure(GPIO_PE5_I2S0TXSD);
GPIOPinConfigure(GPIO_PF1_I2S0TXMCLK);
GPIOPinConfigure(GPIO_PF2_LED1);
GPIOPinConfigure(GPIO_PF3_LED0);
GPIOPinConfigure(GPIO_PF4_SSI1RX);
GPIOPinConfigure(GPIO_PF5_SSI1TX);
GPIOPinConfigure(GPIO_PH4_SSI1CLK);
GPIOPinConfigure(GPIO_PJ0_I2C1SCL);
GPIOPinConfigure(GPIO_PJ1_I2C1SDA);
GPIOPinConfigure(GPIO_PJ3_U1CTS);
GPIOPinConfigure(GPIO_PJ6_U1RTS);
//
// Set up the GPIO port and pin used for the LED.
//
ROM_GPIOPinTypeGPIOOutput(LED_PORT, LED_PIN);
ROM_GPIOPinWrite(LED_PORT, LED_PIN, 0);
//
// Set up the GPIO port and pin used for the user push button.
//
ROM_GPIOPinTypeGPIOInput(USER_BUTTON_PORT, USER_BUTTON_PIN);
//
// Configure the Shutdown Pin.
//
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_4);
ROM_GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_4, 0);
#ifdef DEBUG_ENABLED
//
// Configure UART 0 to be used as the debug console port.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, (GPIO_PIN_0 | GPIO_PIN_1));
ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
#endif
//
// Turn on interrupts in the system.
//
ROM_IntMasterEnable();
} | //*****************************************************************************
//
// The following function is used to configure the hardware platform for the
// intended use.
//
//*****************************************************************************
| The following function is used to configure the hardware platform for the
intended use. | [
"The",
"following",
"function",
"is",
"used",
"to",
"configure",
"the",
"hardware",
"platform",
"for",
"the",
"intended",
"use",
"."
] | static void
ConfigureHardware(void)
{
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinConfigure(GPIO_PA2_SSI0CLK);
GPIOPinConfigure(GPIO_PA3_SSI0FSS);
GPIOPinConfigure(GPIO_PA4_SSI0RX);
GPIOPinConfigure(GPIO_PA5_SSI0TX);
GPIOPinConfigure(GPIO_PA6_USB0EPEN);
GPIOPinConfigure(GPIO_PA7_USB0PFLT);
GPIOPinConfigure(GPIO_PB2_I2C0SCL);
GPIOPinConfigure(GPIO_PB3_I2C0SDA);
GPIOPinConfigure(GPIO_PB6_I2S0TXSCK);
GPIOPinConfigure(GPIO_PB7_NMI);
GPIOPinConfigure(GPIO_PC6_U1RX);
GPIOPinConfigure(GPIO_PC7_U1TX);
GPIOPinConfigure(GPIO_PD0_I2S0RXSCK);
GPIOPinConfigure(GPIO_PD1_I2S0RXWS);
GPIOPinConfigure(GPIO_PD4_I2S0RXSD);
GPIOPinConfigure(GPIO_PD5_I2S0RXMCLK);
GPIOPinConfigure(GPIO_PE1_SSI1FSS);
GPIOPinConfigure(GPIO_PE4_I2S0TXWS);
GPIOPinConfigure(GPIO_PE5_I2S0TXSD);
GPIOPinConfigure(GPIO_PF1_I2S0TXMCLK);
GPIOPinConfigure(GPIO_PF2_LED1);
GPIOPinConfigure(GPIO_PF3_LED0);
GPIOPinConfigure(GPIO_PF4_SSI1RX);
GPIOPinConfigure(GPIO_PF5_SSI1TX);
GPIOPinConfigure(GPIO_PH4_SSI1CLK);
GPIOPinConfigure(GPIO_PJ0_I2C1SCL);
GPIOPinConfigure(GPIO_PJ1_I2C1SDA);
GPIOPinConfigure(GPIO_PJ3_U1CTS);
GPIOPinConfigure(GPIO_PJ6_U1RTS);
ROM_GPIOPinTypeGPIOOutput(LED_PORT, LED_PIN);
ROM_GPIOPinWrite(LED_PORT, LED_PIN, 0);
ROM_GPIOPinTypeGPIOInput(USER_BUTTON_PORT, USER_BUTTON_PIN);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_4);
ROM_GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_4, 0);
#ifdef DEBUG_ENABLED
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, (GPIO_PIN_0 | GPIO_PIN_1));
ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
#endif
ROM_IntMasterEnable();
} | [
"static",
"void",
"ConfigureHardware",
"(",
"void",
")",
"{",
"ROM_SysCtlClockSet",
"(",
"SYSCTL_SYSDIV_4",
"|",
"SYSCTL_USE_PLL",
"|",
"SYSCTL_OSC_MAIN",
"|",
"SYSCTL_XTAL_16MHZ",
")",
";",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOA",
")",
";",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOB",
")",
";",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOC",
")",
";",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOD",
")",
";",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOE",
")",
";",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOF",
")",
";",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOG",
")",
";",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOH",
")",
";",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOJ",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PA0_U0RX",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PA1_U0TX",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PA2_SSI0CLK",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PA3_SSI0FSS",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PA4_SSI0RX",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PA5_SSI0TX",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PA6_USB0EPEN",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PA7_USB0PFLT",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PB2_I2C0SCL",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PB3_I2C0SDA",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PB6_I2S0TXSCK",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PB7_NMI",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PC6_U1RX",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PC7_U1TX",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PD0_I2S0RXSCK",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PD1_I2S0RXWS",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PD4_I2S0RXSD",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PD5_I2S0RXMCLK",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PE1_SSI1FSS",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PE4_I2S0TXWS",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PE5_I2S0TXSD",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PF1_I2S0TXMCLK",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PF2_LED1",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PF3_LED0",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PF4_SSI1RX",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PF5_SSI1TX",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PH4_SSI1CLK",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PJ0_I2C1SCL",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PJ1_I2C1SDA",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PJ3_U1CTS",
")",
";",
"GPIOPinConfigure",
"(",
"GPIO_PJ6_U1RTS",
")",
";",
"ROM_GPIOPinTypeGPIOOutput",
"(",
"LED_PORT",
",",
"LED_PIN",
")",
";",
"ROM_GPIOPinWrite",
"(",
"LED_PORT",
",",
"LED_PIN",
",",
"0",
")",
";",
"ROM_GPIOPinTypeGPIOInput",
"(",
"USER_BUTTON_PORT",
",",
"USER_BUTTON_PIN",
")",
";",
"ROM_GPIOPinTypeGPIOOutput",
"(",
"GPIO_PORTC_BASE",
",",
"GPIO_PIN_4",
")",
";",
"ROM_GPIOPinWrite",
"(",
"GPIO_PORTC_BASE",
",",
"GPIO_PIN_4",
",",
"0",
")",
";",
"#ifdef",
"DEBUG_ENABLED",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_UART0",
")",
";",
"ROM_GPIOPinTypeUART",
"(",
"GPIO_PORTA_BASE",
",",
"(",
"GPIO_PIN_0",
"|",
"GPIO_PIN_1",
")",
")",
";",
"ROM_UARTConfigSetExpClk",
"(",
"UART0_BASE",
",",
"ROM_SysCtlClockGet",
"(",
")",
",",
"115200",
",",
"(",
"UART_CONFIG_WLEN_8",
"|",
"UART_CONFIG_STOP_ONE",
"|",
"UART_CONFIG_PAR_NONE",
")",
")",
";",
"#endif",
"ROM_IntMasterEnable",
"(",
")",
";",
"}"
] | The following function is used to configure the hardware platform for the
intended use. | [
"The",
"following",
"function",
"is",
"used",
"to",
"configure",
"the",
"hardware",
"platform",
"for",
"the",
"intended",
"use",
"."
] | [
"//\r",
"// Set the system clock for 50 MHz.\r",
"//\r",
"//\r",
"// Enable all the GPIO ports that are used for peripherals\r",
"//\r",
"//\r",
"// Configure the pin functions for each GPIO port\r",
"//\r",
"//\r",
"// Set up the GPIO port and pin used for the LED.\r",
"//\r",
"//\r",
"// Set up the GPIO port and pin used for the user push button.\r",
"//\r",
"//\r",
"// Configure the Shutdown Pin.\r",
"//\r",
"//\r",
"// Configure UART 0 to be used as the debug console port.\r",
"//\r",
"//\r",
"// Turn on interrupts in the system.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
41806602c91646163dd00196b04706ed38fe48ed | junyanl-code/Luminary-Micro-Library | boards/rdk-idm-sbc/drivers/sdram.c | [
"BSD-3-Clause"
] | C | SDRAMInit | tBoolean | tBoolean
SDRAMInit(unsigned long ulEPIDivider, unsigned long ulConfig,
unsigned long ulRefresh)
{
//
// Enable the EPI peripheral
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_EPI0);
//
// Configure the GPIO for communication with SDRAM.
//
#ifdef EPI_PORTA_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
ROM_GPIOPadConfigSet(GPIO_PORTA_BASE, EPI_PORTA_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTA_BASE, EPI_PORTA_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_GPIOB_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
ROM_GPIOPadConfigSet(GPIO_PORTB_BASE, EPI_GPIOB_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTB_BASE, EPI_GPIOB_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_PORTC_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
ROM_GPIOPadConfigSet(GPIO_PORTC_BASE, EPI_PORTC_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTC_BASE, EPI_PORTC_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_PORTD_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
ROM_GPIOPadConfigSet(GPIO_PORTD_BASE, EPI_PORTD_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTD_BASE, EPI_PORTD_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_PORTE_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
ROM_GPIOPadConfigSet(GPIO_PORTE_BASE, EPI_PORTE_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTE_BASE, EPI_PORTE_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_PORTF_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
ROM_GPIOPadConfigSet(GPIO_PORTF_BASE, EPI_PORTF_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTF_BASE, EPI_PORTF_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_PORTG_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
ROM_GPIOPadConfigSet(GPIO_PORTG_BASE, EPI_PORTG_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTG_BASE, EPI_PORTG_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_PORTH_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
ROM_GPIOPadConfigSet(GPIO_PORTH_BASE, EPI_PORTH_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTH_BASE, EPI_PORTH_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_PORTJ_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
ROM_GPIOPadConfigSet(GPIO_PORTJ_BASE, EPI_PORTJ_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTJ_BASE, EPI_PORTJ_PINS, GPIO_DIR_MODE_HW);
#endif
#if defined(EPI_CLK_PORT) && defined(EPI_CLK_PIN)
ROM_GPIOPadConfigSet(EPI_CLK_PORT, EPI_CLK_PIN, GPIO_STRENGTH_8MA,
GPIO_PIN_TYPE_STD_WPU);
#endif
//
// Set the EPI divider.
//
EPIDividerSet(EPI0_BASE, ulEPIDivider);
//
// Select SDRAM mode.
//
EPIModeSet(EPI0_BASE, EPI_MODE_SDRAM);
//
// Configure SDRAM mode.
//
EPIConfigSDRAMSet(EPI0_BASE, ulConfig, ulRefresh);
//
// Set the address map.
//
EPIAddressMapSet(EPI0_BASE, EPI_ADDR_RAM_SIZE_256MB | EPI_ADDR_RAM_BASE_6);
//
// Set the EPI mem pointer to the base of EPI mem
//
g_pusEPIMem = (unsigned short *)0x60000000;
//
// Wait for the EPI initialization to complete.
//
while(HWREG(EPI0_BASE + EPI_O_STAT) & EPI_STAT_INITSEQ)
{
//
// Wait for SDRAM initialization to complete.
//
}
//
// At this point, the SDRAM should be accessible. We attempt a couple
// of writes then read back the memory to see if it seems to be there.
//
g_pusEPIMem[0] = 0xABCD;
g_pusEPIMem[1] = 0x5AA5;
//
// Read back the patterns we just wrote to make sure they are valid. Note
// that we declared g_pusEPIMem as volatile so the compiler should not
// optimize these reads out of the image.
//
if((g_pusEPIMem[0] == 0xABCD) && (g_pusEPIMem[1] == 0x5AA5))
{
//
// The memory appears to be there so remember that we found it.
//
g_bSDRAMPresent = true;
//
// Now set up the heap that ExtRAMAlloc() and ExtRAMFree() will use.
//
bpool((void *)g_pusEPIMem, SDRAM_SIZE_BYTES);
}
//
// If we get this far, the SDRAM heap has been successfully initialized.
//
return(g_bSDRAMPresent);
} | //*****************************************************************************
//
//! Initializes the SDRAM.
//!
//! \param ulEPIDivider is the EPI clock divider to use.
//! \param ulConfig is the SDRAM interface configuration.
//! \param ulRefresh is the refresh count in core clocks (0-2047).
//!
//! This function must be called prior to ExtRAMAlloc() or ExtRAMFree(). It
//! configures the Stellaris microcontroller EPI block for SDRAM access and
//! initializes the SDRAM heap (if SDRAM is found). The parameter \e ulConfig
//! is the logical OR of several sets of choices:
//!
//! The processor core frequency must be specified with one of the following:
//!
//! - \b EPI_SDRAM_CORE_FREQ_0_15 - core clock is 0 MHz < clk <= 15 MHz
//! - \b EPI_SDRAM_CORE_FREQ_15_30 - core clock is 15 MHz < clk <= 30 MHz
//! - \b EPI_SDRAM_CORE_FREQ_30_50 - core clock is 30 MHz < clk <= 50 MHz
//! - \b EPI_SDRAM_CORE_FREQ_50_100 - core clock is 50 MHz < clk <= 100 MHz
//!
//! The low power mode is specified with one of the following:
//!
//! - \b EPI_SDRAM_LOW_POWER - enter low power, self-refresh state
//! - \b EPI_SDRAM_FULL_POWER - normal operating state
//!
//! The SDRAM device size is specified with one of the following:
//!
//! - \b EPI_SDRAM_SIZE_64MBIT - 64 Mbit device (8 MB)
//! - \b EPI_SDRAM_SIZE_128MBIT - 128 Mbit device (16 MB)
//! - \b EPI_SDRAM_SIZE_256MBIT - 256 Mbit device (32 MB)
//! - \b EPI_SDRAM_SIZE_512MBIT - 512 Mbit device (64 MB)
//!
//! The parameter \e ulRefresh sets the refresh counter in units of core
//! clock ticks. It is an 11-bit value with a range of 0 - 2047 counts.
//!
//! \return Returns \b true on success of \b false if no SDRAM is found or
//! any other error occurs.
//
//*****************************************************************************
| Initializes the SDRAM.
\param ulEPIDivider is the EPI clock divider to use.
\param ulConfig is the SDRAM interface configuration.
\param ulRefresh is the refresh count in core clocks (0-2047).
This function must be called prior to ExtRAMAlloc() or ExtRAMFree(). It
configures the Stellaris microcontroller EPI block for SDRAM access and
initializes the SDRAM heap (if SDRAM is found). The parameter \e ulConfig
is the logical OR of several sets of choices.
The processor core frequency must be specified with one of the following.
The low power mode is specified with one of the following.
\b EPI_SDRAM_LOW_POWER - enter low power, self-refresh state
\b EPI_SDRAM_FULL_POWER - normal operating state
The SDRAM device size is specified with one of the following.
\b EPI_SDRAM_SIZE_64MBIT - 64 Mbit device (8 MB)
\b EPI_SDRAM_SIZE_128MBIT - 128 Mbit device (16 MB)
\b EPI_SDRAM_SIZE_256MBIT - 256 Mbit device (32 MB)
\b EPI_SDRAM_SIZE_512MBIT - 512 Mbit device (64 MB)
The parameter \e ulRefresh sets the refresh counter in units of core
clock ticks. It is an 11-bit value with a range of 0 - 2047 counts.
\return Returns \b true on success of \b false if no SDRAM is found or
any other error occurs. | [
"Initializes",
"the",
"SDRAM",
".",
"\\",
"param",
"ulEPIDivider",
"is",
"the",
"EPI",
"clock",
"divider",
"to",
"use",
".",
"\\",
"param",
"ulConfig",
"is",
"the",
"SDRAM",
"interface",
"configuration",
".",
"\\",
"param",
"ulRefresh",
"is",
"the",
"refresh",
"count",
"in",
"core",
"clocks",
"(",
"0",
"-",
"2047",
")",
".",
"This",
"function",
"must",
"be",
"called",
"prior",
"to",
"ExtRAMAlloc",
"()",
"or",
"ExtRAMFree",
"()",
".",
"It",
"configures",
"the",
"Stellaris",
"microcontroller",
"EPI",
"block",
"for",
"SDRAM",
"access",
"and",
"initializes",
"the",
"SDRAM",
"heap",
"(",
"if",
"SDRAM",
"is",
"found",
")",
".",
"The",
"parameter",
"\\",
"e",
"ulConfig",
"is",
"the",
"logical",
"OR",
"of",
"several",
"sets",
"of",
"choices",
".",
"The",
"processor",
"core",
"frequency",
"must",
"be",
"specified",
"with",
"one",
"of",
"the",
"following",
".",
"The",
"low",
"power",
"mode",
"is",
"specified",
"with",
"one",
"of",
"the",
"following",
".",
"\\",
"b",
"EPI_SDRAM_LOW_POWER",
"-",
"enter",
"low",
"power",
"self",
"-",
"refresh",
"state",
"\\",
"b",
"EPI_SDRAM_FULL_POWER",
"-",
"normal",
"operating",
"state",
"The",
"SDRAM",
"device",
"size",
"is",
"specified",
"with",
"one",
"of",
"the",
"following",
".",
"\\",
"b",
"EPI_SDRAM_SIZE_64MBIT",
"-",
"64",
"Mbit",
"device",
"(",
"8",
"MB",
")",
"\\",
"b",
"EPI_SDRAM_SIZE_128MBIT",
"-",
"128",
"Mbit",
"device",
"(",
"16",
"MB",
")",
"\\",
"b",
"EPI_SDRAM_SIZE_256MBIT",
"-",
"256",
"Mbit",
"device",
"(",
"32",
"MB",
")",
"\\",
"b",
"EPI_SDRAM_SIZE_512MBIT",
"-",
"512",
"Mbit",
"device",
"(",
"64",
"MB",
")",
"The",
"parameter",
"\\",
"e",
"ulRefresh",
"sets",
"the",
"refresh",
"counter",
"in",
"units",
"of",
"core",
"clock",
"ticks",
".",
"It",
"is",
"an",
"11",
"-",
"bit",
"value",
"with",
"a",
"range",
"of",
"0",
"-",
"2047",
"counts",
".",
"\\",
"return",
"Returns",
"\\",
"b",
"true",
"on",
"success",
"of",
"\\",
"b",
"false",
"if",
"no",
"SDRAM",
"is",
"found",
"or",
"any",
"other",
"error",
"occurs",
"."
] | tBoolean
SDRAMInit(unsigned long ulEPIDivider, unsigned long ulConfig,
unsigned long ulRefresh)
{
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_EPI0);
#ifdef EPI_PORTA_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
ROM_GPIOPadConfigSet(GPIO_PORTA_BASE, EPI_PORTA_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTA_BASE, EPI_PORTA_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_GPIOB_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
ROM_GPIOPadConfigSet(GPIO_PORTB_BASE, EPI_GPIOB_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTB_BASE, EPI_GPIOB_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_PORTC_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
ROM_GPIOPadConfigSet(GPIO_PORTC_BASE, EPI_PORTC_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTC_BASE, EPI_PORTC_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_PORTD_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
ROM_GPIOPadConfigSet(GPIO_PORTD_BASE, EPI_PORTD_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTD_BASE, EPI_PORTD_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_PORTE_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
ROM_GPIOPadConfigSet(GPIO_PORTE_BASE, EPI_PORTE_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTE_BASE, EPI_PORTE_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_PORTF_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
ROM_GPIOPadConfigSet(GPIO_PORTF_BASE, EPI_PORTF_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTF_BASE, EPI_PORTF_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_PORTG_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
ROM_GPIOPadConfigSet(GPIO_PORTG_BASE, EPI_PORTG_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTG_BASE, EPI_PORTG_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_PORTH_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
ROM_GPIOPadConfigSet(GPIO_PORTH_BASE, EPI_PORTH_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTH_BASE, EPI_PORTH_PINS, GPIO_DIR_MODE_HW);
#endif
#ifdef EPI_PORTJ_PINS
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
ROM_GPIOPadConfigSet(GPIO_PORTJ_BASE, EPI_PORTJ_PINS, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
ROM_GPIODirModeSet(GPIO_PORTJ_BASE, EPI_PORTJ_PINS, GPIO_DIR_MODE_HW);
#endif
#if defined(EPI_CLK_PORT) && defined(EPI_CLK_PIN)
ROM_GPIOPadConfigSet(EPI_CLK_PORT, EPI_CLK_PIN, GPIO_STRENGTH_8MA,
GPIO_PIN_TYPE_STD_WPU);
#endif
EPIDividerSet(EPI0_BASE, ulEPIDivider);
EPIModeSet(EPI0_BASE, EPI_MODE_SDRAM);
EPIConfigSDRAMSet(EPI0_BASE, ulConfig, ulRefresh);
EPIAddressMapSet(EPI0_BASE, EPI_ADDR_RAM_SIZE_256MB | EPI_ADDR_RAM_BASE_6);
g_pusEPIMem = (unsigned short *)0x60000000;
while(HWREG(EPI0_BASE + EPI_O_STAT) & EPI_STAT_INITSEQ)
{
}
g_pusEPIMem[0] = 0xABCD;
g_pusEPIMem[1] = 0x5AA5;
if((g_pusEPIMem[0] == 0xABCD) && (g_pusEPIMem[1] == 0x5AA5))
{
g_bSDRAMPresent = true;
bpool((void *)g_pusEPIMem, SDRAM_SIZE_BYTES);
}
return(g_bSDRAMPresent);
} | [
"tBoolean",
"SDRAMInit",
"(",
"unsigned",
"long",
"ulEPIDivider",
",",
"unsigned",
"long",
"ulConfig",
",",
"unsigned",
"long",
"ulRefresh",
")",
"{",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_EPI0",
")",
";",
"#ifdef",
"EPI_PORTA_PINS",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOA",
")",
";",
"ROM_GPIOPadConfigSet",
"(",
"GPIO_PORTA_BASE",
",",
"EPI_PORTA_PINS",
",",
"GPIO_STRENGTH_2MA",
",",
"GPIO_PIN_TYPE_STD_WPU",
")",
";",
"ROM_GPIODirModeSet",
"(",
"GPIO_PORTA_BASE",
",",
"EPI_PORTA_PINS",
",",
"GPIO_DIR_MODE_HW",
")",
";",
"#endif",
"#ifdef",
"EPI_GPIOB_PINS",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOB",
")",
";",
"ROM_GPIOPadConfigSet",
"(",
"GPIO_PORTB_BASE",
",",
"EPI_GPIOB_PINS",
",",
"GPIO_STRENGTH_2MA",
",",
"GPIO_PIN_TYPE_STD_WPU",
")",
";",
"ROM_GPIODirModeSet",
"(",
"GPIO_PORTB_BASE",
",",
"EPI_GPIOB_PINS",
",",
"GPIO_DIR_MODE_HW",
")",
";",
"#endif",
"#ifdef",
"EPI_PORTC_PINS",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOC",
")",
";",
"ROM_GPIOPadConfigSet",
"(",
"GPIO_PORTC_BASE",
",",
"EPI_PORTC_PINS",
",",
"GPIO_STRENGTH_2MA",
",",
"GPIO_PIN_TYPE_STD_WPU",
")",
";",
"ROM_GPIODirModeSet",
"(",
"GPIO_PORTC_BASE",
",",
"EPI_PORTC_PINS",
",",
"GPIO_DIR_MODE_HW",
")",
";",
"#endif",
"#ifdef",
"EPI_PORTD_PINS",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOD",
")",
";",
"ROM_GPIOPadConfigSet",
"(",
"GPIO_PORTD_BASE",
",",
"EPI_PORTD_PINS",
",",
"GPIO_STRENGTH_2MA",
",",
"GPIO_PIN_TYPE_STD_WPU",
")",
";",
"ROM_GPIODirModeSet",
"(",
"GPIO_PORTD_BASE",
",",
"EPI_PORTD_PINS",
",",
"GPIO_DIR_MODE_HW",
")",
";",
"#endif",
"#ifdef",
"EPI_PORTE_PINS",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOE",
")",
";",
"ROM_GPIOPadConfigSet",
"(",
"GPIO_PORTE_BASE",
",",
"EPI_PORTE_PINS",
",",
"GPIO_STRENGTH_2MA",
",",
"GPIO_PIN_TYPE_STD_WPU",
")",
";",
"ROM_GPIODirModeSet",
"(",
"GPIO_PORTE_BASE",
",",
"EPI_PORTE_PINS",
",",
"GPIO_DIR_MODE_HW",
")",
";",
"#endif",
"#ifdef",
"EPI_PORTF_PINS",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOF",
")",
";",
"ROM_GPIOPadConfigSet",
"(",
"GPIO_PORTF_BASE",
",",
"EPI_PORTF_PINS",
",",
"GPIO_STRENGTH_2MA",
",",
"GPIO_PIN_TYPE_STD_WPU",
")",
";",
"ROM_GPIODirModeSet",
"(",
"GPIO_PORTF_BASE",
",",
"EPI_PORTF_PINS",
",",
"GPIO_DIR_MODE_HW",
")",
";",
"#endif",
"#ifdef",
"EPI_PORTG_PINS",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOG",
")",
";",
"ROM_GPIOPadConfigSet",
"(",
"GPIO_PORTG_BASE",
",",
"EPI_PORTG_PINS",
",",
"GPIO_STRENGTH_2MA",
",",
"GPIO_PIN_TYPE_STD_WPU",
")",
";",
"ROM_GPIODirModeSet",
"(",
"GPIO_PORTG_BASE",
",",
"EPI_PORTG_PINS",
",",
"GPIO_DIR_MODE_HW",
")",
";",
"#endif",
"#ifdef",
"EPI_PORTH_PINS",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOH",
")",
";",
"ROM_GPIOPadConfigSet",
"(",
"GPIO_PORTH_BASE",
",",
"EPI_PORTH_PINS",
",",
"GPIO_STRENGTH_2MA",
",",
"GPIO_PIN_TYPE_STD_WPU",
")",
";",
"ROM_GPIODirModeSet",
"(",
"GPIO_PORTH_BASE",
",",
"EPI_PORTH_PINS",
",",
"GPIO_DIR_MODE_HW",
")",
";",
"#endif",
"#ifdef",
"EPI_PORTJ_PINS",
"ROM_SysCtlPeripheralEnable",
"(",
"SYSCTL_PERIPH_GPIOJ",
")",
";",
"ROM_GPIOPadConfigSet",
"(",
"GPIO_PORTJ_BASE",
",",
"EPI_PORTJ_PINS",
",",
"GPIO_STRENGTH_2MA",
",",
"GPIO_PIN_TYPE_STD_WPU",
")",
";",
"ROM_GPIODirModeSet",
"(",
"GPIO_PORTJ_BASE",
",",
"EPI_PORTJ_PINS",
",",
"GPIO_DIR_MODE_HW",
")",
";",
"#endif",
"#if",
"defined",
"(",
"EPI_CLK_PORT",
")",
"&&",
"defined",
"(",
"EPI_CLK_PIN",
")",
"\n",
"ROM_GPIOPadConfigSet",
"(",
"EPI_CLK_PORT",
",",
"EPI_CLK_PIN",
",",
"GPIO_STRENGTH_8MA",
",",
"GPIO_PIN_TYPE_STD_WPU",
")",
";",
"#endif",
"EPIDividerSet",
"(",
"EPI0_BASE",
",",
"ulEPIDivider",
")",
";",
"EPIModeSet",
"(",
"EPI0_BASE",
",",
"EPI_MODE_SDRAM",
")",
";",
"EPIConfigSDRAMSet",
"(",
"EPI0_BASE",
",",
"ulConfig",
",",
"ulRefresh",
")",
";",
"EPIAddressMapSet",
"(",
"EPI0_BASE",
",",
"EPI_ADDR_RAM_SIZE_256MB",
"|",
"EPI_ADDR_RAM_BASE_6",
")",
";",
"g_pusEPIMem",
"=",
"(",
"unsigned",
"short",
"*",
")",
"0x60000000",
";",
"while",
"(",
"HWREG",
"(",
"EPI0_BASE",
"+",
"EPI_O_STAT",
")",
"&",
"EPI_STAT_INITSEQ",
")",
"{",
"}",
"g_pusEPIMem",
"[",
"0",
"]",
"=",
"0xABCD",
";",
"g_pusEPIMem",
"[",
"1",
"]",
"=",
"0x5AA5",
";",
"if",
"(",
"(",
"g_pusEPIMem",
"[",
"0",
"]",
"==",
"0xABCD",
")",
"&&",
"(",
"g_pusEPIMem",
"[",
"1",
"]",
"==",
"0x5AA5",
")",
")",
"{",
"g_bSDRAMPresent",
"=",
"true",
";",
"bpool",
"(",
"(",
"void",
"*",
")",
"g_pusEPIMem",
",",
"SDRAM_SIZE_BYTES",
")",
";",
"}",
"return",
"(",
"g_bSDRAMPresent",
")",
";",
"}"
] | Initializes the SDRAM. | [
"Initializes",
"the",
"SDRAM",
"."
] | [
"//\r",
"// Enable the EPI peripheral\r",
"//\r",
"//\r",
"// Configure the GPIO for communication with SDRAM.\r",
"//\r",
"//\r",
"// Set the EPI divider.\r",
"//\r",
"//\r",
"// Select SDRAM mode.\r",
"//\r",
"//\r",
"// Configure SDRAM mode.\r",
"//\r",
"//\r",
"// Set the address map.\r",
"//\r",
"//\r",
"// Set the EPI mem pointer to the base of EPI mem\r",
"//\r",
"//\r",
"// Wait for the EPI initialization to complete.\r",
"//\r",
"//\r",
"// Wait for SDRAM initialization to complete.\r",
"//\r",
"//\r",
"// At this point, the SDRAM should be accessible. We attempt a couple\r",
"// of writes then read back the memory to see if it seems to be there.\r",
"//\r",
"//\r",
"// Read back the patterns we just wrote to make sure they are valid. Note\r",
"// that we declared g_pusEPIMem as volatile so the compiler should not\r",
"// optimize these reads out of the image.\r",
"//\r",
"//\r",
"// The memory appears to be there so remember that we found it.\r",
"//\r",
"//\r",
"// Now set up the heap that ExtRAMAlloc() and ExtRAMFree() will use.\r",
"//\r",
"//\r",
"// If we get this far, the SDRAM heap has been successfully initialized.\r",
"//\r"
] | [
{
"param": "ulEPIDivider",
"type": "unsigned long"
},
{
"param": "ulConfig",
"type": "unsigned long"
},
{
"param": "ulRefresh",
"type": "unsigned long"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ulEPIDivider",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ulConfig",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ulRefresh",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
41806602c91646163dd00196b04706ed38fe48ed | junyanl-code/Luminary-Micro-Library | boards/rdk-idm-sbc/drivers/sdram.c | [
"BSD-3-Clause"
] | C | ExtRAMAlloc | void | void *
ExtRAMAlloc(unsigned long ulSize)
{
if(g_bSDRAMPresent)
{
return(bget(ulSize));
}
else
{
return((void *)0);
}
} | //*****************************************************************************
//
//! Allocates a block of memory from the SDRAM heap.
//!
//! \param ulSize is the size in bytes of the block of SDRAM to allocate.
//!
//! This function allocates a block of SDRAM and returns its pointer. If
//! insufficient space exists to fulfill the request, a NULL pointer is returned.
//!
//! \return Returns a non-zero pointer on success or NULL if it is not possible
//! to allocate the required memory.
//
//*****************************************************************************
| Allocates a block of memory from the SDRAM heap.
\param ulSize is the size in bytes of the block of SDRAM to allocate.
This function allocates a block of SDRAM and returns its pointer. If
insufficient space exists to fulfill the request, a NULL pointer is returned.
\return Returns a non-zero pointer on success or NULL if it is not possible
to allocate the required memory. | [
"Allocates",
"a",
"block",
"of",
"memory",
"from",
"the",
"SDRAM",
"heap",
".",
"\\",
"param",
"ulSize",
"is",
"the",
"size",
"in",
"bytes",
"of",
"the",
"block",
"of",
"SDRAM",
"to",
"allocate",
".",
"This",
"function",
"allocates",
"a",
"block",
"of",
"SDRAM",
"and",
"returns",
"its",
"pointer",
".",
"If",
"insufficient",
"space",
"exists",
"to",
"fulfill",
"the",
"request",
"a",
"NULL",
"pointer",
"is",
"returned",
".",
"\\",
"return",
"Returns",
"a",
"non",
"-",
"zero",
"pointer",
"on",
"success",
"or",
"NULL",
"if",
"it",
"is",
"not",
"possible",
"to",
"allocate",
"the",
"required",
"memory",
"."
] | void *
ExtRAMAlloc(unsigned long ulSize)
{
if(g_bSDRAMPresent)
{
return(bget(ulSize));
}
else
{
return((void *)0);
}
} | [
"void",
"*",
"ExtRAMAlloc",
"(",
"unsigned",
"long",
"ulSize",
")",
"{",
"if",
"(",
"g_bSDRAMPresent",
")",
"{",
"return",
"(",
"bget",
"(",
"ulSize",
")",
")",
";",
"}",
"else",
"{",
"return",
"(",
"(",
"void",
"*",
")",
"0",
")",
";",
"}",
"}"
] | Allocates a block of memory from the SDRAM heap. | [
"Allocates",
"a",
"block",
"of",
"memory",
"from",
"the",
"SDRAM",
"heap",
"."
] | [] | [
{
"param": "ulSize",
"type": "unsigned long"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ulSize",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
41806602c91646163dd00196b04706ed38fe48ed | junyanl-code/Luminary-Micro-Library | boards/rdk-idm-sbc/drivers/sdram.c | [
"BSD-3-Clause"
] | C | ExtRAMFree | void | void
ExtRAMFree(void *pvBlock)
{
if(g_bSDRAMPresent)
{
brel(pvBlock);
}
} | //*****************************************************************************
//
//! Frees a block of memory in the SDRAM heap.
//!
//! \param pvBlock is the pointer to the block of SDRAM to free.
//!
//! This function frees a block of memory that had previously been allocated
//! using a call to ExtRAMAlloc();
//!
//! \return None.
//
//*****************************************************************************
| Frees a block of memory in the SDRAM heap.
\param pvBlock is the pointer to the block of SDRAM to free.
This function frees a block of memory that had previously been allocated
using a call to ExtRAMAlloc().
\return None. | [
"Frees",
"a",
"block",
"of",
"memory",
"in",
"the",
"SDRAM",
"heap",
".",
"\\",
"param",
"pvBlock",
"is",
"the",
"pointer",
"to",
"the",
"block",
"of",
"SDRAM",
"to",
"free",
".",
"This",
"function",
"frees",
"a",
"block",
"of",
"memory",
"that",
"had",
"previously",
"been",
"allocated",
"using",
"a",
"call",
"to",
"ExtRAMAlloc",
"()",
".",
"\\",
"return",
"None",
"."
] | void
ExtRAMFree(void *pvBlock)
{
if(g_bSDRAMPresent)
{
brel(pvBlock);
}
} | [
"void",
"ExtRAMFree",
"(",
"void",
"*",
"pvBlock",
")",
"{",
"if",
"(",
"g_bSDRAMPresent",
")",
"{",
"brel",
"(",
"pvBlock",
")",
";",
"}",
"}"
] | Frees a block of memory in the SDRAM heap. | [
"Frees",
"a",
"block",
"of",
"memory",
"in",
"the",
"SDRAM",
"heap",
"."
] | [] | [
{
"param": "pvBlock",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pvBlock",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
41806602c91646163dd00196b04706ed38fe48ed | junyanl-code/Luminary-Micro-Library | boards/rdk-idm-sbc/drivers/sdram.c | [
"BSD-3-Clause"
] | C | ExtRAMMaxFree | null | unsigned long
ExtRAMMaxFree(unsigned long *pulTotalFree)
{
bufsize sizeTotalFree, sizeTotalAlloc, sizeMaxFree;
long lGet, lRel;
if(g_bSDRAMPresent)
{
bstats(&sizeTotalAlloc, &sizeTotalFree, &sizeMaxFree, &lGet, &lRel);
*pulTotalFree = (unsigned long)sizeTotalFree;
return(sizeMaxFree);
}
else
{
*pulTotalFree = 0;
return(0);
}
} | //*****************************************************************************
//
//! Reports information on the current heap usage.
//!
//! \param pulTotalFree points to storage which will be written with the total
//! number of bytes unallocated in the heap.
//!
//! This function reports the total amount of memory free in the SDRAM heap and
//! the size of the largest available block. It is included in the build only
//! if label INCLUDE_BGET_STATS is defined.
//!
//! \return Returns the size of the largest available free block in the SDRAM
//! heap.
//
//*****************************************************************************
| Reports information on the current heap usage.
\param pulTotalFree points to storage which will be written with the total
number of bytes unallocated in the heap.
This function reports the total amount of memory free in the SDRAM heap and
the size of the largest available block. It is included in the build only
if label INCLUDE_BGET_STATS is defined.
\return Returns the size of the largest available free block in the SDRAM
heap. | [
"Reports",
"information",
"on",
"the",
"current",
"heap",
"usage",
".",
"\\",
"param",
"pulTotalFree",
"points",
"to",
"storage",
"which",
"will",
"be",
"written",
"with",
"the",
"total",
"number",
"of",
"bytes",
"unallocated",
"in",
"the",
"heap",
".",
"This",
"function",
"reports",
"the",
"total",
"amount",
"of",
"memory",
"free",
"in",
"the",
"SDRAM",
"heap",
"and",
"the",
"size",
"of",
"the",
"largest",
"available",
"block",
".",
"It",
"is",
"included",
"in",
"the",
"build",
"only",
"if",
"label",
"INCLUDE_BGET_STATS",
"is",
"defined",
".",
"\\",
"return",
"Returns",
"the",
"size",
"of",
"the",
"largest",
"available",
"free",
"block",
"in",
"the",
"SDRAM",
"heap",
"."
] | unsigned long
ExtRAMMaxFree(unsigned long *pulTotalFree)
{
bufsize sizeTotalFree, sizeTotalAlloc, sizeMaxFree;
long lGet, lRel;
if(g_bSDRAMPresent)
{
bstats(&sizeTotalAlloc, &sizeTotalFree, &sizeMaxFree, &lGet, &lRel);
*pulTotalFree = (unsigned long)sizeTotalFree;
return(sizeMaxFree);
}
else
{
*pulTotalFree = 0;
return(0);
}
} | [
"unsigned",
"long",
"ExtRAMMaxFree",
"(",
"unsigned",
"long",
"*",
"pulTotalFree",
")",
"{",
"bufsize",
"sizeTotalFree",
",",
"sizeTotalAlloc",
",",
"sizeMaxFree",
";",
"long",
"lGet",
",",
"lRel",
";",
"if",
"(",
"g_bSDRAMPresent",
")",
"{",
"bstats",
"(",
"&",
"sizeTotalAlloc",
",",
"&",
"sizeTotalFree",
",",
"&",
"sizeMaxFree",
",",
"&",
"lGet",
",",
"&",
"lRel",
")",
";",
"*",
"pulTotalFree",
"=",
"(",
"unsigned",
"long",
")",
"sizeTotalFree",
";",
"return",
"(",
"sizeMaxFree",
")",
";",
"}",
"else",
"{",
"*",
"pulTotalFree",
"=",
"0",
";",
"return",
"(",
"0",
")",
";",
"}",
"}"
] | Reports information on the current heap usage. | [
"Reports",
"information",
"on",
"the",
"current",
"heap",
"usage",
"."
] | [] | [
{
"param": "pulTotalFree",
"type": "unsigned long"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pulTotalFree",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
57a559c83bc9f665f4d1f86771cf5d925e4f1dc2 | junyanl-code/Luminary-Micro-Library | boards/mdl-lm4f211cncd/watchdog/watchdog.c | [
"BSD-3-Clause"
] | C | WatchdogIntHandler | void | void
WatchdogIntHandler(void)
{
//
// Clear the watchdog interrupt.
//
WatchdogIntClear(WATCHDOG0_BASE);
//
// Invert the GPIO D0 value.
//
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_5,
(GPIOPinRead(GPIO_PORTG_BASE, GPIO_PIN_5) ^
GPIO_PIN_5));
} | //*****************************************************************************
//
// The interrupt handler for the watchdog. This feeds the dog (so that the
// processor does not get reset) and winks the LED.
//
//***************************************************************************** | The interrupt handler for the watchdog. This feeds the dog (so that the
processor does not get reset) and winks the LED. | [
"The",
"interrupt",
"handler",
"for",
"the",
"watchdog",
".",
"This",
"feeds",
"the",
"dog",
"(",
"so",
"that",
"the",
"processor",
"does",
"not",
"get",
"reset",
")",
"and",
"winks",
"the",
"LED",
"."
] | void
WatchdogIntHandler(void)
{
Clear the watchdog interrupt.
WatchdogIntClear(WATCHDOG0_BASE);
Invert the GPIO D0 value.
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_5,
(GPIOPinRead(GPIO_PORTG_BASE, GPIO_PIN_5) ^
GPIO_PIN_5));
} | [
"void",
"WatchdogIntHandler",
"(",
"void",
")",
"{",
"WatchdogIntClear",
"(",
"WATCHDOG0_BASE",
")",
";",
"GPIOPinWrite",
"(",
"GPIO_PORTG_BASE",
",",
"GPIO_PIN_5",
",",
"(",
"GPIOPinRead",
"(",
"GPIO_PORTG_BASE",
",",
"GPIO_PIN_5",
")",
"^",
"GPIO_PIN_5",
")",
")",
";",
"}"
] | The interrupt handler for the watchdog. | [
"The",
"interrupt",
"handler",
"for",
"the",
"watchdog",
"."
] | [
"//",
"// Clear the watchdog interrupt.",
"//",
"//",
"// Invert the GPIO D0 value.",
"//"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
c4bf33123ef24d0d1fcd8ef5b3e689c1612d2d50 | junyanl-code/Luminary-Micro-Library | boards/ek-lm3s3748/gpio_jtag/gpio_jtag.c | [
"BSD-3-Clause"
] | C | GPIOBIntHandler | void | void
GPIOBIntHandler(void)
{
//
// Clear the GPIO interrupt.
//
ROM_GPIOPinIntClear(GPIO_PORTB_BASE, GPIO_PIN_7);
//
// Toggle the pin mode.
//
g_ulMode ^= 1;
//
// See if the pins should be in JTAG or GPIO mode.
//
if(g_ulMode == 0)
{
//
// Change PC0-3 into hardware (i.e. JTAG) pins.
//
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x01;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) |= 0x01;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x02;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) |= 0x02;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x04;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) |= 0x04;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x08;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) |= 0x08;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x00;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = 0;
}
else
{
//
// Change PC0-3 into GPIO inputs.
//
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x01;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) &= 0xfe;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x02;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) &= 0xfd;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x04;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) &= 0xfb;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x08;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) &= 0xf7;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x00;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = 0;
ROM_GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, (GPIO_PIN_0 | GPIO_PIN_1 |
GPIO_PIN_2 | GPIO_PIN_3));
}
} | //*****************************************************************************
//
// The interrupt handler for the PB7 pin interrupt. When triggered, this will
// toggle the JTAG pins between JTAG and GPIO mode.
//
//*****************************************************************************
| The interrupt handler for the PB7 pin interrupt. When triggered, this will
toggle the JTAG pins between JTAG and GPIO mode. | [
"The",
"interrupt",
"handler",
"for",
"the",
"PB7",
"pin",
"interrupt",
".",
"When",
"triggered",
"this",
"will",
"toggle",
"the",
"JTAG",
"pins",
"between",
"JTAG",
"and",
"GPIO",
"mode",
"."
] | void
GPIOBIntHandler(void)
{
ROM_GPIOPinIntClear(GPIO_PORTB_BASE, GPIO_PIN_7);
g_ulMode ^= 1;
if(g_ulMode == 0)
{
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x01;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) |= 0x01;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x02;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) |= 0x02;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x04;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) |= 0x04;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x08;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) |= 0x08;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x00;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = 0;
}
else
{
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x01;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) &= 0xfe;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x02;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) &= 0xfd;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x04;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) &= 0xfb;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x08;
HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) &= 0xf7;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x00;
HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = 0;
ROM_GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, (GPIO_PIN_0 | GPIO_PIN_1 |
GPIO_PIN_2 | GPIO_PIN_3));
}
} | [
"void",
"GPIOBIntHandler",
"(",
"void",
")",
"{",
"ROM_GPIOPinIntClear",
"(",
"GPIO_PORTB_BASE",
",",
"GPIO_PIN_7",
")",
";",
"g_ulMode",
"^=",
"1",
";",
"if",
"(",
"g_ulMode",
"==",
"0",
")",
"{",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_LOCK",
")",
"=",
"GPIO_LOCK_KEY_DD",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_CR",
")",
"=",
"0x01",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_AFSEL",
")",
"|=",
"0x01",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_LOCK",
")",
"=",
"GPIO_LOCK_KEY_DD",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_CR",
")",
"=",
"0x02",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_AFSEL",
")",
"|=",
"0x02",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_LOCK",
")",
"=",
"GPIO_LOCK_KEY_DD",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_CR",
")",
"=",
"0x04",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_AFSEL",
")",
"|=",
"0x04",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_LOCK",
")",
"=",
"GPIO_LOCK_KEY_DD",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_CR",
")",
"=",
"0x08",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_AFSEL",
")",
"|=",
"0x08",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_LOCK",
")",
"=",
"GPIO_LOCK_KEY_DD",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_CR",
")",
"=",
"0x00",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_LOCK",
")",
"=",
"0",
";",
"}",
"else",
"{",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_LOCK",
")",
"=",
"GPIO_LOCK_KEY_DD",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_CR",
")",
"=",
"0x01",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_AFSEL",
")",
"&=",
"0xfe",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_LOCK",
")",
"=",
"GPIO_LOCK_KEY_DD",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_CR",
")",
"=",
"0x02",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_AFSEL",
")",
"&=",
"0xfd",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_LOCK",
")",
"=",
"GPIO_LOCK_KEY_DD",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_CR",
")",
"=",
"0x04",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_AFSEL",
")",
"&=",
"0xfb",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_LOCK",
")",
"=",
"GPIO_LOCK_KEY_DD",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_CR",
")",
"=",
"0x08",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_AFSEL",
")",
"&=",
"0xf7",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_LOCK",
")",
"=",
"GPIO_LOCK_KEY_DD",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_CR",
")",
"=",
"0x00",
";",
"HWREG",
"(",
"GPIO_PORTC_BASE",
"+",
"GPIO_O_LOCK",
")",
"=",
"0",
";",
"ROM_GPIOPinTypeGPIOInput",
"(",
"GPIO_PORTC_BASE",
",",
"(",
"GPIO_PIN_0",
"|",
"GPIO_PIN_1",
"|",
"GPIO_PIN_2",
"|",
"GPIO_PIN_3",
")",
")",
";",
"}",
"}"
] | The interrupt handler for the PB7 pin interrupt. | [
"The",
"interrupt",
"handler",
"for",
"the",
"PB7",
"pin",
"interrupt",
"."
] | [
"//\r",
"// Clear the GPIO interrupt.\r",
"//\r",
"//\r",
"// Toggle the pin mode.\r",
"//\r",
"//\r",
"// See if the pins should be in JTAG or GPIO mode.\r",
"//\r",
"//\r",
"// Change PC0-3 into hardware (i.e. JTAG) pins.\r",
"//\r",
"//\r",
"// Change PC0-3 into GPIO inputs.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f5bee18ded8cf561ff6e8f4a8b2840f4cf3c6131 | junyanl-code/Luminary-Micro-Library | boards/ek-lm4f120xl/interrupts/interrupts.c | [
"BSD-3-Clause"
] | C | DisplayIntStatus | void | void
DisplayIntStatus(void)
{
unsigned long ulTemp;
//
// Display the currently active interrupts.
//
ulTemp = HWREG(NVIC_ACTIVE0);
UARTprintf("\rActive: %c%c%c ", (ulTemp & 1) ? '1' : ' ',
(ulTemp & 2) ? '2' : ' ', (ulTemp & 4) ? '3' : ' ');
//
// Display the currently pending interrupts.
//
ulTemp = HWREG(NVIC_PEND0);
UARTprintf("Pending: %c%c%c", (ulTemp & 1) ? '1' : ' ',
(ulTemp & 2) ? '2' : ' ', (ulTemp & 4) ? '3' : ' ');
} | //*****************************************************************************
//
// Display the interrupt state on the UART. The currently active and pending
// interrupts are displayed.
//
//***************************************************************************** | Display the interrupt state on the UART. The currently active and pending
interrupts are displayed. | [
"Display",
"the",
"interrupt",
"state",
"on",
"the",
"UART",
".",
"The",
"currently",
"active",
"and",
"pending",
"interrupts",
"are",
"displayed",
"."
] | void
DisplayIntStatus(void)
{
unsigned long ulTemp;
Display the currently active interrupts.
ulTemp = HWREG(NVIC_ACTIVE0);
UARTprintf("\rActive: %c%c%c ", (ulTemp & 1) ? '1' : ' ',
(ulTemp & 2) ? '2' : ' ', (ulTemp & 4) ? '3' : ' ');
Display the currently pending interrupts.
ulTemp = HWREG(NVIC_PEND0);
UARTprintf("Pending: %c%c%c", (ulTemp & 1) ? '1' : ' ',
(ulTemp & 2) ? '2' : ' ', (ulTemp & 4) ? '3' : ' ');
} | [
"void",
"DisplayIntStatus",
"(",
"void",
")",
"{",
"unsigned",
"long",
"ulTemp",
";",
"ulTemp",
"=",
"HWREG",
"(",
"NVIC_ACTIVE0",
")",
";",
"UARTprintf",
"(",
"\"",
"\\r",
"\"",
",",
"(",
"ulTemp",
"&",
"1",
")",
"?",
"'",
"'",
":",
"'",
"'",
",",
"(",
"ulTemp",
"&",
"2",
")",
"?",
"'",
"'",
":",
"'",
"'",
",",
"(",
"ulTemp",
"&",
"4",
")",
"?",
"'",
"'",
":",
"'",
"'",
")",
";",
"ulTemp",
"=",
"HWREG",
"(",
"NVIC_PEND0",
")",
";",
"UARTprintf",
"(",
"\"",
"\"",
",",
"(",
"ulTemp",
"&",
"1",
")",
"?",
"'",
"'",
":",
"'",
"'",
",",
"(",
"ulTemp",
"&",
"2",
")",
"?",
"'",
"'",
":",
"'",
"'",
",",
"(",
"ulTemp",
"&",
"4",
")",
"?",
"'",
"'",
":",
"'",
"'",
")",
";",
"}"
] | Display the interrupt state on the UART. | [
"Display",
"the",
"interrupt",
"state",
"on",
"the",
"UART",
"."
] | [
"//",
"// Display the currently active interrupts.",
"//",
"//",
"// Display the currently pending interrupts.",
"//"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f5bee18ded8cf561ff6e8f4a8b2840f4cf3c6131 | junyanl-code/Luminary-Micro-Library | boards/ek-lm4f120xl/interrupts/interrupts.c | [
"BSD-3-Clause"
] | C | IntGPIOa | void | void
IntGPIOa(void)
{
//
// Set PE1 high to indicate entry to this interrupt handler.
//
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_PIN_1);
//
// Put the current interrupt state on the display.
//
DisplayIntStatus();
//
// Wait two seconds.
//
Delay(2);
//
// Save and increment the interrupt sequence number.
//
g_ulGPIOa = g_ulIndex++;
//
// Set PE1 low to indicate exit from this interrupt handler.
//
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_1, 0);
} | //*****************************************************************************
//
// This is the handler for INT_GPIOA. It simply saves the interrupt sequence
// number.
//
//***************************************************************************** | This is the handler for INT_GPIOA. It simply saves the interrupt sequence
number. | [
"This",
"is",
"the",
"handler",
"for",
"INT_GPIOA",
".",
"It",
"simply",
"saves",
"the",
"interrupt",
"sequence",
"number",
"."
] | void
IntGPIOa(void)
{
Set PE1 high to indicate entry to this interrupt handler.
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_PIN_1);
Put the current interrupt state on the display.
DisplayIntStatus();
Wait two seconds.
Delay(2);
Save and increment the interrupt sequence number.
g_ulGPIOa = g_ulIndex++;
Set PE1 low to indicate exit from this interrupt handler.
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_1, 0);
} | [
"void",
"IntGPIOa",
"(",
"void",
")",
"{",
"ROM_GPIOPinWrite",
"(",
"GPIO_PORTE_BASE",
",",
"GPIO_PIN_1",
",",
"GPIO_PIN_1",
")",
";",
"DisplayIntStatus",
"(",
")",
";",
"Delay",
"(",
"2",
")",
";",
"g_ulGPIOa",
"=",
"g_ulIndex",
"++",
";",
"ROM_GPIOPinWrite",
"(",
"GPIO_PORTE_BASE",
",",
"GPIO_PIN_1",
",",
"0",
")",
";",
"}"
] | This is the handler for INT_GPIOA. | [
"This",
"is",
"the",
"handler",
"for",
"INT_GPIOA",
"."
] | [
"//",
"// Set PE1 high to indicate entry to this interrupt handler.",
"//",
"//",
"// Put the current interrupt state on the display.",
"//",
"//",
"// Wait two seconds.",
"//",
"//",
"// Save and increment the interrupt sequence number.",
"//",
"//",
"// Set PE1 low to indicate exit from this interrupt handler.",
"//"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f5bee18ded8cf561ff6e8f4a8b2840f4cf3c6131 | junyanl-code/Luminary-Micro-Library | boards/ek-lm4f120xl/interrupts/interrupts.c | [
"BSD-3-Clause"
] | C | IntGPIOb | void | void
IntGPIOb(void)
{
//
// Set PE2 high to indicate entry to this interrupt handler.
//
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_2, GPIO_PIN_2);
//
// Put the current interrupt state on the display.
//
DisplayIntStatus();
//
// Trigger the INT_GPIOA interrupt.
//
HWREG(NVIC_SW_TRIG) = INT_GPIOA - 16;
//
// Put the current interrupt state on the display.
//
DisplayIntStatus();
//
// Wait two seconds.
//
Delay(2);
//
// Save and increment the interrupt sequence number.
//
g_ulGPIOb = g_ulIndex++;
//
// Set PE2 low to indicate exit from this interrupt handler.
//
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_2, 0);
} | //*****************************************************************************
//
// This is the handler for INT_GPIOB. It triggers INT_GPIOA and saves the
// interrupt sequence number.
//
//***************************************************************************** | This is the handler for INT_GPIOB. It triggers INT_GPIOA and saves the
interrupt sequence number. | [
"This",
"is",
"the",
"handler",
"for",
"INT_GPIOB",
".",
"It",
"triggers",
"INT_GPIOA",
"and",
"saves",
"the",
"interrupt",
"sequence",
"number",
"."
] | void
IntGPIOb(void)
{
Set PE2 high to indicate entry to this interrupt handler.
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_2, GPIO_PIN_2);
Put the current interrupt state on the display.
DisplayIntStatus();
Trigger the INT_GPIOA interrupt.
HWREG(NVIC_SW_TRIG) = INT_GPIOA - 16;
Put the current interrupt state on the display.
DisplayIntStatus();
Wait two seconds.
Delay(2);
Save and increment the interrupt sequence number.
g_ulGPIOb = g_ulIndex++;
Set PE2 low to indicate exit from this interrupt handler.
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_2, 0);
} | [
"void",
"IntGPIOb",
"(",
"void",
")",
"{",
"ROM_GPIOPinWrite",
"(",
"GPIO_PORTE_BASE",
",",
"GPIO_PIN_2",
",",
"GPIO_PIN_2",
")",
";",
"DisplayIntStatus",
"(",
")",
";",
"HWREG",
"(",
"NVIC_SW_TRIG",
")",
"=",
"INT_GPIOA",
"-",
"16",
";",
"DisplayIntStatus",
"(",
")",
";",
"Delay",
"(",
"2",
")",
";",
"g_ulGPIOb",
"=",
"g_ulIndex",
"++",
";",
"ROM_GPIOPinWrite",
"(",
"GPIO_PORTE_BASE",
",",
"GPIO_PIN_2",
",",
"0",
")",
";",
"}"
] | This is the handler for INT_GPIOB. | [
"This",
"is",
"the",
"handler",
"for",
"INT_GPIOB",
"."
] | [
"//",
"// Set PE2 high to indicate entry to this interrupt handler.",
"//",
"//",
"// Put the current interrupt state on the display.",
"//",
"//",
"// Trigger the INT_GPIOA interrupt.",
"//",
"//",
"// Put the current interrupt state on the display.",
"//",
"//",
"// Wait two seconds.",
"//",
"//",
"// Save and increment the interrupt sequence number.",
"//",
"//",
"// Set PE2 low to indicate exit from this interrupt handler.",
"//"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f5bee18ded8cf561ff6e8f4a8b2840f4cf3c6131 | junyanl-code/Luminary-Micro-Library | boards/ek-lm4f120xl/interrupts/interrupts.c | [
"BSD-3-Clause"
] | C | IntGPIOc | void | void
IntGPIOc(void)
{
//
// Set PE3 high to indicate entry to this interrupt handler.
//
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_3, GPIO_PIN_3);
//
// Put the current interrupt state on the display.
//
DisplayIntStatus();
//
// Trigger the INT_GPIOB interrupt.
//
HWREG(NVIC_SW_TRIG) = INT_GPIOB - 16;
//
// Put the current interrupt state on the display.
//
DisplayIntStatus();
//
// Wait two seconds.
//
Delay(2);
//
// Save and increment the interrupt sequence number.
//
g_ulGPIOc = g_ulIndex++;
//
// Set PE3 low to indicate exit from this interrupt handler.
//
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_3, 0);
} | //*****************************************************************************
//
// This is the handler for INT_GPIOC. It triggers INT_GPIOB and saves the
// interrupt sequence number.
//
//***************************************************************************** | This is the handler for INT_GPIOC. It triggers INT_GPIOB and saves the
interrupt sequence number. | [
"This",
"is",
"the",
"handler",
"for",
"INT_GPIOC",
".",
"It",
"triggers",
"INT_GPIOB",
"and",
"saves",
"the",
"interrupt",
"sequence",
"number",
"."
] | void
IntGPIOc(void)
{
Set PE3 high to indicate entry to this interrupt handler.
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_3, GPIO_PIN_3);
Put the current interrupt state on the display.
DisplayIntStatus();
Trigger the INT_GPIOB interrupt.
HWREG(NVIC_SW_TRIG) = INT_GPIOB - 16;
Put the current interrupt state on the display.
DisplayIntStatus();
Wait two seconds.
Delay(2);
Save and increment the interrupt sequence number.
g_ulGPIOc = g_ulIndex++;
Set PE3 low to indicate exit from this interrupt handler.
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_3, 0);
} | [
"void",
"IntGPIOc",
"(",
"void",
")",
"{",
"ROM_GPIOPinWrite",
"(",
"GPIO_PORTE_BASE",
",",
"GPIO_PIN_3",
",",
"GPIO_PIN_3",
")",
";",
"DisplayIntStatus",
"(",
")",
";",
"HWREG",
"(",
"NVIC_SW_TRIG",
")",
"=",
"INT_GPIOB",
"-",
"16",
";",
"DisplayIntStatus",
"(",
")",
";",
"Delay",
"(",
"2",
")",
";",
"g_ulGPIOc",
"=",
"g_ulIndex",
"++",
";",
"ROM_GPIOPinWrite",
"(",
"GPIO_PORTE_BASE",
",",
"GPIO_PIN_3",
",",
"0",
")",
";",
"}"
] | This is the handler for INT_GPIOC. | [
"This",
"is",
"the",
"handler",
"for",
"INT_GPIOC",
"."
] | [
"//",
"// Set PE3 high to indicate entry to this interrupt handler.",
"//",
"//",
"// Put the current interrupt state on the display.",
"//",
"//",
"// Trigger the INT_GPIOB interrupt.",
"//",
"//",
"// Put the current interrupt state on the display.",
"//",
"//",
"// Wait two seconds.",
"//",
"//",
"// Save and increment the interrupt sequence number.",
"//",
"//",
"// Set PE3 low to indicate exit from this interrupt handler.",
"//"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0ea1d75a72edb5c04a705df93e59d4df838bb875 | junyanl-code/Luminary-Micro-Library | boards/ek-lm3s3748/usb_host_keyboard/usb_host_keyboard.c | [
"BSD-3-Clause"
] | C | PrintChar | void | void
PrintChar(const char ucChar)
{
tRectangle sRect;
//
// If both the line and column have gone to zero then clear the screen.
//
if((g_ulLine == 0) && (g_ulColumn == 0))
{
//
// Form the rectangle that makes up the text box.
//
sRect.sXMin = 0;
sRect.sYMin = DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER;
sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - DISPLAY_TEXT_BORDER;
sRect.sYMax = GrContextDpyHeightGet(&g_sContext) -
DISPLAY_BANNER_HEIGHT - DISPLAY_TEXT_BORDER;
//
// Change the foreground color to black and draw black rectangle to
// clear the screen.
//
GrContextForegroundSet(&g_sContext, DISPLAY_TEXT_BG);
GrRectFill(&g_sContext, &sRect);
//
// Reset the foreground color to the text color.
//
GrContextForegroundSet(&g_sContext, DISPLAY_TEXT_FG);
}
//
// Send the character to the UART.
//
UARTprintf("%c", ucChar);
//
// Allow new lines to cause the column to go back to zero.
//
if(ucChar != '\n')
{
//
// Print the character to the screen.
//
GrStringDraw(&g_sContext, &ucChar, 1,
GrFontMaxWidthGet(g_pFontFixed6x8) * g_ulColumn,
DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER +
(g_ulLine * GrFontHeightGet(g_pFontFixed6x8)), 0);
}
else
{
//
// This will allow the code below to properly handle the new line.
//
g_ulColumn = g_ulCharsPerLine;
}
//
// Update the text row and column that the next character will use.
//
if(g_ulColumn < g_ulCharsPerLine)
{
//
// No line wrap yet so move one column over.
//
g_ulColumn++;
}
else
{
//
// Line wrapped so go back to the first column and update the line.
//
g_ulColumn = 0;
g_ulLine++;
//
// The line has gone past the end so go back to the first line.
//
if(g_ulLine >= g_ulLinesPerScreen)
{
g_ulLine = 0;
}
}
} | //*****************************************************************************
//
// This function prints the character out the UART and into the text area of
// the screen.
//
// \param ucChar is the character to print out.
//
// This function handles all of the detail of printing a character to both the
// UART and to the text area of the screen on the evaluation board. The text
// area of the screen will be cleared any time the text goes beyond the end
// of the text area.
//
// \return None.
//
//*****************************************************************************
| This function prints the character out the UART and into the text area of
the screen.
\param ucChar is the character to print out.
This function handles all of the detail of printing a character to both the
UART and to the text area of the screen on the evaluation board. The text
area of the screen will be cleared any time the text goes beyond the end
of the text area.
\return None. | [
"This",
"function",
"prints",
"the",
"character",
"out",
"the",
"UART",
"and",
"into",
"the",
"text",
"area",
"of",
"the",
"screen",
".",
"\\",
"param",
"ucChar",
"is",
"the",
"character",
"to",
"print",
"out",
".",
"This",
"function",
"handles",
"all",
"of",
"the",
"detail",
"of",
"printing",
"a",
"character",
"to",
"both",
"the",
"UART",
"and",
"to",
"the",
"text",
"area",
"of",
"the",
"screen",
"on",
"the",
"evaluation",
"board",
".",
"The",
"text",
"area",
"of",
"the",
"screen",
"will",
"be",
"cleared",
"any",
"time",
"the",
"text",
"goes",
"beyond",
"the",
"end",
"of",
"the",
"text",
"area",
".",
"\\",
"return",
"None",
"."
] | void
PrintChar(const char ucChar)
{
tRectangle sRect;
if((g_ulLine == 0) && (g_ulColumn == 0))
{
sRect.sXMin = 0;
sRect.sYMin = DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER;
sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - DISPLAY_TEXT_BORDER;
sRect.sYMax = GrContextDpyHeightGet(&g_sContext) -
DISPLAY_BANNER_HEIGHT - DISPLAY_TEXT_BORDER;
GrContextForegroundSet(&g_sContext, DISPLAY_TEXT_BG);
GrRectFill(&g_sContext, &sRect);
GrContextForegroundSet(&g_sContext, DISPLAY_TEXT_FG);
}
UARTprintf("%c", ucChar);
if(ucChar != '\n')
{
GrStringDraw(&g_sContext, &ucChar, 1,
GrFontMaxWidthGet(g_pFontFixed6x8) * g_ulColumn,
DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER +
(g_ulLine * GrFontHeightGet(g_pFontFixed6x8)), 0);
}
else
{
g_ulColumn = g_ulCharsPerLine;
}
if(g_ulColumn < g_ulCharsPerLine)
{
g_ulColumn++;
}
else
{
g_ulColumn = 0;
g_ulLine++;
if(g_ulLine >= g_ulLinesPerScreen)
{
g_ulLine = 0;
}
}
} | [
"void",
"PrintChar",
"(",
"const",
"char",
"ucChar",
")",
"{",
"tRectangle",
"sRect",
";",
"if",
"(",
"(",
"g_ulLine",
"==",
"0",
")",
"&&",
"(",
"g_ulColumn",
"==",
"0",
")",
")",
"{",
"sRect",
".",
"sXMin",
"=",
"0",
";",
"sRect",
".",
"sYMin",
"=",
"DISPLAY_BANNER_HEIGHT",
"+",
"DISPLAY_TEXT_BORDER",
";",
"sRect",
".",
"sXMax",
"=",
"GrContextDpyWidthGet",
"(",
"&",
"g_sContext",
")",
"-",
"DISPLAY_TEXT_BORDER",
";",
"sRect",
".",
"sYMax",
"=",
"GrContextDpyHeightGet",
"(",
"&",
"g_sContext",
")",
"-",
"DISPLAY_BANNER_HEIGHT",
"-",
"DISPLAY_TEXT_BORDER",
";",
"GrContextForegroundSet",
"(",
"&",
"g_sContext",
",",
"DISPLAY_TEXT_BG",
")",
";",
"GrRectFill",
"(",
"&",
"g_sContext",
",",
"&",
"sRect",
")",
";",
"GrContextForegroundSet",
"(",
"&",
"g_sContext",
",",
"DISPLAY_TEXT_FG",
")",
";",
"}",
"UARTprintf",
"(",
"\"",
"\"",
",",
"ucChar",
")",
";",
"if",
"(",
"ucChar",
"!=",
"'",
"\\n",
"'",
")",
"{",
"GrStringDraw",
"(",
"&",
"g_sContext",
",",
"&",
"ucChar",
",",
"1",
",",
"GrFontMaxWidthGet",
"(",
"g_pFontFixed6x8",
")",
"*",
"g_ulColumn",
",",
"DISPLAY_BANNER_HEIGHT",
"+",
"DISPLAY_TEXT_BORDER",
"+",
"(",
"g_ulLine",
"*",
"GrFontHeightGet",
"(",
"g_pFontFixed6x8",
")",
")",
",",
"0",
")",
";",
"}",
"else",
"{",
"g_ulColumn",
"=",
"g_ulCharsPerLine",
";",
"}",
"if",
"(",
"g_ulColumn",
"<",
"g_ulCharsPerLine",
")",
"{",
"g_ulColumn",
"++",
";",
"}",
"else",
"{",
"g_ulColumn",
"=",
"0",
";",
"g_ulLine",
"++",
";",
"if",
"(",
"g_ulLine",
">=",
"g_ulLinesPerScreen",
")",
"{",
"g_ulLine",
"=",
"0",
";",
"}",
"}",
"}"
] | This function prints the character out the UART and into the text area of
the screen. | [
"This",
"function",
"prints",
"the",
"character",
"out",
"the",
"UART",
"and",
"into",
"the",
"text",
"area",
"of",
"the",
"screen",
"."
] | [
"//\r",
"// If both the line and column have gone to zero then clear the screen.\r",
"//\r",
"//\r",
"// Form the rectangle that makes up the text box.\r",
"//\r",
"//\r",
"// Change the foreground color to black and draw black rectangle to\r",
"// clear the screen.\r",
"//\r",
"//\r",
"// Reset the foreground color to the text color.\r",
"//\r",
"//\r",
"// Send the character to the UART.\r",
"//\r",
"//\r",
"// Allow new lines to cause the column to go back to zero.\r",
"//\r",
"//\r",
"// Print the character to the screen.\r",
"//\r",
"//\r",
"// This will allow the code below to properly handle the new line.\r",
"//\r",
"//\r",
"// Update the text row and column that the next character will use.\r",
"//\r",
"//\r",
"// No line wrap yet so move one column over.\r",
"//\r",
"//\r",
"// Line wrapped so go back to the first column and update the line.\r",
"//\r",
"//\r",
"// The line has gone past the end so go back to the first line.\r",
"//\r"
] | [
{
"param": "ucChar",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ucChar",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ea1d75a72edb5c04a705df93e59d4df838bb875 | junyanl-code/Luminary-Micro-Library | boards/ek-lm3s3748/usb_host_keyboard/usb_host_keyboard.c | [
"BSD-3-Clause"
] | C | UpdateStatus | void | void
UpdateStatus(void)
{
tRectangle sRect;
//
// Fill the bottom rows of the screen with blue to create the status area.
//
sRect.sXMin = 0;
sRect.sYMin = GrContextDpyHeightGet(&g_sContext) -
DISPLAY_BANNER_HEIGHT - 1;
sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
sRect.sYMax = sRect.sYMin + DISPLAY_BANNER_HEIGHT;
GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_BG);
GrRectFill(&g_sContext, &sRect);
//
// Put a white box around the banner.
//
GrContextForegroundSet(&g_sContext, ClrWhite);
GrRectDraw(&g_sContext, &sRect);
//
// Put the application name in the middle of the banner.
//
GrContextFontSet(&g_sContext, g_pFontFixed6x8);
//
// Update the status on the screen.
//
if(g_eUSBState == STATE_NO_DEVICE)
{
//
// Keyboard is currently disconnected.
//
GrStringDraw(&g_sContext, "No Device", -1, 4, sRect.sYMin + 4, 0);
}
else if(g_eUSBState == STATE_UNKNOWN_DEVICE)
{
//
// Unknown device is currently connected.
//
GrStringDraw(&g_sContext, "Unknown Device", -1, 4, sRect.sYMin + 4, 0);
}
else if(g_eUSBState == STATE_POWER_FAULT)
{
//
// Something caused a power fault.
//
GrStringDraw(&g_sContext, "Power Fault", -1, 4, sRect.sYMin + 4, 0);
}
else if((g_eUSBState == STATE_KEYBOARD_CONNECTED) ||
(g_eUSBState == STATE_KEYBOARD_UPDATE))
{
//
// Keyboard is connected.
//
GrStringDraw(&g_sContext, "Connected", -1, 4, sRect.sYMin + 4, 0);
//
// Update the CAPS Lock status.
//
if(g_ulModifiers & HID_KEYB_CAPS_LOCK)
{
GrStringDraw(&g_sContext, "CAPS", 4, sRect.sXMax - 28,
sRect.sYMin + 4, 0);
}
}
} | //*****************************************************************************
//
// This function updates the status area of the screen. It uses the current
// state of the application to print the status bar.
//
//*****************************************************************************
| This function updates the status area of the screen. It uses the current
state of the application to print the status bar. | [
"This",
"function",
"updates",
"the",
"status",
"area",
"of",
"the",
"screen",
".",
"It",
"uses",
"the",
"current",
"state",
"of",
"the",
"application",
"to",
"print",
"the",
"status",
"bar",
"."
] | void
UpdateStatus(void)
{
tRectangle sRect;
sRect.sXMin = 0;
sRect.sYMin = GrContextDpyHeightGet(&g_sContext) -
DISPLAY_BANNER_HEIGHT - 1;
sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
sRect.sYMax = sRect.sYMin + DISPLAY_BANNER_HEIGHT;
GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_BG);
GrRectFill(&g_sContext, &sRect);
GrContextForegroundSet(&g_sContext, ClrWhite);
GrRectDraw(&g_sContext, &sRect);
GrContextFontSet(&g_sContext, g_pFontFixed6x8);
if(g_eUSBState == STATE_NO_DEVICE)
{
GrStringDraw(&g_sContext, "No Device", -1, 4, sRect.sYMin + 4, 0);
}
else if(g_eUSBState == STATE_UNKNOWN_DEVICE)
{
GrStringDraw(&g_sContext, "Unknown Device", -1, 4, sRect.sYMin + 4, 0);
}
else if(g_eUSBState == STATE_POWER_FAULT)
{
GrStringDraw(&g_sContext, "Power Fault", -1, 4, sRect.sYMin + 4, 0);
}
else if((g_eUSBState == STATE_KEYBOARD_CONNECTED) ||
(g_eUSBState == STATE_KEYBOARD_UPDATE))
{
GrStringDraw(&g_sContext, "Connected", -1, 4, sRect.sYMin + 4, 0);
if(g_ulModifiers & HID_KEYB_CAPS_LOCK)
{
GrStringDraw(&g_sContext, "CAPS", 4, sRect.sXMax - 28,
sRect.sYMin + 4, 0);
}
}
} | [
"void",
"UpdateStatus",
"(",
"void",
")",
"{",
"tRectangle",
"sRect",
";",
"sRect",
".",
"sXMin",
"=",
"0",
";",
"sRect",
".",
"sYMin",
"=",
"GrContextDpyHeightGet",
"(",
"&",
"g_sContext",
")",
"-",
"DISPLAY_BANNER_HEIGHT",
"-",
"1",
";",
"sRect",
".",
"sXMax",
"=",
"GrContextDpyWidthGet",
"(",
"&",
"g_sContext",
")",
"-",
"1",
";",
"sRect",
".",
"sYMax",
"=",
"sRect",
".",
"sYMin",
"+",
"DISPLAY_BANNER_HEIGHT",
";",
"GrContextForegroundSet",
"(",
"&",
"g_sContext",
",",
"DISPLAY_BANNER_BG",
")",
";",
"GrRectFill",
"(",
"&",
"g_sContext",
",",
"&",
"sRect",
")",
";",
"GrContextForegroundSet",
"(",
"&",
"g_sContext",
",",
"ClrWhite",
")",
";",
"GrRectDraw",
"(",
"&",
"g_sContext",
",",
"&",
"sRect",
")",
";",
"GrContextFontSet",
"(",
"&",
"g_sContext",
",",
"g_pFontFixed6x8",
")",
";",
"if",
"(",
"g_eUSBState",
"==",
"STATE_NO_DEVICE",
")",
"{",
"GrStringDraw",
"(",
"&",
"g_sContext",
",",
"\"",
"\"",
",",
"-1",
",",
"4",
",",
"sRect",
".",
"sYMin",
"+",
"4",
",",
"0",
")",
";",
"}",
"else",
"if",
"(",
"g_eUSBState",
"==",
"STATE_UNKNOWN_DEVICE",
")",
"{",
"GrStringDraw",
"(",
"&",
"g_sContext",
",",
"\"",
"\"",
",",
"-1",
",",
"4",
",",
"sRect",
".",
"sYMin",
"+",
"4",
",",
"0",
")",
";",
"}",
"else",
"if",
"(",
"g_eUSBState",
"==",
"STATE_POWER_FAULT",
")",
"{",
"GrStringDraw",
"(",
"&",
"g_sContext",
",",
"\"",
"\"",
",",
"-1",
",",
"4",
",",
"sRect",
".",
"sYMin",
"+",
"4",
",",
"0",
")",
";",
"}",
"else",
"if",
"(",
"(",
"g_eUSBState",
"==",
"STATE_KEYBOARD_CONNECTED",
")",
"||",
"(",
"g_eUSBState",
"==",
"STATE_KEYBOARD_UPDATE",
")",
")",
"{",
"GrStringDraw",
"(",
"&",
"g_sContext",
",",
"\"",
"\"",
",",
"-1",
",",
"4",
",",
"sRect",
".",
"sYMin",
"+",
"4",
",",
"0",
")",
";",
"if",
"(",
"g_ulModifiers",
"&",
"HID_KEYB_CAPS_LOCK",
")",
"{",
"GrStringDraw",
"(",
"&",
"g_sContext",
",",
"\"",
"\"",
",",
"4",
",",
"sRect",
".",
"sXMax",
"-",
"28",
",",
"sRect",
".",
"sYMin",
"+",
"4",
",",
"0",
")",
";",
"}",
"}",
"}"
] | This function updates the status area of the screen. | [
"This",
"function",
"updates",
"the",
"status",
"area",
"of",
"the",
"screen",
"."
] | [
"//\r",
"// Fill the bottom rows of the screen with blue to create the status area.\r",
"//\r",
"//\r",
"// Put a white box around the banner.\r",
"//\r",
"//\r",
"// Put the application name in the middle of the banner.\r",
"//\r",
"//\r",
"// Update the status on the screen.\r",
"//\r",
"//\r",
"// Keyboard is currently disconnected.\r",
"//\r",
"//\r",
"// Unknown device is currently connected.\r",
"//\r",
"//\r",
"// Something caused a power fault.\r",
"//\r",
"//\r",
"// Keyboard is connected.\r",
"//\r",
"//\r",
"// Update the CAPS Lock status.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0ea1d75a72edb5c04a705df93e59d4df838bb875 | junyanl-code/Luminary-Micro-Library | boards/ek-lm3s3748/usb_host_keyboard/usb_host_keyboard.c | [
"BSD-3-Clause"
] | C | KeyboardCallback | null | unsigned long
KeyboardCallback(void *pvCBData, unsigned long ulEvent,
unsigned long ulMsgParam, void *pvMsgData)
{
unsigned char ucChar;
switch(ulEvent)
{
//
// New Key press detected.
//
case USBH_EVENT_HID_KB_PRESS:
{
//
// If this was a Caps Lock key then update the Caps Lock state.
//
if(ulMsgParam == HID_KEYB_USAGE_CAPSLOCK)
{
//
// The main loop needs to update the keyboard's Caps Lock
// state.
//
g_eUSBState = STATE_KEYBOARD_UPDATE;
//
// Toggle the current Caps Lock state.
//
g_ulModifiers ^= HID_KEYB_CAPS_LOCK;
//
// Update the screen based on the Caps Lock status.
//
UpdateStatus();
}
else if(ulMsgParam == HID_KEYB_USAGE_SCROLLOCK)
{
//
// The main loop needs to update the keyboard's Scroll Lock
// state.
//
g_eUSBState = STATE_KEYBOARD_UPDATE;
//
// Toggle the current Scroll Lock state.
//
g_ulModifiers ^= HID_KEYB_SCROLL_LOCK;
}
else if(ulMsgParam == HID_KEYB_USAGE_NUMLOCK)
{
//
// The main loop needs to update the keyboard's Scroll Lock
// state.
//
g_eUSBState = STATE_KEYBOARD_UPDATE;
//
// Toggle the current Num Lock state.
//
g_ulModifiers ^= HID_KEYB_NUM_LOCK;
}
else
{
//
// Print the current key out the UART.
//
ucChar = (unsigned char)
USBHKeyboardUsageToChar(g_ulKeyboardInstance,
&g_sUSKeyboardMap,
(unsigned char)ulMsgParam);
//
// A zero value indicates there was no textual mapping of this
// usage code.
//
if(ucChar != 0)
{
PrintChar(ucChar);
}
}
break;
}
case USBH_EVENT_HID_KB_MOD:
{
//
// This application ignores the state of the shift or control
// and other special keys.
//
break;
}
case USBH_EVENT_HID_KB_REL:
{
//
// This applications ignores the release of keys as well.
//
break;
}
}
return(0);
} | //*****************************************************************************
//
// This is the callback from the USB HID keyboard handler.
//
// \param pvCBData is ignored by this function.
// \param ulEvent is one of the valid events for a keyboard device.
// \param ulMsgParam is defined by the event that occurs.
// \param pvMsgData is a pointer to data that is defined by the event that
// occurs.
//
// This function will be called to inform the application when a keyboard has
// been plugged in or removed and any time a key is pressed or released.
//
// \return This function will return 0.
//
//*****************************************************************************
| This is the callback from the USB HID keyboard handler.
\param pvCBData is ignored by this function.
\param ulEvent is one of the valid events for a keyboard device.
\param ulMsgParam is defined by the event that occurs.
\param pvMsgData is a pointer to data that is defined by the event that
occurs.
This function will be called to inform the application when a keyboard has
been plugged in or removed and any time a key is pressed or released.
\return This function will return 0. | [
"This",
"is",
"the",
"callback",
"from",
"the",
"USB",
"HID",
"keyboard",
"handler",
".",
"\\",
"param",
"pvCBData",
"is",
"ignored",
"by",
"this",
"function",
".",
"\\",
"param",
"ulEvent",
"is",
"one",
"of",
"the",
"valid",
"events",
"for",
"a",
"keyboard",
"device",
".",
"\\",
"param",
"ulMsgParam",
"is",
"defined",
"by",
"the",
"event",
"that",
"occurs",
".",
"\\",
"param",
"pvMsgData",
"is",
"a",
"pointer",
"to",
"data",
"that",
"is",
"defined",
"by",
"the",
"event",
"that",
"occurs",
".",
"This",
"function",
"will",
"be",
"called",
"to",
"inform",
"the",
"application",
"when",
"a",
"keyboard",
"has",
"been",
"plugged",
"in",
"or",
"removed",
"and",
"any",
"time",
"a",
"key",
"is",
"pressed",
"or",
"released",
".",
"\\",
"return",
"This",
"function",
"will",
"return",
"0",
"."
] | unsigned long
KeyboardCallback(void *pvCBData, unsigned long ulEvent,
unsigned long ulMsgParam, void *pvMsgData)
{
unsigned char ucChar;
switch(ulEvent)
{
case USBH_EVENT_HID_KB_PRESS:
{
if(ulMsgParam == HID_KEYB_USAGE_CAPSLOCK)
{
g_eUSBState = STATE_KEYBOARD_UPDATE;
g_ulModifiers ^= HID_KEYB_CAPS_LOCK;
UpdateStatus();
}
else if(ulMsgParam == HID_KEYB_USAGE_SCROLLOCK)
{
g_eUSBState = STATE_KEYBOARD_UPDATE;
g_ulModifiers ^= HID_KEYB_SCROLL_LOCK;
}
else if(ulMsgParam == HID_KEYB_USAGE_NUMLOCK)
{
g_eUSBState = STATE_KEYBOARD_UPDATE;
g_ulModifiers ^= HID_KEYB_NUM_LOCK;
}
else
{
ucChar = (unsigned char)
USBHKeyboardUsageToChar(g_ulKeyboardInstance,
&g_sUSKeyboardMap,
(unsigned char)ulMsgParam);
if(ucChar != 0)
{
PrintChar(ucChar);
}
}
break;
}
case USBH_EVENT_HID_KB_MOD:
{
break;
}
case USBH_EVENT_HID_KB_REL:
{
break;
}
}
return(0);
} | [
"unsigned",
"long",
"KeyboardCallback",
"(",
"void",
"*",
"pvCBData",
",",
"unsigned",
"long",
"ulEvent",
",",
"unsigned",
"long",
"ulMsgParam",
",",
"void",
"*",
"pvMsgData",
")",
"{",
"unsigned",
"char",
"ucChar",
";",
"switch",
"(",
"ulEvent",
")",
"{",
"case",
"USBH_EVENT_HID_KB_PRESS",
":",
"{",
"if",
"(",
"ulMsgParam",
"==",
"HID_KEYB_USAGE_CAPSLOCK",
")",
"{",
"g_eUSBState",
"=",
"STATE_KEYBOARD_UPDATE",
";",
"g_ulModifiers",
"^=",
"HID_KEYB_CAPS_LOCK",
";",
"UpdateStatus",
"(",
")",
";",
"}",
"else",
"if",
"(",
"ulMsgParam",
"==",
"HID_KEYB_USAGE_SCROLLOCK",
")",
"{",
"g_eUSBState",
"=",
"STATE_KEYBOARD_UPDATE",
";",
"g_ulModifiers",
"^=",
"HID_KEYB_SCROLL_LOCK",
";",
"}",
"else",
"if",
"(",
"ulMsgParam",
"==",
"HID_KEYB_USAGE_NUMLOCK",
")",
"{",
"g_eUSBState",
"=",
"STATE_KEYBOARD_UPDATE",
";",
"g_ulModifiers",
"^=",
"HID_KEYB_NUM_LOCK",
";",
"}",
"else",
"{",
"ucChar",
"=",
"(",
"unsigned",
"char",
")",
"USBHKeyboardUsageToChar",
"(",
"g_ulKeyboardInstance",
",",
"&",
"g_sUSKeyboardMap",
",",
"(",
"unsigned",
"char",
")",
"ulMsgParam",
")",
";",
"if",
"(",
"ucChar",
"!=",
"0",
")",
"{",
"PrintChar",
"(",
"ucChar",
")",
";",
"}",
"}",
"break",
";",
"}",
"case",
"USBH_EVENT_HID_KB_MOD",
":",
"{",
"break",
";",
"}",
"case",
"USBH_EVENT_HID_KB_REL",
":",
"{",
"break",
";",
"}",
"}",
"return",
"(",
"0",
")",
";",
"}"
] | This is the callback from the USB HID keyboard handler. | [
"This",
"is",
"the",
"callback",
"from",
"the",
"USB",
"HID",
"keyboard",
"handler",
"."
] | [
"//\r",
"// New Key press detected.\r",
"//\r",
"//\r",
"// If this was a Caps Lock key then update the Caps Lock state.\r",
"//\r",
"//\r",
"// The main loop needs to update the keyboard's Caps Lock\r",
"// state.\r",
"//\r",
"//\r",
"// Toggle the current Caps Lock state.\r",
"//\r",
"//\r",
"// Update the screen based on the Caps Lock status.\r",
"//\r",
"//\r",
"// The main loop needs to update the keyboard's Scroll Lock\r",
"// state.\r",
"//\r",
"//\r",
"// Toggle the current Scroll Lock state.\r",
"//\r",
"//\r",
"// The main loop needs to update the keyboard's Scroll Lock\r",
"// state.\r",
"//\r",
"//\r",
"// Toggle the current Num Lock state.\r",
"//\r",
"//\r",
"// Print the current key out the UART.\r",
"//\r",
"//\r",
"// A zero value indicates there was no textual mapping of this\r",
"// usage code.\r",
"//\r",
"//\r",
"// This application ignores the state of the shift or control\r",
"// and other special keys.\r",
"//\r",
"//\r",
"// This applications ignores the release of keys as well.\r",
"//\r"
] | [
{
"param": "pvCBData",
"type": "void"
},
{
"param": "ulEvent",
"type": "unsigned long"
},
{
"param": "ulMsgParam",
"type": "unsigned long"
},
{
"param": "pvMsgData",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pvCBData",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ulEvent",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ulMsgParam",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pvMsgData",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f5a9f01609eee740608fda7c07db627f13b38d09 | junyanl-code/Luminary-Micro-Library | boards/rdk-idm-sbc/qs-blox/qs-blox.c | [
"BSD-3-Clause"
] | C | OnStartButtonPress | void | void OnStartButtonPress(tWidget *pWidget)
{
//
// Tell the main loop to switch into "Starting" mode and show the
// countdown.
//
g_ulCommandFlags |= BLOX_CMD_START;
} | //*****************************************************************************
//
// Widget handler for the "Start" button.
//
//*****************************************************************************
| Widget handler for the "Start" button. | [
"Widget",
"handler",
"for",
"the",
"\"",
"Start",
"\"",
"button",
"."
] | void OnStartButtonPress(tWidget *pWidget)
{
g_ulCommandFlags |= BLOX_CMD_START;
} | [
"void",
"OnStartButtonPress",
"(",
"tWidget",
"*",
"pWidget",
")",
"{",
"g_ulCommandFlags",
"|=",
"BLOX_CMD_START",
";",
"}"
] | Widget handler for the "Start" button. | [
"Widget",
"handler",
"for",
"the",
"\"",
"Start",
"\"",
"button",
"."
] | [
"//\r",
"// Tell the main loop to switch into \"Starting\" mode and show the\r",
"// countdown.\r",
"//\r"
] | [
{
"param": "pWidget",
"type": "tWidget"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pWidget",
"type": "tWidget",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f5a9f01609eee740608fda7c07db627f13b38d09 | junyanl-code/Luminary-Micro-Library | boards/rdk-idm-sbc/qs-blox/qs-blox.c | [
"BSD-3-Clause"
] | C | SysTickIntHandler | void | void
SysTickIntHandler(void)
{
//
// Update our system timer counter.
//
g_ulSysTickCount++;
//
// Call the lwIP timer if necessary.
//
if(g_ulLWIPDivider == 0)
{
lwIPTimer(1000 / LWIP_TICKS_PER_SECOND);
g_ulLWIPDivider = LWIP_DIVIDER;
}
//
// Decrement the lwIP timer divider.
//
g_ulLWIPDivider--;
} | //*****************************************************************************
//
// This is the handler for this SysTick interrupt.
//
//*****************************************************************************
| This is the handler for this SysTick interrupt. | [
"This",
"is",
"the",
"handler",
"for",
"this",
"SysTick",
"interrupt",
"."
] | void
SysTickIntHandler(void)
{
g_ulSysTickCount++;
if(g_ulLWIPDivider == 0)
{
lwIPTimer(1000 / LWIP_TICKS_PER_SECOND);
g_ulLWIPDivider = LWIP_DIVIDER;
}
g_ulLWIPDivider--;
} | [
"void",
"SysTickIntHandler",
"(",
"void",
")",
"{",
"g_ulSysTickCount",
"++",
";",
"if",
"(",
"g_ulLWIPDivider",
"==",
"0",
")",
"{",
"lwIPTimer",
"(",
"1000",
"/",
"LWIP_TICKS_PER_SECOND",
")",
";",
"g_ulLWIPDivider",
"=",
"LWIP_DIVIDER",
";",
"}",
"g_ulLWIPDivider",
"--",
";",
"}"
] | This is the handler for this SysTick interrupt. | [
"This",
"is",
"the",
"handler",
"for",
"this",
"SysTick",
"interrupt",
"."
] | [
"//\r",
"// Update our system timer counter.\r",
"//\r",
"//\r",
"// Call the lwIP timer if necessary.\r",
"//\r",
"//\r",
"// Decrement the lwIP timer divider.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f5a9f01609eee740608fda7c07db627f13b38d09 | junyanl-code/Luminary-Micro-Library | boards/rdk-idm-sbc/qs-blox/qs-blox.c | [
"BSD-3-Clause"
] | C | AudioSoundEffectProcess | void | void
AudioSoundEffectProcess(void)
{
tBoolean bComplete;
//
// Are we currently playing a sound effect?
//
if(g_bSoundPlaying)
{
//
// Feed the wave file processor.
//
bComplete = WavePlayContinue(&g_sSoundEffectHeader);
//
// Did we finish playback of this sound effect?
//
if(bComplete)
{
//
// Yes - remember that we are no longer playing anything.
//
g_bSoundPlaying = false;
}
}
} | //*****************************************************************************
//
// Do any housekeeping necessary to keep the sound effects playing.
//
//*****************************************************************************
| Do any housekeeping necessary to keep the sound effects playing. | [
"Do",
"any",
"housekeeping",
"necessary",
"to",
"keep",
"the",
"sound",
"effects",
"playing",
"."
] | void
AudioSoundEffectProcess(void)
{
tBoolean bComplete;
if(g_bSoundPlaying)
{
bComplete = WavePlayContinue(&g_sSoundEffectHeader);
if(bComplete)
{
g_bSoundPlaying = false;
}
}
} | [
"void",
"AudioSoundEffectProcess",
"(",
"void",
")",
"{",
"tBoolean",
"bComplete",
";",
"if",
"(",
"g_bSoundPlaying",
")",
"{",
"bComplete",
"=",
"WavePlayContinue",
"(",
"&",
"g_sSoundEffectHeader",
")",
";",
"if",
"(",
"bComplete",
")",
"{",
"g_bSoundPlaying",
"=",
"false",
";",
"}",
"}",
"}"
] | Do any housekeeping necessary to keep the sound effects playing. | [
"Do",
"any",
"housekeeping",
"necessary",
"to",
"keep",
"the",
"sound",
"effects",
"playing",
"."
] | [
"//\r",
"// Are we currently playing a sound effect?\r",
"//\r",
"//\r",
"// Feed the wave file processor.\r",
"//\r",
"//\r",
"// Did we finish playback of this sound effect?\r",
"//\r",
"//\r",
"// Yes - remember that we are no longer playing anything.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f5a9f01609eee740608fda7c07db627f13b38d09 | junyanl-code/Luminary-Micro-Library | boards/rdk-idm-sbc/qs-blox/qs-blox.c | [
"BSD-3-Clause"
] | C | PlayNewSoundEffect | void | void
PlayNewSoundEffect(unsigned long ulFlags)
{
const unsigned char *pucNewSound;
tWaveReturnCode eRetcode;
//
// Are we being told to do anything?
//
if(!(ulFlags & BLOX_STAT_MASK))
{
//
// No - there is no new sound effect to play.
//
return;
}
//
// Is the game over?
//
if(ulFlags & BLOX_STAT_END)
{
pucNewSound = g_pucGameOverSound;
}
else
{
//
// Did a block reach the bottom of its drop?
//
if(ulFlags & BLOX_STAT_DROPPED)
{
pucNewSound = g_pucBumpSound;
}
else
{
//
// Nothing special happened so just play the basic tick beep.
//
pucNewSound = g_pucBeepSound;
}
}
//
// Start playing the new sound.
//
eRetcode = WaveOpen((unsigned long *)pucNewSound,
&g_sSoundEffectHeader);
//
// Did we parse the sound successfully?
//
if(eRetcode == WAVE_OK)
{
//
// Remember that we are playing a sound effect.
//
g_bSoundPlaying = true;
//
// Start playback of the wave file data.
//
WavePlayStart(&g_sSoundEffectHeader);
}
} | //*****************************************************************************
//
// Play a new audio clip based on the game status flags passed.
//
//*****************************************************************************
| Play a new audio clip based on the game status flags passed. | [
"Play",
"a",
"new",
"audio",
"clip",
"based",
"on",
"the",
"game",
"status",
"flags",
"passed",
"."
] | void
PlayNewSoundEffect(unsigned long ulFlags)
{
const unsigned char *pucNewSound;
tWaveReturnCode eRetcode;
if(!(ulFlags & BLOX_STAT_MASK))
{
return;
}
if(ulFlags & BLOX_STAT_END)
{
pucNewSound = g_pucGameOverSound;
}
else
{
if(ulFlags & BLOX_STAT_DROPPED)
{
pucNewSound = g_pucBumpSound;
}
else
{
pucNewSound = g_pucBeepSound;
}
}
eRetcode = WaveOpen((unsigned long *)pucNewSound,
&g_sSoundEffectHeader);
if(eRetcode == WAVE_OK)
{
g_bSoundPlaying = true;
WavePlayStart(&g_sSoundEffectHeader);
}
} | [
"void",
"PlayNewSoundEffect",
"(",
"unsigned",
"long",
"ulFlags",
")",
"{",
"const",
"unsigned",
"char",
"*",
"pucNewSound",
";",
"tWaveReturnCode",
"eRetcode",
";",
"if",
"(",
"!",
"(",
"ulFlags",
"&",
"BLOX_STAT_MASK",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"ulFlags",
"&",
"BLOX_STAT_END",
")",
"{",
"pucNewSound",
"=",
"g_pucGameOverSound",
";",
"}",
"else",
"{",
"if",
"(",
"ulFlags",
"&",
"BLOX_STAT_DROPPED",
")",
"{",
"pucNewSound",
"=",
"g_pucBumpSound",
";",
"}",
"else",
"{",
"pucNewSound",
"=",
"g_pucBeepSound",
";",
"}",
"}",
"eRetcode",
"=",
"WaveOpen",
"(",
"(",
"unsigned",
"long",
"*",
")",
"pucNewSound",
",",
"&",
"g_sSoundEffectHeader",
")",
";",
"if",
"(",
"eRetcode",
"==",
"WAVE_OK",
")",
"{",
"g_bSoundPlaying",
"=",
"true",
";",
"WavePlayStart",
"(",
"&",
"g_sSoundEffectHeader",
")",
";",
"}",
"}"
] | Play a new audio clip based on the game status flags passed. | [
"Play",
"a",
"new",
"audio",
"clip",
"based",
"on",
"the",
"game",
"status",
"flags",
"passed",
"."
] | [
"//\r",
"// Are we being told to do anything?\r",
"//\r",
"//\r",
"// No - there is no new sound effect to play.\r",
"//\r",
"//\r",
"// Is the game over?\r",
"//\r",
"//\r",
"// Did a block reach the bottom of its drop?\r",
"//\r",
"//\r",
"// Nothing special happened so just play the basic tick beep.\r",
"//\r",
"//\r",
"// Start playing the new sound.\r",
"//\r",
"//\r",
"// Did we parse the sound successfully?\r",
"//\r",
"//\r",
"// Remember that we are playing a sound effect.\r",
"//\r",
"//\r",
"// Start playback of the wave file data.\r",
"//\r"
] | [
{
"param": "ulFlags",
"type": "unsigned long"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ulFlags",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
be7748507b0a4577d2c2e5876ae706794eab941e | junyanl-code/Luminary-Micro-Library | boards/dk-lm3s9b96/IQmath_demo/IQmath_demo.c | [
"BSD-3-Clause"
] | C | DrawModel | void | void
DrawModel(void)
{
unsigned long ulIdx, ulLine;
tDisplay sDisplay;
tContext sContext;
tRectangle sRect;
//
// Initialize the off-screen buffer.
//
GrOffScreen1BPPInit(&sDisplay, g_pucBuffer, WIDTH, HEIGHT);
GrContextInit(&sContext, &sDisplay);
//
// Clear the off-screen buffer.
//
sRect.sXMin = 0;
sRect.sYMin = 0;
sRect.sXMax = WIDTH - 1;
sRect.sYMax = HEIGHT - 1;
GrContextForegroundSet(&sContext, ClrBlack);
GrRectFill(&sContext, &sRect);
//
// Set the foreground color that will be used to draw the model.
//
GrContextForegroundSet(&sContext, ClrWhite);
//
// Loop through the faces of the model.
//
for(ulIdx = 0; ulIdx < NUM_FACES; ulIdx++)
{
//
// Skip this face if it is not visible.
//
if(g_plIsVisible[ulIdx] == 0)
{
continue;
}
//
// Draw the lines that make up this face.
//
for(ulLine = 0; ulLine < NUM_FACE_LINES; ulLine++)
{
GrLineDraw(&sContext, g_pplPoints[g_pplFaces[ulIdx][ulLine]][0],
g_pplPoints[g_pplFaces[ulIdx][ulLine]][1],
g_pplPoints[g_pplFaces[ulIdx][ulLine + 1]][0],
g_pplPoints[g_pplFaces[ulIdx][ulLine + 1]][1]);
}
//
// Draw the lines that make up the logo on this face.
//
for(ulLine = 0; ulLine < NUM_LOGO_LINES; ulLine++)
{
GrLineDraw(&sContext, g_pplPoints[g_pplLogos[ulIdx][ulLine]][0],
g_pplPoints[g_pplLogos[ulIdx][ulLine]][1],
g_pplPoints[g_pplLogos[ulIdx][ulLine + 1]][0],
g_pplPoints[g_pplLogos[ulIdx][ulLine + 1]][1]);
}
}
} | //*****************************************************************************
//
// Draws the rotated model into the off-screen buffer.
//
//*****************************************************************************
| Draws the rotated model into the off-screen buffer. | [
"Draws",
"the",
"rotated",
"model",
"into",
"the",
"off",
"-",
"screen",
"buffer",
"."
] | void
DrawModel(void)
{
unsigned long ulIdx, ulLine;
tDisplay sDisplay;
tContext sContext;
tRectangle sRect;
GrOffScreen1BPPInit(&sDisplay, g_pucBuffer, WIDTH, HEIGHT);
GrContextInit(&sContext, &sDisplay);
sRect.sXMin = 0;
sRect.sYMin = 0;
sRect.sXMax = WIDTH - 1;
sRect.sYMax = HEIGHT - 1;
GrContextForegroundSet(&sContext, ClrBlack);
GrRectFill(&sContext, &sRect);
GrContextForegroundSet(&sContext, ClrWhite);
for(ulIdx = 0; ulIdx < NUM_FACES; ulIdx++)
{
if(g_plIsVisible[ulIdx] == 0)
{
continue;
}
for(ulLine = 0; ulLine < NUM_FACE_LINES; ulLine++)
{
GrLineDraw(&sContext, g_pplPoints[g_pplFaces[ulIdx][ulLine]][0],
g_pplPoints[g_pplFaces[ulIdx][ulLine]][1],
g_pplPoints[g_pplFaces[ulIdx][ulLine + 1]][0],
g_pplPoints[g_pplFaces[ulIdx][ulLine + 1]][1]);
}
for(ulLine = 0; ulLine < NUM_LOGO_LINES; ulLine++)
{
GrLineDraw(&sContext, g_pplPoints[g_pplLogos[ulIdx][ulLine]][0],
g_pplPoints[g_pplLogos[ulIdx][ulLine]][1],
g_pplPoints[g_pplLogos[ulIdx][ulLine + 1]][0],
g_pplPoints[g_pplLogos[ulIdx][ulLine + 1]][1]);
}
}
} | [
"void",
"DrawModel",
"(",
"void",
")",
"{",
"unsigned",
"long",
"ulIdx",
",",
"ulLine",
";",
"tDisplay",
"sDisplay",
";",
"tContext",
"sContext",
";",
"tRectangle",
"sRect",
";",
"GrOffScreen1BPPInit",
"(",
"&",
"sDisplay",
",",
"g_pucBuffer",
",",
"WIDTH",
",",
"HEIGHT",
")",
";",
"GrContextInit",
"(",
"&",
"sContext",
",",
"&",
"sDisplay",
")",
";",
"sRect",
".",
"sXMin",
"=",
"0",
";",
"sRect",
".",
"sYMin",
"=",
"0",
";",
"sRect",
".",
"sXMax",
"=",
"WIDTH",
"-",
"1",
";",
"sRect",
".",
"sYMax",
"=",
"HEIGHT",
"-",
"1",
";",
"GrContextForegroundSet",
"(",
"&",
"sContext",
",",
"ClrBlack",
")",
";",
"GrRectFill",
"(",
"&",
"sContext",
",",
"&",
"sRect",
")",
";",
"GrContextForegroundSet",
"(",
"&",
"sContext",
",",
"ClrWhite",
")",
";",
"for",
"(",
"ulIdx",
"=",
"0",
";",
"ulIdx",
"<",
"NUM_FACES",
";",
"ulIdx",
"++",
")",
"{",
"if",
"(",
"g_plIsVisible",
"[",
"ulIdx",
"]",
"==",
"0",
")",
"{",
"continue",
";",
"}",
"for",
"(",
"ulLine",
"=",
"0",
";",
"ulLine",
"<",
"NUM_FACE_LINES",
";",
"ulLine",
"++",
")",
"{",
"GrLineDraw",
"(",
"&",
"sContext",
",",
"g_pplPoints",
"[",
"g_pplFaces",
"[",
"ulIdx",
"]",
"[",
"ulLine",
"]",
"]",
"[",
"0",
"]",
",",
"g_pplPoints",
"[",
"g_pplFaces",
"[",
"ulIdx",
"]",
"[",
"ulLine",
"]",
"]",
"[",
"1",
"]",
",",
"g_pplPoints",
"[",
"g_pplFaces",
"[",
"ulIdx",
"]",
"[",
"ulLine",
"+",
"1",
"]",
"]",
"[",
"0",
"]",
",",
"g_pplPoints",
"[",
"g_pplFaces",
"[",
"ulIdx",
"]",
"[",
"ulLine",
"+",
"1",
"]",
"]",
"[",
"1",
"]",
")",
";",
"}",
"for",
"(",
"ulLine",
"=",
"0",
";",
"ulLine",
"<",
"NUM_LOGO_LINES",
";",
"ulLine",
"++",
")",
"{",
"GrLineDraw",
"(",
"&",
"sContext",
",",
"g_pplPoints",
"[",
"g_pplLogos",
"[",
"ulIdx",
"]",
"[",
"ulLine",
"]",
"]",
"[",
"0",
"]",
",",
"g_pplPoints",
"[",
"g_pplLogos",
"[",
"ulIdx",
"]",
"[",
"ulLine",
"]",
"]",
"[",
"1",
"]",
",",
"g_pplPoints",
"[",
"g_pplLogos",
"[",
"ulIdx",
"]",
"[",
"ulLine",
"+",
"1",
"]",
"]",
"[",
"0",
"]",
",",
"g_pplPoints",
"[",
"g_pplLogos",
"[",
"ulIdx",
"]",
"[",
"ulLine",
"+",
"1",
"]",
"]",
"[",
"1",
"]",
")",
";",
"}",
"}",
"}"
] | Draws the rotated model into the off-screen buffer. | [
"Draws",
"the",
"rotated",
"model",
"into",
"the",
"off",
"-",
"screen",
"buffer",
"."
] | [
"//\r",
"// Initialize the off-screen buffer.\r",
"//\r",
"//\r",
"// Clear the off-screen buffer.\r",
"//\r",
"//\r",
"// Set the foreground color that will be used to draw the model.\r",
"//\r",
"//\r",
"// Loop through the faces of the model.\r",
"//\r",
"//\r",
"// Skip this face if it is not visible.\r",
"//\r",
"//\r",
"// Draw the lines that make up this face.\r",
"//\r",
"//\r",
"// Draw the lines that make up the logo on this face.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
be7748507b0a4577d2c2e5876ae706794eab941e | junyanl-code/Luminary-Micro-Library | boards/dk-lm3s9b96/IQmath_demo/IQmath_demo.c | [
"BSD-3-Clause"
] | C | RandomNumber | null | unsigned long
RandomNumber(void)
{
//
// Generate a new pseudo-random number with a linear congruence random
// number generator. This new random number becomes the seed for the next
// random number.
//
g_ulRandomSeed = (g_ulRandomSeed * 1664525) + 1013904223;
//
// Return the new random number.
//
return(g_ulRandomSeed);
} | //*****************************************************************************
//
// Generate a new random number. The number returned would more accruately be
// described as a pseudo-random number since a linear congruence generator is
// being used.
//
//*****************************************************************************
| Generate a new random number. The number returned would more accruately be
described as a pseudo-random number since a linear congruence generator is
being used. | [
"Generate",
"a",
"new",
"random",
"number",
".",
"The",
"number",
"returned",
"would",
"more",
"accruately",
"be",
"described",
"as",
"a",
"pseudo",
"-",
"random",
"number",
"since",
"a",
"linear",
"congruence",
"generator",
"is",
"being",
"used",
"."
] | unsigned long
RandomNumber(void)
{
g_ulRandomSeed = (g_ulRandomSeed * 1664525) + 1013904223;
return(g_ulRandomSeed);
} | [
"unsigned",
"long",
"RandomNumber",
"(",
"void",
")",
"{",
"g_ulRandomSeed",
"=",
"(",
"g_ulRandomSeed",
"*",
"1664525",
")",
"+",
"1013904223",
";",
"return",
"(",
"g_ulRandomSeed",
")",
";",
"}"
] | Generate a new random number. | [
"Generate",
"a",
"new",
"random",
"number",
"."
] | [
"//\r",
"// Generate a new pseudo-random number with a linear congruence random\r",
"// number generator. This new random number becomes the seed for the next\r",
"// random number.\r",
"//\r",
"//\r",
"// Return the new random number.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
be7748507b0a4577d2c2e5876ae706794eab941e | junyanl-code/Luminary-Micro-Library | boards/dk-lm3s9b96/IQmath_demo/IQmath_demo.c | [
"BSD-3-Clause"
] | C | UpdatePosition | null | unsigned long
UpdatePosition(long *plPosition, long *plDelta, long lMin, long lMax)
{
//
// Update the position by the delta.
//
*plPosition += *plDelta;
//
// See if the position has exceeded the minimum or maximum. If it has not,
// then return without any further processing.
//
if(*plPosition < lMin)
{
*plPosition = lMin;
}
else if(*plPosition > lMax)
{
*plPosition = lMax;
}
else
{
return(0);
}
//
// Choose a new delta based on a random number.
//
*plDelta = (long)(RandomNumber() >> 28) - 8;
//
// Make sure that the delta is not too small.
//
if((*plDelta < 0) && (*plDelta > -4))
{
*plDelta = -4;
}
if((*plDelta >= 0) && (*plDelta < 4))
{
*plDelta = 4;
}
//
// Indicate that an extent was reached.
//
return(1);
} | //*****************************************************************************
//
// Updates the value of one axis of the model's position.
//
//*****************************************************************************
| Updates the value of one axis of the model's position. | [
"Updates",
"the",
"value",
"of",
"one",
"axis",
"of",
"the",
"model",
"'",
"s",
"position",
"."
] | unsigned long
UpdatePosition(long *plPosition, long *plDelta, long lMin, long lMax)
{
*plPosition += *plDelta;
if(*plPosition < lMin)
{
*plPosition = lMin;
}
else if(*plPosition > lMax)
{
*plPosition = lMax;
}
else
{
return(0);
}
*plDelta = (long)(RandomNumber() >> 28) - 8;
if((*plDelta < 0) && (*plDelta > -4))
{
*plDelta = -4;
}
if((*plDelta >= 0) && (*plDelta < 4))
{
*plDelta = 4;
}
return(1);
} | [
"unsigned",
"long",
"UpdatePosition",
"(",
"long",
"*",
"plPosition",
",",
"long",
"*",
"plDelta",
",",
"long",
"lMin",
",",
"long",
"lMax",
")",
"{",
"*",
"plPosition",
"+=",
"*",
"plDelta",
";",
"if",
"(",
"*",
"plPosition",
"<",
"lMin",
")",
"{",
"*",
"plPosition",
"=",
"lMin",
";",
"}",
"else",
"if",
"(",
"*",
"plPosition",
">",
"lMax",
")",
"{",
"*",
"plPosition",
"=",
"lMax",
";",
"}",
"else",
"{",
"return",
"(",
"0",
")",
";",
"}",
"*",
"plDelta",
"=",
"(",
"long",
")",
"(",
"RandomNumber",
"(",
")",
">>",
"28",
")",
"-",
"8",
";",
"if",
"(",
"(",
"*",
"plDelta",
"<",
"0",
")",
"&&",
"(",
"*",
"plDelta",
">",
"-4",
")",
")",
"{",
"*",
"plDelta",
"=",
"-4",
";",
"}",
"if",
"(",
"(",
"*",
"plDelta",
">=",
"0",
")",
"&&",
"(",
"*",
"plDelta",
"<",
"4",
")",
")",
"{",
"*",
"plDelta",
"=",
"4",
";",
"}",
"return",
"(",
"1",
")",
";",
"}"
] | Updates the value of one axis of the model's position. | [
"Updates",
"the",
"value",
"of",
"one",
"axis",
"of",
"the",
"model",
"'",
"s",
"position",
"."
] | [
"//\r",
"// Update the position by the delta.\r",
"//\r",
"//\r",
"// See if the position has exceeded the minimum or maximum. If it has not,\r",
"// then return without any further processing.\r",
"//\r",
"//\r",
"// Choose a new delta based on a random number.\r",
"//\r",
"//\r",
"// Make sure that the delta is not too small.\r",
"//\r",
"//\r",
"// Indicate that an extent was reached.\r",
"//\r"
] | [
{
"param": "plPosition",
"type": "long"
},
{
"param": "plDelta",
"type": "long"
},
{
"param": "lMin",
"type": "long"
},
{
"param": "lMax",
"type": "long"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "plPosition",
"type": "long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "plDelta",
"type": "long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lMin",
"type": "long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lMax",
"type": "long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
be7748507b0a4577d2c2e5876ae706794eab941e | junyanl-code/Luminary-Micro-Library | boards/dk-lm3s9b96/IQmath_demo/IQmath_demo.c | [
"BSD-3-Clause"
] | C | UpdateColor | void | void
UpdateColor(void)
{
unsigned long ulIdx, ulNew;
//
// Loop through the three components of the color.
//
ulNew = 1;
for(ulIdx = 0; ulIdx < 3; ulIdx++)
{
//
// See if this component of the color has reached the target.
//
if(g_pucColors[ulIdx] != g_pucColorTarget[ulIdx])
{
//
// Either increment or decrement this component of the color as
// required to make it approach the target.
//
if(g_pucColors[ulIdx] > g_pucColorTarget[ulIdx])
{
g_pucColors[ulIdx] -= 3;
}
else
{
g_pucColors[ulIdx] += 3;
}
//
// Indicate that it is not time for a new color target.
//
ulNew = 0;
}
}
//
// See if it is time for a new color target.
//
if(ulNew)
{
//
// Increment the color target array index.
//
g_ulColorTarget++;
if(g_ulColorTarget == NUM_COLORS)
{
g_ulColorTarget = 0;
}
//
// Copy the color components of the new target color from the array
// into the color target.
//
for(ulIdx = 0; ulIdx < 3; ulIdx++)
{
g_pucColorTarget[ulIdx] =
g_ppucColorTargets[g_ulColorTarget][ulIdx];
}
}
} | //*****************************************************************************
//
// Updates the color used for drawing the model.
//
//*****************************************************************************
| Updates the color used for drawing the model. | [
"Updates",
"the",
"color",
"used",
"for",
"drawing",
"the",
"model",
"."
] | void
UpdateColor(void)
{
unsigned long ulIdx, ulNew;
ulNew = 1;
for(ulIdx = 0; ulIdx < 3; ulIdx++)
{
if(g_pucColors[ulIdx] != g_pucColorTarget[ulIdx])
{
if(g_pucColors[ulIdx] > g_pucColorTarget[ulIdx])
{
g_pucColors[ulIdx] -= 3;
}
else
{
g_pucColors[ulIdx] += 3;
}
ulNew = 0;
}
}
if(ulNew)
{
g_ulColorTarget++;
if(g_ulColorTarget == NUM_COLORS)
{
g_ulColorTarget = 0;
}
for(ulIdx = 0; ulIdx < 3; ulIdx++)
{
g_pucColorTarget[ulIdx] =
g_ppucColorTargets[g_ulColorTarget][ulIdx];
}
}
} | [
"void",
"UpdateColor",
"(",
"void",
")",
"{",
"unsigned",
"long",
"ulIdx",
",",
"ulNew",
";",
"ulNew",
"=",
"1",
";",
"for",
"(",
"ulIdx",
"=",
"0",
";",
"ulIdx",
"<",
"3",
";",
"ulIdx",
"++",
")",
"{",
"if",
"(",
"g_pucColors",
"[",
"ulIdx",
"]",
"!=",
"g_pucColorTarget",
"[",
"ulIdx",
"]",
")",
"{",
"if",
"(",
"g_pucColors",
"[",
"ulIdx",
"]",
">",
"g_pucColorTarget",
"[",
"ulIdx",
"]",
")",
"{",
"g_pucColors",
"[",
"ulIdx",
"]",
"-=",
"3",
";",
"}",
"else",
"{",
"g_pucColors",
"[",
"ulIdx",
"]",
"+=",
"3",
";",
"}",
"ulNew",
"=",
"0",
";",
"}",
"}",
"if",
"(",
"ulNew",
")",
"{",
"g_ulColorTarget",
"++",
";",
"if",
"(",
"g_ulColorTarget",
"==",
"NUM_COLORS",
")",
"{",
"g_ulColorTarget",
"=",
"0",
";",
"}",
"for",
"(",
"ulIdx",
"=",
"0",
";",
"ulIdx",
"<",
"3",
";",
"ulIdx",
"++",
")",
"{",
"g_pucColorTarget",
"[",
"ulIdx",
"]",
"=",
"g_ppucColorTargets",
"[",
"g_ulColorTarget",
"]",
"[",
"ulIdx",
"]",
";",
"}",
"}",
"}"
] | Updates the color used for drawing the model. | [
"Updates",
"the",
"color",
"used",
"for",
"drawing",
"the",
"model",
"."
] | [
"//\r",
"// Loop through the three components of the color.\r",
"//\r",
"//\r",
"// See if this component of the color has reached the target.\r",
"//\r",
"//\r",
"// Either increment or decrement this component of the color as\r",
"// required to make it approach the target.\r",
"//\r",
"//\r",
"// Indicate that it is not time for a new color target.\r",
"//\r",
"//\r",
"// See if it is time for a new color target.\r",
"//\r",
"//\r",
"// Increment the color target array index.\r",
"//\r",
"//\r",
"// Copy the color components of the new target color from the array\r",
"// into the color target.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
be83ff7b8ca9efd9faadd993d0286d16fbede9ed | junyanl-code/Luminary-Micro-Library | boards/rdk-bdc24/qs-bdc24/uart_if.c | [
"BSD-3-Clause"
] | C | UARTIFPutChar | void | static void
UARTIFPutChar(unsigned long ulChar)
{
//
// See if the character being sent is 0xff.
//
if(ulChar == 0xff)
{
//
// Send 0xfe 0xfe, the escaped version of 0xff. A sign extended
// version of 0xfe is used to avoid the check below for 0xfe, thereby
// avoiding an infinite loop. Only the lower 8 bits are actually sent,
// so 0xfe is what is actually transmitted.
//
UARTIFPutChar(0xfffffffe);
UARTIFPutChar(0xfffffffe);
}
//
// Otherwise, see if the character being sent is 0xfe.
//
else if(ulChar == 0xfe)
{
//
// Send 0xfe 0xfd, the escaped version of 0xfe. A sign extended
// version of 0xfe is used to avoid the check above for 0xfe, thereby
// avoiding an infinite loop. Only the lower 8 bits are actually sent,
// so 0xfe is what is actually transmitted.
//
UARTIFPutChar(0xfffffffe);
UARTIFPutChar(0xfd);
}
//
// Otherwise, simply send this character.
//
else
{
//
// Disable the UART interrupt to avoid having characters stick in the
// local buffer.
//
ROM_UARTIntDisable(UART0_BASE, UART_INT_TX);
//
// See if the local buffer is empty and there is space available in the
// UART FIFO.
//
if((g_ulUARTXmitRead == g_ulUARTXmitWrite) &&
ROM_UARTSpaceAvail(UART0_BASE))
{
//
// Simply write this character into the UART FIFO.
//
ROM_UARTCharPut(UART0_BASE, ulChar);
}
else
{
//
// Write this character into the local buffer.
//
g_pucUARTXmit[g_ulUARTXmitWrite] = ulChar;
//
// Increment the local write buffer pointer.
//
g_ulUARTXmitWrite = (g_ulUARTXmitWrite + 1) % UART_XMIT_SIZE;
}
//
// Re-enable the UART interrupt.
//
ROM_UARTIntEnable(UART0_BASE, UART_INT_TX);
}
} | //*****************************************************************************
//
// Sends a character to the UART.
//
//*****************************************************************************
| Sends a character to the UART. | [
"Sends",
"a",
"character",
"to",
"the",
"UART",
"."
] | static void
UARTIFPutChar(unsigned long ulChar)
{
if(ulChar == 0xff)
{
UARTIFPutChar(0xfffffffe);
UARTIFPutChar(0xfffffffe);
}
else if(ulChar == 0xfe)
{
UARTIFPutChar(0xfffffffe);
UARTIFPutChar(0xfd);
}
else
{
ROM_UARTIntDisable(UART0_BASE, UART_INT_TX);
if((g_ulUARTXmitRead == g_ulUARTXmitWrite) &&
ROM_UARTSpaceAvail(UART0_BASE))
{
ROM_UARTCharPut(UART0_BASE, ulChar);
}
else
{
g_pucUARTXmit[g_ulUARTXmitWrite] = ulChar;
g_ulUARTXmitWrite = (g_ulUARTXmitWrite + 1) % UART_XMIT_SIZE;
}
ROM_UARTIntEnable(UART0_BASE, UART_INT_TX);
}
} | [
"static",
"void",
"UARTIFPutChar",
"(",
"unsigned",
"long",
"ulChar",
")",
"{",
"if",
"(",
"ulChar",
"==",
"0xff",
")",
"{",
"UARTIFPutChar",
"(",
"0xfffffffe",
")",
";",
"UARTIFPutChar",
"(",
"0xfffffffe",
")",
";",
"}",
"else",
"if",
"(",
"ulChar",
"==",
"0xfe",
")",
"{",
"UARTIFPutChar",
"(",
"0xfffffffe",
")",
";",
"UARTIFPutChar",
"(",
"0xfd",
")",
";",
"}",
"else",
"{",
"ROM_UARTIntDisable",
"(",
"UART0_BASE",
",",
"UART_INT_TX",
")",
";",
"if",
"(",
"(",
"g_ulUARTXmitRead",
"==",
"g_ulUARTXmitWrite",
")",
"&&",
"ROM_UARTSpaceAvail",
"(",
"UART0_BASE",
")",
")",
"{",
"ROM_UARTCharPut",
"(",
"UART0_BASE",
",",
"ulChar",
")",
";",
"}",
"else",
"{",
"g_pucUARTXmit",
"[",
"g_ulUARTXmitWrite",
"]",
"=",
"ulChar",
";",
"g_ulUARTXmitWrite",
"=",
"(",
"g_ulUARTXmitWrite",
"+",
"1",
")",
"%",
"UART_XMIT_SIZE",
";",
"}",
"ROM_UARTIntEnable",
"(",
"UART0_BASE",
",",
"UART_INT_TX",
")",
";",
"}",
"}"
] | Sends a character to the UART. | [
"Sends",
"a",
"character",
"to",
"the",
"UART",
"."
] | [
"//\r",
"// See if the character being sent is 0xff.\r",
"//\r",
"//\r",
"// Send 0xfe 0xfe, the escaped version of 0xff. A sign extended\r",
"// version of 0xfe is used to avoid the check below for 0xfe, thereby\r",
"// avoiding an infinite loop. Only the lower 8 bits are actually sent,\r",
"// so 0xfe is what is actually transmitted.\r",
"//\r",
"//\r",
"// Otherwise, see if the character being sent is 0xfe.\r",
"//\r",
"//\r",
"// Send 0xfe 0xfd, the escaped version of 0xfe. A sign extended\r",
"// version of 0xfe is used to avoid the check above for 0xfe, thereby\r",
"// avoiding an infinite loop. Only the lower 8 bits are actually sent,\r",
"// so 0xfe is what is actually transmitted.\r",
"//\r",
"//\r",
"// Otherwise, simply send this character.\r",
"//\r",
"//\r",
"// Disable the UART interrupt to avoid having characters stick in the\r",
"// local buffer.\r",
"//\r",
"//\r",
"// See if the local buffer is empty and there is space available in the\r",
"// UART FIFO.\r",
"//\r",
"//\r",
"// Simply write this character into the UART FIFO.\r",
"//\r",
"//\r",
"// Write this character into the local buffer.\r",
"//\r",
"//\r",
"// Increment the local write buffer pointer.\r",
"//\r",
"//\r",
"// Re-enable the UART interrupt.\r",
"//\r"
] | [
{
"param": "ulChar",
"type": "unsigned long"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ulChar",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
be83ff7b8ca9efd9faadd993d0286d16fbede9ed | junyanl-code/Luminary-Micro-Library | boards/rdk-bdc24/qs-bdc24/uart_if.c | [
"BSD-3-Clause"
] | C | UARTIFSendMessage | void | void
UARTIFSendMessage(unsigned long ulID, unsigned char *pucData,
unsigned long ulDataLength)
{
//
// Send the start of packet indicator. A sign extended version of 0xff is
// used to avoid having it escaped.
//
UARTIFPutChar(0xffffffff);
//
// Send the length of the data packet.
//
UARTIFPutChar(ulDataLength + 4);
//
// Send the message ID.
//
UARTIFPutChar(ulID & 0xff);
UARTIFPutChar((ulID >> 8) & 0xff);
UARTIFPutChar((ulID >> 16) & 0xff);
UARTIFPutChar((ulID >> 24) & 0xff);
//
// Send the associated data, if any.
//
while(ulDataLength--)
{
UARTIFPutChar(*pucData++);
}
} | //*****************************************************************************
//
// Sends a message to the UART.
//
//*****************************************************************************
| Sends a message to the UART. | [
"Sends",
"a",
"message",
"to",
"the",
"UART",
"."
] | void
UARTIFSendMessage(unsigned long ulID, unsigned char *pucData,
unsigned long ulDataLength)
{
UARTIFPutChar(0xffffffff);
UARTIFPutChar(ulDataLength + 4);
UARTIFPutChar(ulID & 0xff);
UARTIFPutChar((ulID >> 8) & 0xff);
UARTIFPutChar((ulID >> 16) & 0xff);
UARTIFPutChar((ulID >> 24) & 0xff);
while(ulDataLength--)
{
UARTIFPutChar(*pucData++);
}
} | [
"void",
"UARTIFSendMessage",
"(",
"unsigned",
"long",
"ulID",
",",
"unsigned",
"char",
"*",
"pucData",
",",
"unsigned",
"long",
"ulDataLength",
")",
"{",
"UARTIFPutChar",
"(",
"0xffffffff",
")",
";",
"UARTIFPutChar",
"(",
"ulDataLength",
"+",
"4",
")",
";",
"UARTIFPutChar",
"(",
"ulID",
"&",
"0xff",
")",
";",
"UARTIFPutChar",
"(",
"(",
"ulID",
">>",
"8",
")",
"&",
"0xff",
")",
";",
"UARTIFPutChar",
"(",
"(",
"ulID",
">>",
"16",
")",
"&",
"0xff",
")",
";",
"UARTIFPutChar",
"(",
"(",
"ulID",
">>",
"24",
")",
"&",
"0xff",
")",
";",
"while",
"(",
"ulDataLength",
"--",
")",
"{",
"UARTIFPutChar",
"(",
"*",
"pucData",
"++",
")",
";",
"}",
"}"
] | Sends a message to the UART. | [
"Sends",
"a",
"message",
"to",
"the",
"UART",
"."
] | [
"//\r",
"// Send the start of packet indicator. A sign extended version of 0xff is\r",
"// used to avoid having it escaped.\r",
"//\r",
"//\r",
"// Send the length of the data packet.\r",
"//\r",
"//\r",
"// Send the message ID.\r",
"//\r",
"//\r",
"// Send the associated data, if any.\r",
"//\r"
] | [
{
"param": "ulID",
"type": "unsigned long"
},
{
"param": "pucData",
"type": "unsigned char"
},
{
"param": "ulDataLength",
"type": "unsigned long"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ulID",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pucData",
"type": "unsigned char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ulDataLength",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
be83ff7b8ca9efd9faadd993d0286d16fbede9ed | junyanl-code/Luminary-Micro-Library | boards/rdk-bdc24/qs-bdc24/uart_if.c | [
"BSD-3-Clause"
] | C | UART0IntHandler | void | void
UART0IntHandler(void)
{
unsigned long ulStatus;
unsigned char ucChar;
//
// Get the interrupts that are being asserted by the UART.
//
ulStatus = ROM_UARTIntStatus(UART0_BASE, true);
//
// Clear the asserted interrupts.
//
ROM_UARTIntClear(UART0_BASE, ulStatus);
//
// Indicate that the UART link is good.
//
ControllerLinkGood(LINK_TYPE_UART);
//
// See if the receive interrupt has been asserted.
//
if(ulStatus & (UART_INT_RX | UART_INT_RT))
{
//
// Loop while there are more characters to be read from the UART.
//
while(ROM_UARTCharsAvail(UART0_BASE))
{
//
// Read the next character from the UART.
//
ucChar = ROM_UARTCharGet(UART0_BASE);
//
// See if this is a start of packet byte.
//
if(ucChar == 0xff)
{
//
// Reset the length of the UART message.
//
g_ulUARTLength = 0;
//
// Set the state such that the next byte received is the size
// of the message.
//
g_ulUARTState = UART_STATE_LENGTH;
}
//
// See if this byte is the size of the message.
//
else if(g_ulUARTState == UART_STATE_LENGTH)
{
//
// Save the size of the message.
//
g_ulUARTSize = ucChar;
//
// Subsequent bytes received are the message data.
//
g_ulUARTState = UART_STATE_DATA;
}
//
// See if the previous character was an escape character.
//
else if(g_ulUARTState == UART_STATE_ESCAPE)
{
//
// See if this 0xfe, the escaped version of 0xff.
//
if(ucChar == 0xfe)
{
//
// Store a 0xff in the message buffer.
//
g_pucUARTMessage[g_ulUARTLength++] = 0xff;
//
// Subsequent bytes received are the message data.
//
g_ulUARTState = UART_STATE_DATA;
}
//
// Otherwise, see if this is 0xfd, the escaped version of 0xfe.
//
else if(ucChar == 0xfd)
{
//
// Store a 0xfe in the message buffer.
//
g_pucUARTMessage[g_ulUARTLength++] = 0xfe;
//
// Subsequent bytes received are the message data.
//
g_ulUARTState = UART_STATE_DATA;
}
//
// Otherwise, this is a corrupted sequence. Set the receiver
// to idle so this message is dropped, and subsequent data is
// ignored until another start of packet is received.
//
else
{
g_ulUARTState = UART_STATE_IDLE;
}
}
//
// See if this is a part of the message data.
//
else if(g_ulUARTState == UART_STATE_DATA)
{
//
// See if this character is an escape character.
//
if(ucChar == 0xfe)
{
//
// The next byte is an escaped byte.
//
g_ulUARTState = UART_STATE_ESCAPE;
}
else
{
//
// Store this byte in the message buffer.
//
g_pucUARTMessage[g_ulUARTLength++] = ucChar;
}
}
//
// See if the entire message has been received but has not been
// processed (i.e. the most recent byte received was the end of the
// message).
//
if((g_ulUARTLength == g_ulUARTSize) &&
(g_ulUARTState == UART_STATE_DATA))
{
//
// Process this message.
//
UARTIFCommandHandler();
//
// The UART interface is idle, meaning all bytes will be
// dropped until the next start of packet byte.
//
g_ulUARTState = UART_STATE_IDLE;
}
}
//
// Tell the controller that CAN activity was detected.
//
ControllerWatchdog(LINK_TYPE_UART);
}
//
// See if the transmit interrupt has been asserted.
//
if(ulStatus & UART_INT_TX)
{
//
// Loop while there are more characters to be transmitted and more
// space in the UART FIFO.
//
while((g_ulUARTXmitRead != g_ulUARTXmitWrite) &&
ROM_UARTSpaceAvail(UART0_BASE))
{
//
// Put the next character into the UART FIFO.
//
ROM_UARTCharPut(UART0_BASE, g_pucUARTXmit[g_ulUARTXmitRead]);
//
// Increment the read pointer.
//
g_ulUARTXmitRead = (g_ulUARTXmitRead + 1) % UART_XMIT_SIZE;
}
}
//
// See if an enumeration response needs to be sent.
//
if(HWREGBITW(&g_ulUARTFlags, UART_FLAG_ENUM) != 0)
{
//
// Send the enumeration response for this device.
//
UARTIFSendMessage(CAN_MSGID_API_ENUMERATE |
g_sParameters.ucDeviceNumber, 0, 0);
//
// Clear the enumeration response flag.
//
HWREGBITW(&g_ulUARTFlags, UART_FLAG_ENUM) = 0;
}
//
// See if periodic status messages need to be sent.
//
if(HWREGBITW(&g_ulUARTFlags, UART_FLAG_PSTATUS) != 0)
{
//
// Send out the first periodic status message if it needs to be sent.
//
if(g_ulPStatFlags & 1)
{
UARTIFSendMessage(LM_API_PSTAT_DATA_S0 |
g_sParameters.ucDeviceNumber,
g_ppucPStatMessages[0],
g_pucPStatMessageLen[0]);
}
//
// Send out the second periodic status message if it needs to be sent.
//
if(g_ulPStatFlags & 2)
{
UARTIFSendMessage(LM_API_PSTAT_DATA_S1 |
g_sParameters.ucDeviceNumber,
g_ppucPStatMessages[1],
g_pucPStatMessageLen[1]);
}
//
// Send out the third periodic status message if it needs to be sent.
//
if(g_ulPStatFlags & 4)
{
UARTIFSendMessage(LM_API_PSTAT_DATA_S2 |
g_sParameters.ucDeviceNumber,
g_ppucPStatMessages[2],
g_pucPStatMessageLen[2]);
}
//
// Send out the fourth periodic status message if it needs to be sent.
//
if(g_ulPStatFlags & 8)
{
UARTIFSendMessage(LM_API_PSTAT_DATA_S3 |
g_sParameters.ucDeviceNumber,
g_ppucPStatMessages[3],
g_pucPStatMessageLen[3]);
}
//
// Clear the periodic status message flag.
//
HWREGBITW(&g_ulUARTFlags, UART_FLAG_PSTATUS) = 0;
}
} | //*****************************************************************************
//
// Handles interrupts from the UART.
//
//*****************************************************************************
| Handles interrupts from the UART. | [
"Handles",
"interrupts",
"from",
"the",
"UART",
"."
] | void
UART0IntHandler(void)
{
unsigned long ulStatus;
unsigned char ucChar;
ulStatus = ROM_UARTIntStatus(UART0_BASE, true);
ROM_UARTIntClear(UART0_BASE, ulStatus);
ControllerLinkGood(LINK_TYPE_UART);
if(ulStatus & (UART_INT_RX | UART_INT_RT))
{
while(ROM_UARTCharsAvail(UART0_BASE))
{
ucChar = ROM_UARTCharGet(UART0_BASE);
if(ucChar == 0xff)
{
g_ulUARTLength = 0;
g_ulUARTState = UART_STATE_LENGTH;
}
else if(g_ulUARTState == UART_STATE_LENGTH)
{
g_ulUARTSize = ucChar;
g_ulUARTState = UART_STATE_DATA;
}
else if(g_ulUARTState == UART_STATE_ESCAPE)
{
if(ucChar == 0xfe)
{
g_pucUARTMessage[g_ulUARTLength++] = 0xff;
g_ulUARTState = UART_STATE_DATA;
}
else if(ucChar == 0xfd)
{
g_pucUARTMessage[g_ulUARTLength++] = 0xfe;
g_ulUARTState = UART_STATE_DATA;
}
else
{
g_ulUARTState = UART_STATE_IDLE;
}
}
else if(g_ulUARTState == UART_STATE_DATA)
{
if(ucChar == 0xfe)
{
g_ulUARTState = UART_STATE_ESCAPE;
}
else
{
g_pucUARTMessage[g_ulUARTLength++] = ucChar;
}
}
if((g_ulUARTLength == g_ulUARTSize) &&
(g_ulUARTState == UART_STATE_DATA))
{
UARTIFCommandHandler();
g_ulUARTState = UART_STATE_IDLE;
}
}
ControllerWatchdog(LINK_TYPE_UART);
}
if(ulStatus & UART_INT_TX)
{
while((g_ulUARTXmitRead != g_ulUARTXmitWrite) &&
ROM_UARTSpaceAvail(UART0_BASE))
{
ROM_UARTCharPut(UART0_BASE, g_pucUARTXmit[g_ulUARTXmitRead]);
g_ulUARTXmitRead = (g_ulUARTXmitRead + 1) % UART_XMIT_SIZE;
}
}
if(HWREGBITW(&g_ulUARTFlags, UART_FLAG_ENUM) != 0)
{
UARTIFSendMessage(CAN_MSGID_API_ENUMERATE |
g_sParameters.ucDeviceNumber, 0, 0);
HWREGBITW(&g_ulUARTFlags, UART_FLAG_ENUM) = 0;
}
if(HWREGBITW(&g_ulUARTFlags, UART_FLAG_PSTATUS) != 0)
{
if(g_ulPStatFlags & 1)
{
UARTIFSendMessage(LM_API_PSTAT_DATA_S0 |
g_sParameters.ucDeviceNumber,
g_ppucPStatMessages[0],
g_pucPStatMessageLen[0]);
}
if(g_ulPStatFlags & 2)
{
UARTIFSendMessage(LM_API_PSTAT_DATA_S1 |
g_sParameters.ucDeviceNumber,
g_ppucPStatMessages[1],
g_pucPStatMessageLen[1]);
}
if(g_ulPStatFlags & 4)
{
UARTIFSendMessage(LM_API_PSTAT_DATA_S2 |
g_sParameters.ucDeviceNumber,
g_ppucPStatMessages[2],
g_pucPStatMessageLen[2]);
}
if(g_ulPStatFlags & 8)
{
UARTIFSendMessage(LM_API_PSTAT_DATA_S3 |
g_sParameters.ucDeviceNumber,
g_ppucPStatMessages[3],
g_pucPStatMessageLen[3]);
}
HWREGBITW(&g_ulUARTFlags, UART_FLAG_PSTATUS) = 0;
}
} | [
"void",
"UART0IntHandler",
"(",
"void",
")",
"{",
"unsigned",
"long",
"ulStatus",
";",
"unsigned",
"char",
"ucChar",
";",
"ulStatus",
"=",
"ROM_UARTIntStatus",
"(",
"UART0_BASE",
",",
"true",
")",
";",
"ROM_UARTIntClear",
"(",
"UART0_BASE",
",",
"ulStatus",
")",
";",
"ControllerLinkGood",
"(",
"LINK_TYPE_UART",
")",
";",
"if",
"(",
"ulStatus",
"&",
"(",
"UART_INT_RX",
"|",
"UART_INT_RT",
")",
")",
"{",
"while",
"(",
"ROM_UARTCharsAvail",
"(",
"UART0_BASE",
")",
")",
"{",
"ucChar",
"=",
"ROM_UARTCharGet",
"(",
"UART0_BASE",
")",
";",
"if",
"(",
"ucChar",
"==",
"0xff",
")",
"{",
"g_ulUARTLength",
"=",
"0",
";",
"g_ulUARTState",
"=",
"UART_STATE_LENGTH",
";",
"}",
"else",
"if",
"(",
"g_ulUARTState",
"==",
"UART_STATE_LENGTH",
")",
"{",
"g_ulUARTSize",
"=",
"ucChar",
";",
"g_ulUARTState",
"=",
"UART_STATE_DATA",
";",
"}",
"else",
"if",
"(",
"g_ulUARTState",
"==",
"UART_STATE_ESCAPE",
")",
"{",
"if",
"(",
"ucChar",
"==",
"0xfe",
")",
"{",
"g_pucUARTMessage",
"[",
"g_ulUARTLength",
"++",
"]",
"=",
"0xff",
";",
"g_ulUARTState",
"=",
"UART_STATE_DATA",
";",
"}",
"else",
"if",
"(",
"ucChar",
"==",
"0xfd",
")",
"{",
"g_pucUARTMessage",
"[",
"g_ulUARTLength",
"++",
"]",
"=",
"0xfe",
";",
"g_ulUARTState",
"=",
"UART_STATE_DATA",
";",
"}",
"else",
"{",
"g_ulUARTState",
"=",
"UART_STATE_IDLE",
";",
"}",
"}",
"else",
"if",
"(",
"g_ulUARTState",
"==",
"UART_STATE_DATA",
")",
"{",
"if",
"(",
"ucChar",
"==",
"0xfe",
")",
"{",
"g_ulUARTState",
"=",
"UART_STATE_ESCAPE",
";",
"}",
"else",
"{",
"g_pucUARTMessage",
"[",
"g_ulUARTLength",
"++",
"]",
"=",
"ucChar",
";",
"}",
"}",
"if",
"(",
"(",
"g_ulUARTLength",
"==",
"g_ulUARTSize",
")",
"&&",
"(",
"g_ulUARTState",
"==",
"UART_STATE_DATA",
")",
")",
"{",
"UARTIFCommandHandler",
"(",
")",
";",
"g_ulUARTState",
"=",
"UART_STATE_IDLE",
";",
"}",
"}",
"ControllerWatchdog",
"(",
"LINK_TYPE_UART",
")",
";",
"}",
"if",
"(",
"ulStatus",
"&",
"UART_INT_TX",
")",
"{",
"while",
"(",
"(",
"g_ulUARTXmitRead",
"!=",
"g_ulUARTXmitWrite",
")",
"&&",
"ROM_UARTSpaceAvail",
"(",
"UART0_BASE",
")",
")",
"{",
"ROM_UARTCharPut",
"(",
"UART0_BASE",
",",
"g_pucUARTXmit",
"[",
"g_ulUARTXmitRead",
"]",
")",
";",
"g_ulUARTXmitRead",
"=",
"(",
"g_ulUARTXmitRead",
"+",
"1",
")",
"%",
"UART_XMIT_SIZE",
";",
"}",
"}",
"if",
"(",
"HWREGBITW",
"(",
"&",
"g_ulUARTFlags",
",",
"UART_FLAG_ENUM",
")",
"!=",
"0",
")",
"{",
"UARTIFSendMessage",
"(",
"CAN_MSGID_API_ENUMERATE",
"|",
"g_sParameters",
".",
"ucDeviceNumber",
",",
"0",
",",
"0",
")",
";",
"HWREGBITW",
"(",
"&",
"g_ulUARTFlags",
",",
"UART_FLAG_ENUM",
")",
"=",
"0",
";",
"}",
"if",
"(",
"HWREGBITW",
"(",
"&",
"g_ulUARTFlags",
",",
"UART_FLAG_PSTATUS",
")",
"!=",
"0",
")",
"{",
"if",
"(",
"g_ulPStatFlags",
"&",
"1",
")",
"{",
"UARTIFSendMessage",
"(",
"LM_API_PSTAT_DATA_S0",
"|",
"g_sParameters",
".",
"ucDeviceNumber",
",",
"g_ppucPStatMessages",
"[",
"0",
"]",
",",
"g_pucPStatMessageLen",
"[",
"0",
"]",
")",
";",
"}",
"if",
"(",
"g_ulPStatFlags",
"&",
"2",
")",
"{",
"UARTIFSendMessage",
"(",
"LM_API_PSTAT_DATA_S1",
"|",
"g_sParameters",
".",
"ucDeviceNumber",
",",
"g_ppucPStatMessages",
"[",
"1",
"]",
",",
"g_pucPStatMessageLen",
"[",
"1",
"]",
")",
";",
"}",
"if",
"(",
"g_ulPStatFlags",
"&",
"4",
")",
"{",
"UARTIFSendMessage",
"(",
"LM_API_PSTAT_DATA_S2",
"|",
"g_sParameters",
".",
"ucDeviceNumber",
",",
"g_ppucPStatMessages",
"[",
"2",
"]",
",",
"g_pucPStatMessageLen",
"[",
"2",
"]",
")",
";",
"}",
"if",
"(",
"g_ulPStatFlags",
"&",
"8",
")",
"{",
"UARTIFSendMessage",
"(",
"LM_API_PSTAT_DATA_S3",
"|",
"g_sParameters",
".",
"ucDeviceNumber",
",",
"g_ppucPStatMessages",
"[",
"3",
"]",
",",
"g_pucPStatMessageLen",
"[",
"3",
"]",
")",
";",
"}",
"HWREGBITW",
"(",
"&",
"g_ulUARTFlags",
",",
"UART_FLAG_PSTATUS",
")",
"=",
"0",
";",
"}",
"}"
] | Handles interrupts from the UART. | [
"Handles",
"interrupts",
"from",
"the",
"UART",
"."
] | [
"//\r",
"// Get the interrupts that are being asserted by the UART.\r",
"//\r",
"//\r",
"// Clear the asserted interrupts.\r",
"//\r",
"//\r",
"// Indicate that the UART link is good.\r",
"//\r",
"//\r",
"// See if the receive interrupt has been asserted.\r",
"//\r",
"//\r",
"// Loop while there are more characters to be read from the UART.\r",
"//\r",
"//\r",
"// Read the next character from the UART.\r",
"//\r",
"//\r",
"// See if this is a start of packet byte.\r",
"//\r",
"//\r",
"// Reset the length of the UART message.\r",
"//\r",
"//\r",
"// Set the state such that the next byte received is the size\r",
"// of the message.\r",
"//\r",
"//\r",
"// See if this byte is the size of the message.\r",
"//\r",
"//\r",
"// Save the size of the message.\r",
"//\r",
"//\r",
"// Subsequent bytes received are the message data.\r",
"//\r",
"//\r",
"// See if the previous character was an escape character.\r",
"//\r",
"//\r",
"// See if this 0xfe, the escaped version of 0xff.\r",
"//\r",
"//\r",
"// Store a 0xff in the message buffer.\r",
"//\r",
"//\r",
"// Subsequent bytes received are the message data.\r",
"//\r",
"//\r",
"// Otherwise, see if this is 0xfd, the escaped version of 0xfe.\r",
"//\r",
"//\r",
"// Store a 0xfe in the message buffer.\r",
"//\r",
"//\r",
"// Subsequent bytes received are the message data.\r",
"//\r",
"//\r",
"// Otherwise, this is a corrupted sequence. Set the receiver\r",
"// to idle so this message is dropped, and subsequent data is\r",
"// ignored until another start of packet is received.\r",
"//\r",
"//\r",
"// See if this is a part of the message data.\r",
"//\r",
"//\r",
"// See if this character is an escape character.\r",
"//\r",
"//\r",
"// The next byte is an escaped byte.\r",
"//\r",
"//\r",
"// Store this byte in the message buffer.\r",
"//\r",
"//\r",
"// See if the entire message has been received but has not been\r",
"// processed (i.e. the most recent byte received was the end of the\r",
"// message).\r",
"//\r",
"//\r",
"// Process this message.\r",
"//\r",
"//\r",
"// The UART interface is idle, meaning all bytes will be\r",
"// dropped until the next start of packet byte.\r",
"//\r",
"//\r",
"// Tell the controller that CAN activity was detected.\r",
"//\r",
"//\r",
"// See if the transmit interrupt has been asserted.\r",
"//\r",
"//\r",
"// Loop while there are more characters to be transmitted and more\r",
"// space in the UART FIFO.\r",
"//\r",
"//\r",
"// Put the next character into the UART FIFO.\r",
"//\r",
"//\r",
"// Increment the read pointer.\r",
"//\r",
"//\r",
"// See if an enumeration response needs to be sent.\r",
"//\r",
"//\r",
"// Send the enumeration response for this device.\r",
"//\r",
"//\r",
"// Clear the enumeration response flag.\r",
"//\r",
"//\r",
"// See if periodic status messages need to be sent.\r",
"//\r",
"//\r",
"// Send out the first periodic status message if it needs to be sent.\r",
"//\r",
"//\r",
"// Send out the second periodic status message if it needs to be sent.\r",
"//\r",
"//\r",
"// Send out the third periodic status message if it needs to be sent.\r",
"//\r",
"//\r",
"// Send out the fourth periodic status message if it needs to be sent.\r",
"//\r",
"//\r",
"// Clear the periodic status message flag.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
be83ff7b8ca9efd9faadd993d0286d16fbede9ed | junyanl-code/Luminary-Micro-Library | boards/rdk-bdc24/qs-bdc24/uart_if.c | [
"BSD-3-Clause"
] | C | UARTIFEnumerate | void | void
UARTIFEnumerate(void)
{
//
// Set the enumeration response flag.
//
HWREGBITW(&g_ulUARTFlags, UART_FLAG_ENUM) = 1;
//
// Generate a fake UART interrupt, during which the enumeration response
// will be sent.
//
HWREG(NVIC_SW_TRIG) = INT_UART0 - 16;
} | //*****************************************************************************
//
// Indicates that an enumeration response should be sent for this device.
//
//*****************************************************************************
| Indicates that an enumeration response should be sent for this device. | [
"Indicates",
"that",
"an",
"enumeration",
"response",
"should",
"be",
"sent",
"for",
"this",
"device",
"."
] | void
UARTIFEnumerate(void)
{
HWREGBITW(&g_ulUARTFlags, UART_FLAG_ENUM) = 1;
HWREG(NVIC_SW_TRIG) = INT_UART0 - 16;
} | [
"void",
"UARTIFEnumerate",
"(",
"void",
")",
"{",
"HWREGBITW",
"(",
"&",
"g_ulUARTFlags",
",",
"UART_FLAG_ENUM",
")",
"=",
"1",
";",
"HWREG",
"(",
"NVIC_SW_TRIG",
")",
"=",
"INT_UART0",
"-",
"16",
";",
"}"
] | Indicates that an enumeration response should be sent for this device. | [
"Indicates",
"that",
"an",
"enumeration",
"response",
"should",
"be",
"sent",
"for",
"this",
"device",
"."
] | [
"//\r",
"// Set the enumeration response flag.\r",
"//\r",
"//\r",
"// Generate a fake UART interrupt, during which the enumeration response\r",
"// will be sent.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
be83ff7b8ca9efd9faadd993d0286d16fbede9ed | junyanl-code/Luminary-Micro-Library | boards/rdk-bdc24/qs-bdc24/uart_if.c | [
"BSD-3-Clause"
] | C | UARTIFInit | void | void
UARTIFInit(void)
{
//
// Configure the UART pins.
//
#if UART_RX_PORT == UART_TX_PORT
ROM_GPIOPinTypeUART(UART_RX_PORT, UART_RX_PIN | UART_TX_PIN);
#else
ROM_GPIOPinTypeUART(UART_RX_PORT, UART_RX_PIN);
ROM_GPIOPinTypeUART(UART_TX_PORT, UART_TX_PIN);
#endif
//
// Configure the UART for 115,200, 8-N-1 operation.
//
ROM_UARTConfigSetExpClk(UART0_BASE, SYSCLK, 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
//
// Enable the UART interrupts.
//
ROM_UARTIntEnable(UART0_BASE, UART_INT_TX | UART_INT_RX | UART_INT_RT);
ROM_IntEnable(INT_UART0);
//
// Send an enumeration response message to the UART to indicate that the
// firmware has just started.
//
if(g_sParameters.ucDeviceNumber != 0)
{
UARTIFSendMessage(CAN_MSGID_API_ENUMERATE |
g_sParameters.ucDeviceNumber, 0, 0);
}
} | //*****************************************************************************
//
// Initializes the UART and prepares it to be used as a control interface.
//
//*****************************************************************************
| Initializes the UART and prepares it to be used as a control interface. | [
"Initializes",
"the",
"UART",
"and",
"prepares",
"it",
"to",
"be",
"used",
"as",
"a",
"control",
"interface",
"."
] | void
UARTIFInit(void)
{
#if UART_RX_PORT == UART_TX_PORT
ROM_GPIOPinTypeUART(UART_RX_PORT, UART_RX_PIN | UART_TX_PIN);
#else
ROM_GPIOPinTypeUART(UART_RX_PORT, UART_RX_PIN);
ROM_GPIOPinTypeUART(UART_TX_PORT, UART_TX_PIN);
#endif
ROM_UARTConfigSetExpClk(UART0_BASE, SYSCLK, 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
ROM_UARTIntEnable(UART0_BASE, UART_INT_TX | UART_INT_RX | UART_INT_RT);
ROM_IntEnable(INT_UART0);
if(g_sParameters.ucDeviceNumber != 0)
{
UARTIFSendMessage(CAN_MSGID_API_ENUMERATE |
g_sParameters.ucDeviceNumber, 0, 0);
}
} | [
"void",
"UARTIFInit",
"(",
"void",
")",
"{",
"#if",
"UART_RX_PORT",
"==",
"UART_TX_PORT",
"\n",
"ROM_GPIOPinTypeUART",
"(",
"UART_RX_PORT",
",",
"UART_RX_PIN",
"|",
"UART_TX_PIN",
")",
";",
"#else",
"ROM_GPIOPinTypeUART",
"(",
"UART_RX_PORT",
",",
"UART_RX_PIN",
")",
";",
"ROM_GPIOPinTypeUART",
"(",
"UART_TX_PORT",
",",
"UART_TX_PIN",
")",
";",
"#endif",
"ROM_UARTConfigSetExpClk",
"(",
"UART0_BASE",
",",
"SYSCLK",
",",
"115200",
",",
"(",
"UART_CONFIG_WLEN_8",
"|",
"UART_CONFIG_STOP_ONE",
"|",
"UART_CONFIG_PAR_NONE",
")",
")",
";",
"ROM_UARTIntEnable",
"(",
"UART0_BASE",
",",
"UART_INT_TX",
"|",
"UART_INT_RX",
"|",
"UART_INT_RT",
")",
";",
"ROM_IntEnable",
"(",
"INT_UART0",
")",
";",
"if",
"(",
"g_sParameters",
".",
"ucDeviceNumber",
"!=",
"0",
")",
"{",
"UARTIFSendMessage",
"(",
"CAN_MSGID_API_ENUMERATE",
"|",
"g_sParameters",
".",
"ucDeviceNumber",
",",
"0",
",",
"0",
")",
";",
"}",
"}"
] | Initializes the UART and prepares it to be used as a control interface. | [
"Initializes",
"the",
"UART",
"and",
"prepares",
"it",
"to",
"be",
"used",
"as",
"a",
"control",
"interface",
"."
] | [
"//\r",
"// Configure the UART pins.\r",
"//\r",
"//\r",
"// Configure the UART for 115,200, 8-N-1 operation.\r",
"//\r",
"//\r",
"// Enable the UART interrupts.\r",
"//\r",
"//\r",
"// Send an enumeration response message to the UART to indicate that the\r",
"// firmware has just started.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
bef3870557950b1c06cde2aa1dc31c2cb2e11577 | junyanl-code/Luminary-Micro-Library | third_party/fatfs/port/mmc-dk-lm3s9d96.c | [
"BSD-3-Clause"
] | C | SELECT | void | static
void SELECT (void)
{
//
// Make sure that the serial flash which shares this SSI port is
// not selected.
//
GPIOPinWrite(SFLASH_CS_BASE, SFLASH_CS_PIN, SFLASH_CS_PIN);
//
// Select the SD card.
//
GPIOPinWrite(SDCARD_CS_BASE, SDCARD_CS_PIN, 0);
} | // asserts the CS pin to the card
| asserts the CS pin to the card | [
"asserts",
"the",
"CS",
"pin",
"to",
"the",
"card"
] | static
void SELECT (void)
{
GPIOPinWrite(SFLASH_CS_BASE, SFLASH_CS_PIN, SFLASH_CS_PIN);
GPIOPinWrite(SDCARD_CS_BASE, SDCARD_CS_PIN, 0);
} | [
"static",
"void",
"SELECT",
"(",
"void",
")",
"{",
"GPIOPinWrite",
"(",
"SFLASH_CS_BASE",
",",
"SFLASH_CS_PIN",
",",
"SFLASH_CS_PIN",
")",
";",
"GPIOPinWrite",
"(",
"SDCARD_CS_BASE",
",",
"SDCARD_CS_PIN",
",",
"0",
")",
";",
"}"
] | asserts the CS pin to the card | [
"asserts",
"the",
"CS",
"pin",
"to",
"the",
"card"
] | [
"//\r",
"// Make sure that the serial flash which shares this SSI port is\r",
"// not selected.\r",
"//\r",
"//\r",
"// Select the SD card.\r",
"//\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
bef3870557950b1c06cde2aa1dc31c2cb2e11577 | junyanl-code/Luminary-Micro-Library | third_party/fatfs/port/mmc-dk-lm3s9d96.c | [
"BSD-3-Clause"
] | C | DESELECT | void | static
void DESELECT (void)
{
GPIOPinWrite(SDCARD_CS_BASE, SDCARD_CS_PIN, SDCARD_CS_PIN);
} | // de-asserts the CS pin to the card.
| de-asserts the CS pin to the card. | [
"de",
"-",
"asserts",
"the",
"CS",
"pin",
"to",
"the",
"card",
"."
] | static
void DESELECT (void)
{
GPIOPinWrite(SDCARD_CS_BASE, SDCARD_CS_PIN, SDCARD_CS_PIN);
} | [
"static",
"void",
"DESELECT",
"(",
"void",
")",
"{",
"GPIOPinWrite",
"(",
"SDCARD_CS_BASE",
",",
"SDCARD_CS_PIN",
",",
"SDCARD_CS_PIN",
")",
";",
"}"
] | de-asserts the CS pin to the card. | [
"de",
"-",
"asserts",
"the",
"CS",
"pin",
"to",
"the",
"card",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
bef3870557950b1c06cde2aa1dc31c2cb2e11577 | junyanl-code/Luminary-Micro-Library | third_party/fatfs/port/mmc-dk-lm3s9d96.c | [
"BSD-3-Clause"
] | C | send_initial_clock_train | void | static
void send_initial_clock_train (void)
{
unsigned int i;
DWORD dat;
/* Ensure CS is held high. */
DESELECT();
/* Switch the SSI TX line to a GPIO and drive it high too. */
GPIOPinTypeGPIOOutput(SDC_GPIO_PORT_BASE, SDC_SSI_TX);
GPIOPinWrite(SDC_GPIO_PORT_BASE, SDC_SSI_TX, SDC_SSI_TX);
/* Send 10 bytes over the SSI. This causes the clock to wiggle the */
/* required number of times. */
for(i = 0 ; i < 10 ; i++)
{
/* Write DUMMY data. SSIDataPut() waits until there is room in the */
/* FIFO. */
SSIDataPut(SDC_SSI_BASE, 0xFF);
/* Flush data read during data write. */
SSIDataGet(SDC_SSI_BASE, &dat);
}
/* Revert to hardware control of the SSI TX line. */
GPIOPinTypeSSI(SDC_GPIO_PORT_BASE, SDC_SSI_TX);
} | /*-----------------------------------------------------------------------*/
/* Send 80 or so clock transitions with CS and DI held high. This is */
/* required after card power up to get it into SPI mode */
/*-----------------------------------------------------------------------*/ | Send 80 or so clock transitions with CS and DI held high. This is
required after card power up to get it into SPI mode | [
"Send",
"80",
"or",
"so",
"clock",
"transitions",
"with",
"CS",
"and",
"DI",
"held",
"high",
".",
"This",
"is",
"required",
"after",
"card",
"power",
"up",
"to",
"get",
"it",
"into",
"SPI",
"mode"
] | static
void send_initial_clock_train (void)
{
unsigned int i;
DWORD dat;
DESELECT();
GPIOPinTypeGPIOOutput(SDC_GPIO_PORT_BASE, SDC_SSI_TX);
GPIOPinWrite(SDC_GPIO_PORT_BASE, SDC_SSI_TX, SDC_SSI_TX);
for(i = 0 ; i < 10 ; i++)
{
SSIDataPut(SDC_SSI_BASE, 0xFF);
SSIDataGet(SDC_SSI_BASE, &dat);
}
GPIOPinTypeSSI(SDC_GPIO_PORT_BASE, SDC_SSI_TX);
} | [
"static",
"void",
"send_initial_clock_train",
"(",
"void",
")",
"{",
"unsigned",
"int",
"i",
";",
"DWORD",
"dat",
";",
"DESELECT",
"(",
")",
";",
"GPIOPinTypeGPIOOutput",
"(",
"SDC_GPIO_PORT_BASE",
",",
"SDC_SSI_TX",
")",
";",
"GPIOPinWrite",
"(",
"SDC_GPIO_PORT_BASE",
",",
"SDC_SSI_TX",
",",
"SDC_SSI_TX",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"SSIDataPut",
"(",
"SDC_SSI_BASE",
",",
"0xFF",
")",
";",
"SSIDataGet",
"(",
"SDC_SSI_BASE",
",",
"&",
"dat",
")",
";",
"}",
"GPIOPinTypeSSI",
"(",
"SDC_GPIO_PORT_BASE",
",",
"SDC_SSI_TX",
")",
";",
"}"
] | Send 80 or so clock transitions with CS and DI held high. | [
"Send",
"80",
"or",
"so",
"clock",
"transitions",
"with",
"CS",
"and",
"DI",
"held",
"high",
"."
] | [
"/* Ensure CS is held high. */",
"/* Switch the SSI TX line to a GPIO and drive it high too. */",
"/* Send 10 bytes over the SSI. This causes the clock to wiggle the */",
"/* required number of times. */",
"/* Write DUMMY data. SSIDataPut() waits until there is room in the */",
"/* FIFO. */",
"/* Flush data read during data write. */",
"/* Revert to hardware control of the SSI TX line. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
bef3870557950b1c06cde2aa1dc31c2cb2e11577 | junyanl-code/Luminary-Micro-Library | third_party/fatfs/port/mmc-dk-lm3s9d96.c | [
"BSD-3-Clause"
] | C | power_on | void | static
void power_on (void)
{
/*
* This doesn't really turn the power on, but initializes the
* SSI port and pins needed to talk to the card.
*/
/* Enable the peripherals used to drive the SDC on SSI */
SysCtlPeripheralEnable(SDC_SSI_SYSCTL_PERIPH);
SysCtlPeripheralEnable(SDC_GPIO_SYSCTL_PERIPH);
SysCtlPeripheralEnable(SDCARD_CS_PERIPH);
SysCtlPeripheralEnable(SFLASH_CS_PERIPH);
/*
* Configure the appropriate pins to be SSI instead of GPIO. The CS
* signal is directly driven to ensure that we can hold it low through a
* complete transaction with the SD card.
*/
GPIOPinTypeSSI(SDC_GPIO_PORT_BASE, SDC_SSI_TX | SDC_SSI_RX | SDC_SSI_CLK);
GPIOPinTypeGPIOOutput(SDCARD_CS_BASE, SDCARD_CS_PIN);
GPIOPinTypeGPIOOutput(SFLASH_CS_BASE, SFLASH_CS_PIN);
GPIOPadConfigSet(SDC_GPIO_PORT_BASE, SDC_SSI_PINS, GPIO_STRENGTH_4MA,
GPIO_PIN_TYPE_STD_WPU);
GPIOPadConfigSet(SDCARD_CS_BASE, SDCARD_CS_PIN, GPIO_STRENGTH_4MA,
GPIO_PIN_TYPE_STD_WPU);
GPIOPadConfigSet(SFLASH_CS_BASE, SFLASH_CS_PIN, GPIO_STRENGTH_4MA,
GPIO_PIN_TYPE_STD_WPU);
/* Deassert the SSI0 chip selects for both the SD card and serial flash */
GPIOPinWrite(SDCARD_CS_BASE, SDCARD_CS_PIN, SDCARD_CS_PIN);
GPIOPinWrite(SFLASH_CS_BASE, SFLASH_CS_PIN, SFLASH_CS_PIN);
/* Configure the SSI0 port */
SSIConfigSetExpClk(SDC_SSI_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0,
SSI_MODE_MASTER, 400000, 8);
SSIEnable(SDC_SSI_BASE);
/* Set DI and CS high and apply more than 74 pulses to SCLK for the card */
/* to be able to accept a native command. */
send_initial_clock_train();
PowerFlag = 1;
} | /*-----------------------------------------------------------------------*/
/* Power Control (Platform dependent) */
/*-----------------------------------------------------------------------*/
/* When the target system does not support socket power control, there */
/* is nothing to do in these functions and chk_power always returns 1. */ | Power Control (Platform dependent)
When the target system does not support socket power control, there
is nothing to do in these functions and chk_power always returns 1. | [
"Power",
"Control",
"(",
"Platform",
"dependent",
")",
"When",
"the",
"target",
"system",
"does",
"not",
"support",
"socket",
"power",
"control",
"there",
"is",
"nothing",
"to",
"do",
"in",
"these",
"functions",
"and",
"chk_power",
"always",
"returns",
"1",
"."
] | static
void power_on (void)
{
SysCtlPeripheralEnable(SDC_SSI_SYSCTL_PERIPH);
SysCtlPeripheralEnable(SDC_GPIO_SYSCTL_PERIPH);
SysCtlPeripheralEnable(SDCARD_CS_PERIPH);
SysCtlPeripheralEnable(SFLASH_CS_PERIPH);
GPIOPinTypeSSI(SDC_GPIO_PORT_BASE, SDC_SSI_TX | SDC_SSI_RX | SDC_SSI_CLK);
GPIOPinTypeGPIOOutput(SDCARD_CS_BASE, SDCARD_CS_PIN);
GPIOPinTypeGPIOOutput(SFLASH_CS_BASE, SFLASH_CS_PIN);
GPIOPadConfigSet(SDC_GPIO_PORT_BASE, SDC_SSI_PINS, GPIO_STRENGTH_4MA,
GPIO_PIN_TYPE_STD_WPU);
GPIOPadConfigSet(SDCARD_CS_BASE, SDCARD_CS_PIN, GPIO_STRENGTH_4MA,
GPIO_PIN_TYPE_STD_WPU);
GPIOPadConfigSet(SFLASH_CS_BASE, SFLASH_CS_PIN, GPIO_STRENGTH_4MA,
GPIO_PIN_TYPE_STD_WPU);
GPIOPinWrite(SDCARD_CS_BASE, SDCARD_CS_PIN, SDCARD_CS_PIN);
GPIOPinWrite(SFLASH_CS_BASE, SFLASH_CS_PIN, SFLASH_CS_PIN);
SSIConfigSetExpClk(SDC_SSI_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0,
SSI_MODE_MASTER, 400000, 8);
SSIEnable(SDC_SSI_BASE);
send_initial_clock_train();
PowerFlag = 1;
} | [
"static",
"void",
"power_on",
"(",
"void",
")",
"{",
"SysCtlPeripheralEnable",
"(",
"SDC_SSI_SYSCTL_PERIPH",
")",
";",
"SysCtlPeripheralEnable",
"(",
"SDC_GPIO_SYSCTL_PERIPH",
")",
";",
"SysCtlPeripheralEnable",
"(",
"SDCARD_CS_PERIPH",
")",
";",
"SysCtlPeripheralEnable",
"(",
"SFLASH_CS_PERIPH",
")",
";",
"GPIOPinTypeSSI",
"(",
"SDC_GPIO_PORT_BASE",
",",
"SDC_SSI_TX",
"|",
"SDC_SSI_RX",
"|",
"SDC_SSI_CLK",
")",
";",
"GPIOPinTypeGPIOOutput",
"(",
"SDCARD_CS_BASE",
",",
"SDCARD_CS_PIN",
")",
";",
"GPIOPinTypeGPIOOutput",
"(",
"SFLASH_CS_BASE",
",",
"SFLASH_CS_PIN",
")",
";",
"GPIOPadConfigSet",
"(",
"SDC_GPIO_PORT_BASE",
",",
"SDC_SSI_PINS",
",",
"GPIO_STRENGTH_4MA",
",",
"GPIO_PIN_TYPE_STD_WPU",
")",
";",
"GPIOPadConfigSet",
"(",
"SDCARD_CS_BASE",
",",
"SDCARD_CS_PIN",
",",
"GPIO_STRENGTH_4MA",
",",
"GPIO_PIN_TYPE_STD_WPU",
")",
";",
"GPIOPadConfigSet",
"(",
"SFLASH_CS_BASE",
",",
"SFLASH_CS_PIN",
",",
"GPIO_STRENGTH_4MA",
",",
"GPIO_PIN_TYPE_STD_WPU",
")",
";",
"GPIOPinWrite",
"(",
"SDCARD_CS_BASE",
",",
"SDCARD_CS_PIN",
",",
"SDCARD_CS_PIN",
")",
";",
"GPIOPinWrite",
"(",
"SFLASH_CS_BASE",
",",
"SFLASH_CS_PIN",
",",
"SFLASH_CS_PIN",
")",
";",
"SSIConfigSetExpClk",
"(",
"SDC_SSI_BASE",
",",
"SysCtlClockGet",
"(",
")",
",",
"SSI_FRF_MOTO_MODE_0",
",",
"SSI_MODE_MASTER",
",",
"400000",
",",
"8",
")",
";",
"SSIEnable",
"(",
"SDC_SSI_BASE",
")",
";",
"send_initial_clock_train",
"(",
")",
";",
"PowerFlag",
"=",
"1",
";",
"}"
] | Power Control (Platform dependent)
When the target system does not support socket power control, there
is nothing to do in these functions and chk_power always returns 1. | [
"Power",
"Control",
"(",
"Platform",
"dependent",
")",
"When",
"the",
"target",
"system",
"does",
"not",
"support",
"socket",
"power",
"control",
"there",
"is",
"nothing",
"to",
"do",
"in",
"these",
"functions",
"and",
"chk_power",
"always",
"returns",
"1",
"."
] | [
"/*\r\n * This doesn't really turn the power on, but initializes the\r\n * SSI port and pins needed to talk to the card.\r\n */",
"/* Enable the peripherals used to drive the SDC on SSI */",
"/*\r\n * Configure the appropriate pins to be SSI instead of GPIO. The CS\r\n * signal is directly driven to ensure that we can hold it low through a\r\n * complete transaction with the SD card.\r\n */",
"/* Deassert the SSI0 chip selects for both the SD card and serial flash */",
"/* Configure the SSI0 port */",
"/* Set DI and CS high and apply more than 74 pulses to SCLK for the card */",
"/* to be able to accept a native command. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
bef3870557950b1c06cde2aa1dc31c2cb2e11577 | junyanl-code/Luminary-Micro-Library | third_party/fatfs/port/mmc-dk-lm3s9d96.c | [
"BSD-3-Clause"
] | C | send_cmd | BYTE | static
BYTE send_cmd (
BYTE cmd, /* Command byte */
DWORD arg /* Argument */
)
{
BYTE n, res;
if (wait_ready() != 0xFF) return 0xFF;
/* Send command packet */
xmit_spi(cmd); /* Command */
xmit_spi((BYTE)(arg >> 24)); /* Argument[31..24] */
xmit_spi((BYTE)(arg >> 16)); /* Argument[23..16] */
xmit_spi((BYTE)(arg >> 8)); /* Argument[15..8] */
xmit_spi((BYTE)arg); /* Argument[7..0] */
n = 0xff;
if (cmd == CMD0) n = 0x95; /* CRC for CMD0(0) */
if (cmd == CMD8) n = 0x87; /* CRC for CMD8(0x1AA) */
xmit_spi(n);
/* Receive command response */
if (cmd == CMD12) rcvr_spi(); /* Skip a stuff byte when stop reading */
n = 10; /* Wait for a valid response in timeout of 10 attempts */
do
res = rcvr_spi();
while ((res & 0x80) && --n);
return res; /* Return with the response value */
} | /*-----------------------------------------------------------------------*/
/* Send a command packet to MMC */
/*-----------------------------------------------------------------------*/ | Send a command packet to MMC | [
"Send",
"a",
"command",
"packet",
"to",
"MMC"
] | static
BYTE send_cmd (
BYTE cmd,
DWORD arg
)
{
BYTE n, res;
if (wait_ready() != 0xFF) return 0xFF;
xmit_spi(cmd);
xmit_spi((BYTE)(arg >> 24));
xmit_spi((BYTE)(arg >> 16));
xmit_spi((BYTE)(arg >> 8));
xmit_spi((BYTE)arg);
n = 0xff;
if (cmd == CMD0) n = 0x95;
if (cmd == CMD8) n = 0x87;
xmit_spi(n);
if (cmd == CMD12) rcvr_spi();
n = 10;
do
res = rcvr_spi();
while ((res & 0x80) && --n);
return res;
} | [
"static",
"BYTE",
"send_cmd",
"(",
"BYTE",
"cmd",
",",
"DWORD",
"arg",
")",
"{",
"BYTE",
"n",
",",
"res",
";",
"if",
"(",
"wait_ready",
"(",
")",
"!=",
"0xFF",
")",
"return",
"0xFF",
";",
"xmit_spi",
"(",
"cmd",
")",
";",
"xmit_spi",
"(",
"(",
"BYTE",
")",
"(",
"arg",
">>",
"24",
")",
")",
";",
"xmit_spi",
"(",
"(",
"BYTE",
")",
"(",
"arg",
">>",
"16",
")",
")",
";",
"xmit_spi",
"(",
"(",
"BYTE",
")",
"(",
"arg",
">>",
"8",
")",
")",
";",
"xmit_spi",
"(",
"(",
"BYTE",
")",
"arg",
")",
";",
"n",
"=",
"0xff",
";",
"if",
"(",
"cmd",
"==",
"CMD0",
")",
"n",
"=",
"0x95",
";",
"if",
"(",
"cmd",
"==",
"CMD8",
")",
"n",
"=",
"0x87",
";",
"xmit_spi",
"(",
"n",
")",
";",
"if",
"(",
"cmd",
"==",
"CMD12",
")",
"rcvr_spi",
"(",
")",
";",
"n",
"=",
"10",
";",
"do",
"res",
"=",
"rcvr_spi",
"(",
")",
";",
"while",
"(",
"(",
"res",
"&",
"0x80",
")",
"&&",
"--",
"n",
")",
";",
"return",
"res",
";",
"}"
] | Send a command packet to MMC | [
"Send",
"a",
"command",
"packet",
"to",
"MMC"
] | [
"/* Command byte */",
"/* Argument */",
"/* Send command packet */",
"/* Command */",
"/* Argument[31..24] */",
"/* Argument[23..16] */",
"/* Argument[15..8] */",
"/* Argument[7..0] */",
"/* CRC for CMD0(0) */",
"/* CRC for CMD8(0x1AA) */",
"/* Receive command response */",
"/* Skip a stuff byte when stop reading */",
"/* Wait for a valid response in timeout of 10 attempts */",
"/* Return with the response value */"
] | [
{
"param": "cmd",
"type": "BYTE"
},
{
"param": "arg",
"type": "DWORD"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cmd",
"type": "BYTE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "arg",
"type": "DWORD",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
877e1fd2208a6c6204696a9d5640c2a0ea3bc270 | dragontas/BNo055 | lcdgfx/src/lcd_hal/custom_interface.h | [
"MIT"
] | C | send | void | void send(uint8_t data)
{
m_buffer[m_data_size] = data;
m_data_size++;
if ( m_data_size == sizeof(m_buffer) )
{
forceTransfer();
}
} | /**
* Sends byte to custom interface
* @param data - byte to send
*/ | Sends byte to custom interface
@param data - byte to send | [
"Sends",
"byte",
"to",
"custom",
"interface",
"@param",
"data",
"-",
"byte",
"to",
"send"
] | void send(uint8_t data)
{
m_buffer[m_data_size] = data;
m_data_size++;
if ( m_data_size == sizeof(m_buffer) )
{
forceTransfer();
}
} | [
"void",
"send",
"(",
"uint8_t",
"data",
")",
"{",
"m_buffer",
"[",
"m_data_size",
"]",
"=",
"data",
";",
"m_data_size",
"++",
";",
"if",
"(",
"m_data_size",
"==",
"sizeof",
"(",
"m_buffer",
")",
")",
"{",
"forceTransfer",
"(",
")",
";",
"}",
"}"
] | Sends byte to custom interface
@param data - byte to send | [
"Sends",
"byte",
"to",
"custom",
"interface",
"@param",
"data",
"-",
"byte",
"to",
"send"
] | [] | [
{
"param": "data",
"type": "uint8_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
877e1fd2208a6c6204696a9d5640c2a0ea3bc270 | dragontas/BNo055 | lcdgfx/src/lcd_hal/custom_interface.h | [
"MIT"
] | C | sendBuffer | void | void sendBuffer(const uint8_t *buffer, uint16_t size)
{
while ( size )
{
send(*buffer);
size--;
buffer++;
}
} | /**
* @brief Sends bytes to custom interface
*
* Sends bytes to custom interface.
*
* @param buffer - bytes to send
* @param size - number of bytes to send
*/ | @brief Sends bytes to custom interface
Sends bytes to custom interface.
@param buffer - bytes to send
@param size - number of bytes to send | [
"@brief",
"Sends",
"bytes",
"to",
"custom",
"interface",
"Sends",
"bytes",
"to",
"custom",
"interface",
".",
"@param",
"buffer",
"-",
"bytes",
"to",
"send",
"@param",
"size",
"-",
"number",
"of",
"bytes",
"to",
"send"
] | void sendBuffer(const uint8_t *buffer, uint16_t size)
{
while ( size )
{
send(*buffer);
size--;
buffer++;
}
} | [
"void",
"sendBuffer",
"(",
"const",
"uint8_t",
"*",
"buffer",
",",
"uint16_t",
"size",
")",
"{",
"while",
"(",
"size",
")",
"{",
"send",
"(",
"*",
"buffer",
")",
";",
"size",
"--",
";",
"buffer",
"++",
";",
"}",
"}"
] | @brief Sends bytes to custom interface
Sends bytes to custom interface. | [
"@brief",
"Sends",
"bytes",
"to",
"custom",
"interface",
"Sends",
"bytes",
"to",
"custom",
"interface",
"."
] | [] | [
{
"param": "buffer",
"type": "uint8_t"
},
{
"param": "size",
"type": "uint16_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "buffer",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
877e1fd2208a6c6204696a9d5640c2a0ea3bc270 | dragontas/BNo055 | lcdgfx/src/lcd_hal/custom_interface.h | [
"MIT"
] | C | forceTransfer | void | void forceTransfer()
{
transferToHw(m_buffer, m_data_size);
m_data_size = 0;
} | /**
* Call this method to transfer data to hardware. This method is called
* automatically, when internal interface buffer is overflown.
*/ | Call this method to transfer data to hardware. This method is called
automatically, when internal interface buffer is overflown. | [
"Call",
"this",
"method",
"to",
"transfer",
"data",
"to",
"hardware",
".",
"This",
"method",
"is",
"called",
"automatically",
"when",
"internal",
"interface",
"buffer",
"is",
"overflown",
"."
] | void forceTransfer()
{
transferToHw(m_buffer, m_data_size);
m_data_size = 0;
} | [
"void",
"forceTransfer",
"(",
")",
"{",
"transferToHw",
"(",
"m_buffer",
",",
"m_data_size",
")",
";",
"m_data_size",
"=",
"0",
";",
"}"
] | Call this method to transfer data to hardware. | [
"Call",
"this",
"method",
"to",
"transfer",
"data",
"to",
"hardware",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
c8072e3c2a127204179b05022c0c5e0b95f08961 | dragontas/BNo055 | lcdgfx/src/v2/nano_engine/menu.h | [
"MIT"
] | C | down | void | void down()
{
if ( m_selected )
{
m_selected->defocus();
}
m_selected = this->getNext(m_selected);
if ( !m_selected )
{
m_selected = this->getNext();
}
if ( m_selected )
{
m_selected->focus();
}
} | /**
* Moves active menu item position to the next item.
* If active menu item is the last one, then first
* menu item becomes active.
*/ | Moves active menu item position to the next item.
If active menu item is the last one, then first
menu item becomes active. | [
"Moves",
"active",
"menu",
"item",
"position",
"to",
"the",
"next",
"item",
".",
"If",
"active",
"menu",
"item",
"is",
"the",
"last",
"one",
"then",
"first",
"menu",
"item",
"becomes",
"active",
"."
] | void down()
{
if ( m_selected )
{
m_selected->defocus();
}
m_selected = this->getNext(m_selected);
if ( !m_selected )
{
m_selected = this->getNext();
}
if ( m_selected )
{
m_selected->focus();
}
} | [
"void",
"down",
"(",
")",
"{",
"if",
"(",
"m_selected",
")",
"{",
"m_selected",
"->",
"defocus",
"(",
")",
";",
"}",
"m_selected",
"=",
"this",
"->",
"getNext",
"(",
"m_selected",
")",
";",
"if",
"(",
"!",
"m_selected",
")",
"{",
"m_selected",
"=",
"this",
"->",
"getNext",
"(",
")",
";",
"}",
"if",
"(",
"m_selected",
")",
"{",
"m_selected",
"->",
"focus",
"(",
")",
";",
"}",
"}"
] | Moves active menu item position to the next item. | [
"Moves",
"active",
"menu",
"item",
"position",
"to",
"the",
"next",
"item",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
c8072e3c2a127204179b05022c0c5e0b95f08961 | dragontas/BNo055 | lcdgfx/src/v2/nano_engine/menu.h | [
"MIT"
] | C | up | void | void up()
{
if ( m_selected )
{
m_selected->defocus();
}
m_selected = getPrev(m_selected);
if ( !m_selected )
{
m_selected = this->getPrev();
}
if ( m_selected )
{
m_selected->focus();
}
} | /**
* Moves active menu item position to the previous item.
* If active menu item is the first one, then last
* menu item becomes active.
*/ | Moves active menu item position to the previous item.
If active menu item is the first one, then last
menu item becomes active. | [
"Moves",
"active",
"menu",
"item",
"position",
"to",
"the",
"previous",
"item",
".",
"If",
"active",
"menu",
"item",
"is",
"the",
"first",
"one",
"then",
"last",
"menu",
"item",
"becomes",
"active",
"."
] | void up()
{
if ( m_selected )
{
m_selected->defocus();
}
m_selected = getPrev(m_selected);
if ( !m_selected )
{
m_selected = this->getPrev();
}
if ( m_selected )
{
m_selected->focus();
}
} | [
"void",
"up",
"(",
")",
"{",
"if",
"(",
"m_selected",
")",
"{",
"m_selected",
"->",
"defocus",
"(",
")",
";",
"}",
"m_selected",
"=",
"getPrev",
"(",
"m_selected",
")",
";",
"if",
"(",
"!",
"m_selected",
")",
"{",
"m_selected",
"=",
"this",
"->",
"getPrev",
"(",
")",
";",
"}",
"if",
"(",
"m_selected",
")",
"{",
"m_selected",
"->",
"focus",
"(",
")",
";",
"}",
"}"
] | Moves active menu item position to the previous item. | [
"Moves",
"active",
"menu",
"item",
"position",
"to",
"the",
"previous",
"item",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
be4b34096161d5f596f89576bfd3c0b6a459d66a | dragontas/BNo055 | lcdgfx/src/v2/nano_engine/tiler.h | [
"MIT"
] | C | refresh | void | void refresh(lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2) __attribute__((noinline))
{
if ( y2 < 0 || x2 < 0 )
return;
if ( y1 < 0 )
y1 = 0;
if ( x1 < 0 )
x1 = 0;
y1 = y1 / canvas.height();
y2 = min((y2 / canvas.height()), NE_MAX_TILE_ROWS - 1);
for ( uint8_t x = x1 / canvas.width(); x <= (x2 / canvas.width()); x++ )
{
for ( uint8_t y = y1; y <= y2; y++ )
{
m_refreshFlags[y] |= (1 << x);
}
}
} | /**
* Mark specified area in pixels for redrawing by NanoEngine.
* Actual update will take place in display() method.
*/ | Mark specified area in pixels for redrawing by NanoEngine.
Actual update will take place in display() method. | [
"Mark",
"specified",
"area",
"in",
"pixels",
"for",
"redrawing",
"by",
"NanoEngine",
".",
"Actual",
"update",
"will",
"take",
"place",
"in",
"display",
"()",
"method",
"."
] | void refresh(lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2) __attribute__((noinline))
{
if ( y2 < 0 || x2 < 0 )
return;
if ( y1 < 0 )
y1 = 0;
if ( x1 < 0 )
x1 = 0;
y1 = y1 / canvas.height();
y2 = min((y2 / canvas.height()), NE_MAX_TILE_ROWS - 1);
for ( uint8_t x = x1 / canvas.width(); x <= (x2 / canvas.width()); x++ )
{
for ( uint8_t y = y1; y <= y2; y++ )
{
m_refreshFlags[y] |= (1 << x);
}
}
} | [
"void",
"refresh",
"(",
"lcdint_t",
"x1",
",",
"lcdint_t",
"y1",
",",
"lcdint_t",
"x2",
",",
"lcdint_t",
"y2",
")",
"__attribute__",
"(",
"(",
"noinline",
")",
")",
"{",
"if",
"(",
"y2",
"<",
"0",
"||",
"x2",
"<",
"0",
")",
"return",
";",
"if",
"(",
"y1",
"<",
"0",
")",
"y1",
"=",
"0",
";",
"if",
"(",
"x1",
"<",
"0",
")",
"x1",
"=",
"0",
";",
"y1",
"=",
"y1",
"/",
"canvas",
".",
"height",
"(",
")",
";",
"y2",
"=",
"min",
"(",
"(",
"y2",
"/",
"canvas",
".",
"height",
"(",
")",
")",
",",
"NE_MAX_TILE_ROWS",
"-",
"1",
")",
";",
"for",
"(",
"uint8_t",
"x",
"=",
"x1",
"/",
"canvas",
".",
"width",
"(",
")",
";",
"x",
"<=",
"(",
"x2",
"/",
"canvas",
".",
"width",
"(",
")",
")",
";",
"x",
"++",
")",
"{",
"for",
"(",
"uint8_t",
"y",
"=",
"y1",
";",
"y",
"<=",
"y2",
";",
"y",
"++",
")",
"{",
"m_refreshFlags",
"[",
"y",
"]",
"|=",
"(",
"1",
"<<",
"x",
")",
";",
"}",
"}",
"}"
] | Mark specified area in pixels for redrawing by NanoEngine. | [
"Mark",
"specified",
"area",
"in",
"pixels",
"for",
"redrawing",
"by",
"NanoEngine",
"."
] | [] | [
{
"param": "x1",
"type": "lcdint_t"
},
{
"param": "y1",
"type": "lcdint_t"
},
{
"param": "x2",
"type": "lcdint_t"
},
{
"param": "y2",
"type": "lcdint_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x1",
"type": "lcdint_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y1",
"type": "lcdint_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x2",
"type": "lcdint_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y2",
"type": "lcdint_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
be4b34096161d5f596f89576bfd3c0b6a459d66a | dragontas/BNo055 | lcdgfx/src/v2/nano_engine/tiler.h | [
"MIT"
] | C | update | void | void update() __attribute__((noinline))
{
NanoEngineObject<TilerT> *p = m_first;
while ( p )
{
p->update();
p = p->m_next;
}
} | /**
* Updates all objects. This method doesn't refresh screen content
*/ | Updates all objects. This method doesn't refresh screen content | [
"Updates",
"all",
"objects",
".",
"This",
"method",
"doesn",
"'",
"t",
"refresh",
"screen",
"content"
] | void update() __attribute__((noinline))
{
NanoEngineObject<TilerT> *p = m_first;
while ( p )
{
p->update();
p = p->m_next;
}
} | [
"void",
"update",
"(",
")",
"__attribute__",
"(",
"(",
"noinline",
")",
")",
"{",
"NanoEngineObject",
"<",
"TilerT",
">",
"*",
"p",
"=",
"m_first",
";",
"while",
"(",
"p",
")",
"{",
"p",
"->",
"update",
"(",
")",
";",
"p",
"=",
"p",
"->",
"m_next",
";",
"}",
"}"
] | Updates all objects. | [
"Updates",
"all",
"objects",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
be72cd5bb4dcc67ed7b711763a0c04394ed066e7 | dthaler/QCBOR | src/qcbor_encode.c | [
"Unlicense",
"BSD-3-Clause"
] | C | QCBOREncode_EncodeHead | UsefulBufC | UsefulBufC QCBOREncode_EncodeHead(UsefulBuf buffer,
uint8_t uMajorType,
uint8_t uMinLen,
uint64_t uArgument)
{
/**
All CBOR data items have a type and an "argument". The argument is
either the value of the item for integer types, the length of the
content for string, byte, array and map types, a tag for major type
6, and has several uses for major type 7.
This function encodes the type and the argument. There are several
encodings for the argument depending on how large it is and how it is
used.
Every encoding of the type and argument has at least one byte, the
"initial byte".
The top three bits of the initial byte are the major type for the
CBOR data item. The eight major types defined by the standard are
defined as CBOR_MAJOR_TYPE_xxxx in qcbor/qcbor_common.h.
The remaining five bits, known as "additional information", and
possibly more bytes encode the argument. If the argument is less than
24, then it is encoded entirely in the five bits. This is neat
because it allows you to encode an entire CBOR data item in 1 byte
for many values and types (integers 0-23, true, false, and tags).
If the argument is larger than 24, then it is encoded in 1,2,4 or 8
additional bytes, with the number of these bytes indicated by the
values of the 5 bits 24, 25, 25 and 27.
It is possible to encode a particular argument in many ways with this
representation. This implementation always uses the smallest
possible representation. This conforms with CBOR preferred encoding.
This function inserts them into the output buffer at the specified
position. AppendEncodedTypeAndNumber() appends to the end.
This function takes care of converting to network byte order.
This function is also used to insert floats and doubles. Before this
function is called the float or double must be copied into a
uint64_t. That is how they are passed in. They are then converted to
network byte order correctly. The uMinLen parameter makes sure that
even if all the digits of a half, float or double are 0 it is still
correctly encoded in 2, 4 or 8 bytes.
*/
/*
This code does endian conversion without hton or knowing the
endianness of the machine using masks and shifts. This avoids the
dependency on hton and the mess of figuring out how to find the
machine's endianness.
This is a good efficient implementation on little-endian machines.
A faster and small implementation is possible on big-endian
machines because CBOR/network byte order is big endian. However
big endian machines are uncommon.
On x86, it is about 200 bytes instead of 500 bytes for the more
formal unoptimized code.
This also does the CBOR preferred shortest encoding for integers
and is called to do endian conversion for floats.
It works backwards from the LSB to the MSB as needed.
Code Reviewers: THIS FUNCTION DOES POINTER MATH
*/
/*
The type int is used here for several variables because of the way
integer promotion works in C for integer variables that are
uint8_t or uint16_t. The basic rule is that they will always be
promoted to int if they will fit. All of these integer variables
need only hold values less than 255 or are promoted from uint8_t,
so they will always fit into an int. Note that promotion is only
to unsigned int if the value won't fit into an int even if the
promotion is for an unsigned like uint8_t.
By declaring them int, there are few implicit conversions and fewer
casts needed. Code size is reduced a little. It also makes static
analyzers happier.
Note also that declaring them uint8_t won't stop integer wrap
around if the code is wrong. It won't make the code more correct.
https://stackoverflow.com/questions/46073295/implicit-type-promotion-rules
https://stackoverflow.com/questions/589575/what-does-the-c-standard-state-the-size-of-int-long-type-to-be
*/
// Buffer must have room for the largest CBOR HEAD + one extra as the
// one extra is needed for this code to work as it does a pre-decrement.
if(buffer.len < QCBOR_HEAD_BUFFER_SIZE) {
return NULLUsefulBufC;
}
// Pointer to last valid byte in the buffer
uint8_t * const pBufferEnd = &((uint8_t *)buffer.ptr)[QCBOR_HEAD_BUFFER_SIZE-1];
// Point to the last byte and work backwards
uint8_t *pByte = pBufferEnd;
// The 5 bits in the initial byte that are not the major type
int nAdditionalInfo;
if (uMajorType == CBOR_MAJOR_NONE_TYPE_ARRAY_INDEFINITE_LEN) {
uMajorType = CBOR_MAJOR_TYPE_ARRAY;
nAdditionalInfo = LEN_IS_INDEFINITE;
} else if (uMajorType == CBOR_MAJOR_NONE_TYPE_MAP_INDEFINITE_LEN) {
uMajorType = CBOR_MAJOR_TYPE_MAP;
nAdditionalInfo = LEN_IS_INDEFINITE;
} else if (uArgument < CBOR_TWENTY_FOUR && uMinLen == 0) {
// Simple case where argument is < 24
nAdditionalInfo = (int)uArgument;
} else if (uMajorType == CBOR_MAJOR_TYPE_SIMPLE && uArgument == CBOR_SIMPLE_BREAK) {
// Break statement can be encoded in single byte too (0xff)
nAdditionalInfo = (int)uArgument;
} else {
/*
Encode argument in 1,2,4 or 8 bytes. Outer loop
runs once for 1 byte and 4 times for 8 bytes.
Inner loop runs 1, 2 or 4 times depending on
outer loop counter. This works backwards taking
8 bits off the argument being encoded at a time
until all bits from uNumber have been encoded
and the minimum encoding size is reached.
Minimum encoding size is for floating point
numbers with zero bytes.
*/
static const uint8_t aIterate[] = {1,1,2,4};
// The parameter passed in is unsigned, but goes negative in the loop
// so it must be converted to a signed value.
int nMinLen = (int)uMinLen;
int i;
for(i = 0; uArgument || nMinLen > 0; i++) {
const int nIterations = (int)aIterate[i];
for(int j = 0; j < nIterations; j++) {
*--pByte = (uint8_t)(uArgument & 0xff);
uArgument = uArgument >> 8;
}
nMinLen -= nIterations;
}
// Additional info is the encoding of the number of additional
// bytes to encode argument.
nAdditionalInfo = LEN_IS_ONE_BYTE-1 + i;
}
/*
This expression integer-promotes to type int. The code above in
function guarantees that nAdditionalInfo will never be larger than
0x1f. The caller may pass in a too-large uMajor type. The
conversion to unint8_t will cause an integer wrap around and
incorrect CBOR will be generated, but no security issue will
occur.
*/
*--pByte = (uint8_t)((uMajorType << 5) + nAdditionalInfo);
#ifdef EXTRA_ENCODE_HEAD_CHECK
/* This is a sanity check that can be turned on to verify the pointer
* math in this function is not going wrong. Turn it on and run the
* whole test suite to perform the check.
*/
if(pBufferEnd - pByte > 9 || pBufferEnd - pByte < 1 || pByte < (uint8_t *)buffer.ptr) {
return NULLUsefulBufC;
}
#endif
// Length will not go negative because the loops run for at most 8 decrements
// of pByte, only one other decrement is made, and the array is sized
// for this.
return (UsefulBufC){pByte, (size_t)(pBufferEnd - pByte)};
} | /*
Public function to encode a CBOR head. See qcbor/qcbor_encode.h
*/ | Public function to encode a CBOR head. | [
"Public",
"function",
"to",
"encode",
"a",
"CBOR",
"head",
"."
] | UsefulBufC QCBOREncode_EncodeHead(UsefulBuf buffer,
uint8_t uMajorType,
uint8_t uMinLen,
uint64_t uArgument)
{
if(buffer.len < QCBOR_HEAD_BUFFER_SIZE) {
return NULLUsefulBufC;
}
uint8_t * const pBufferEnd = &((uint8_t *)buffer.ptr)[QCBOR_HEAD_BUFFER_SIZE-1];
uint8_t *pByte = pBufferEnd;
int nAdditionalInfo;
if (uMajorType == CBOR_MAJOR_NONE_TYPE_ARRAY_INDEFINITE_LEN) {
uMajorType = CBOR_MAJOR_TYPE_ARRAY;
nAdditionalInfo = LEN_IS_INDEFINITE;
} else if (uMajorType == CBOR_MAJOR_NONE_TYPE_MAP_INDEFINITE_LEN) {
uMajorType = CBOR_MAJOR_TYPE_MAP;
nAdditionalInfo = LEN_IS_INDEFINITE;
} else if (uArgument < CBOR_TWENTY_FOUR && uMinLen == 0) {
nAdditionalInfo = (int)uArgument;
} else if (uMajorType == CBOR_MAJOR_TYPE_SIMPLE && uArgument == CBOR_SIMPLE_BREAK) {
nAdditionalInfo = (int)uArgument;
} else {
static const uint8_t aIterate[] = {1,1,2,4};
int nMinLen = (int)uMinLen;
int i;
for(i = 0; uArgument || nMinLen > 0; i++) {
const int nIterations = (int)aIterate[i];
for(int j = 0; j < nIterations; j++) {
*--pByte = (uint8_t)(uArgument & 0xff);
uArgument = uArgument >> 8;
}
nMinLen -= nIterations;
}
nAdditionalInfo = LEN_IS_ONE_BYTE-1 + i;
}
*--pByte = (uint8_t)((uMajorType << 5) + nAdditionalInfo);
#ifdef EXTRA_ENCODE_HEAD_CHECK
if(pBufferEnd - pByte > 9 || pBufferEnd - pByte < 1 || pByte < (uint8_t *)buffer.ptr) {
return NULLUsefulBufC;
}
#endif
return (UsefulBufC){pByte, (size_t)(pBufferEnd - pByte)};
} | [
"UsefulBufC",
"QCBOREncode_EncodeHead",
"(",
"UsefulBuf",
"buffer",
",",
"uint8_t",
"uMajorType",
",",
"uint8_t",
"uMinLen",
",",
"uint64_t",
"uArgument",
")",
"{",
"if",
"(",
"buffer",
".",
"len",
"<",
"QCBOR_HEAD_BUFFER_SIZE",
")",
"{",
"return",
"NULLUsefulBufC",
";",
"}",
"uint8_t",
"*",
"const",
"pBufferEnd",
"=",
"&",
"(",
"(",
"uint8_t",
"*",
")",
"buffer",
".",
"ptr",
")",
"[",
"QCBOR_HEAD_BUFFER_SIZE",
"-",
"1",
"]",
";",
"uint8_t",
"*",
"pByte",
"=",
"pBufferEnd",
";",
"int",
"nAdditionalInfo",
";",
"if",
"(",
"uMajorType",
"==",
"CBOR_MAJOR_NONE_TYPE_ARRAY_INDEFINITE_LEN",
")",
"{",
"uMajorType",
"=",
"CBOR_MAJOR_TYPE_ARRAY",
";",
"nAdditionalInfo",
"=",
"LEN_IS_INDEFINITE",
";",
"}",
"else",
"if",
"(",
"uMajorType",
"==",
"CBOR_MAJOR_NONE_TYPE_MAP_INDEFINITE_LEN",
")",
"{",
"uMajorType",
"=",
"CBOR_MAJOR_TYPE_MAP",
";",
"nAdditionalInfo",
"=",
"LEN_IS_INDEFINITE",
";",
"}",
"else",
"if",
"(",
"uArgument",
"<",
"CBOR_TWENTY_FOUR",
"&&",
"uMinLen",
"==",
"0",
")",
"{",
"nAdditionalInfo",
"=",
"(",
"int",
")",
"uArgument",
";",
"}",
"else",
"if",
"(",
"uMajorType",
"==",
"CBOR_MAJOR_TYPE_SIMPLE",
"&&",
"uArgument",
"==",
"CBOR_SIMPLE_BREAK",
")",
"{",
"nAdditionalInfo",
"=",
"(",
"int",
")",
"uArgument",
";",
"}",
"else",
"{",
"static",
"const",
"uint8_t",
"aIterate",
"[",
"]",
"=",
"{",
"1",
",",
"1",
",",
"2",
",",
"4",
"}",
";",
"int",
"nMinLen",
"=",
"(",
"int",
")",
"uMinLen",
";",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"uArgument",
"||",
"nMinLen",
">",
"0",
";",
"i",
"++",
")",
"{",
"const",
"int",
"nIterations",
"=",
"(",
"int",
")",
"aIterate",
"[",
"i",
"]",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"nIterations",
";",
"j",
"++",
")",
"{",
"*",
"--",
"pByte",
"=",
"(",
"uint8_t",
")",
"(",
"uArgument",
"&",
"0xff",
")",
";",
"uArgument",
"=",
"uArgument",
">>",
"8",
";",
"}",
"nMinLen",
"-=",
"nIterations",
";",
"}",
"nAdditionalInfo",
"=",
"LEN_IS_ONE_BYTE",
"-",
"1",
"+",
"i",
";",
"}",
"*",
"--",
"pByte",
"=",
"(",
"uint8_t",
")",
"(",
"(",
"uMajorType",
"<<",
"5",
")",
"+",
"nAdditionalInfo",
")",
";",
"#ifdef",
"EXTRA_ENCODE_HEAD_CHECK",
"if",
"(",
"pBufferEnd",
"-",
"pByte",
">",
"9",
"||",
"pBufferEnd",
"-",
"pByte",
"<",
"1",
"||",
"pByte",
"<",
"(",
"uint8_t",
"*",
")",
"buffer",
".",
"ptr",
")",
"{",
"return",
"NULLUsefulBufC",
";",
"}",
"#endif",
"return",
"(",
"UsefulBufC",
")",
"{",
"pByte",
",",
"(",
"size_t",
")",
"(",
"pBufferEnd",
"-",
"pByte",
")",
"}",
";",
"}"
] | Public function to encode a CBOR head. | [
"Public",
"function",
"to",
"encode",
"a",
"CBOR",
"head",
"."
] | [
"/**\n All CBOR data items have a type and an \"argument\". The argument is\n either the value of the item for integer types, the length of the\n content for string, byte, array and map types, a tag for major type\n 6, and has several uses for major type 7.\n\n This function encodes the type and the argument. There are several\n encodings for the argument depending on how large it is and how it is\n used.\n\n Every encoding of the type and argument has at least one byte, the\n \"initial byte\".\n\n The top three bits of the initial byte are the major type for the\n CBOR data item. The eight major types defined by the standard are\n defined as CBOR_MAJOR_TYPE_xxxx in qcbor/qcbor_common.h.\n\n The remaining five bits, known as \"additional information\", and\n possibly more bytes encode the argument. If the argument is less than\n 24, then it is encoded entirely in the five bits. This is neat\n because it allows you to encode an entire CBOR data item in 1 byte\n for many values and types (integers 0-23, true, false, and tags).\n\n If the argument is larger than 24, then it is encoded in 1,2,4 or 8\n additional bytes, with the number of these bytes indicated by the\n values of the 5 bits 24, 25, 25 and 27.\n\n It is possible to encode a particular argument in many ways with this\n representation. This implementation always uses the smallest\n possible representation. This conforms with CBOR preferred encoding.\n\n This function inserts them into the output buffer at the specified\n position. AppendEncodedTypeAndNumber() appends to the end.\n\n This function takes care of converting to network byte order.\n\n This function is also used to insert floats and doubles. Before this\n function is called the float or double must be copied into a\n uint64_t. That is how they are passed in. They are then converted to\n network byte order correctly. The uMinLen parameter makes sure that\n even if all the digits of a half, float or double are 0 it is still\n correctly encoded in 2, 4 or 8 bytes.\n */",
"/*\n This code does endian conversion without hton or knowing the\n endianness of the machine using masks and shifts. This avoids the\n dependency on hton and the mess of figuring out how to find the\n machine's endianness.\n\n This is a good efficient implementation on little-endian machines.\n A faster and small implementation is possible on big-endian\n machines because CBOR/network byte order is big endian. However\n big endian machines are uncommon.\n\n On x86, it is about 200 bytes instead of 500 bytes for the more\n formal unoptimized code.\n\n This also does the CBOR preferred shortest encoding for integers\n and is called to do endian conversion for floats.\n\n It works backwards from the LSB to the MSB as needed.\n\n Code Reviewers: THIS FUNCTION DOES POINTER MATH\n */",
"/*\n The type int is used here for several variables because of the way\n integer promotion works in C for integer variables that are\n uint8_t or uint16_t. The basic rule is that they will always be\n promoted to int if they will fit. All of these integer variables\n need only hold values less than 255 or are promoted from uint8_t,\n so they will always fit into an int. Note that promotion is only\n to unsigned int if the value won't fit into an int even if the\n promotion is for an unsigned like uint8_t.\n\n By declaring them int, there are few implicit conversions and fewer\n casts needed. Code size is reduced a little. It also makes static\n analyzers happier.\n\n Note also that declaring them uint8_t won't stop integer wrap\n around if the code is wrong. It won't make the code more correct.\n\n https://stackoverflow.com/questions/46073295/implicit-type-promotion-rules\n https://stackoverflow.com/questions/589575/what-does-the-c-standard-state-the-size-of-int-long-type-to-be\n */",
"// Buffer must have room for the largest CBOR HEAD + one extra as the",
"// one extra is needed for this code to work as it does a pre-decrement.",
"// Pointer to last valid byte in the buffer",
"// Point to the last byte and work backwards",
"// The 5 bits in the initial byte that are not the major type",
"// Simple case where argument is < 24",
"// Break statement can be encoded in single byte too (0xff)",
"/*\n Encode argument in 1,2,4 or 8 bytes. Outer loop\n runs once for 1 byte and 4 times for 8 bytes.\n Inner loop runs 1, 2 or 4 times depending on\n outer loop counter. This works backwards taking\n 8 bits off the argument being encoded at a time\n until all bits from uNumber have been encoded\n and the minimum encoding size is reached.\n Minimum encoding size is for floating point\n numbers with zero bytes.\n */",
"// The parameter passed in is unsigned, but goes negative in the loop",
"// so it must be converted to a signed value.",
"// Additional info is the encoding of the number of additional",
"// bytes to encode argument.",
"/*\n This expression integer-promotes to type int. The code above in\n function guarantees that nAdditionalInfo will never be larger than\n 0x1f. The caller may pass in a too-large uMajor type. The\n conversion to unint8_t will cause an integer wrap around and\n incorrect CBOR will be generated, but no security issue will\n occur.\n */",
"/* This is a sanity check that can be turned on to verify the pointer\n * math in this function is not going wrong. Turn it on and run the\n * whole test suite to perform the check.\n */",
"// Length will not go negative because the loops run for at most 8 decrements",
"// of pByte, only one other decrement is made, and the array is sized",
"// for this."
] | [
{
"param": "buffer",
"type": "UsefulBuf"
},
{
"param": "uMajorType",
"type": "uint8_t"
},
{
"param": "uMinLen",
"type": "uint8_t"
},
{
"param": "uArgument",
"type": "uint64_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "buffer",
"type": "UsefulBuf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "uMajorType",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "uMinLen",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "uArgument",
"type": "uint64_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
be72cd5bb4dcc67ed7b711763a0c04394ed066e7 | dthaler/QCBOR | src/qcbor_encode.c | [
"Unlicense",
"BSD-3-Clause"
] | C | QCBOREncode_AddUInt64 | void | void QCBOREncode_AddUInt64(QCBOREncodeContext *me, uint64_t uValue)
{
if(me->uError == QCBOR_SUCCESS) {
AppendCBORHead(me, CBOR_MAJOR_TYPE_POSITIVE_INT, uValue, 0);
me->uError = Nesting_Increment(&(me->nesting));
}
} | /*
Public functions for adding integers. See qcbor/qcbor_encode.h
*/ | Public functions for adding integers. | [
"Public",
"functions",
"for",
"adding",
"integers",
"."
] | void QCBOREncode_AddUInt64(QCBOREncodeContext *me, uint64_t uValue)
{
if(me->uError == QCBOR_SUCCESS) {
AppendCBORHead(me, CBOR_MAJOR_TYPE_POSITIVE_INT, uValue, 0);
me->uError = Nesting_Increment(&(me->nesting));
}
} | [
"void",
"QCBOREncode_AddUInt64",
"(",
"QCBOREncodeContext",
"*",
"me",
",",
"uint64_t",
"uValue",
")",
"{",
"if",
"(",
"me",
"->",
"uError",
"==",
"QCBOR_SUCCESS",
")",
"{",
"AppendCBORHead",
"(",
"me",
",",
"CBOR_MAJOR_TYPE_POSITIVE_INT",
",",
"uValue",
",",
"0",
")",
";",
"me",
"->",
"uError",
"=",
"Nesting_Increment",
"(",
"&",
"(",
"me",
"->",
"nesting",
")",
")",
";",
"}",
"}"
] | Public functions for adding integers. | [
"Public",
"functions",
"for",
"adding",
"integers",
"."
] | [] | [
{
"param": "me",
"type": "QCBOREncodeContext"
},
{
"param": "uValue",
"type": "uint64_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "me",
"type": "QCBOREncodeContext",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "uValue",
"type": "uint64_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
be72cd5bb4dcc67ed7b711763a0c04394ed066e7 | dthaler/QCBOR | src/qcbor_encode.c | [
"Unlicense",
"BSD-3-Clause"
] | C | QCBOREncode_AddInt64 | void | void QCBOREncode_AddInt64(QCBOREncodeContext *me, int64_t nNum)
{
if(me->uError == QCBOR_SUCCESS) {
uint8_t uMajorType;
uint64_t uValue;
if(nNum < 0) {
// In CBOR -1 encodes as 0x00 with major type negative int.
uValue = (uint64_t)(-nNum - 1);
uMajorType = CBOR_MAJOR_TYPE_NEGATIVE_INT;
} else {
uValue = (uint64_t)nNum;
uMajorType = CBOR_MAJOR_TYPE_POSITIVE_INT;
}
AppendCBORHead(me, uMajorType, uValue, 0);
me->uError = Nesting_Increment(&(me->nesting));
}
} | /*
Public functions for adding unsigned. See qcbor/qcbor_encode.h
*/ | Public functions for adding unsigned. | [
"Public",
"functions",
"for",
"adding",
"unsigned",
"."
] | void QCBOREncode_AddInt64(QCBOREncodeContext *me, int64_t nNum)
{
if(me->uError == QCBOR_SUCCESS) {
uint8_t uMajorType;
uint64_t uValue;
if(nNum < 0) {
uValue = (uint64_t)(-nNum - 1);
uMajorType = CBOR_MAJOR_TYPE_NEGATIVE_INT;
} else {
uValue = (uint64_t)nNum;
uMajorType = CBOR_MAJOR_TYPE_POSITIVE_INT;
}
AppendCBORHead(me, uMajorType, uValue, 0);
me->uError = Nesting_Increment(&(me->nesting));
}
} | [
"void",
"QCBOREncode_AddInt64",
"(",
"QCBOREncodeContext",
"*",
"me",
",",
"int64_t",
"nNum",
")",
"{",
"if",
"(",
"me",
"->",
"uError",
"==",
"QCBOR_SUCCESS",
")",
"{",
"uint8_t",
"uMajorType",
";",
"uint64_t",
"uValue",
";",
"if",
"(",
"nNum",
"<",
"0",
")",
"{",
"uValue",
"=",
"(",
"uint64_t",
")",
"(",
"-",
"nNum",
"-",
"1",
")",
";",
"uMajorType",
"=",
"CBOR_MAJOR_TYPE_NEGATIVE_INT",
";",
"}",
"else",
"{",
"uValue",
"=",
"(",
"uint64_t",
")",
"nNum",
";",
"uMajorType",
"=",
"CBOR_MAJOR_TYPE_POSITIVE_INT",
";",
"}",
"AppendCBORHead",
"(",
"me",
",",
"uMajorType",
",",
"uValue",
",",
"0",
")",
";",
"me",
"->",
"uError",
"=",
"Nesting_Increment",
"(",
"&",
"(",
"me",
"->",
"nesting",
")",
")",
";",
"}",
"}"
] | Public functions for adding unsigned. | [
"Public",
"functions",
"for",
"adding",
"unsigned",
"."
] | [
"// In CBOR -1 encodes as 0x00 with major type negative int."
] | [
{
"param": "me",
"type": "QCBOREncodeContext"
},
{
"param": "nNum",
"type": "int64_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "me",
"type": "QCBOREncodeContext",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nNum",
"type": "int64_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
be72cd5bb4dcc67ed7b711763a0c04394ed066e7 | dthaler/QCBOR | src/qcbor_encode.c | [
"Unlicense",
"BSD-3-Clause"
] | C | QCBOREncode_AddBuffer | void | void QCBOREncode_AddBuffer(QCBOREncodeContext *me, uint8_t uMajorType, UsefulBufC Bytes)
{
if(me->uError == QCBOR_SUCCESS) {
// If it is not Raw CBOR, add the type and the length
if(uMajorType != CBOR_MAJOR_NONE_TYPE_RAW) {
uint8_t uRealMajorType = uMajorType;
if(uRealMajorType == CBOR_MAJOR_NONE_TYPE_BSTR_LEN_ONLY) {
uRealMajorType = CBOR_MAJOR_TYPE_BYTE_STRING;
}
AppendCBORHead(me, uRealMajorType, Bytes.len, 0);
}
if(uMajorType != CBOR_MAJOR_NONE_TYPE_BSTR_LEN_ONLY) {
// Actually add the bytes
UsefulOutBuf_AppendUsefulBuf(&(me->OutBuf), Bytes);
}
// Update the array counting if there is any nesting at all
me->uError = Nesting_Increment(&(me->nesting));
}
} | /*
Semi-private function. It is exposed to user of the interface, but
they will usually call one of the inline wrappers rather than this.
See qcbor/qcbor_encode.h
Does the work of adding actual strings bytes to the CBOR output (as
opposed to numbers and opening / closing aggregate types).
There are four use cases:
CBOR_MAJOR_TYPE_BYTE_STRING -- Byte strings
CBOR_MAJOR_TYPE_TEXT_STRING -- Text strings
CBOR_MAJOR_NONE_TYPE_RAW -- Already-encoded CBOR
CBOR_MAJOR_NONE_TYPE_BSTR_LEN_ONLY -- Special case
The first two add the type and length plus the actual bytes. The
third just adds the bytes as the type and length are presumed to be
in the bytes. The fourth just adds the type and length for the very
special case of QCBOREncode_AddBytesLenOnly().
*/ | Semi-private function. It is exposed to user of the interface, but
they will usually call one of the inline wrappers rather than this.
Does the work of adding actual strings bytes to the CBOR output (as
opposed to numbers and opening / closing aggregate types).
The first two add the type and length plus the actual bytes. The
third just adds the bytes as the type and length are presumed to be
in the bytes. The fourth just adds the type and length for the very
special case of QCBOREncode_AddBytesLenOnly(). | [
"Semi",
"-",
"private",
"function",
".",
"It",
"is",
"exposed",
"to",
"user",
"of",
"the",
"interface",
"but",
"they",
"will",
"usually",
"call",
"one",
"of",
"the",
"inline",
"wrappers",
"rather",
"than",
"this",
".",
"Does",
"the",
"work",
"of",
"adding",
"actual",
"strings",
"bytes",
"to",
"the",
"CBOR",
"output",
"(",
"as",
"opposed",
"to",
"numbers",
"and",
"opening",
"/",
"closing",
"aggregate",
"types",
")",
".",
"The",
"first",
"two",
"add",
"the",
"type",
"and",
"length",
"plus",
"the",
"actual",
"bytes",
".",
"The",
"third",
"just",
"adds",
"the",
"bytes",
"as",
"the",
"type",
"and",
"length",
"are",
"presumed",
"to",
"be",
"in",
"the",
"bytes",
".",
"The",
"fourth",
"just",
"adds",
"the",
"type",
"and",
"length",
"for",
"the",
"very",
"special",
"case",
"of",
"QCBOREncode_AddBytesLenOnly",
"()",
"."
] | void QCBOREncode_AddBuffer(QCBOREncodeContext *me, uint8_t uMajorType, UsefulBufC Bytes)
{
if(me->uError == QCBOR_SUCCESS) {
if(uMajorType != CBOR_MAJOR_NONE_TYPE_RAW) {
uint8_t uRealMajorType = uMajorType;
if(uRealMajorType == CBOR_MAJOR_NONE_TYPE_BSTR_LEN_ONLY) {
uRealMajorType = CBOR_MAJOR_TYPE_BYTE_STRING;
}
AppendCBORHead(me, uRealMajorType, Bytes.len, 0);
}
if(uMajorType != CBOR_MAJOR_NONE_TYPE_BSTR_LEN_ONLY) {
UsefulOutBuf_AppendUsefulBuf(&(me->OutBuf), Bytes);
}
me->uError = Nesting_Increment(&(me->nesting));
}
} | [
"void",
"QCBOREncode_AddBuffer",
"(",
"QCBOREncodeContext",
"*",
"me",
",",
"uint8_t",
"uMajorType",
",",
"UsefulBufC",
"Bytes",
")",
"{",
"if",
"(",
"me",
"->",
"uError",
"==",
"QCBOR_SUCCESS",
")",
"{",
"if",
"(",
"uMajorType",
"!=",
"CBOR_MAJOR_NONE_TYPE_RAW",
")",
"{",
"uint8_t",
"uRealMajorType",
"=",
"uMajorType",
";",
"if",
"(",
"uRealMajorType",
"==",
"CBOR_MAJOR_NONE_TYPE_BSTR_LEN_ONLY",
")",
"{",
"uRealMajorType",
"=",
"CBOR_MAJOR_TYPE_BYTE_STRING",
";",
"}",
"AppendCBORHead",
"(",
"me",
",",
"uRealMajorType",
",",
"Bytes",
".",
"len",
",",
"0",
")",
";",
"}",
"if",
"(",
"uMajorType",
"!=",
"CBOR_MAJOR_NONE_TYPE_BSTR_LEN_ONLY",
")",
"{",
"UsefulOutBuf_AppendUsefulBuf",
"(",
"&",
"(",
"me",
"->",
"OutBuf",
")",
",",
"Bytes",
")",
";",
"}",
"me",
"->",
"uError",
"=",
"Nesting_Increment",
"(",
"&",
"(",
"me",
"->",
"nesting",
")",
")",
";",
"}",
"}"
] | Semi-private function. | [
"Semi",
"-",
"private",
"function",
"."
] | [
"// If it is not Raw CBOR, add the type and the length",
"// Actually add the bytes",
"// Update the array counting if there is any nesting at all"
] | [
{
"param": "me",
"type": "QCBOREncodeContext"
},
{
"param": "uMajorType",
"type": "uint8_t"
},
{
"param": "Bytes",
"type": "UsefulBufC"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "me",
"type": "QCBOREncodeContext",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "uMajorType",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "Bytes",
"type": "UsefulBufC",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
be72cd5bb4dcc67ed7b711763a0c04394ed066e7 | dthaler/QCBOR | src/qcbor_encode.c | [
"Unlicense",
"BSD-3-Clause"
] | C | QCBOREncode_AddDouble | void | void QCBOREncode_AddDouble(QCBOREncodeContext *me, double dNum)
{
const IEEE754_union uNum = IEEE754_DoubleToSmallest(dNum);
QCBOREncode_AddType7(me, uNum.uSize, uNum.uValue);
} | /*
Public functions for adding a double. See qcbor/qcbor_encode.h
*/ | Public functions for adding a double. | [
"Public",
"functions",
"for",
"adding",
"a",
"double",
"."
] | void QCBOREncode_AddDouble(QCBOREncodeContext *me, double dNum)
{
const IEEE754_union uNum = IEEE754_DoubleToSmallest(dNum);
QCBOREncode_AddType7(me, uNum.uSize, uNum.uValue);
} | [
"void",
"QCBOREncode_AddDouble",
"(",
"QCBOREncodeContext",
"*",
"me",
",",
"double",
"dNum",
")",
"{",
"const",
"IEEE754_union",
"uNum",
"=",
"IEEE754_DoubleToSmallest",
"(",
"dNum",
")",
";",
"QCBOREncode_AddType7",
"(",
"me",
",",
"uNum",
".",
"uSize",
",",
"uNum",
".",
"uValue",
")",
";",
"}"
] | Public functions for adding a double. | [
"Public",
"functions",
"for",
"adding",
"a",
"double",
"."
] | [] | [
{
"param": "me",
"type": "QCBOREncodeContext"
},
{
"param": "dNum",
"type": "double"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "me",
"type": "QCBOREncodeContext",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dNum",
"type": "double",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
be72cd5bb4dcc67ed7b711763a0c04394ed066e7 | dthaler/QCBOR | src/qcbor_encode.c | [
"Unlicense",
"BSD-3-Clause"
] | C | QCBOREncode_AddExponentAndMantissa | void | void QCBOREncode_AddExponentAndMantissa(QCBOREncodeContext *pMe,
uint64_t uTag,
UsefulBufC BigNumMantissa,
bool bBigNumIsNegative,
int64_t nMantissa,
int64_t nExponent)
{
/*
This is for encoding either a big float or a decimal fraction,
both of which are an array of two items, an exponent and a
mantissa. The difference between the two is that the exponent is
base-2 for big floats and base-10 for decimal fractions, but that
has no effect on the code here.
*/
QCBOREncode_AddTag(pMe, uTag);
QCBOREncode_OpenArray(pMe);
QCBOREncode_AddInt64(pMe, nExponent);
if(!UsefulBuf_IsNULLC(BigNumMantissa)) {
if(bBigNumIsNegative) {
QCBOREncode_AddNegativeBignum(pMe, BigNumMantissa);
} else {
QCBOREncode_AddPositiveBignum(pMe, BigNumMantissa);
}
} else {
QCBOREncode_AddInt64(pMe, nMantissa);
}
QCBOREncode_CloseArray(pMe);
} | /*
Semi-public function. It is exposed to the user of the interface, but
one of the inline wrappers will usually be called rather than this.
See qcbor/qcbor_encode.h
*/ | Semi-public function. It is exposed to the user of the interface, but
one of the inline wrappers will usually be called rather than this.
| [
"Semi",
"-",
"public",
"function",
".",
"It",
"is",
"exposed",
"to",
"the",
"user",
"of",
"the",
"interface",
"but",
"one",
"of",
"the",
"inline",
"wrappers",
"will",
"usually",
"be",
"called",
"rather",
"than",
"this",
"."
] | void QCBOREncode_AddExponentAndMantissa(QCBOREncodeContext *pMe,
uint64_t uTag,
UsefulBufC BigNumMantissa,
bool bBigNumIsNegative,
int64_t nMantissa,
int64_t nExponent)
{
QCBOREncode_AddTag(pMe, uTag);
QCBOREncode_OpenArray(pMe);
QCBOREncode_AddInt64(pMe, nExponent);
if(!UsefulBuf_IsNULLC(BigNumMantissa)) {
if(bBigNumIsNegative) {
QCBOREncode_AddNegativeBignum(pMe, BigNumMantissa);
} else {
QCBOREncode_AddPositiveBignum(pMe, BigNumMantissa);
}
} else {
QCBOREncode_AddInt64(pMe, nMantissa);
}
QCBOREncode_CloseArray(pMe);
} | [
"void",
"QCBOREncode_AddExponentAndMantissa",
"(",
"QCBOREncodeContext",
"*",
"pMe",
",",
"uint64_t",
"uTag",
",",
"UsefulBufC",
"BigNumMantissa",
",",
"bool",
"bBigNumIsNegative",
",",
"int64_t",
"nMantissa",
",",
"int64_t",
"nExponent",
")",
"{",
"QCBOREncode_AddTag",
"(",
"pMe",
",",
"uTag",
")",
";",
"QCBOREncode_OpenArray",
"(",
"pMe",
")",
";",
"QCBOREncode_AddInt64",
"(",
"pMe",
",",
"nExponent",
")",
";",
"if",
"(",
"!",
"UsefulBuf_IsNULLC",
"(",
"BigNumMantissa",
")",
")",
"{",
"if",
"(",
"bBigNumIsNegative",
")",
"{",
"QCBOREncode_AddNegativeBignum",
"(",
"pMe",
",",
"BigNumMantissa",
")",
";",
"}",
"else",
"{",
"QCBOREncode_AddPositiveBignum",
"(",
"pMe",
",",
"BigNumMantissa",
")",
";",
"}",
"}",
"else",
"{",
"QCBOREncode_AddInt64",
"(",
"pMe",
",",
"nMantissa",
")",
";",
"}",
"QCBOREncode_CloseArray",
"(",
"pMe",
")",
";",
"}"
] | Semi-public function. | [
"Semi",
"-",
"public",
"function",
"."
] | [
"/*\n This is for encoding either a big float or a decimal fraction,\n both of which are an array of two items, an exponent and a\n mantissa. The difference between the two is that the exponent is\n base-2 for big floats and base-10 for decimal fractions, but that\n has no effect on the code here.\n */"
] | [
{
"param": "pMe",
"type": "QCBOREncodeContext"
},
{
"param": "uTag",
"type": "uint64_t"
},
{
"param": "BigNumMantissa",
"type": "UsefulBufC"
},
{
"param": "bBigNumIsNegative",
"type": "bool"
},
{
"param": "nMantissa",
"type": "int64_t"
},
{
"param": "nExponent",
"type": "int64_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pMe",
"type": "QCBOREncodeContext",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "uTag",
"type": "uint64_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "BigNumMantissa",
"type": "UsefulBufC",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bBigNumIsNegative",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nMantissa",
"type": "int64_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nExponent",
"type": "int64_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
be72cd5bb4dcc67ed7b711763a0c04394ed066e7 | dthaler/QCBOR | src/qcbor_encode.c | [
"Unlicense",
"BSD-3-Clause"
] | C | QCBOREncode_CloseMapOrArrayIndefiniteLength | void | void QCBOREncode_CloseMapOrArrayIndefiniteLength(QCBOREncodeContext *me, uint8_t uMajorType)
{
if(me->uError == QCBOR_SUCCESS) {
if(!Nesting_IsInNest(&(me->nesting))) {
me->uError = QCBOR_ERR_TOO_MANY_CLOSES;
} else if(Nesting_GetMajorType(&(me->nesting)) != uMajorType) {
me->uError = QCBOR_ERR_CLOSE_MISMATCH;
} else {
// Append the break marker (0xff for both arrays and maps)
AppendCBORHead(me, CBOR_MAJOR_TYPE_SIMPLE, CBOR_SIMPLE_BREAK, 0);
Nesting_Decrease(&(me->nesting));
}
}
} | /*
Public functions for closing arrays and maps. See qcbor/qcbor_encode.h
*/ | Public functions for closing arrays and maps. | [
"Public",
"functions",
"for",
"closing",
"arrays",
"and",
"maps",
"."
] | void QCBOREncode_CloseMapOrArrayIndefiniteLength(QCBOREncodeContext *me, uint8_t uMajorType)
{
if(me->uError == QCBOR_SUCCESS) {
if(!Nesting_IsInNest(&(me->nesting))) {
me->uError = QCBOR_ERR_TOO_MANY_CLOSES;
} else if(Nesting_GetMajorType(&(me->nesting)) != uMajorType) {
me->uError = QCBOR_ERR_CLOSE_MISMATCH;
} else {
AppendCBORHead(me, CBOR_MAJOR_TYPE_SIMPLE, CBOR_SIMPLE_BREAK, 0);
Nesting_Decrease(&(me->nesting));
}
}
} | [
"void",
"QCBOREncode_CloseMapOrArrayIndefiniteLength",
"(",
"QCBOREncodeContext",
"*",
"me",
",",
"uint8_t",
"uMajorType",
")",
"{",
"if",
"(",
"me",
"->",
"uError",
"==",
"QCBOR_SUCCESS",
")",
"{",
"if",
"(",
"!",
"Nesting_IsInNest",
"(",
"&",
"(",
"me",
"->",
"nesting",
")",
")",
")",
"{",
"me",
"->",
"uError",
"=",
"QCBOR_ERR_TOO_MANY_CLOSES",
";",
"}",
"else",
"if",
"(",
"Nesting_GetMajorType",
"(",
"&",
"(",
"me",
"->",
"nesting",
")",
")",
"!=",
"uMajorType",
")",
"{",
"me",
"->",
"uError",
"=",
"QCBOR_ERR_CLOSE_MISMATCH",
";",
"}",
"else",
"{",
"AppendCBORHead",
"(",
"me",
",",
"CBOR_MAJOR_TYPE_SIMPLE",
",",
"CBOR_SIMPLE_BREAK",
",",
"0",
")",
";",
"Nesting_Decrease",
"(",
"&",
"(",
"me",
"->",
"nesting",
")",
")",
";",
"}",
"}",
"}"
] | Public functions for closing arrays and maps. | [
"Public",
"functions",
"for",
"closing",
"arrays",
"and",
"maps",
"."
] | [
"// Append the break marker (0xff for both arrays and maps)"
] | [
{
"param": "me",
"type": "QCBOREncodeContext"
},
{
"param": "uMajorType",
"type": "uint8_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "me",
"type": "QCBOREncodeContext",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "uMajorType",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3cbfe44e88e58a6c4fefd1e01f5eb9ee10318217 | abezhovets/netty-incubator-codec-quic | src/main/c/netty_quic_boringssl.c | [
"Apache-2.0",
"BSD-2-Clause",
"MIT"
] | C | netty_boringssl_JNI_OnLoad | jint | jint netty_boringssl_JNI_OnLoad(JNIEnv* env, const char* packagePrefix) {
int ret = JNI_ERR;
int staticallyRegistered = 0;
int nativeRegistered = 0;
char* name = NULL;
// We must register the statically referenced methods first!
if (netty_jni_util_register_natives(env,
packagePrefix,
STATICALLY_CLASSNAME,
statically_referenced_fixed_method_table,
statically_referenced_fixed_method_table_size) != 0) {
goto done;
}
staticallyRegistered = 1;
if (netty_jni_util_register_natives(env,
packagePrefix,
CLASSNAME,
fixed_method_table,
fixed_method_table_size) != 0) {
goto done;
}
nativeRegistered = 1;
// Initialize this module
NETTY_JNI_UTIL_LOAD_CLASS(env, byteArrayClass, "[B", done);
NETTY_JNI_UTIL_LOAD_CLASS(env, stringClass, "java/lang/String", done);
NETTY_JNI_UTIL_PREPEND(packagePrefix, "io/netty/incubator/codec/quic/BoringSSLCertificateCallback", name, done);
NETTY_JNI_UTIL_LOAD_CLASS(env, certificateCallbackClass, name, done);
NETTY_JNI_UTIL_GET_METHOD(env, certificateCallbackClass, certificateCallbackMethod, "handle", "(J[B[[B[Ljava/lang/String;)[J", done);
NETTY_JNI_UTIL_PREPEND(packagePrefix, "io/netty/incubator/codec/quic/BoringSSLCertificateVerifyCallback", name, done);
NETTY_JNI_UTIL_LOAD_CLASS(env, verifyCallbackClass, name, done);
NETTY_JNI_UTIL_GET_METHOD(env, verifyCallbackClass, verifyCallbackMethod, "verify", "(J[[BLjava/lang/String;)I", done);
NETTY_JNI_UTIL_PREPEND(packagePrefix, "io/netty/incubator/codec/quic/BoringSSLHandshakeCompleteCallback", name, done);
NETTY_JNI_UTIL_LOAD_CLASS(env, handshakeCompleteCallbackClass, name, done);
NETTY_JNI_UTIL_GET_METHOD(env, handshakeCompleteCallbackClass, handshakeCompleteCallbackMethod, "handshakeComplete", "(J[BLjava/lang/String;Ljava/lang/String;[B[[BJJ[B)V", done);
NETTY_JNI_UTIL_PREPEND(packagePrefix, "io/netty/incubator/codec/quic/BoringSSLTlsextServernameCallback", name, done);
NETTY_JNI_UTIL_LOAD_CLASS(env, servernameCallbackClass, name, done);
NETTY_JNI_UTIL_GET_METHOD(env, servernameCallbackClass, servernameCallbackMethod, "selectCtx", "(JLjava/lang/String;)J", done);
NETTY_JNI_UTIL_PREPEND(packagePrefix, "io/netty/incubator/codec/quic/BoringSSLKeylogCallback", name, done);
NETTY_JNI_UTIL_LOAD_CLASS(env, keylogCallbackClass, name, done);
NETTY_JNI_UTIL_GET_METHOD(env, keylogCallbackClass, keylogCallbackMethod, "logKey", "(JLjava/lang/String;)V", done);
verifyCallbackIdx = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
certificateCallbackIdx = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
handshakeCompleteCallbackIdx = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
servernameCallbackIdx = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
keylogCallbackIdx = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
alpn_data_idx = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
crypto_buffer_pool_idx = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
ret = NETTY_JNI_UTIL_JNI_VERSION;
done:
if (ret == JNI_ERR) {
if (staticallyRegistered == 1) {
netty_jni_util_unregister_natives(env, packagePrefix, STATICALLY_CLASSNAME);
}
if (nativeRegistered == 1) {
netty_jni_util_unregister_natives(env, packagePrefix, CLASSNAME);
}
NETTY_JNI_UTIL_UNLOAD_CLASS(env, byteArrayClass);
NETTY_JNI_UTIL_UNLOAD_CLASS(env, stringClass);
NETTY_JNI_UTIL_UNLOAD_CLASS(env, certificateCallbackClass);
NETTY_JNI_UTIL_UNLOAD_CLASS(env, verifyCallbackClass);
NETTY_JNI_UTIL_UNLOAD_CLASS(env, handshakeCompleteCallbackClass);
NETTY_JNI_UTIL_UNLOAD_CLASS(env, servernameCallbackClass);
NETTY_JNI_UTIL_UNLOAD_CLASS(env, keylogCallbackClass);
}
return ret;
} | // IMPORTANT: If you add any NETTY_JNI_UTIL_LOAD_CLASS or NETTY_JNI_UTIL_FIND_CLASS calls you also need to update
// Quiche to reflect that. | If you add any NETTY_JNI_UTIL_LOAD_CLASS or NETTY_JNI_UTIL_FIND_CLASS calls you also need to update
Quiche to reflect that. | [
"If",
"you",
"add",
"any",
"NETTY_JNI_UTIL_LOAD_CLASS",
"or",
"NETTY_JNI_UTIL_FIND_CLASS",
"calls",
"you",
"also",
"need",
"to",
"update",
"Quiche",
"to",
"reflect",
"that",
"."
] | jint netty_boringssl_JNI_OnLoad(JNIEnv* env, const char* packagePrefix) {
int ret = JNI_ERR;
int staticallyRegistered = 0;
int nativeRegistered = 0;
char* name = NULL;
if (netty_jni_util_register_natives(env,
packagePrefix,
STATICALLY_CLASSNAME,
statically_referenced_fixed_method_table,
statically_referenced_fixed_method_table_size) != 0) {
goto done;
}
staticallyRegistered = 1;
if (netty_jni_util_register_natives(env,
packagePrefix,
CLASSNAME,
fixed_method_table,
fixed_method_table_size) != 0) {
goto done;
}
nativeRegistered = 1;
NETTY_JNI_UTIL_LOAD_CLASS(env, byteArrayClass, "[B", done);
NETTY_JNI_UTIL_LOAD_CLASS(env, stringClass, "java/lang/String", done);
NETTY_JNI_UTIL_PREPEND(packagePrefix, "io/netty/incubator/codec/quic/BoringSSLCertificateCallback", name, done);
NETTY_JNI_UTIL_LOAD_CLASS(env, certificateCallbackClass, name, done);
NETTY_JNI_UTIL_GET_METHOD(env, certificateCallbackClass, certificateCallbackMethod, "handle", "(J[B[[B[Ljava/lang/String;)[J", done);
NETTY_JNI_UTIL_PREPEND(packagePrefix, "io/netty/incubator/codec/quic/BoringSSLCertificateVerifyCallback", name, done);
NETTY_JNI_UTIL_LOAD_CLASS(env, verifyCallbackClass, name, done);
NETTY_JNI_UTIL_GET_METHOD(env, verifyCallbackClass, verifyCallbackMethod, "verify", "(J[[BLjava/lang/String;)I", done);
NETTY_JNI_UTIL_PREPEND(packagePrefix, "io/netty/incubator/codec/quic/BoringSSLHandshakeCompleteCallback", name, done);
NETTY_JNI_UTIL_LOAD_CLASS(env, handshakeCompleteCallbackClass, name, done);
NETTY_JNI_UTIL_GET_METHOD(env, handshakeCompleteCallbackClass, handshakeCompleteCallbackMethod, "handshakeComplete", "(J[BLjava/lang/String;Ljava/lang/String;[B[[BJJ[B)V", done);
NETTY_JNI_UTIL_PREPEND(packagePrefix, "io/netty/incubator/codec/quic/BoringSSLTlsextServernameCallback", name, done);
NETTY_JNI_UTIL_LOAD_CLASS(env, servernameCallbackClass, name, done);
NETTY_JNI_UTIL_GET_METHOD(env, servernameCallbackClass, servernameCallbackMethod, "selectCtx", "(JLjava/lang/String;)J", done);
NETTY_JNI_UTIL_PREPEND(packagePrefix, "io/netty/incubator/codec/quic/BoringSSLKeylogCallback", name, done);
NETTY_JNI_UTIL_LOAD_CLASS(env, keylogCallbackClass, name, done);
NETTY_JNI_UTIL_GET_METHOD(env, keylogCallbackClass, keylogCallbackMethod, "logKey", "(JLjava/lang/String;)V", done);
verifyCallbackIdx = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
certificateCallbackIdx = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
handshakeCompleteCallbackIdx = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
servernameCallbackIdx = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
keylogCallbackIdx = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
alpn_data_idx = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
crypto_buffer_pool_idx = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
ret = NETTY_JNI_UTIL_JNI_VERSION;
done:
if (ret == JNI_ERR) {
if (staticallyRegistered == 1) {
netty_jni_util_unregister_natives(env, packagePrefix, STATICALLY_CLASSNAME);
}
if (nativeRegistered == 1) {
netty_jni_util_unregister_natives(env, packagePrefix, CLASSNAME);
}
NETTY_JNI_UTIL_UNLOAD_CLASS(env, byteArrayClass);
NETTY_JNI_UTIL_UNLOAD_CLASS(env, stringClass);
NETTY_JNI_UTIL_UNLOAD_CLASS(env, certificateCallbackClass);
NETTY_JNI_UTIL_UNLOAD_CLASS(env, verifyCallbackClass);
NETTY_JNI_UTIL_UNLOAD_CLASS(env, handshakeCompleteCallbackClass);
NETTY_JNI_UTIL_UNLOAD_CLASS(env, servernameCallbackClass);
NETTY_JNI_UTIL_UNLOAD_CLASS(env, keylogCallbackClass);
}
return ret;
} | [
"jint",
"netty_boringssl_JNI_OnLoad",
"(",
"JNIEnv",
"*",
"env",
",",
"const",
"char",
"*",
"packagePrefix",
")",
"{",
"int",
"ret",
"=",
"JNI_ERR",
";",
"int",
"staticallyRegistered",
"=",
"0",
";",
"int",
"nativeRegistered",
"=",
"0",
";",
"char",
"*",
"name",
"=",
"NULL",
";",
"if",
"(",
"netty_jni_util_register_natives",
"(",
"env",
",",
"packagePrefix",
",",
"STATICALLY_CLASSNAME",
",",
"statically_referenced_fixed_method_table",
",",
"statically_referenced_fixed_method_table_size",
")",
"!=",
"0",
")",
"{",
"goto",
"done",
";",
"}",
"staticallyRegistered",
"=",
"1",
";",
"if",
"(",
"netty_jni_util_register_natives",
"(",
"env",
",",
"packagePrefix",
",",
"CLASSNAME",
",",
"fixed_method_table",
",",
"fixed_method_table_size",
")",
"!=",
"0",
")",
"{",
"goto",
"done",
";",
"}",
"nativeRegistered",
"=",
"1",
";",
"NETTY_JNI_UTIL_LOAD_CLASS",
"(",
"env",
",",
"byteArrayClass",
",",
"\"",
"\"",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_LOAD_CLASS",
"(",
"env",
",",
"stringClass",
",",
"\"",
"\"",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_PREPEND",
"(",
"packagePrefix",
",",
"\"",
"\"",
",",
"name",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_LOAD_CLASS",
"(",
"env",
",",
"certificateCallbackClass",
",",
"name",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_GET_METHOD",
"(",
"env",
",",
"certificateCallbackClass",
",",
"certificateCallbackMethod",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_PREPEND",
"(",
"packagePrefix",
",",
"\"",
"\"",
",",
"name",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_LOAD_CLASS",
"(",
"env",
",",
"verifyCallbackClass",
",",
"name",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_GET_METHOD",
"(",
"env",
",",
"verifyCallbackClass",
",",
"verifyCallbackMethod",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_PREPEND",
"(",
"packagePrefix",
",",
"\"",
"\"",
",",
"name",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_LOAD_CLASS",
"(",
"env",
",",
"handshakeCompleteCallbackClass",
",",
"name",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_GET_METHOD",
"(",
"env",
",",
"handshakeCompleteCallbackClass",
",",
"handshakeCompleteCallbackMethod",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_PREPEND",
"(",
"packagePrefix",
",",
"\"",
"\"",
",",
"name",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_LOAD_CLASS",
"(",
"env",
",",
"servernameCallbackClass",
",",
"name",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_GET_METHOD",
"(",
"env",
",",
"servernameCallbackClass",
",",
"servernameCallbackMethod",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_PREPEND",
"(",
"packagePrefix",
",",
"\"",
"\"",
",",
"name",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_LOAD_CLASS",
"(",
"env",
",",
"keylogCallbackClass",
",",
"name",
",",
"done",
")",
";",
"NETTY_JNI_UTIL_GET_METHOD",
"(",
"env",
",",
"keylogCallbackClass",
",",
"keylogCallbackMethod",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"done",
")",
";",
"verifyCallbackIdx",
"=",
"SSL_CTX_get_ex_new_index",
"(",
"0",
",",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"NULL",
")",
";",
"certificateCallbackIdx",
"=",
"SSL_CTX_get_ex_new_index",
"(",
"0",
",",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"NULL",
")",
";",
"handshakeCompleteCallbackIdx",
"=",
"SSL_CTX_get_ex_new_index",
"(",
"0",
",",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"NULL",
")",
";",
"servernameCallbackIdx",
"=",
"SSL_CTX_get_ex_new_index",
"(",
"0",
",",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"NULL",
")",
";",
"keylogCallbackIdx",
"=",
"SSL_CTX_get_ex_new_index",
"(",
"0",
",",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"NULL",
")",
";",
"alpn_data_idx",
"=",
"SSL_CTX_get_ex_new_index",
"(",
"0",
",",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"NULL",
")",
";",
"crypto_buffer_pool_idx",
"=",
"SSL_CTX_get_ex_new_index",
"(",
"0",
",",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"NULL",
")",
";",
"ret",
"=",
"NETTY_JNI_UTIL_JNI_VERSION",
";",
"done",
":",
"if",
"(",
"ret",
"==",
"JNI_ERR",
")",
"{",
"if",
"(",
"staticallyRegistered",
"==",
"1",
")",
"{",
"netty_jni_util_unregister_natives",
"(",
"env",
",",
"packagePrefix",
",",
"STATICALLY_CLASSNAME",
")",
";",
"}",
"if",
"(",
"nativeRegistered",
"==",
"1",
")",
"{",
"netty_jni_util_unregister_natives",
"(",
"env",
",",
"packagePrefix",
",",
"CLASSNAME",
")",
";",
"}",
"NETTY_JNI_UTIL_UNLOAD_CLASS",
"(",
"env",
",",
"byteArrayClass",
")",
";",
"NETTY_JNI_UTIL_UNLOAD_CLASS",
"(",
"env",
",",
"stringClass",
")",
";",
"NETTY_JNI_UTIL_UNLOAD_CLASS",
"(",
"env",
",",
"certificateCallbackClass",
")",
";",
"NETTY_JNI_UTIL_UNLOAD_CLASS",
"(",
"env",
",",
"verifyCallbackClass",
")",
";",
"NETTY_JNI_UTIL_UNLOAD_CLASS",
"(",
"env",
",",
"handshakeCompleteCallbackClass",
")",
";",
"NETTY_JNI_UTIL_UNLOAD_CLASS",
"(",
"env",
",",
"servernameCallbackClass",
")",
";",
"NETTY_JNI_UTIL_UNLOAD_CLASS",
"(",
"env",
",",
"keylogCallbackClass",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | IMPORTANT: If you add any NETTY_JNI_UTIL_LOAD_CLASS or NETTY_JNI_UTIL_FIND_CLASS calls you also need to update
Quiche to reflect that. | [
"IMPORTANT",
":",
"If",
"you",
"add",
"any",
"NETTY_JNI_UTIL_LOAD_CLASS",
"or",
"NETTY_JNI_UTIL_FIND_CLASS",
"calls",
"you",
"also",
"need",
"to",
"update",
"Quiche",
"to",
"reflect",
"that",
"."
] | [
"// We must register the statically referenced methods first!",
"// Initialize this module"
] | [
{
"param": "env",
"type": "JNIEnv"
},
{
"param": "packagePrefix",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "env",
"type": "JNIEnv",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "packagePrefix",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
94ccdb1dafc8438fdec461e14ee967dc0d1d0635 | junaruga/pstools | graph.h | [
"MIT"
] | C | asg_arc_del_multi | int | int asg_arc_del_multi(asg_t *g)
{
//the number of nodes are number of read times 2
uint32_t *cnt, n_vtx = g->n_seq * 2, n_multi = 0, v;
cnt = (uint32_t*)calloc(n_vtx, 4);
for (v = 0; v < n_vtx; ++v) {
///out-nodes of v
asg_arc_t *av = asg_arc_a(g, v);
int32_t i, nv = asg_arc_n(g, v);
///if v just have one out-node, there is no muti-edge
if (nv < 2) continue;
for (i = nv - 1; i >= 0; --i) ++cnt[av[i].v];
for (i = nv - 1; i >= 0; --i)
if (--cnt[av[i].v] != 0)
av[i].del = 1, ++n_multi;
}
free(cnt);
if (n_multi) gfa_cleanup(g);
if(VERBOSE >= 1)
{
fprintf(stderr, "[M::%s] removed %d multi-arcs\n", __func__, n_multi);
}
return n_multi;
} | // delete multi-arcs
/**
* remove edges like: v has two out-edges to w
**/ | delete multi-arcs
remove edges like: v has two out-edges to w | [
"delete",
"multi",
"-",
"arcs",
"remove",
"edges",
"like",
":",
"v",
"has",
"two",
"out",
"-",
"edges",
"to",
"w"
] | int asg_arc_del_multi(asg_t *g)
{
uint32_t *cnt, n_vtx = g->n_seq * 2, n_multi = 0, v;
cnt = (uint32_t*)calloc(n_vtx, 4);
for (v = 0; v < n_vtx; ++v) {
asg_arc_t *av = asg_arc_a(g, v);
int32_t i, nv = asg_arc_n(g, v);
if (nv < 2) continue;
for (i = nv - 1; i >= 0; --i) ++cnt[av[i].v];
for (i = nv - 1; i >= 0; --i)
if (--cnt[av[i].v] != 0)
av[i].del = 1, ++n_multi;
}
free(cnt);
if (n_multi) gfa_cleanup(g);
if(VERBOSE >= 1)
{
fprintf(stderr, "[M::%s] removed %d multi-arcs\n", __func__, n_multi);
}
return n_multi;
} | [
"int",
"asg_arc_del_multi",
"(",
"asg_t",
"*",
"g",
")",
"{",
"uint32_t",
"*",
"cnt",
",",
"n_vtx",
"=",
"g",
"->",
"n_seq",
"*",
"2",
",",
"n_multi",
"=",
"0",
",",
"v",
";",
"cnt",
"=",
"(",
"uint32_t",
"*",
")",
"calloc",
"(",
"n_vtx",
",",
"4",
")",
";",
"for",
"(",
"v",
"=",
"0",
";",
"v",
"<",
"n_vtx",
";",
"++",
"v",
")",
"{",
"asg_arc_t",
"*",
"av",
"=",
"asg_arc_a",
"(",
"g",
",",
"v",
")",
";",
"int32_t",
"i",
",",
"nv",
"=",
"asg_arc_n",
"(",
"g",
",",
"v",
")",
";",
"if",
"(",
"nv",
"<",
"2",
")",
"continue",
";",
"for",
"(",
"i",
"=",
"nv",
"-",
"1",
";",
"i",
">=",
"0",
";",
"--",
"i",
")",
"++",
"cnt",
"[",
"av",
"[",
"i",
"]",
".",
"v",
"]",
";",
"for",
"(",
"i",
"=",
"nv",
"-",
"1",
";",
"i",
">=",
"0",
";",
"--",
"i",
")",
"if",
"(",
"--",
"cnt",
"[",
"av",
"[",
"i",
"]",
".",
"v",
"]",
"!=",
"0",
")",
"av",
"[",
"i",
"]",
".",
"del",
"=",
"1",
",",
"++",
"n_multi",
";",
"}",
"free",
"(",
"cnt",
")",
";",
"if",
"(",
"n_multi",
")",
"gfa_cleanup",
"(",
"g",
")",
";",
"if",
"(",
"VERBOSE",
">=",
"1",
")",
"{",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
",",
"__func__",
",",
"n_multi",
")",
";",
"}",
"return",
"n_multi",
";",
"}"
] | delete multi-arcs
remove edges like: v has two out-edges to w | [
"delete",
"multi",
"-",
"arcs",
"remove",
"edges",
"like",
":",
"v",
"has",
"two",
"out",
"-",
"edges",
"to",
"w"
] | [
"//the number of nodes are number of read times 2",
"///out-nodes of v",
"///if v just have one out-node, there is no muti-edge"
] | [
{
"param": "g",
"type": "asg_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "g",
"type": "asg_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7b389d3e2bcff27d5d5c639a28f8d35daae75f73 | junaruga/pstools | array.c | [
"MIT"
] | C | arrayRemove | BOOL | BOOL arrayRemove (Array a, void * s, int (* order)(const void*, const void*))
{
int i;
if (!arrayExists (a))
die ("arrayRemove called on bad array %lx", (long unsigned int) a) ;
if (arrayFind(a, s, &i,order))
{
/* memcpy would be faster but regions overlap
* and memcpy is said to fail with some compilers
*/
char *cp = uArray(a,i), *cq = cp + a->size ;
int j = (arrayMax(a) - i)*(a->size) ;
while (j--)
*cp++ = *cq++ ;
arrayMax(a)-- ;
return TRUE ;
}
else
return FALSE ;
} | /**************************************************************/
/* Removes Entry s from Array a
* sorted in ascending order of order()
*/ | Removes Entry s from Array a
sorted in ascending order of order() | [
"Removes",
"Entry",
"s",
"from",
"Array",
"a",
"sorted",
"in",
"ascending",
"order",
"of",
"order",
"()"
] | BOOL arrayRemove (Array a, void * s, int (* order)(const void*, const void*))
{
int i;
if (!arrayExists (a))
die ("arrayRemove called on bad array %lx", (long unsigned int) a) ;
if (arrayFind(a, s, &i,order))
{
char *cp = uArray(a,i), *cq = cp + a->size ;
int j = (arrayMax(a) - i)*(a->size) ;
while (j--)
*cp++ = *cq++ ;
arrayMax(a)-- ;
return TRUE ;
}
else
return FALSE ;
} | [
"BOOL",
"arrayRemove",
"(",
"Array",
"a",
",",
"void",
"*",
"s",
",",
"int",
"(",
"*",
"order",
")",
"(",
"const",
"void",
"*",
",",
"const",
"void",
"*",
")",
")",
"{",
"int",
"i",
";",
"if",
"(",
"!",
"arrayExists",
"(",
"a",
")",
")",
"die",
"(",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
"int",
")",
"a",
")",
";",
"if",
"(",
"arrayFind",
"(",
"a",
",",
"s",
",",
"&",
"i",
",",
"order",
")",
")",
"{",
"char",
"*",
"cp",
"=",
"uArray",
"(",
"a",
",",
"i",
")",
",",
"*",
"cq",
"=",
"cp",
"+",
"a",
"->",
"size",
";",
"int",
"j",
"=",
"(",
"arrayMax",
"(",
"a",
")",
"-",
"i",
")",
"*",
"(",
"a",
"->",
"size",
")",
";",
"while",
"(",
"j",
"--",
")",
"*",
"cp",
"++",
"=",
"*",
"cq",
"++",
";",
"arrayMax",
"(",
"a",
")",
"--",
";",
"return",
"TRUE",
";",
"}",
"else",
"return",
"FALSE",
";",
"}"
] | Removes Entry s from Array a
sorted in ascending order of order() | [
"Removes",
"Entry",
"s",
"from",
"Array",
"a",
"sorted",
"in",
"ascending",
"order",
"of",
"order",
"()"
] | [
"/* memcpy would be faster but regions overlap\n * and memcpy is said to fail with some compilers\n */"
] | [
{
"param": "a",
"type": "Array"
},
{
"param": "s",
"type": "void"
},
{
"param": "order",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "a",
"type": "Array",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "s",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "order",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7b389d3e2bcff27d5d5c639a28f8d35daae75f73 | junaruga/pstools | array.c | [
"MIT"
] | C | arrayInsert | BOOL | BOOL arrayInsert(Array a, void * s, int (*order)(const void*, const void*))
{
int i, j, arraySize;
if (!arrayExists (a))
die ("arrayInsert called on bad array %x", (long unsigned int)a) ;
if (arrayFind(a, s, &i,order))
return FALSE ; /* no doubles */
arraySize = arrayMax(a) ;
j = arraySize + 1 ;
uArray(a,j-1) ; /* to create space */
/* avoid memcpy for same reasons as above */
{
char *cp, *cq ;
int k ;
if (arraySize > 0)
{ cp = uArray(a,j - 1) + a->size - 1 ;
cq = cp - a->size ;
k = (j - i - 1)*(a->size) ;
while (k--)
*cp-- = *cq-- ;
}
cp = uArray(a,i+1) ;
cq = (char *) s ;
k = a->size ;
while (k--)
*cp++ = *cq++ ;
}
return TRUE ;
} | /**************************************************************/
/* Insert Segment s in Array a
* in ascending order of s.begin
*/ | Insert Segment s in Array a
in ascending order of s.begin | [
"Insert",
"Segment",
"s",
"in",
"Array",
"a",
"in",
"ascending",
"order",
"of",
"s",
".",
"begin"
] | BOOL arrayInsert(Array a, void * s, int (*order)(const void*, const void*))
{
int i, j, arraySize;
if (!arrayExists (a))
die ("arrayInsert called on bad array %x", (long unsigned int)a) ;
if (arrayFind(a, s, &i,order))
return FALSE ;
arraySize = arrayMax(a) ;
j = arraySize + 1 ;
uArray(a,j-1) ;
{
char *cp, *cq ;
int k ;
if (arraySize > 0)
{ cp = uArray(a,j - 1) + a->size - 1 ;
cq = cp - a->size ;
k = (j - i - 1)*(a->size) ;
while (k--)
*cp-- = *cq-- ;
}
cp = uArray(a,i+1) ;
cq = (char *) s ;
k = a->size ;
while (k--)
*cp++ = *cq++ ;
}
return TRUE ;
} | [
"BOOL",
"arrayInsert",
"(",
"Array",
"a",
",",
"void",
"*",
"s",
",",
"int",
"(",
"*",
"order",
")",
"(",
"const",
"void",
"*",
",",
"const",
"void",
"*",
")",
")",
"{",
"int",
"i",
",",
"j",
",",
"arraySize",
";",
"if",
"(",
"!",
"arrayExists",
"(",
"a",
")",
")",
"die",
"(",
"\"",
"\"",
",",
"(",
"long",
"unsigned",
"int",
")",
"a",
")",
";",
"if",
"(",
"arrayFind",
"(",
"a",
",",
"s",
",",
"&",
"i",
",",
"order",
")",
")",
"return",
"FALSE",
";",
"arraySize",
"=",
"arrayMax",
"(",
"a",
")",
";",
"j",
"=",
"arraySize",
"+",
"1",
";",
"uArray",
"(",
"a",
",",
"j",
"-",
"1",
")",
";",
"{",
"char",
"*",
"cp",
",",
"*",
"cq",
";",
"int",
"k",
";",
"if",
"(",
"arraySize",
">",
"0",
")",
"{",
"cp",
"=",
"uArray",
"(",
"a",
",",
"j",
"-",
"1",
")",
"+",
"a",
"->",
"size",
"-",
"1",
";",
"cq",
"=",
"cp",
"-",
"a",
"->",
"size",
";",
"k",
"=",
"(",
"j",
"-",
"i",
"-",
"1",
")",
"*",
"(",
"a",
"->",
"size",
")",
";",
"while",
"(",
"k",
"--",
")",
"*",
"cp",
"--",
"=",
"*",
"cq",
"--",
";",
"}",
"cp",
"=",
"uArray",
"(",
"a",
",",
"i",
"+",
"1",
")",
";",
"cq",
"=",
"(",
"char",
"*",
")",
"s",
";",
"k",
"=",
"a",
"->",
"size",
";",
"while",
"(",
"k",
"--",
")",
"*",
"cp",
"++",
"=",
"*",
"cq",
"++",
";",
"}",
"return",
"TRUE",
";",
"}"
] | Insert Segment s in Array a
in ascending order of s.begin | [
"Insert",
"Segment",
"s",
"in",
"Array",
"a",
"in",
"ascending",
"order",
"of",
"s",
".",
"begin"
] | [
"/* no doubles */",
"/* to create space */",
"/* avoid memcpy for same reasons as above */"
] | [
{
"param": "a",
"type": "Array"
},
{
"param": "s",
"type": "void"
},
{
"param": "order",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "a",
"type": "Array",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "s",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "order",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6813524e8c3290df447ada4553875bdba3d1814f | junaruga/pstools | dict.c | [
"MIT"
] | C | dictFind | BOOL | BOOL dictFind (DICT *dict, char *s, int *ip)
{
int i, x, d ;
if (!dict) die ("dictAdd received null dict\n") ;
if (!s) die ("dictAdd received null string\n") ;
x = hashString (s, dict->dim, 0) ;
if (!(i = dict->table[x]))
{ newPos = x ;
return FALSE ;
}
else if (!strcmp (s, dict->names[i]))
{ if (ip) *ip = i-1 ;
return TRUE ;
}
else
{ d = hashString (s, dict->dim, 1) ;
while (1)
{ x = (x + d) & ((1 << dict->dim) - 1) ;
if (!(i = dict->table[x]))
{ newPos = x ;
return FALSE ;
}
else if (!strcmp (s, dict->names[i]))
{ if (ip) *ip = i-1 ;
return TRUE ;
}
}
}
} | /* communication between dictFind() and dictAdd() */ | communication between dictFind() and dictAdd() | [
"communication",
"between",
"dictFind",
"()",
"and",
"dictAdd",
"()"
] | BOOL dictFind (DICT *dict, char *s, int *ip)
{
int i, x, d ;
if (!dict) die ("dictAdd received null dict\n") ;
if (!s) die ("dictAdd received null string\n") ;
x = hashString (s, dict->dim, 0) ;
if (!(i = dict->table[x]))
{ newPos = x ;
return FALSE ;
}
else if (!strcmp (s, dict->names[i]))
{ if (ip) *ip = i-1 ;
return TRUE ;
}
else
{ d = hashString (s, dict->dim, 1) ;
while (1)
{ x = (x + d) & ((1 << dict->dim) - 1) ;
if (!(i = dict->table[x]))
{ newPos = x ;
return FALSE ;
}
else if (!strcmp (s, dict->names[i]))
{ if (ip) *ip = i-1 ;
return TRUE ;
}
}
}
} | [
"BOOL",
"dictFind",
"(",
"DICT",
"*",
"dict",
",",
"char",
"*",
"s",
",",
"int",
"*",
"ip",
")",
"{",
"int",
"i",
",",
"x",
",",
"d",
";",
"if",
"(",
"!",
"dict",
")",
"die",
"(",
"\"",
"\\n",
"\"",
")",
";",
"if",
"(",
"!",
"s",
")",
"die",
"(",
"\"",
"\\n",
"\"",
")",
";",
"x",
"=",
"hashString",
"(",
"s",
",",
"dict",
"->",
"dim",
",",
"0",
")",
";",
"if",
"(",
"!",
"(",
"i",
"=",
"dict",
"->",
"table",
"[",
"x",
"]",
")",
")",
"{",
"newPos",
"=",
"x",
";",
"return",
"FALSE",
";",
"}",
"else",
"if",
"(",
"!",
"strcmp",
"(",
"s",
",",
"dict",
"->",
"names",
"[",
"i",
"]",
")",
")",
"{",
"if",
"(",
"ip",
")",
"*",
"ip",
"=",
"i",
"-",
"1",
";",
"return",
"TRUE",
";",
"}",
"else",
"{",
"d",
"=",
"hashString",
"(",
"s",
",",
"dict",
"->",
"dim",
",",
"1",
")",
";",
"while",
"(",
"1",
")",
"{",
"x",
"=",
"(",
"x",
"+",
"d",
")",
"&",
"(",
"(",
"1",
"<<",
"dict",
"->",
"dim",
")",
"-",
"1",
")",
";",
"if",
"(",
"!",
"(",
"i",
"=",
"dict",
"->",
"table",
"[",
"x",
"]",
")",
")",
"{",
"newPos",
"=",
"x",
";",
"return",
"FALSE",
";",
"}",
"else",
"if",
"(",
"!",
"strcmp",
"(",
"s",
",",
"dict",
"->",
"names",
"[",
"i",
"]",
")",
")",
"{",
"if",
"(",
"ip",
")",
"*",
"ip",
"=",
"i",
"-",
"1",
";",
"return",
"TRUE",
";",
"}",
"}",
"}",
"}"
] | communication between dictFind() and dictAdd() | [
"communication",
"between",
"dictFind",
"()",
"and",
"dictAdd",
"()"
] | [] | [
{
"param": "dict",
"type": "DICT"
},
{
"param": "s",
"type": "char"
},
{
"param": "ip",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dict",
"type": "DICT",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "s",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ip",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
572585f29d637b9ccf5ecb0bda441f30408f1d36 | junaruga/pstools | hash.c | [
"MIT"
] | C | hashAdd | BOOL | BOOL hashAdd (HASH hx, HASHKEY k, int *index)
{
TRUE_HASH *h = (TRUE_HASH*) hx ;
long int hash, delta = 0 ;
int test ;
if (!h->guard)
hashDouble (h) ;
HASH_FUNC(k) ;
while (TRUE)
if (!h->keys[hash] || h->keys[hash] == REMOVED) /* free slot to fill */
{ if (!h->keys[hash]) --h->guard ;
h->keys[hash] = k.i ;
if (h->nFree)
h->values[hash] = arr(h->freeList, h->nFree--, int) ;
else
h->values[hash] = ++h->n ;
nAdded++ ;
if (index) *index = h->values[hash] - 1 ;
return TRUE ;
}
else if (h->keys[hash] == k.i) /* already there */
{ ++nFound ;
if (index) *index = h->values[hash] - 1 ;
return FALSE ;
}
else
{ nBounced++ ;
if (!delta) DELTA (k) ;
hash = (hash + delta) & h->mask ;
}
} | /* if already there returns FALSE, else inserts and returns TRUE */ | if already there returns FALSE, else inserts and returns TRUE | [
"if",
"already",
"there",
"returns",
"FALSE",
"else",
"inserts",
"and",
"returns",
"TRUE"
] | BOOL hashAdd (HASH hx, HASHKEY k, int *index)
{
TRUE_HASH *h = (TRUE_HASH*) hx ;
long int hash, delta = 0 ;
int test ;
if (!h->guard)
hashDouble (h) ;
HASH_FUNC(k) ;
while (TRUE)
if (!h->keys[hash] || h->keys[hash] == REMOVED)
{ if (!h->keys[hash]) --h->guard ;
h->keys[hash] = k.i ;
if (h->nFree)
h->values[hash] = arr(h->freeList, h->nFree--, int) ;
else
h->values[hash] = ++h->n ;
nAdded++ ;
if (index) *index = h->values[hash] - 1 ;
return TRUE ;
}
else if (h->keys[hash] == k.i)
{ ++nFound ;
if (index) *index = h->values[hash] - 1 ;
return FALSE ;
}
else
{ nBounced++ ;
if (!delta) DELTA (k) ;
hash = (hash + delta) & h->mask ;
}
} | [
"BOOL",
"hashAdd",
"(",
"HASH",
"hx",
",",
"HASHKEY",
"k",
",",
"int",
"*",
"index",
")",
"{",
"TRUE_HASH",
"*",
"h",
"=",
"(",
"TRUE_HASH",
"*",
")",
"hx",
";",
"long",
"int",
"hash",
",",
"delta",
"=",
"0",
";",
"int",
"test",
";",
"if",
"(",
"!",
"h",
"->",
"guard",
")",
"hashDouble",
"(",
"h",
")",
";",
"HASH_FUNC",
"(",
"k",
")",
";",
"while",
"(",
"TRUE",
")",
"if",
"(",
"!",
"h",
"->",
"keys",
"[",
"hash",
"]",
"||",
"h",
"->",
"keys",
"[",
"hash",
"]",
"==",
"REMOVED",
")",
"{",
"if",
"(",
"!",
"h",
"->",
"keys",
"[",
"hash",
"]",
")",
"--",
"h",
"->",
"guard",
";",
"h",
"->",
"keys",
"[",
"hash",
"]",
"=",
"k",
".",
"i",
";",
"if",
"(",
"h",
"->",
"nFree",
")",
"h",
"->",
"values",
"[",
"hash",
"]",
"=",
"arr",
"(",
"h",
"->",
"freeList",
",",
"h",
"->",
"nFree",
"--",
",",
"int",
")",
";",
"else",
"h",
"->",
"values",
"[",
"hash",
"]",
"=",
"++",
"h",
"->",
"n",
";",
"nAdded",
"++",
";",
"if",
"(",
"index",
")",
"*",
"index",
"=",
"h",
"->",
"values",
"[",
"hash",
"]",
"-",
"1",
";",
"return",
"TRUE",
";",
"}",
"else",
"if",
"(",
"h",
"->",
"keys",
"[",
"hash",
"]",
"==",
"k",
".",
"i",
")",
"{",
"++",
"nFound",
";",
"if",
"(",
"index",
")",
"*",
"index",
"=",
"h",
"->",
"values",
"[",
"hash",
"]",
"-",
"1",
";",
"return",
"FALSE",
";",
"}",
"else",
"{",
"nBounced",
"++",
";",
"if",
"(",
"!",
"delta",
")",
"DELTA",
"(",
"k",
")",
";",
"hash",
"=",
"(",
"hash",
"+",
"delta",
")",
"&",
"h",
"->",
"mask",
";",
"}",
"}"
] | if already there returns FALSE, else inserts and returns TRUE | [
"if",
"already",
"there",
"returns",
"FALSE",
"else",
"inserts",
"and",
"returns",
"TRUE"
] | [
"/* free slot to fill */",
"/* already there */"
] | [
{
"param": "hx",
"type": "HASH"
},
{
"param": "k",
"type": "HASHKEY"
},
{
"param": "index",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hx",
"type": "HASH",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "k",
"type": "HASHKEY",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "index",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
572585f29d637b9ccf5ecb0bda441f30408f1d36 | junaruga/pstools | hash.c | [
"MIT"
] | C | hashInitIterator | void | void hashInitIterator (HASH hx)
{
TRUE_HASH *h = (TRUE_HASH*) hx ;
h->iter = -1 ;
} | /********************* iterator through members of a HASH **********************/ | iterator through members of a HASH | [
"iterator",
"through",
"members",
"of",
"a",
"HASH"
] | void hashInitIterator (HASH hx)
{
TRUE_HASH *h = (TRUE_HASH*) hx ;
h->iter = -1 ;
} | [
"void",
"hashInitIterator",
"(",
"HASH",
"hx",
")",
"{",
"TRUE_HASH",
"*",
"h",
"=",
"(",
"TRUE_HASH",
"*",
")",
"hx",
";",
"h",
"->",
"iter",
"=",
"-1",
";",
"}"
] | iterator through members of a HASH | [
"iterator",
"through",
"members",
"of",
"a",
"HASH"
] | [] | [
{
"param": "hx",
"type": "HASH"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hx",
"type": "HASH",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
10e56bab9c68c3a1ecd8784c78eea145dc54f7a5 | geekman/badger | crypto.h | [
"BSD-3-Clause"
] | C | do_aes128_decrypt | int | inline int do_aes128_decrypt(const u8 *key, const u8 *crypt, u8 *plain) {
void *ctx = aes_decrypt_init(key, AES_BLOCK_SIZE);
if (ctx == NULL)
return -1;
aes_decrypt(ctx, crypt, plain);
aes_decrypt_deinit(ctx);
return 0;
} | // helper to do decryption of AES 128 | helper to do decryption of AES 128 | [
"helper",
"to",
"do",
"decryption",
"of",
"AES",
"128"
] | inline int do_aes128_decrypt(const u8 *key, const u8 *crypt, u8 *plain) {
void *ctx = aes_decrypt_init(key, AES_BLOCK_SIZE);
if (ctx == NULL)
return -1;
aes_decrypt(ctx, crypt, plain);
aes_decrypt_deinit(ctx);
return 0;
} | [
"inline",
"int",
"do_aes128_decrypt",
"(",
"const",
"u8",
"*",
"key",
",",
"const",
"u8",
"*",
"crypt",
",",
"u8",
"*",
"plain",
")",
"{",
"void",
"*",
"ctx",
"=",
"aes_decrypt_init",
"(",
"key",
",",
"AES_BLOCK_SIZE",
")",
";",
"if",
"(",
"ctx",
"==",
"NULL",
")",
"return",
"-1",
";",
"aes_decrypt",
"(",
"ctx",
",",
"crypt",
",",
"plain",
")",
";",
"aes_decrypt_deinit",
"(",
"ctx",
")",
";",
"return",
"0",
";",
"}"
] | helper to do decryption of AES 128 | [
"helper",
"to",
"do",
"decryption",
"of",
"AES",
"128"
] | [] | [
{
"param": "key",
"type": "u8"
},
{
"param": "crypt",
"type": "u8"
},
{
"param": "plain",
"type": "u8"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "key",
"type": "u8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "crypt",
"type": "u8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "plain",
"type": "u8",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | start_cpu_timer | void | static void start_cpu_timer(int cpu)
{
struct delayed_work *reap_work = &per_cpu(slab_reap_work, cpu);
/*
* When this gets called from do_initcalls via cpucache_init(),
* init_workqueues() has already run, so keventd will be setup
* at that time.
*/
if (keventd_up() && reap_work->work.func == NULL) {
init_reap_node(cpu);
INIT_DEFERRABLE_WORK(reap_work, cache_reap);
schedule_delayed_work_on(cpu, reap_work,
__round_jiffies_relative(HZ, cpu));
}
} | /*
* Initiate the reap timer running on the target CPU. We run at around 1 to 2Hz
* via the workqueue/eventd.
* Add the CPU number into the expiration time to minimize the possibility of
* the CPUs getting into lockstep and contending for the global cache chain
* lock.
*/ | Initiate the reap timer running on the target CPU. We run at around 1 to 2Hz
via the workqueue/eventd.
Add the CPU number into the expiration time to minimize the possibility of
the CPUs getting into lockstep and contending for the global cache chain
lock. | [
"Initiate",
"the",
"reap",
"timer",
"running",
"on",
"the",
"target",
"CPU",
".",
"We",
"run",
"at",
"around",
"1",
"to",
"2Hz",
"via",
"the",
"workqueue",
"/",
"eventd",
".",
"Add",
"the",
"CPU",
"number",
"into",
"the",
"expiration",
"time",
"to",
"minimize",
"the",
"possibility",
"of",
"the",
"CPUs",
"getting",
"into",
"lockstep",
"and",
"contending",
"for",
"the",
"global",
"cache",
"chain",
"lock",
"."
] | static void start_cpu_timer(int cpu)
{
struct delayed_work *reap_work = &per_cpu(slab_reap_work, cpu);
if (keventd_up() && reap_work->work.func == NULL) {
init_reap_node(cpu);
INIT_DEFERRABLE_WORK(reap_work, cache_reap);
schedule_delayed_work_on(cpu, reap_work,
__round_jiffies_relative(HZ, cpu));
}
} | [
"static",
"void",
"start_cpu_timer",
"(",
"int",
"cpu",
")",
"{",
"struct",
"delayed_work",
"*",
"reap_work",
"=",
"&",
"per_cpu",
"(",
"slab_reap_work",
",",
"cpu",
")",
";",
"if",
"(",
"keventd_up",
"(",
")",
"&&",
"reap_work",
"->",
"work",
".",
"func",
"==",
"NULL",
")",
"{",
"init_reap_node",
"(",
"cpu",
")",
";",
"INIT_DEFERRABLE_WORK",
"(",
"reap_work",
",",
"cache_reap",
")",
";",
"schedule_delayed_work_on",
"(",
"cpu",
",",
"reap_work",
",",
"__round_jiffies_relative",
"(",
"HZ",
",",
"cpu",
")",
")",
";",
"}",
"}"
] | Initiate the reap timer running on the target CPU. | [
"Initiate",
"the",
"reap",
"timer",
"running",
"on",
"the",
"target",
"CPU",
"."
] | [
"/*\n\t * When this gets called from do_initcalls via cpucache_init(),\n\t * init_workqueues() has already run, so keventd will be setup\n\t * at that time.\n\t */"
] | [
{
"param": "cpu",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpu",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | recheck_pfmemalloc_active | void | static void recheck_pfmemalloc_active(struct kmem_cache *cachep,
struct array_cache *ac)
{
struct kmem_cache_node *n = cachep->node[numa_mem_id()];
struct slab *slabp;
unsigned long flags;
if (!pfmemalloc_active)
return;
spin_lock_irqsave(&n->list_lock, flags);
//list_for_each_entry(slabp, &n->slabs_full, list)
// if (is_slab_pfmemalloc(slabp))
// goto out;
//list_for_each_entry(slabp, &n->slabs_partial, list)
// if (is_slab_pfmemalloc(slabp))
// goto out;
//list_for_each_entry(slabp, &n->slabs_free, list)
// if (is_slab_pfmemalloc(slabp))
// goto out;
pfmemalloc_active = false;
out:
spin_unlock_irqrestore(&n->list_lock, flags);
} | /* Clears pfmemalloc_active if no slabs have pfmalloc set */ | Clears pfmemalloc_active if no slabs have pfmalloc set | [
"Clears",
"pfmemalloc_active",
"if",
"no",
"slabs",
"have",
"pfmalloc",
"set"
] | static void recheck_pfmemalloc_active(struct kmem_cache *cachep,
struct array_cache *ac)
{
struct kmem_cache_node *n = cachep->node[numa_mem_id()];
struct slab *slabp;
unsigned long flags;
if (!pfmemalloc_active)
return;
spin_lock_irqsave(&n->list_lock, flags);
pfmemalloc_active = false;
out:
spin_unlock_irqrestore(&n->list_lock, flags);
} | [
"static",
"void",
"recheck_pfmemalloc_active",
"(",
"struct",
"kmem_cache",
"*",
"cachep",
",",
"struct",
"array_cache",
"*",
"ac",
")",
"{",
"struct",
"kmem_cache_node",
"*",
"n",
"=",
"cachep",
"->",
"node",
"[",
"numa_mem_id",
"(",
")",
"]",
";",
"struct",
"slab",
"*",
"slabp",
";",
"unsigned",
"long",
"flags",
";",
"if",
"(",
"!",
"pfmemalloc_active",
")",
"return",
";",
"spin_lock_irqsave",
"(",
"&",
"n",
"->",
"list_lock",
",",
"flags",
")",
";",
"pfmemalloc_active",
"=",
"false",
";",
"out",
":",
"spin_unlock_irqrestore",
"(",
"&",
"n",
"->",
"list_lock",
",",
"flags",
")",
";",
"}"
] | Clears pfmemalloc_active if no slabs have pfmalloc set | [
"Clears",
"pfmemalloc_active",
"if",
"no",
"slabs",
"have",
"pfmalloc",
"set"
] | [
"//list_for_each_entry(slabp, &n->slabs_full, list)",
"//\tif (is_slab_pfmemalloc(slabp))",
"//\t\tgoto out;",
"//list_for_each_entry(slabp, &n->slabs_partial, list)",
"//\tif (is_slab_pfmemalloc(slabp))",
"//\t\tgoto out;",
"//list_for_each_entry(slabp, &n->slabs_free, list)",
"//\tif (is_slab_pfmemalloc(slabp))",
"//\t\tgoto out;"
] | [
{
"param": "cachep",
"type": "struct kmem_cache"
},
{
"param": "ac",
"type": "struct array_cache"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cachep",
"type": "struct kmem_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ac",
"type": "struct array_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | transfer_objects | int | static int transfer_objects(struct array_cache *to,
struct array_cache *from, unsigned int max)
{
/* Figure out how many entries to transfer */
int nr = min3(from->avail, max, to->limit - to->avail);
if (!nr)
return 0;
memcpy(to->entry + to->avail, from->entry + from->avail -nr,
sizeof(void *) *nr);
from->avail -= nr;
to->avail += nr;
return nr;
} | /*
* Transfer objects in one arraycache to another.
* Locking must be handled by the caller.
*
* Return the number of entries transferred.
*/ | Transfer objects in one arraycache to another.
Locking must be handled by the caller.
Return the number of entries transferred. | [
"Transfer",
"objects",
"in",
"one",
"arraycache",
"to",
"another",
".",
"Locking",
"must",
"be",
"handled",
"by",
"the",
"caller",
".",
"Return",
"the",
"number",
"of",
"entries",
"transferred",
"."
] | static int transfer_objects(struct array_cache *to,
struct array_cache *from, unsigned int max)
{
int nr = min3(from->avail, max, to->limit - to->avail);
if (!nr)
return 0;
memcpy(to->entry + to->avail, from->entry + from->avail -nr,
sizeof(void *) *nr);
from->avail -= nr;
to->avail += nr;
return nr;
} | [
"static",
"int",
"transfer_objects",
"(",
"struct",
"array_cache",
"*",
"to",
",",
"struct",
"array_cache",
"*",
"from",
",",
"unsigned",
"int",
"max",
")",
"{",
"int",
"nr",
"=",
"min3",
"(",
"from",
"->",
"avail",
",",
"max",
",",
"to",
"->",
"limit",
"-",
"to",
"->",
"avail",
")",
";",
"if",
"(",
"!",
"nr",
")",
"return",
"0",
";",
"memcpy",
"(",
"to",
"->",
"entry",
"+",
"to",
"->",
"avail",
",",
"from",
"->",
"entry",
"+",
"from",
"->",
"avail",
"-",
"nr",
",",
"sizeof",
"(",
"void",
"*",
")",
"*",
"nr",
")",
";",
"from",
"->",
"avail",
"-=",
"nr",
";",
"to",
"->",
"avail",
"+=",
"nr",
";",
"return",
"nr",
";",
"}"
] | Transfer objects in one arraycache to another. | [
"Transfer",
"objects",
"in",
"one",
"arraycache",
"to",
"another",
"."
] | [
"/* Figure out how many entries to transfer */"
] | [
{
"param": "to",
"type": "struct array_cache"
},
{
"param": "from",
"type": "struct array_cache"
},
{
"param": "max",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "to",
"type": "struct array_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "from",
"type": "struct array_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "max",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | reap_alien | void | static void reap_alien(struct kmem_cache *cachep, struct kmem_cache_node *n)
{
int node = __this_cpu_read(slab_reap_node);
if (n->alien) {
struct array_cache *ac = n->alien[node];
if (ac && ac->avail && spin_trylock_irq(&ac->lock)) {
__drain_alien_cache(cachep, ac, node);
spin_unlock_irq(&ac->lock);
}
}
} | /*
* Called from cache_reap() to regularly drain alien caches round robin.
*/ | Called from cache_reap() to regularly drain alien caches round robin. | [
"Called",
"from",
"cache_reap",
"()",
"to",
"regularly",
"drain",
"alien",
"caches",
"round",
"robin",
"."
] | static void reap_alien(struct kmem_cache *cachep, struct kmem_cache_node *n)
{
int node = __this_cpu_read(slab_reap_node);
if (n->alien) {
struct array_cache *ac = n->alien[node];
if (ac && ac->avail && spin_trylock_irq(&ac->lock)) {
__drain_alien_cache(cachep, ac, node);
spin_unlock_irq(&ac->lock);
}
}
} | [
"static",
"void",
"reap_alien",
"(",
"struct",
"kmem_cache",
"*",
"cachep",
",",
"struct",
"kmem_cache_node",
"*",
"n",
")",
"{",
"int",
"node",
"=",
"__this_cpu_read",
"(",
"slab_reap_node",
")",
";",
"if",
"(",
"n",
"->",
"alien",
")",
"{",
"struct",
"array_cache",
"*",
"ac",
"=",
"n",
"->",
"alien",
"[",
"node",
"]",
";",
"if",
"(",
"ac",
"&&",
"ac",
"->",
"avail",
"&&",
"spin_trylock_irq",
"(",
"&",
"ac",
"->",
"lock",
")",
")",
"{",
"__drain_alien_cache",
"(",
"cachep",
",",
"ac",
",",
"node",
")",
";",
"spin_unlock_irq",
"(",
"&",
"ac",
"->",
"lock",
")",
";",
"}",
"}",
"}"
] | Called from cache_reap() to regularly drain alien caches round robin. | [
"Called",
"from",
"cache_reap",
"()",
"to",
"regularly",
"drain",
"alien",
"caches",
"round",
"robin",
"."
] | [] | [
{
"param": "cachep",
"type": "struct kmem_cache"
},
{
"param": "n",
"type": "struct kmem_cache_node"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cachep",
"type": "struct kmem_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "struct kmem_cache_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | init_cache_node_node | int | static int init_cache_node_node(int node)
{
struct kmem_cache *cachep;
struct kmem_cache_node *n;
const int memsize = sizeof(struct kmem_cache_node);
//list_for_each_entry(cachep, &slab_caches, list) {
/*
* Set up the size64 kmemlist for cpu before we can
* begin anything. Make sure some other cpu on this
* node has not already allocated this
*/
if (!cachep->node[node]) {
n = kmalloc_node(memsize, GFP_KERNEL, node);
if (!n)
return -ENOMEM;
kmem_cache_node_init(n);
n->next_reap = jiffies + REAPTIMEOUT_LIST3 +
((unsigned long)cachep) % REAPTIMEOUT_LIST3;
/*
* The l3s don't come and go as CPUs come and
* go. slab_mutex is sufficient
* protection here.
*/
cachep->node[node] = n;
}
spin_lock_irq(&cachep->node[node]->list_lock);
cachep->node[node]->free_limit =
(1 + nr_cpus_node(node)) *
cachep->batchcount + cachep->num;
spin_unlock_irq(&cachep->node[node]->list_lock);
//}
return 0;
} | /*
* Allocates and initializes node for a node on each slab cache, used for
* either memory or cpu hotplug. If memory is being hot-added, the kmem_cache_node
* will be allocated off-node since memory is not yet online for the new node.
* When hotplugging memory or a cpu, existing node are not replaced if
* already in use.
*
* Must hold slab_mutex.
*/ | Allocates and initializes node for a node on each slab cache, used for
either memory or cpu hotplug. If memory is being hot-added, the kmem_cache_node
will be allocated off-node since memory is not yet online for the new node.
When hotplugging memory or a cpu, existing node are not replaced if
already in use.
| [
"Allocates",
"and",
"initializes",
"node",
"for",
"a",
"node",
"on",
"each",
"slab",
"cache",
"used",
"for",
"either",
"memory",
"or",
"cpu",
"hotplug",
".",
"If",
"memory",
"is",
"being",
"hot",
"-",
"added",
"the",
"kmem_cache_node",
"will",
"be",
"allocated",
"off",
"-",
"node",
"since",
"memory",
"is",
"not",
"yet",
"online",
"for",
"the",
"new",
"node",
".",
"When",
"hotplugging",
"memory",
"or",
"a",
"cpu",
"existing",
"node",
"are",
"not",
"replaced",
"if",
"already",
"in",
"use",
"."
] | static int init_cache_node_node(int node)
{
struct kmem_cache *cachep;
struct kmem_cache_node *n;
const int memsize = sizeof(struct kmem_cache_node);
if (!cachep->node[node]) {
n = kmalloc_node(memsize, GFP_KERNEL, node);
if (!n)
return -ENOMEM;
kmem_cache_node_init(n);
n->next_reap = jiffies + REAPTIMEOUT_LIST3 +
((unsigned long)cachep) % REAPTIMEOUT_LIST3;
cachep->node[node] = n;
}
spin_lock_irq(&cachep->node[node]->list_lock);
cachep->node[node]->free_limit =
(1 + nr_cpus_node(node)) *
cachep->batchcount + cachep->num;
spin_unlock_irq(&cachep->node[node]->list_lock);
return 0;
} | [
"static",
"int",
"init_cache_node_node",
"(",
"int",
"node",
")",
"{",
"struct",
"kmem_cache",
"*",
"cachep",
";",
"struct",
"kmem_cache_node",
"*",
"n",
";",
"const",
"int",
"memsize",
"=",
"sizeof",
"(",
"struct",
"kmem_cache_node",
")",
";",
"if",
"(",
"!",
"cachep",
"->",
"node",
"[",
"node",
"]",
")",
"{",
"n",
"=",
"kmalloc_node",
"(",
"memsize",
",",
"GFP_KERNEL",
",",
"node",
")",
";",
"if",
"(",
"!",
"n",
")",
"return",
"-",
"ENOMEM",
";",
"kmem_cache_node_init",
"(",
"n",
")",
";",
"n",
"->",
"next_reap",
"=",
"jiffies",
"+",
"REAPTIMEOUT_LIST3",
"+",
"(",
"(",
"unsigned",
"long",
")",
"cachep",
")",
"%",
"REAPTIMEOUT_LIST3",
";",
"cachep",
"->",
"node",
"[",
"node",
"]",
"=",
"n",
";",
"}",
"spin_lock_irq",
"(",
"&",
"cachep",
"->",
"node",
"[",
"node",
"]",
"->",
"list_lock",
")",
";",
"cachep",
"->",
"node",
"[",
"node",
"]",
"->",
"free_limit",
"=",
"(",
"1",
"+",
"nr_cpus_node",
"(",
"node",
")",
")",
"*",
"cachep",
"->",
"batchcount",
"+",
"cachep",
"->",
"num",
";",
"spin_unlock_irq",
"(",
"&",
"cachep",
"->",
"node",
"[",
"node",
"]",
"->",
"list_lock",
")",
";",
"return",
"0",
";",
"}"
] | Allocates and initializes node for a node on each slab cache, used for
either memory or cpu hotplug. | [
"Allocates",
"and",
"initializes",
"node",
"for",
"a",
"node",
"on",
"each",
"slab",
"cache",
"used",
"for",
"either",
"memory",
"or",
"cpu",
"hotplug",
"."
] | [
"//list_for_each_entry(cachep, &slab_caches, list) {",
"/*\n\t\t * Set up the size64 kmemlist for cpu before we can\n\t\t * begin anything. Make sure some other cpu on this\n\t\t * node has not already allocated this\n\t\t */",
"/*\n\t\t\t * The l3s don't come and go as CPUs come and\n\t\t\t * go. slab_mutex is sufficient\n\t\t\t * protection here.\n\t\t\t */",
"//}"
] | [
{
"param": "node",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | kmem_cache_init | void | void kmem_cache_init(void)
{
int i;
kmem_cache = &kmem_cache_boot;
setup_node_pointer(kmem_cache);
if (num_possible_nodes() == 1)
use_alien_caches = 0;
for (i = 0; i < NUM_INIT_LISTS; i++)
kmem_cache_node_init(&init_kmem_cache_node[i]);
set_up_node(kmem_cache, CACHE_CACHE);
/*
* Fragmentation resistance on low memory - only use bigger
* page orders on machines with more than 32MB of memory if
* not overridden on the command line.
*/
if (!slab_max_order_set && totalram_pages > (32 << 20) >> PAGE_SHIFT)
slab_max_order = SLAB_MAX_ORDER_HI;
/* Bootstrap is tricky, because several objects are allocated
* from caches that do not exist yet:
* 1) initialize the kmem_cache cache: it contains the struct
* kmem_cache structures of all caches, except kmem_cache itself:
* kmem_cache is statically allocated.
* Initially an data area is used for the head array and the
* kmem_cache_node structures, it's replaced with a kmalloc allocated
* array at the end of the bootstrap.
* 2) Create the first kmalloc cache.
* The struct kmem_cache for the new cache is allocated normally.
* An data area is used for the head array.
* 3) Create the remaining kmalloc caches, with minimally sized
* head arrays.
* 4) Replace the data head arrays for kmem_cache and the first
* kmalloc cache with kmalloc allocated arrays.
* 5) Replace the data for kmem_cache_node for kmem_cache and
* the other cache's with kmalloc allocated memory.
* 6) Resize the head arrays of the kmalloc caches to their final sizes.
*/
/* 1) create the kmem_cache */
/*
* struct kmem_cache size depends on nr_node_ids & nr_cpu_ids
*/
//create_boot_cache(kmem_cache, "kmem_cache",
// offsetof(struct kmem_cache, array[nr_cpu_ids]) +
// nr_node_ids * sizeof(struct kmem_cache_node *),
// SLAB_HWCACHE_ALIGN);
//list_add(&kmem_cache->list, &slab_caches);
/* 2+3) create the kmalloc caches */
/*
* Initialize the caches that provide memory for the array cache and the
* kmem_cache_node structures first. Without this, further allocations will
* bug.
*/
//kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
// kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
//if (INDEX_AC != INDEX_NODE)
// kmalloc_caches[INDEX_NODE] =
// create_kmalloc_cache("kmalloc-node",
// kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
slab_early_init = 0;
/* 4) Replace the bootstrap head arrays */
{
struct array_cache *ptr;
ptr = kmalloc(sizeof(struct arraycache_init), GFP_NOWAIT);
memcpy(ptr, cpu_cache_get(kmem_cache),
sizeof(struct arraycache_init));
/*
* Do not assume that spinlocks can be initialized via memcpy:
*/
spin_lock_init(&ptr->lock);
kmem_cache->array[smp_processor_id()] = ptr;
ptr = kmalloc(sizeof(struct arraycache_init), GFP_NOWAIT);
BUG_ON(cpu_cache_get(kmalloc_caches[INDEX_AC])
!= &initarray_generic.cache);
memcpy(ptr, cpu_cache_get(kmalloc_caches[INDEX_AC]),
sizeof(struct arraycache_init));
/*
* Do not assume that spinlocks can be initialized via memcpy:
*/
spin_lock_init(&ptr->lock);
kmalloc_caches[INDEX_AC]->array[smp_processor_id()] = ptr;
}
/* 5) Replace the bootstrap kmem_cache_node */
{
int nid;
//for_each_online_node(nid) {
init_list(kmem_cache, &init_kmem_cache_node[CACHE_CACHE + nid], nid);
init_list(kmalloc_caches[INDEX_AC],
&init_kmem_cache_node[SIZE_AC + nid], nid);
if (INDEX_AC != INDEX_NODE) {
init_list(kmalloc_caches[INDEX_NODE],
&init_kmem_cache_node[SIZE_NODE + nid], nid);
}
//}
}
create_kmalloc_caches(ARCH_KMALLOC_FLAGS);
} | /*
* Initialisation. Called after the page allocator have been initialised and
* before smp_init().
*/ | Initialisation. Called after the page allocator have been initialised and
before smp_init(). | [
"Initialisation",
".",
"Called",
"after",
"the",
"page",
"allocator",
"have",
"been",
"initialised",
"and",
"before",
"smp_init",
"()",
"."
] | void kmem_cache_init(void)
{
int i;
kmem_cache = &kmem_cache_boot;
setup_node_pointer(kmem_cache);
if (num_possible_nodes() == 1)
use_alien_caches = 0;
for (i = 0; i < NUM_INIT_LISTS; i++)
kmem_cache_node_init(&init_kmem_cache_node[i]);
set_up_node(kmem_cache, CACHE_CACHE);
if (!slab_max_order_set && totalram_pages > (32 << 20) >> PAGE_SHIFT)
slab_max_order = SLAB_MAX_ORDER_HI;
slab_early_init = 0;
{
struct array_cache *ptr;
ptr = kmalloc(sizeof(struct arraycache_init), GFP_NOWAIT);
memcpy(ptr, cpu_cache_get(kmem_cache),
sizeof(struct arraycache_init));
spin_lock_init(&ptr->lock);
kmem_cache->array[smp_processor_id()] = ptr;
ptr = kmalloc(sizeof(struct arraycache_init), GFP_NOWAIT);
BUG_ON(cpu_cache_get(kmalloc_caches[INDEX_AC])
!= &initarray_generic.cache);
memcpy(ptr, cpu_cache_get(kmalloc_caches[INDEX_AC]),
sizeof(struct arraycache_init));
spin_lock_init(&ptr->lock);
kmalloc_caches[INDEX_AC]->array[smp_processor_id()] = ptr;
}
{
int nid;
init_list(kmem_cache, &init_kmem_cache_node[CACHE_CACHE + nid], nid);
init_list(kmalloc_caches[INDEX_AC],
&init_kmem_cache_node[SIZE_AC + nid], nid);
if (INDEX_AC != INDEX_NODE) {
init_list(kmalloc_caches[INDEX_NODE],
&init_kmem_cache_node[SIZE_NODE + nid], nid);
}
}
create_kmalloc_caches(ARCH_KMALLOC_FLAGS);
} | [
"void",
"kmem_cache_init",
"(",
"void",
")",
"{",
"int",
"i",
";",
"kmem_cache",
"=",
"&",
"kmem_cache_boot",
";",
"setup_node_pointer",
"(",
"kmem_cache",
")",
";",
"if",
"(",
"num_possible_nodes",
"(",
")",
"==",
"1",
")",
"use_alien_caches",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"NUM_INIT_LISTS",
";",
"i",
"++",
")",
"kmem_cache_node_init",
"(",
"&",
"init_kmem_cache_node",
"[",
"i",
"]",
")",
";",
"set_up_node",
"(",
"kmem_cache",
",",
"CACHE_CACHE",
")",
";",
"if",
"(",
"!",
"slab_max_order_set",
"&&",
"totalram_pages",
">",
"(",
"32",
"<<",
"20",
")",
">>",
"PAGE_SHIFT",
")",
"slab_max_order",
"=",
"SLAB_MAX_ORDER_HI",
";",
"slab_early_init",
"=",
"0",
";",
"{",
"struct",
"array_cache",
"*",
"ptr",
";",
"ptr",
"=",
"kmalloc",
"(",
"sizeof",
"(",
"struct",
"arraycache_init",
")",
",",
"GFP_NOWAIT",
")",
";",
"memcpy",
"(",
"ptr",
",",
"cpu_cache_get",
"(",
"kmem_cache",
")",
",",
"sizeof",
"(",
"struct",
"arraycache_init",
")",
")",
";",
"spin_lock_init",
"(",
"&",
"ptr",
"->",
"lock",
")",
";",
"kmem_cache",
"->",
"array",
"[",
"smp_processor_id",
"(",
")",
"]",
"=",
"ptr",
";",
"ptr",
"=",
"kmalloc",
"(",
"sizeof",
"(",
"struct",
"arraycache_init",
")",
",",
"GFP_NOWAIT",
")",
";",
"BUG_ON",
"(",
"cpu_cache_get",
"(",
"kmalloc_caches",
"[",
"INDEX_AC",
"]",
")",
"!=",
"&",
"initarray_generic",
".",
"cache",
")",
";",
"memcpy",
"(",
"ptr",
",",
"cpu_cache_get",
"(",
"kmalloc_caches",
"[",
"INDEX_AC",
"]",
")",
",",
"sizeof",
"(",
"struct",
"arraycache_init",
")",
")",
";",
"spin_lock_init",
"(",
"&",
"ptr",
"->",
"lock",
")",
";",
"kmalloc_caches",
"[",
"INDEX_AC",
"]",
"->",
"array",
"[",
"smp_processor_id",
"(",
")",
"]",
"=",
"ptr",
";",
"}",
"{",
"int",
"nid",
";",
"init_list",
"(",
"kmem_cache",
",",
"&",
"init_kmem_cache_node",
"[",
"CACHE_CACHE",
"+",
"nid",
"]",
",",
"nid",
")",
";",
"init_list",
"(",
"kmalloc_caches",
"[",
"INDEX_AC",
"]",
",",
"&",
"init_kmem_cache_node",
"[",
"SIZE_AC",
"+",
"nid",
"]",
",",
"nid",
")",
";",
"if",
"(",
"INDEX_AC",
"!=",
"INDEX_NODE",
")",
"{",
"init_list",
"(",
"kmalloc_caches",
"[",
"INDEX_NODE",
"]",
",",
"&",
"init_kmem_cache_node",
"[",
"SIZE_NODE",
"+",
"nid",
"]",
",",
"nid",
")",
";",
"}",
"}",
"create_kmalloc_caches",
"(",
"ARCH_KMALLOC_FLAGS",
")",
";",
"}"
] | Initialisation. | [
"Initialisation",
"."
] | [
"/*\n\t * Fragmentation resistance on low memory - only use bigger\n\t * page orders on machines with more than 32MB of memory if\n\t * not overridden on the command line.\n\t */",
"/* Bootstrap is tricky, because several objects are allocated\n\t * from caches that do not exist yet:\n\t * 1) initialize the kmem_cache cache: it contains the struct\n\t * kmem_cache structures of all caches, except kmem_cache itself:\n\t * kmem_cache is statically allocated.\n\t * Initially an data area is used for the head array and the\n\t * kmem_cache_node structures, it's replaced with a kmalloc allocated\n\t * array at the end of the bootstrap.\n\t * 2) Create the first kmalloc cache.\n\t * The struct kmem_cache for the new cache is allocated normally.\n\t * An data area is used for the head array.\n\t * 3) Create the remaining kmalloc caches, with minimally sized\n\t * head arrays.\n\t * 4) Replace the data head arrays for kmem_cache and the first\n\t * kmalloc cache with kmalloc allocated arrays.\n\t * 5) Replace the data for kmem_cache_node for kmem_cache and\n\t * the other cache's with kmalloc allocated memory.\n\t * 6) Resize the head arrays of the kmalloc caches to their final sizes.\n\t */",
"/* 1) create the kmem_cache */",
"/*\n\t * struct kmem_cache size depends on nr_node_ids & nr_cpu_ids\n\t */",
"//create_boot_cache(kmem_cache, \"kmem_cache\",",
"//\toffsetof(struct kmem_cache, array[nr_cpu_ids]) +",
"//\t\t\t nr_node_ids * sizeof(struct kmem_cache_node *),",
"//\t\t\t SLAB_HWCACHE_ALIGN);",
"//list_add(&kmem_cache->list, &slab_caches);",
"/* 2+3) create the kmalloc caches */",
"/*\n\t * Initialize the caches that provide memory for the array cache and the\n\t * kmem_cache_node structures first. Without this, further allocations will\n\t * bug.\n\t */",
"//kmalloc_caches[INDEX_AC] = create_kmalloc_cache(\"kmalloc-ac\",",
"//\t\t\t\tkmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);",
"//if (INDEX_AC != INDEX_NODE)",
"//\tkmalloc_caches[INDEX_NODE] =",
"//\t\tcreate_kmalloc_cache(\"kmalloc-node\",",
"//\t\t\tkmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);",
"/* 4) Replace the bootstrap head arrays */",
"/*\n\t\t * Do not assume that spinlocks can be initialized via memcpy:\n\t\t */",
"/*\n\t\t * Do not assume that spinlocks can be initialized via memcpy:\n\t\t */",
"/* 5) Replace the bootstrap kmem_cache_node */",
"//for_each_online_node(nid) {",
"//}"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | kmem_getpages | void | static void *kmem_getpages()
{
struct page *page;
int nr_pages;
int i;
#ifndef CONFIG_MMU
/*
* Nommu uses slab's for process anonymous memory allocations, and thus
* requires __GFP_COMP to properly refcount higher order allocations
*/
flags = GFP_COMP;
#endif
return page_address(page);
} | /*
* Interface to system's page allocator. No need to hold the cache-lock.
*
* If we requested dmaable memory, we will get it. Even if we
* did not request dmaable memory, we might get it, but that
* would be relatively rare and ignorable.
*/ | Interface to system's page allocator. No need to hold the cache-lock.
If we requested dmaable memory, we will get it. Even if we
did not request dmaable memory, we might get it, but that
would be relatively rare and ignorable. | [
"Interface",
"to",
"system",
"'",
"s",
"page",
"allocator",
".",
"No",
"need",
"to",
"hold",
"the",
"cache",
"-",
"lock",
".",
"If",
"we",
"requested",
"dmaable",
"memory",
"we",
"will",
"get",
"it",
".",
"Even",
"if",
"we",
"did",
"not",
"request",
"dmaable",
"memory",
"we",
"might",
"get",
"it",
"but",
"that",
"would",
"be",
"relatively",
"rare",
"and",
"ignorable",
"."
] | static void *kmem_getpages()
{
struct page *page;
int nr_pages;
int i;
#ifndef CONFIG_MMU
flags = GFP_COMP;
#endif
return page_address(page);
} | [
"static",
"void",
"*",
"kmem_getpages",
"(",
")",
"{",
"struct",
"page",
"*",
"page",
";",
"int",
"nr_pages",
";",
"int",
"i",
";",
"#ifndef",
"CONFIG_MMU",
"flags",
"=",
"GFP_COMP",
";",
"#endif",
"return",
"page_address",
"(",
"page",
")",
";",
"}"
] | Interface to system's page allocator. | [
"Interface",
"to",
"system",
"'",
"s",
"page",
"allocator",
"."
] | [
"/*\n\t * Nommu uses slab's for process anonymous memory allocations, and thus\n\t * requires __GFP_COMP to properly refcount higher order allocations\n\t */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | kmem_freepages | void | static void kmem_freepages(struct kmem_cache *cachep, void *addr)
{
unsigned long i = (1 << cachep->gfporder);
struct page *page = virt_to_page(addr);
const unsigned long nr_freed = i;
kmemcheck_free_shadow(page, cachep->gfporder);
if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
sub_zone_page_state(page_zone(page),
NR_SLAB_RECLAIMABLE, nr_freed);
else
sub_zone_page_state(page_zone(page),
NR_SLAB_UNRECLAIMABLE, nr_freed);
while (i--) {
BUG_ON(!PageSlab(page));
__ClearPageSlabPfmemalloc(page);
__ClearPageSlab(page);
page++;
}
memcg_release_pages(cachep, cachep->gfporder);
if (current->reclaim_state)
current->reclaim_state->reclaimed_slab += nr_freed;
free_memcg_kmem_pages((unsigned long)addr, cachep->gfporder);
} | /*
* Interface to system's page release.
*/ | Interface to system's page release. | [
"Interface",
"to",
"system",
"'",
"s",
"page",
"release",
"."
] | static void kmem_freepages(struct kmem_cache *cachep, void *addr)
{
unsigned long i = (1 << cachep->gfporder);
struct page *page = virt_to_page(addr);
const unsigned long nr_freed = i;
kmemcheck_free_shadow(page, cachep->gfporder);
if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
sub_zone_page_state(page_zone(page),
NR_SLAB_RECLAIMABLE, nr_freed);
else
sub_zone_page_state(page_zone(page),
NR_SLAB_UNRECLAIMABLE, nr_freed);
while (i--) {
BUG_ON(!PageSlab(page));
__ClearPageSlabPfmemalloc(page);
__ClearPageSlab(page);
page++;
}
memcg_release_pages(cachep, cachep->gfporder);
if (current->reclaim_state)
current->reclaim_state->reclaimed_slab += nr_freed;
free_memcg_kmem_pages((unsigned long)addr, cachep->gfporder);
} | [
"static",
"void",
"kmem_freepages",
"(",
"struct",
"kmem_cache",
"*",
"cachep",
",",
"void",
"*",
"addr",
")",
"{",
"unsigned",
"long",
"i",
"=",
"(",
"1",
"<<",
"cachep",
"->",
"gfporder",
")",
";",
"struct",
"page",
"*",
"page",
"=",
"virt_to_page",
"(",
"addr",
")",
";",
"const",
"unsigned",
"long",
"nr_freed",
"=",
"i",
";",
"kmemcheck_free_shadow",
"(",
"page",
",",
"cachep",
"->",
"gfporder",
")",
";",
"if",
"(",
"cachep",
"->",
"flags",
"&",
"SLAB_RECLAIM_ACCOUNT",
")",
"sub_zone_page_state",
"(",
"page_zone",
"(",
"page",
")",
",",
"NR_SLAB_RECLAIMABLE",
",",
"nr_freed",
")",
";",
"else",
"sub_zone_page_state",
"(",
"page_zone",
"(",
"page",
")",
",",
"NR_SLAB_UNRECLAIMABLE",
",",
"nr_freed",
")",
";",
"while",
"(",
"i",
"--",
")",
"{",
"BUG_ON",
"(",
"!",
"PageSlab",
"(",
"page",
")",
")",
";",
"__ClearPageSlabPfmemalloc",
"(",
"page",
")",
";",
"__ClearPageSlab",
"(",
"page",
")",
";",
"page",
"++",
";",
"}",
"memcg_release_pages",
"(",
"cachep",
",",
"cachep",
"->",
"gfporder",
")",
";",
"if",
"(",
"current",
"->",
"reclaim_state",
")",
"current",
"->",
"reclaim_state",
"->",
"reclaimed_slab",
"+=",
"nr_freed",
";",
"free_memcg_kmem_pages",
"(",
"(",
"unsigned",
"long",
")",
"addr",
",",
"cachep",
"->",
"gfporder",
")",
";",
"}"
] | Interface to system's page release. | [
"Interface",
"to",
"system",
"'",
"s",
"page",
"release",
"."
] | [] | [
{
"param": "cachep",
"type": "struct kmem_cache"
},
{
"param": "addr",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cachep",
"type": "struct kmem_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | slab_destroy | void | static void slab_destroy(struct kmem_cache *cachep, struct slab *slabp)
{
void *addr = slabp->s_mem - slabp->colouroff;
slab_destroy_debugcheck(cachep, slabp);
if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) {
struct slab_rcu *slab_rcu;
slab_rcu = (struct slab_rcu *)slabp;
slab_rcu->cachep = cachep;
slab_rcu->addr = addr;
call_rcu(&slab_rcu->head, kmem_rcu_free);
} else {
kmem_freepages(cachep, addr);
if (OFF_SLAB(cachep))
kmem_cache_free(cachep->slabp_cache, slabp);
}
} | /**
* slab_destroy - destroy and release all objects in a slab
* @cachep: cache pointer being destroyed
* @slabp: slab pointer being destroyed
*
* Destroy all the objs in a slab, and release the mem back to the system.
* Before calling the slab must have been unlinked from the cache. The
* cache-lock is not held/needed.
*/ | destroy and release all objects in a slab
@cachep: cache pointer being destroyed
@slabp: slab pointer being destroyed
Destroy all the objs in a slab, and release the mem back to the system.
Before calling the slab must have been unlinked from the cache. The
cache-lock is not held/needed. | [
"destroy",
"and",
"release",
"all",
"objects",
"in",
"a",
"slab",
"@cachep",
":",
"cache",
"pointer",
"being",
"destroyed",
"@slabp",
":",
"slab",
"pointer",
"being",
"destroyed",
"Destroy",
"all",
"the",
"objs",
"in",
"a",
"slab",
"and",
"release",
"the",
"mem",
"back",
"to",
"the",
"system",
".",
"Before",
"calling",
"the",
"slab",
"must",
"have",
"been",
"unlinked",
"from",
"the",
"cache",
".",
"The",
"cache",
"-",
"lock",
"is",
"not",
"held",
"/",
"needed",
"."
] | static void slab_destroy(struct kmem_cache *cachep, struct slab *slabp)
{
void *addr = slabp->s_mem - slabp->colouroff;
slab_destroy_debugcheck(cachep, slabp);
if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) {
struct slab_rcu *slab_rcu;
slab_rcu = (struct slab_rcu *)slabp;
slab_rcu->cachep = cachep;
slab_rcu->addr = addr;
call_rcu(&slab_rcu->head, kmem_rcu_free);
} else {
kmem_freepages(cachep, addr);
if (OFF_SLAB(cachep))
kmem_cache_free(cachep->slabp_cache, slabp);
}
} | [
"static",
"void",
"slab_destroy",
"(",
"struct",
"kmem_cache",
"*",
"cachep",
",",
"struct",
"slab",
"*",
"slabp",
")",
"{",
"void",
"*",
"addr",
"=",
"slabp",
"->",
"s_mem",
"-",
"slabp",
"->",
"colouroff",
";",
"slab_destroy_debugcheck",
"(",
"cachep",
",",
"slabp",
")",
";",
"if",
"(",
"unlikely",
"(",
"cachep",
"->",
"flags",
"&",
"SLAB_DESTROY_BY_RCU",
")",
")",
"{",
"struct",
"slab_rcu",
"*",
"slab_rcu",
";",
"slab_rcu",
"=",
"(",
"struct",
"slab_rcu",
"*",
")",
"slabp",
";",
"slab_rcu",
"->",
"cachep",
"=",
"cachep",
";",
"slab_rcu",
"->",
"addr",
"=",
"addr",
";",
"call_rcu",
"(",
"&",
"slab_rcu",
"->",
"head",
",",
"kmem_rcu_free",
")",
";",
"}",
"else",
"{",
"kmem_freepages",
"(",
"cachep",
",",
"addr",
")",
";",
"if",
"(",
"OFF_SLAB",
"(",
"cachep",
")",
")",
"kmem_cache_free",
"(",
"cachep",
"->",
"slabp_cache",
",",
"slabp",
")",
";",
"}",
"}"
] | slab_destroy - destroy and release all objects in a slab
@cachep: cache pointer being destroyed
@slabp: slab pointer being destroyed | [
"slab_destroy",
"-",
"destroy",
"and",
"release",
"all",
"objects",
"in",
"a",
"slab",
"@cachep",
":",
"cache",
"pointer",
"being",
"destroyed",
"@slabp",
":",
"slab",
"pointer",
"being",
"destroyed"
] | [] | [
{
"param": "cachep",
"type": "struct kmem_cache"
},
{
"param": "slabp",
"type": "struct slab"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cachep",
"type": "struct kmem_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "slabp",
"type": "struct slab",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | calculate_slab_order | size_t | static size_t calculate_slab_order(struct kmem_cache *cachep,
size_t size, size_t align, unsigned long flags)
{
unsigned long offslab_limit;
size_t left_over = 0;
int gfporder;
for (gfporder = 0; gfporder <= KMALLOC_MAX_ORDER; gfporder++) {
unsigned int num;
size_t remainder;
cache_estimate(gfporder, size, align, flags, &remainder, &num);
if (!num)
continue;
if (flags & CFLGS_OFF_SLAB) {
/*
* Max number of objs-per-slab for caches which
* use off-slab slabs. Needed to avoid a possible
* looping condition in cache_grow().
*/
offslab_limit = size - sizeof(struct slab);
offslab_limit /= sizeof(kmem_bufctl_t);
if (num > offslab_limit)
break;
}
/* Found something acceptable - save it away */
cachep->num = num;
cachep->gfporder = gfporder;
left_over = remainder;
/*
* A VFS-reclaimable slab tends to have most allocations
* as GFP_NOFS and we really don't want to have to be allocating
* higher-order pages when we are unable to shrink dcache.
*/
if (flags & SLAB_RECLAIM_ACCOUNT)
break;
/*
* Large number of objects is good, but very large slabs are
* currently bad for the gfp()s.
*/
if (gfporder >= slab_max_order)
break;
/*
* Acceptable internal fragmentation?
*/
if (left_over * 8 <= (PAGE_SIZE << gfporder))
break;
}
return left_over;
} | /**
* calculate_slab_order - calculate size (page order) of slabs
* @cachep: pointer to the cache that is being created
* @size: size of objects to be created in this cache.
* @align: required alignment for the objects.
* @flags: slab allocation flags
*
* Also calculates the number of objects per slab.
*
* This could be made much more intelligent. For now, try to avoid using
* high order pages for slabs. When the gfp() functions are more friendly
* towards high-order requests, this should be changed.
*/ | calculate size (page order) of slabs
@cachep: pointer to the cache that is being created
@size: size of objects to be created in this cache.
@align: required alignment for the objects.
@flags: slab allocation flags
Also calculates the number of objects per slab.
This could be made much more intelligent. For now, try to avoid using
high order pages for slabs. When the gfp() functions are more friendly
towards high-order requests, this should be changed. | [
"calculate",
"size",
"(",
"page",
"order",
")",
"of",
"slabs",
"@cachep",
":",
"pointer",
"to",
"the",
"cache",
"that",
"is",
"being",
"created",
"@size",
":",
"size",
"of",
"objects",
"to",
"be",
"created",
"in",
"this",
"cache",
".",
"@align",
":",
"required",
"alignment",
"for",
"the",
"objects",
".",
"@flags",
":",
"slab",
"allocation",
"flags",
"Also",
"calculates",
"the",
"number",
"of",
"objects",
"per",
"slab",
".",
"This",
"could",
"be",
"made",
"much",
"more",
"intelligent",
".",
"For",
"now",
"try",
"to",
"avoid",
"using",
"high",
"order",
"pages",
"for",
"slabs",
".",
"When",
"the",
"gfp",
"()",
"functions",
"are",
"more",
"friendly",
"towards",
"high",
"-",
"order",
"requests",
"this",
"should",
"be",
"changed",
"."
] | static size_t calculate_slab_order(struct kmem_cache *cachep,
size_t size, size_t align, unsigned long flags)
{
unsigned long offslab_limit;
size_t left_over = 0;
int gfporder;
for (gfporder = 0; gfporder <= KMALLOC_MAX_ORDER; gfporder++) {
unsigned int num;
size_t remainder;
cache_estimate(gfporder, size, align, flags, &remainder, &num);
if (!num)
continue;
if (flags & CFLGS_OFF_SLAB) {
offslab_limit = size - sizeof(struct slab);
offslab_limit /= sizeof(kmem_bufctl_t);
if (num > offslab_limit)
break;
}
cachep->num = num;
cachep->gfporder = gfporder;
left_over = remainder;
if (flags & SLAB_RECLAIM_ACCOUNT)
break;
if (gfporder >= slab_max_order)
break;
if (left_over * 8 <= (PAGE_SIZE << gfporder))
break;
}
return left_over;
} | [
"static",
"size_t",
"calculate_slab_order",
"(",
"struct",
"kmem_cache",
"*",
"cachep",
",",
"size_t",
"size",
",",
"size_t",
"align",
",",
"unsigned",
"long",
"flags",
")",
"{",
"unsigned",
"long",
"offslab_limit",
";",
"size_t",
"left_over",
"=",
"0",
";",
"int",
"gfporder",
";",
"for",
"(",
"gfporder",
"=",
"0",
";",
"gfporder",
"<=",
"KMALLOC_MAX_ORDER",
";",
"gfporder",
"++",
")",
"{",
"unsigned",
"int",
"num",
";",
"size_t",
"remainder",
";",
"cache_estimate",
"(",
"gfporder",
",",
"size",
",",
"align",
",",
"flags",
",",
"&",
"remainder",
",",
"&",
"num",
")",
";",
"if",
"(",
"!",
"num",
")",
"continue",
";",
"if",
"(",
"flags",
"&",
"CFLGS_OFF_SLAB",
")",
"{",
"offslab_limit",
"=",
"size",
"-",
"sizeof",
"(",
"struct",
"slab",
")",
";",
"offslab_limit",
"/=",
"sizeof",
"(",
"kmem_bufctl_t",
")",
";",
"if",
"(",
"num",
">",
"offslab_limit",
")",
"break",
";",
"}",
"cachep",
"->",
"num",
"=",
"num",
";",
"cachep",
"->",
"gfporder",
"=",
"gfporder",
";",
"left_over",
"=",
"remainder",
";",
"if",
"(",
"flags",
"&",
"SLAB_RECLAIM_ACCOUNT",
")",
"break",
";",
"if",
"(",
"gfporder",
">=",
"slab_max_order",
")",
"break",
";",
"if",
"(",
"left_over",
"*",
"8",
"<=",
"(",
"PAGE_SIZE",
"<<",
"gfporder",
")",
")",
"break",
";",
"}",
"return",
"left_over",
";",
"}"
] | calculate_slab_order - calculate size (page order) of slabs
@cachep: pointer to the cache that is being created
@size: size of objects to be created in this cache. | [
"calculate_slab_order",
"-",
"calculate",
"size",
"(",
"page",
"order",
")",
"of",
"slabs",
"@cachep",
":",
"pointer",
"to",
"the",
"cache",
"that",
"is",
"being",
"created",
"@size",
":",
"size",
"of",
"objects",
"to",
"be",
"created",
"in",
"this",
"cache",
"."
] | [
"/*\n\t\t\t * Max number of objs-per-slab for caches which\n\t\t\t * use off-slab slabs. Needed to avoid a possible\n\t\t\t * looping condition in cache_grow().\n\t\t\t */",
"/* Found something acceptable - save it away */",
"/*\n\t\t * A VFS-reclaimable slab tends to have most allocations\n\t\t * as GFP_NOFS and we really don't want to have to be allocating\n\t\t * higher-order pages when we are unable to shrink dcache.\n\t\t */",
"/*\n\t\t * Large number of objects is good, but very large slabs are\n\t\t * currently bad for the gfp()s.\n\t\t */",
"/*\n\t\t * Acceptable internal fragmentation?\n\t\t */"
] | [
{
"param": "cachep",
"type": "struct kmem_cache"
},
{
"param": "size",
"type": "size_t"
},
{
"param": "align",
"type": "size_t"
},
{
"param": "flags",
"type": "unsigned long"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cachep",
"type": "struct kmem_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "align",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flags",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | alloc_slabmgmt | null | static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,
int colour_off, gfp_t local_flags,
int nodeid)
{
struct slab *slabp;
if (OFF_SLAB(cachep)) {
/* Slab management obj is off-slab. */
slabp = kmem_cache_alloc_node(cachep->slabp_cache,
local_flags, nodeid);
/*
* If the first object in the slab is leaked (it's allocated
* but no one has a reference to it), we want to make sure
* kmemleak does not treat the ->s_mem pointer as a reference
* to the object. Otherwise we will not report the leak.
*/
kmemleak_scan_area(&slabp->list, sizeof(struct list_head),
local_flags);
if (!slabp)
return NULL;
} else {
slabp = objp + colour_off;
colour_off += cachep->slab_size;
}
slabp->inuse = 0;
slabp->colouroff = colour_off;
slabp->s_mem = objp + colour_off;
slabp->nodeid = nodeid;
slabp->free = 0;
return slabp;
} | /*
* Get the memory for a slab management obj.
* For a slab cache when the slab descriptor is off-slab, slab descriptors
* always come from malloc_sizes caches. The slab descriptor cannot
* come from the same cache which is getting created because,
* when we are searching for an appropriate cache for these
* descriptors in kmem_cache_create, we search through the malloc_sizes array.
* If we are creating a malloc_sizes cache here it would not be visible to
* kmem_find_general_cachep till the initialization is complete.
* Hence we cannot have slabp_cache same as the original cache.
*/ | Get the memory for a slab management obj.
For a slab cache when the slab descriptor is off-slab, slab descriptors
always come from malloc_sizes caches. The slab descriptor cannot
come from the same cache which is getting created because,
when we are searching for an appropriate cache for these
descriptors in kmem_cache_create, we search through the malloc_sizes array.
If we are creating a malloc_sizes cache here it would not be visible to
kmem_find_general_cachep till the initialization is complete.
Hence we cannot have slabp_cache same as the original cache. | [
"Get",
"the",
"memory",
"for",
"a",
"slab",
"management",
"obj",
".",
"For",
"a",
"slab",
"cache",
"when",
"the",
"slab",
"descriptor",
"is",
"off",
"-",
"slab",
"slab",
"descriptors",
"always",
"come",
"from",
"malloc_sizes",
"caches",
".",
"The",
"slab",
"descriptor",
"cannot",
"come",
"from",
"the",
"same",
"cache",
"which",
"is",
"getting",
"created",
"because",
"when",
"we",
"are",
"searching",
"for",
"an",
"appropriate",
"cache",
"for",
"these",
"descriptors",
"in",
"kmem_cache_create",
"we",
"search",
"through",
"the",
"malloc_sizes",
"array",
".",
"If",
"we",
"are",
"creating",
"a",
"malloc_sizes",
"cache",
"here",
"it",
"would",
"not",
"be",
"visible",
"to",
"kmem_find_general_cachep",
"till",
"the",
"initialization",
"is",
"complete",
".",
"Hence",
"we",
"cannot",
"have",
"slabp_cache",
"same",
"as",
"the",
"original",
"cache",
"."
] | static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,
int colour_off, gfp_t local_flags,
int nodeid)
{
struct slab *slabp;
if (OFF_SLAB(cachep)) {
slabp = kmem_cache_alloc_node(cachep->slabp_cache,
local_flags, nodeid);
kmemleak_scan_area(&slabp->list, sizeof(struct list_head),
local_flags);
if (!slabp)
return NULL;
} else {
slabp = objp + colour_off;
colour_off += cachep->slab_size;
}
slabp->inuse = 0;
slabp->colouroff = colour_off;
slabp->s_mem = objp + colour_off;
slabp->nodeid = nodeid;
slabp->free = 0;
return slabp;
} | [
"static",
"struct",
"slab",
"*",
"alloc_slabmgmt",
"(",
"struct",
"kmem_cache",
"*",
"cachep",
",",
"void",
"*",
"objp",
",",
"int",
"colour_off",
",",
"gfp_t",
"local_flags",
",",
"int",
"nodeid",
")",
"{",
"struct",
"slab",
"*",
"slabp",
";",
"if",
"(",
"OFF_SLAB",
"(",
"cachep",
")",
")",
"{",
"slabp",
"=",
"kmem_cache_alloc_node",
"(",
"cachep",
"->",
"slabp_cache",
",",
"local_flags",
",",
"nodeid",
")",
";",
"kmemleak_scan_area",
"(",
"&",
"slabp",
"->",
"list",
",",
"sizeof",
"(",
"struct",
"list_head",
")",
",",
"local_flags",
")",
";",
"if",
"(",
"!",
"slabp",
")",
"return",
"NULL",
";",
"}",
"else",
"{",
"slabp",
"=",
"objp",
"+",
"colour_off",
";",
"colour_off",
"+=",
"cachep",
"->",
"slab_size",
";",
"}",
"slabp",
"->",
"inuse",
"=",
"0",
";",
"slabp",
"->",
"colouroff",
"=",
"colour_off",
";",
"slabp",
"->",
"s_mem",
"=",
"objp",
"+",
"colour_off",
";",
"slabp",
"->",
"nodeid",
"=",
"nodeid",
";",
"slabp",
"->",
"free",
"=",
"0",
";",
"return",
"slabp",
";",
"}"
] | Get the memory for a slab management obj. | [
"Get",
"the",
"memory",
"for",
"a",
"slab",
"management",
"obj",
"."
] | [
"/* Slab management obj is off-slab. */",
"/*\n\t\t * If the first object in the slab is leaked (it's allocated\n\t\t * but no one has a reference to it), we want to make sure\n\t\t * kmemleak does not treat the ->s_mem pointer as a reference\n\t\t * to the object. Otherwise we will not report the leak.\n\t\t */"
] | [
{
"param": "cachep",
"type": "struct kmem_cache"
},
{
"param": "objp",
"type": "void"
},
{
"param": "colour_off",
"type": "int"
},
{
"param": "local_flags",
"type": "gfp_t"
},
{
"param": "nodeid",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cachep",
"type": "struct kmem_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "objp",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "colour_off",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "local_flags",
"type": "gfp_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nodeid",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | slab_map_pages | void | static void slab_map_pages(struct kmem_cache *cache, struct slab *slab,
void *addr)
{
int nr_pages;
struct page *page;
page = virt_to_page(addr);
nr_pages = 1;
if (likely(!PageCompound(page)))
nr_pages <<= cache->gfporder;
do {
page->slab_cache = cache;
page->slab_page = slab;
page++;
} while (--nr_pages);
} | /*
* Map pages beginning at addr to the given cache and slab. This is required
* for the slab allocator to be able to lookup the cache and slab of a
* virtual address for kfree, ksize, and slab debugging.
*/ | Map pages beginning at addr to the given cache and slab. This is required
for the slab allocator to be able to lookup the cache and slab of a
virtual address for kfree, ksize, and slab debugging. | [
"Map",
"pages",
"beginning",
"at",
"addr",
"to",
"the",
"given",
"cache",
"and",
"slab",
".",
"This",
"is",
"required",
"for",
"the",
"slab",
"allocator",
"to",
"be",
"able",
"to",
"lookup",
"the",
"cache",
"and",
"slab",
"of",
"a",
"virtual",
"address",
"for",
"kfree",
"ksize",
"and",
"slab",
"debugging",
"."
] | static void slab_map_pages(struct kmem_cache *cache, struct slab *slab,
void *addr)
{
int nr_pages;
struct page *page;
page = virt_to_page(addr);
nr_pages = 1;
if (likely(!PageCompound(page)))
nr_pages <<= cache->gfporder;
do {
page->slab_cache = cache;
page->slab_page = slab;
page++;
} while (--nr_pages);
} | [
"static",
"void",
"slab_map_pages",
"(",
"struct",
"kmem_cache",
"*",
"cache",
",",
"struct",
"slab",
"*",
"slab",
",",
"void",
"*",
"addr",
")",
"{",
"int",
"nr_pages",
";",
"struct",
"page",
"*",
"page",
";",
"page",
"=",
"virt_to_page",
"(",
"addr",
")",
";",
"nr_pages",
"=",
"1",
";",
"if",
"(",
"likely",
"(",
"!",
"PageCompound",
"(",
"page",
")",
")",
")",
"nr_pages",
"<<=",
"cache",
"->",
"gfporder",
";",
"do",
"{",
"page",
"->",
"slab_cache",
"=",
"cache",
";",
"page",
"->",
"slab_page",
"=",
"slab",
";",
"page",
"++",
";",
"}",
"while",
"(",
"--",
"nr_pages",
")",
";",
"}"
] | Map pages beginning at addr to the given cache and slab. | [
"Map",
"pages",
"beginning",
"at",
"addr",
"to",
"the",
"given",
"cache",
"and",
"slab",
"."
] | [] | [
{
"param": "cache",
"type": "struct kmem_cache"
},
{
"param": "slab",
"type": "struct slab"
},
{
"param": "addr",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cache",
"type": "struct kmem_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "slab",
"type": "struct slab",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | cache_grow | int | static int cache_grow(struct kmem_cache *cachep,
gfp_t flags, int nodeid, void *objp)
{
struct slab *slabp;
size_t offset;
gfp_t local_flags;
struct kmem_cache_node *n;
/*
* Be lazy and only check for valid flags here, keeping it out of the
* critical path in kmem_cache_alloc().
*/
BUG_ON(flags & GFP_SLAB_BUG_MASK);
local_flags = flags & (GFP_CONSTRAINT_MASK|GFP_RECLAIM_MASK);
/* Take the node list lock to change the colour_next on this node */
check_irq_off();
n = cachep->node[nodeid];
spin_lock(&n->list_lock);
/* Get colour for the slab, and cal the next value. */
offset = n->colour_next;
n->colour_next++;
if (n->colour_next >= cachep->colour)
n->colour_next = 0;
spin_unlock(&n->list_lock);
offset *= cachep->colour_off;
if (local_flags & __GFP_WAIT)
local_irq_enable();
/*
* The test for missing atomic flag is performed here, rather than
* the more obvious place, simply to reduce the critical path length
* in kmem_cache_alloc(). If a caller is seriously mis-behaving they
* will eventually be caught here (where it matters).
*/
kmem_flagcheck(cachep, flags);
/*
* Get mem for the objs. Attempt to allocate a physical page from
* 'nodeid'.
*/
if (!objp)
objp = kmem_getpages(cachep, local_flags, nodeid);
if (!objp)
goto failed;
/* Get slab management. */
slabp = alloc_slabmgmt(cachep, objp, offset,
local_flags & ~GFP_CONSTRAINT_MASK, nodeid);
if (!slabp)
goto opps1;
slab_map_pages(cachep, slabp, objp);
cache_init_objs(cachep, slabp);
if (local_flags & __GFP_WAIT)
local_irq_disable();
check_irq_off();
spin_lock(&n->list_lock);
/* Make slab active. */
list_add_tail(&slabp->list, &(n->slabs_free));
STATS_INC_GROWN(cachep);
n->free_objects += cachep->num;
spin_unlock(&n->list_lock);
return 1;
opps1:
kmem_freepages(cachep, objp);
failed:
if (local_flags & __GFP_WAIT)
local_irq_disable();
return 0;
} | /*
* Grow (by 1) the number of slabs within a cache. This is called by
* kmem_cache_alloc() when there are no active objs left in a cache.
*/ | Grow (by 1) the number of slabs within a cache. This is called by
kmem_cache_alloc() when there are no active objs left in a cache. | [
"Grow",
"(",
"by",
"1",
")",
"the",
"number",
"of",
"slabs",
"within",
"a",
"cache",
".",
"This",
"is",
"called",
"by",
"kmem_cache_alloc",
"()",
"when",
"there",
"are",
"no",
"active",
"objs",
"left",
"in",
"a",
"cache",
"."
] | static int cache_grow(struct kmem_cache *cachep,
gfp_t flags, int nodeid, void *objp)
{
struct slab *slabp;
size_t offset;
gfp_t local_flags;
struct kmem_cache_node *n;
BUG_ON(flags & GFP_SLAB_BUG_MASK);
local_flags = flags & (GFP_CONSTRAINT_MASK|GFP_RECLAIM_MASK);
check_irq_off();
n = cachep->node[nodeid];
spin_lock(&n->list_lock);
offset = n->colour_next;
n->colour_next++;
if (n->colour_next >= cachep->colour)
n->colour_next = 0;
spin_unlock(&n->list_lock);
offset *= cachep->colour_off;
if (local_flags & __GFP_WAIT)
local_irq_enable();
kmem_flagcheck(cachep, flags);
if (!objp)
objp = kmem_getpages(cachep, local_flags, nodeid);
if (!objp)
goto failed;
slabp = alloc_slabmgmt(cachep, objp, offset,
local_flags & ~GFP_CONSTRAINT_MASK, nodeid);
if (!slabp)
goto opps1;
slab_map_pages(cachep, slabp, objp);
cache_init_objs(cachep, slabp);
if (local_flags & __GFP_WAIT)
local_irq_disable();
check_irq_off();
spin_lock(&n->list_lock);
list_add_tail(&slabp->list, &(n->slabs_free));
STATS_INC_GROWN(cachep);
n->free_objects += cachep->num;
spin_unlock(&n->list_lock);
return 1;
opps1:
kmem_freepages(cachep, objp);
failed:
if (local_flags & __GFP_WAIT)
local_irq_disable();
return 0;
} | [
"static",
"int",
"cache_grow",
"(",
"struct",
"kmem_cache",
"*",
"cachep",
",",
"gfp_t",
"flags",
",",
"int",
"nodeid",
",",
"void",
"*",
"objp",
")",
"{",
"struct",
"slab",
"*",
"slabp",
";",
"size_t",
"offset",
";",
"gfp_t",
"local_flags",
";",
"struct",
"kmem_cache_node",
"*",
"n",
";",
"BUG_ON",
"(",
"flags",
"&",
"GFP_SLAB_BUG_MASK",
")",
";",
"local_flags",
"=",
"flags",
"&",
"(",
"GFP_CONSTRAINT_MASK",
"|",
"GFP_RECLAIM_MASK",
")",
";",
"check_irq_off",
"(",
")",
";",
"n",
"=",
"cachep",
"->",
"node",
"[",
"nodeid",
"]",
";",
"spin_lock",
"(",
"&",
"n",
"->",
"list_lock",
")",
";",
"offset",
"=",
"n",
"->",
"colour_next",
";",
"n",
"->",
"colour_next",
"++",
";",
"if",
"(",
"n",
"->",
"colour_next",
">=",
"cachep",
"->",
"colour",
")",
"n",
"->",
"colour_next",
"=",
"0",
";",
"spin_unlock",
"(",
"&",
"n",
"->",
"list_lock",
")",
";",
"offset",
"*=",
"cachep",
"->",
"colour_off",
";",
"if",
"(",
"local_flags",
"&",
"__GFP_WAIT",
")",
"local_irq_enable",
"(",
")",
";",
"kmem_flagcheck",
"(",
"cachep",
",",
"flags",
")",
";",
"if",
"(",
"!",
"objp",
")",
"objp",
"=",
"kmem_getpages",
"(",
"cachep",
",",
"local_flags",
",",
"nodeid",
")",
";",
"if",
"(",
"!",
"objp",
")",
"goto",
"failed",
";",
"slabp",
"=",
"alloc_slabmgmt",
"(",
"cachep",
",",
"objp",
",",
"offset",
",",
"local_flags",
"&",
"~",
"GFP_CONSTRAINT_MASK",
",",
"nodeid",
")",
";",
"if",
"(",
"!",
"slabp",
")",
"goto",
"opps1",
";",
"slab_map_pages",
"(",
"cachep",
",",
"slabp",
",",
"objp",
")",
";",
"cache_init_objs",
"(",
"cachep",
",",
"slabp",
")",
";",
"if",
"(",
"local_flags",
"&",
"__GFP_WAIT",
")",
"local_irq_disable",
"(",
")",
";",
"check_irq_off",
"(",
")",
";",
"spin_lock",
"(",
"&",
"n",
"->",
"list_lock",
")",
";",
"list_add_tail",
"(",
"&",
"slabp",
"->",
"list",
",",
"&",
"(",
"n",
"->",
"slabs_free",
")",
")",
";",
"STATS_INC_GROWN",
"(",
"cachep",
")",
";",
"n",
"->",
"free_objects",
"+=",
"cachep",
"->",
"num",
";",
"spin_unlock",
"(",
"&",
"n",
"->",
"list_lock",
")",
";",
"return",
"1",
";",
"opps1",
":",
"kmem_freepages",
"(",
"cachep",
",",
"objp",
")",
";",
"failed",
":",
"if",
"(",
"local_flags",
"&",
"__GFP_WAIT",
")",
"local_irq_disable",
"(",
")",
";",
"return",
"0",
";",
"}"
] | Grow (by 1) the number of slabs within a cache. | [
"Grow",
"(",
"by",
"1",
")",
"the",
"number",
"of",
"slabs",
"within",
"a",
"cache",
"."
] | [
"/*\n\t * Be lazy and only check for valid flags here, keeping it out of the\n\t * critical path in kmem_cache_alloc().\n\t */",
"/* Take the node list lock to change the colour_next on this node */",
"/* Get colour for the slab, and cal the next value. */",
"/*\n\t * The test for missing atomic flag is performed here, rather than\n\t * the more obvious place, simply to reduce the critical path length\n\t * in kmem_cache_alloc(). If a caller is seriously mis-behaving they\n\t * will eventually be caught here (where it matters).\n\t */",
"/*\n\t * Get mem for the objs. Attempt to allocate a physical page from\n\t * 'nodeid'.\n\t */",
"/* Get slab management. */",
"/* Make slab active. */"
] | [
{
"param": "cachep",
"type": "struct kmem_cache"
},
{
"param": "flags",
"type": "gfp_t"
},
{
"param": "nodeid",
"type": "int"
},
{
"param": "objp",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cachep",
"type": "struct kmem_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flags",
"type": "gfp_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nodeid",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "objp",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | kfree_debugcheck | void | static void kfree_debugcheck(const void *objp)
{
if (!virt_addr_valid(objp)) {
//printk(KERN_ERR "kfree_debugcheck: out of range ptr %lxh.\n",
// (unsigned long)objp);
BUG();
}
} | /*
* Perform extra freeing checks:
* - detect bad pointers.
* - POISON/RED_ZONE checking
*/ | Perform extra freeing checks:
- detect bad pointers. | [
"Perform",
"extra",
"freeing",
"checks",
":",
"-",
"detect",
"bad",
"pointers",
"."
] | static void kfree_debugcheck(const void *objp)
{
if (!virt_addr_valid(objp)) {
BUG();
}
} | [
"static",
"void",
"kfree_debugcheck",
"(",
"const",
"void",
"*",
"objp",
")",
"{",
"if",
"(",
"!",
"virt_addr_valid",
"(",
"objp",
")",
")",
"{",
"BUG",
"(",
")",
";",
"}",
"}"
] | Perform extra freeing checks:
- detect bad pointers. | [
"Perform",
"extra",
"freeing",
"checks",
":",
"-",
"detect",
"bad",
"pointers",
"."
] | [
"//printk(KERN_ERR \"kfree_debugcheck: out of range ptr %lxh.\\n\",",
"// (unsigned long)objp);"
] | [
{
"param": "objp",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "objp",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | alternate_node_alloc | void | static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags)
{
int nid_alloc, nid_here;
if (in_interrupt() || (flags & __GFP_THISNODE))
return NULL;
nid_alloc = nid_here = numa_mem_id();
if (cpuset_do_slab_mem_spread() && (cachep->flags & SLAB_MEM_SPREAD))
nid_alloc = cpuset_slab_spread_node();
else if (current->mempolicy)
nid_alloc = slab_node();
if (nid_alloc != nid_here)
return ____cache_alloc_node(cachep, flags, nid_alloc);
return NULL;
} | /*
* Try allocating on another node if PF_SPREAD_SLAB|PF_MEMPOLICY.
*
* If we are in_interrupt, then process context, including cpusets and
* mempolicy, may not apply and should not be used for allocation policy.
*/ | Try allocating on another node if PF_SPREAD_SLAB|PF_MEMPOLICY.
If we are in_interrupt, then process context, including cpusets and
mempolicy, may not apply and should not be used for allocation policy. | [
"Try",
"allocating",
"on",
"another",
"node",
"if",
"PF_SPREAD_SLAB|PF_MEMPOLICY",
".",
"If",
"we",
"are",
"in_interrupt",
"then",
"process",
"context",
"including",
"cpusets",
"and",
"mempolicy",
"may",
"not",
"apply",
"and",
"should",
"not",
"be",
"used",
"for",
"allocation",
"policy",
"."
] | static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags)
{
int nid_alloc, nid_here;
if (in_interrupt() || (flags & __GFP_THISNODE))
return NULL;
nid_alloc = nid_here = numa_mem_id();
if (cpuset_do_slab_mem_spread() && (cachep->flags & SLAB_MEM_SPREAD))
nid_alloc = cpuset_slab_spread_node();
else if (current->mempolicy)
nid_alloc = slab_node();
if (nid_alloc != nid_here)
return ____cache_alloc_node(cachep, flags, nid_alloc);
return NULL;
} | [
"static",
"void",
"*",
"alternate_node_alloc",
"(",
"struct",
"kmem_cache",
"*",
"cachep",
",",
"gfp_t",
"flags",
")",
"{",
"int",
"nid_alloc",
",",
"nid_here",
";",
"if",
"(",
"in_interrupt",
"(",
")",
"||",
"(",
"flags",
"&",
"__GFP_THISNODE",
")",
")",
"return",
"NULL",
";",
"nid_alloc",
"=",
"nid_here",
"=",
"numa_mem_id",
"(",
")",
";",
"if",
"(",
"cpuset_do_slab_mem_spread",
"(",
")",
"&&",
"(",
"cachep",
"->",
"flags",
"&",
"SLAB_MEM_SPREAD",
")",
")",
"nid_alloc",
"=",
"cpuset_slab_spread_node",
"(",
")",
";",
"else",
"if",
"(",
"current",
"->",
"mempolicy",
")",
"nid_alloc",
"=",
"slab_node",
"(",
")",
";",
"if",
"(",
"nid_alloc",
"!=",
"nid_here",
")",
"return",
"____cache_alloc_node",
"(",
"cachep",
",",
"flags",
",",
"nid_alloc",
")",
";",
"return",
"NULL",
";",
"}"
] | Try allocating on another node if PF_SPREAD_SLAB|PF_MEMPOLICY. | [
"Try",
"allocating",
"on",
"another",
"node",
"if",
"PF_SPREAD_SLAB|PF_MEMPOLICY",
"."
] | [] | [
{
"param": "cachep",
"type": "struct kmem_cache"
},
{
"param": "flags",
"type": "gfp_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cachep",
"type": "struct kmem_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flags",
"type": "gfp_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | fallback_alloc | void | static void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
{
struct zonelist *zonelist;
gfp_t local_flags;
struct zoneref *z;
struct zone *zone;
enum zone_type high_zoneidx = gfp_zone(flags);
void *obj = NULL;
int nid;
unsigned int cpuset_mems_cookie;
if (flags & __GFP_THISNODE)
return NULL;
local_flags = flags & (GFP_CONSTRAINT_MASK|GFP_RECLAIM_MASK);
retry_cpuset:
cpuset_mems_cookie = get_mems_allowed();
zonelist = node_zonelist(slab_node(), flags);
retry:
/*
* Look through allowed nodes for objects available
* from existing per node queues.
*/
//for_each_zone_zonelist(zone, z, zonelist, high_zoneidx) {
nid = zone_to_nid(zone);
if (cpuset_zone_allowed_hardwall(zone, flags) &&
cache->node[nid] &&
cache->node[nid]->free_objects) {
obj = ____cache_alloc_node(cache,
flags | GFP_THISNODE, nid);
if (obj)
break;
}
//}
if (!obj) {
/*
* This allocation will be performed within the constraints
* of the current cpuset / memory policy requirements.
* We may trigger various forms of reclaim on the allowed
* set and go into memory reserves if necessary.
*/
if (local_flags & __GFP_WAIT)
local_irq_enable();
kmem_flagcheck(cache, flags);
obj = kmem_getpages(cache, local_flags, numa_mem_id());
if (local_flags & __GFP_WAIT)
local_irq_disable();
if (obj) {
/*
* Insert into the appropriate per node queues
*/
nid = page_to_nid(virt_to_page(obj));
if (cache_grow(cache, flags, nid, obj)) {
obj = ____cache_alloc_node(cache,
flags | GFP_THISNODE, nid);
if (!obj)
/*
* Another processor may allocate the
* objects in the slab since we are
* not holding any locks.
*/
goto retry;
} else {
/* cache_grow already freed obj */
obj = NULL;
}
}
}
if (unlikely(!put_mems_allowed(cpuset_mems_cookie) && !obj))
goto retry_cpuset;
return obj;
} | /*
* Fallback function if there was no memory available and no objects on a
* certain node and fall back is permitted. First we scan all the
* available node for available objects. If that fails then we
* perform an allocation without specifying a node. This allows the page
* allocator to do its reclaim / fallback magic. We then insert the
* slab into the proper nodelist and then allocate from it.
*/ | Fallback function if there was no memory available and no objects on a
certain node and fall back is permitted. First we scan all the
available node for available objects. If that fails then we
perform an allocation without specifying a node. This allows the page
allocator to do its reclaim / fallback magic. We then insert the
slab into the proper nodelist and then allocate from it. | [
"Fallback",
"function",
"if",
"there",
"was",
"no",
"memory",
"available",
"and",
"no",
"objects",
"on",
"a",
"certain",
"node",
"and",
"fall",
"back",
"is",
"permitted",
".",
"First",
"we",
"scan",
"all",
"the",
"available",
"node",
"for",
"available",
"objects",
".",
"If",
"that",
"fails",
"then",
"we",
"perform",
"an",
"allocation",
"without",
"specifying",
"a",
"node",
".",
"This",
"allows",
"the",
"page",
"allocator",
"to",
"do",
"its",
"reclaim",
"/",
"fallback",
"magic",
".",
"We",
"then",
"insert",
"the",
"slab",
"into",
"the",
"proper",
"nodelist",
"and",
"then",
"allocate",
"from",
"it",
"."
] | static void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
{
struct zonelist *zonelist;
gfp_t local_flags;
struct zoneref *z;
struct zone *zone;
enum zone_type high_zoneidx = gfp_zone(flags);
void *obj = NULL;
int nid;
unsigned int cpuset_mems_cookie;
if (flags & __GFP_THISNODE)
return NULL;
local_flags = flags & (GFP_CONSTRAINT_MASK|GFP_RECLAIM_MASK);
retry_cpuset:
cpuset_mems_cookie = get_mems_allowed();
zonelist = node_zonelist(slab_node(), flags);
retry:
nid = zone_to_nid(zone);
if (cpuset_zone_allowed_hardwall(zone, flags) &&
cache->node[nid] &&
cache->node[nid]->free_objects) {
obj = ____cache_alloc_node(cache,
flags | GFP_THISNODE, nid);
if (obj)
break;
}
if (!obj) {
if (local_flags & __GFP_WAIT)
local_irq_enable();
kmem_flagcheck(cache, flags);
obj = kmem_getpages(cache, local_flags, numa_mem_id());
if (local_flags & __GFP_WAIT)
local_irq_disable();
if (obj) {
nid = page_to_nid(virt_to_page(obj));
if (cache_grow(cache, flags, nid, obj)) {
obj = ____cache_alloc_node(cache,
flags | GFP_THISNODE, nid);
if (!obj)
goto retry;
} else {
obj = NULL;
}
}
}
if (unlikely(!put_mems_allowed(cpuset_mems_cookie) && !obj))
goto retry_cpuset;
return obj;
} | [
"static",
"void",
"*",
"fallback_alloc",
"(",
"struct",
"kmem_cache",
"*",
"cache",
",",
"gfp_t",
"flags",
")",
"{",
"struct",
"zonelist",
"*",
"zonelist",
";",
"gfp_t",
"local_flags",
";",
"struct",
"zoneref",
"*",
"z",
";",
"struct",
"zone",
"*",
"zone",
";",
"enum",
"zone_type",
"high_zoneidx",
"=",
"gfp_zone",
"(",
"flags",
")",
";",
"void",
"*",
"obj",
"=",
"NULL",
";",
"int",
"nid",
";",
"unsigned",
"int",
"cpuset_mems_cookie",
";",
"if",
"(",
"flags",
"&",
"__GFP_THISNODE",
")",
"return",
"NULL",
";",
"local_flags",
"=",
"flags",
"&",
"(",
"GFP_CONSTRAINT_MASK",
"|",
"GFP_RECLAIM_MASK",
")",
";",
"retry_cpuset",
":",
"cpuset_mems_cookie",
"=",
"get_mems_allowed",
"(",
")",
";",
"zonelist",
"=",
"node_zonelist",
"(",
"slab_node",
"(",
")",
",",
"flags",
")",
";",
"retry",
":",
"nid",
"=",
"zone_to_nid",
"(",
"zone",
")",
";",
"if",
"(",
"cpuset_zone_allowed_hardwall",
"(",
"zone",
",",
"flags",
")",
"&&",
"cache",
"->",
"node",
"[",
"nid",
"]",
"&&",
"cache",
"->",
"node",
"[",
"nid",
"]",
"->",
"free_objects",
")",
"{",
"obj",
"=",
"____cache_alloc_node",
"(",
"cache",
",",
"flags",
"|",
"GFP_THISNODE",
",",
"nid",
")",
";",
"if",
"(",
"obj",
")",
"break",
";",
"}",
"if",
"(",
"!",
"obj",
")",
"{",
"if",
"(",
"local_flags",
"&",
"__GFP_WAIT",
")",
"local_irq_enable",
"(",
")",
";",
"kmem_flagcheck",
"(",
"cache",
",",
"flags",
")",
";",
"obj",
"=",
"kmem_getpages",
"(",
"cache",
",",
"local_flags",
",",
"numa_mem_id",
"(",
")",
")",
";",
"if",
"(",
"local_flags",
"&",
"__GFP_WAIT",
")",
"local_irq_disable",
"(",
")",
";",
"if",
"(",
"obj",
")",
"{",
"nid",
"=",
"page_to_nid",
"(",
"virt_to_page",
"(",
"obj",
")",
")",
";",
"if",
"(",
"cache_grow",
"(",
"cache",
",",
"flags",
",",
"nid",
",",
"obj",
")",
")",
"{",
"obj",
"=",
"____cache_alloc_node",
"(",
"cache",
",",
"flags",
"|",
"GFP_THISNODE",
",",
"nid",
")",
";",
"if",
"(",
"!",
"obj",
")",
"goto",
"retry",
";",
"}",
"else",
"{",
"obj",
"=",
"NULL",
";",
"}",
"}",
"}",
"if",
"(",
"unlikely",
"(",
"!",
"put_mems_allowed",
"(",
"cpuset_mems_cookie",
")",
"&&",
"!",
"obj",
")",
")",
"goto",
"retry_cpuset",
";",
"return",
"obj",
";",
"}"
] | Fallback function if there was no memory available and no objects on a
certain node and fall back is permitted. | [
"Fallback",
"function",
"if",
"there",
"was",
"no",
"memory",
"available",
"and",
"no",
"objects",
"on",
"a",
"certain",
"node",
"and",
"fall",
"back",
"is",
"permitted",
"."
] | [
"/*\n\t * Look through allowed nodes for objects available\n\t * from existing per node queues.\n\t */",
"//for_each_zone_zonelist(zone, z, zonelist, high_zoneidx) {",
"//}",
"/*\n\t\t * This allocation will be performed within the constraints\n\t\t * of the current cpuset / memory policy requirements.\n\t\t * We may trigger various forms of reclaim on the allowed\n\t\t * set and go into memory reserves if necessary.\n\t\t */",
"/*\n\t\t\t * Insert into the appropriate per node queues\n\t\t\t */",
"/*\n\t\t\t\t\t * Another processor may allocate the\n\t\t\t\t\t * objects in the slab since we are\n\t\t\t\t\t * not holding any locks.\n\t\t\t\t\t */",
"/* cache_grow already freed obj */"
] | [
{
"param": "cache",
"type": "struct kmem_cache"
},
{
"param": "flags",
"type": "gfp_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cache",
"type": "struct kmem_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flags",
"type": "gfp_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | __cache_free | void | static inline void __cache_free()
{
struct array_cache *ac = cpu_cache_get(cachep);
check_irq_off();
kmemleak_free_recursive(objp, cachep->flags);
objp = cache_free_debugcheck(cachep, objp, caller);
kmemcheck_slab_free(cachep, objp, cachep->object_size);
} | /*
* Release an obj back to its cache. If the obj has a constructed state, it must
* be in this state _before_ it is released. Called with disabled ints.
*/ | Release an obj back to its cache. If the obj has a constructed state, it must
be in this state _before_ it is released. Called with disabled ints. | [
"Release",
"an",
"obj",
"back",
"to",
"its",
"cache",
".",
"If",
"the",
"obj",
"has",
"a",
"constructed",
"state",
"it",
"must",
"be",
"in",
"this",
"state",
"_before_",
"it",
"is",
"released",
".",
"Called",
"with",
"disabled",
"ints",
"."
] | static inline void __cache_free()
{
struct array_cache *ac = cpu_cache_get(cachep);
check_irq_off();
kmemleak_free_recursive(objp, cachep->flags);
objp = cache_free_debugcheck(cachep, objp, caller);
kmemcheck_slab_free(cachep, objp, cachep->object_size);
} | [
"static",
"inline",
"void",
"__cache_free",
"(",
")",
"{",
"struct",
"array_cache",
"*",
"ac",
"=",
"cpu_cache_get",
"(",
"cachep",
")",
";",
"check_irq_off",
"(",
")",
";",
"kmemleak_free_recursive",
"(",
"objp",
",",
"cachep",
"->",
"flags",
")",
";",
"objp",
"=",
"cache_free_debugcheck",
"(",
"cachep",
",",
"objp",
",",
"caller",
")",
";",
"kmemcheck_slab_free",
"(",
"cachep",
",",
"objp",
",",
"cachep",
"->",
"object_size",
")",
";",
"}"
] | Release an obj back to its cache. | [
"Release",
"an",
"obj",
"back",
"to",
"its",
"cache",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | kmem_cache_alloc_node | void | void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
{
void *ret = slab_alloc_node(cachep, flags, nodeid, _RET_IP_);
trace_kmem_cache_alloc_node(_RET_IP_, ret,
cachep->object_size, cachep->size,
flags, nodeid);
return ret;
} | /**
* kmem_cache_alloc_node - Allocate an object on the specified node
* @cachep: The cache to allocate from.
* @flags: See kmalloc().
* @nodeid: node number of the target node.
*
* Identical to kmem_cache_alloc but it will allocate memory on the given
* node, which can improve the performance for cpu bound structures.
*
* Fallback to other node is possible if __GFP_THISNODE is not set.
*/ | Allocate an object on the specified node
@cachep: The cache to allocate from.
@flags: See kmalloc().
@nodeid: node number of the target node.
Identical to kmem_cache_alloc but it will allocate memory on the given
node, which can improve the performance for cpu bound structures.
Fallback to other node is possible if __GFP_THISNODE is not set. | [
"Allocate",
"an",
"object",
"on",
"the",
"specified",
"node",
"@cachep",
":",
"The",
"cache",
"to",
"allocate",
"from",
".",
"@flags",
":",
"See",
"kmalloc",
"()",
".",
"@nodeid",
":",
"node",
"number",
"of",
"the",
"target",
"node",
".",
"Identical",
"to",
"kmem_cache_alloc",
"but",
"it",
"will",
"allocate",
"memory",
"on",
"the",
"given",
"node",
"which",
"can",
"improve",
"the",
"performance",
"for",
"cpu",
"bound",
"structures",
".",
"Fallback",
"to",
"other",
"node",
"is",
"possible",
"if",
"__GFP_THISNODE",
"is",
"not",
"set",
"."
] | void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
{
void *ret = slab_alloc_node(cachep, flags, nodeid, _RET_IP_);
trace_kmem_cache_alloc_node(_RET_IP_, ret,
cachep->object_size, cachep->size,
flags, nodeid);
return ret;
} | [
"void",
"*",
"kmem_cache_alloc_node",
"(",
"struct",
"kmem_cache",
"*",
"cachep",
",",
"gfp_t",
"flags",
",",
"int",
"nodeid",
")",
"{",
"void",
"*",
"ret",
"=",
"slab_alloc_node",
"(",
"cachep",
",",
"flags",
",",
"nodeid",
",",
"_RET_IP_",
")",
";",
"trace_kmem_cache_alloc_node",
"(",
"_RET_IP_",
",",
"ret",
",",
"cachep",
"->",
"object_size",
",",
"cachep",
"->",
"size",
",",
"flags",
",",
"nodeid",
")",
";",
"return",
"ret",
";",
"}"
] | kmem_cache_alloc_node - Allocate an object on the specified node
@cachep: The cache to allocate from. | [
"kmem_cache_alloc_node",
"-",
"Allocate",
"an",
"object",
"on",
"the",
"specified",
"node",
"@cachep",
":",
"The",
"cache",
"to",
"allocate",
"from",
"."
] | [] | [
{
"param": "cachep",
"type": "struct kmem_cache"
},
{
"param": "flags",
"type": "gfp_t"
},
{
"param": "nodeid",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cachep",
"type": "struct kmem_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flags",
"type": "gfp_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nodeid",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | __do_kmalloc | void | static void *__do_kmalloc(size_t size, gfp_t flags,
unsigned long caller)
{
struct kmem_cache *cachep;
void *ret;
/* If you want to save a few bytes .text space: replace
* __ with kmem_.
* Then kmalloc uses the uninlined functions instead of the inline
* functions.
*/
cachep = kmalloc_slab(size, flags);
if (unlikely(ZERO_OR_NULL_PTR(cachep)))
return cachep;
ret = slab_alloc(cachep, flags, caller);
trace_kmalloc(caller, ret,
size, cachep->size, flags);
return ret;
} | /**
* __do_kmalloc - allocate memory
* @size: how many bytes of memory are required.
* @flags: the type of memory to allocate (see kmalloc).
* @caller: function caller for debug tracking of the caller
*/ | allocate memory
@size: how many bytes of memory are required.
@flags: the type of memory to allocate . | [
"allocate",
"memory",
"@size",
":",
"how",
"many",
"bytes",
"of",
"memory",
"are",
"required",
".",
"@flags",
":",
"the",
"type",
"of",
"memory",
"to",
"allocate",
"."
] | static void *__do_kmalloc(size_t size, gfp_t flags,
unsigned long caller)
{
struct kmem_cache *cachep;
void *ret;
cachep = kmalloc_slab(size, flags);
if (unlikely(ZERO_OR_NULL_PTR(cachep)))
return cachep;
ret = slab_alloc(cachep, flags, caller);
trace_kmalloc(caller, ret,
size, cachep->size, flags);
return ret;
} | [
"static",
"void",
"*",
"__do_kmalloc",
"(",
"size_t",
"size",
",",
"gfp_t",
"flags",
",",
"unsigned",
"long",
"caller",
")",
"{",
"struct",
"kmem_cache",
"*",
"cachep",
";",
"void",
"*",
"ret",
";",
"cachep",
"=",
"kmalloc_slab",
"(",
"size",
",",
"flags",
")",
";",
"if",
"(",
"unlikely",
"(",
"ZERO_OR_NULL_PTR",
"(",
"cachep",
")",
")",
")",
"return",
"cachep",
";",
"ret",
"=",
"slab_alloc",
"(",
"cachep",
",",
"flags",
",",
"caller",
")",
";",
"trace_kmalloc",
"(",
"caller",
",",
"ret",
",",
"size",
",",
"cachep",
"->",
"size",
",",
"flags",
")",
";",
"return",
"ret",
";",
"}"
] | __do_kmalloc - allocate memory
@size: how many bytes of memory are required. | [
"__do_kmalloc",
"-",
"allocate",
"memory",
"@size",
":",
"how",
"many",
"bytes",
"of",
"memory",
"are",
"required",
"."
] | [
"/* If you want to save a few bytes .text space: replace\n\t * __ with kmem_.\n\t * Then kmalloc uses the uninlined functions instead of the inline\n\t * functions.\n\t */"
] | [
{
"param": "size",
"type": "size_t"
},
{
"param": "flags",
"type": "gfp_t"
},
{
"param": "caller",
"type": "unsigned long"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "size",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flags",
"type": "gfp_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "caller",
"type": "unsigned long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | kmem_cache_free | void | void kmem_cache_free(struct kmem_cache *cachep, void *objp)
{
unsigned long flags;
cachep = cache_from_obj(cachep, objp);
if (!cachep)
return;
local_irq_save(flags);
debug_check_no_locks_freed(objp, cachep->object_size);
if (!(cachep->flags & SLAB_DEBUG_OBJECTS))
debug_check_no_obj_freed(objp, cachep->object_size);
__cache_free(cachep, objp, _RET_IP_);
local_irq_restore(flags);
trace_kmem_cache_free(_RET_IP_, objp);
} | /**
* kmem_cache_free - Deallocate an object
* @cachep: The cache the allocation was from.
* @objp: The previously allocated object.
*
* Free an object which was previously allocated from this
* cache.
*/ | Deallocate an object
@cachep: The cache the allocation was from.
@objp: The previously allocated object.
Free an object which was previously allocated from this
cache. | [
"Deallocate",
"an",
"object",
"@cachep",
":",
"The",
"cache",
"the",
"allocation",
"was",
"from",
".",
"@objp",
":",
"The",
"previously",
"allocated",
"object",
".",
"Free",
"an",
"object",
"which",
"was",
"previously",
"allocated",
"from",
"this",
"cache",
"."
] | void kmem_cache_free(struct kmem_cache *cachep, void *objp)
{
unsigned long flags;
cachep = cache_from_obj(cachep, objp);
if (!cachep)
return;
local_irq_save(flags);
debug_check_no_locks_freed(objp, cachep->object_size);
if (!(cachep->flags & SLAB_DEBUG_OBJECTS))
debug_check_no_obj_freed(objp, cachep->object_size);
__cache_free(cachep, objp, _RET_IP_);
local_irq_restore(flags);
trace_kmem_cache_free(_RET_IP_, objp);
} | [
"void",
"kmem_cache_free",
"(",
"struct",
"kmem_cache",
"*",
"cachep",
",",
"void",
"*",
"objp",
")",
"{",
"unsigned",
"long",
"flags",
";",
"cachep",
"=",
"cache_from_obj",
"(",
"cachep",
",",
"objp",
")",
";",
"if",
"(",
"!",
"cachep",
")",
"return",
";",
"local_irq_save",
"(",
"flags",
")",
";",
"debug_check_no_locks_freed",
"(",
"objp",
",",
"cachep",
"->",
"object_size",
")",
";",
"if",
"(",
"!",
"(",
"cachep",
"->",
"flags",
"&",
"SLAB_DEBUG_OBJECTS",
")",
")",
"debug_check_no_obj_freed",
"(",
"objp",
",",
"cachep",
"->",
"object_size",
")",
";",
"__cache_free",
"(",
"cachep",
",",
"objp",
",",
"_RET_IP_",
")",
";",
"local_irq_restore",
"(",
"flags",
")",
";",
"trace_kmem_cache_free",
"(",
"_RET_IP_",
",",
"objp",
")",
";",
"}"
] | kmem_cache_free - Deallocate an object
@cachep: The cache the allocation was from. | [
"kmem_cache_free",
"-",
"Deallocate",
"an",
"object",
"@cachep",
":",
"The",
"cache",
"the",
"allocation",
"was",
"from",
"."
] | [] | [
{
"param": "cachep",
"type": "struct kmem_cache"
},
{
"param": "objp",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cachep",
"type": "struct kmem_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "objp",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | kfree | void | void kfree(const void *objp)
{
struct kmem_cache *c;
unsigned long flags;
trace_kfree(_RET_IP_, objp);
if (unlikely(ZERO_OR_NULL_PTR(objp)))
return;
local_irq_save(flags);
kfree_debugcheck(objp);
c = virt_to_cache(objp);
debug_check_no_locks_freed(objp, c->object_size);
debug_check_no_obj_freed(objp, c->object_size);
__cache_free(c, (void *)objp, _RET_IP_);
local_irq_restore(flags);
} | /**
* kfree - free previously allocated memory
* @objp: pointer returned by kmalloc.
*
* If @objp is NULL, no operation is performed.
*
* Don't free memory not originally allocated by kmalloc()
* or you will run into trouble.
*/ | free previously allocated memory
@objp: pointer returned by kmalloc.
If @objp is NULL, no operation is performed.
Don't free memory not originally allocated by kmalloc()
or you will run into trouble. | [
"free",
"previously",
"allocated",
"memory",
"@objp",
":",
"pointer",
"returned",
"by",
"kmalloc",
".",
"If",
"@objp",
"is",
"NULL",
"no",
"operation",
"is",
"performed",
".",
"Don",
"'",
"t",
"free",
"memory",
"not",
"originally",
"allocated",
"by",
"kmalloc",
"()",
"or",
"you",
"will",
"run",
"into",
"trouble",
"."
] | void kfree(const void *objp)
{
struct kmem_cache *c;
unsigned long flags;
trace_kfree(_RET_IP_, objp);
if (unlikely(ZERO_OR_NULL_PTR(objp)))
return;
local_irq_save(flags);
kfree_debugcheck(objp);
c = virt_to_cache(objp);
debug_check_no_locks_freed(objp, c->object_size);
debug_check_no_obj_freed(objp, c->object_size);
__cache_free(c, (void *)objp, _RET_IP_);
local_irq_restore(flags);
} | [
"void",
"kfree",
"(",
"const",
"void",
"*",
"objp",
")",
"{",
"struct",
"kmem_cache",
"*",
"c",
";",
"unsigned",
"long",
"flags",
";",
"trace_kfree",
"(",
"_RET_IP_",
",",
"objp",
")",
";",
"if",
"(",
"unlikely",
"(",
"ZERO_OR_NULL_PTR",
"(",
"objp",
")",
")",
")",
"return",
";",
"local_irq_save",
"(",
"flags",
")",
";",
"kfree_debugcheck",
"(",
"objp",
")",
";",
"c",
"=",
"virt_to_cache",
"(",
"objp",
")",
";",
"debug_check_no_locks_freed",
"(",
"objp",
",",
"c",
"->",
"object_size",
")",
";",
"debug_check_no_obj_freed",
"(",
"objp",
",",
"c",
"->",
"object_size",
")",
";",
"__cache_free",
"(",
"c",
",",
"(",
"void",
"*",
")",
"objp",
",",
"_RET_IP_",
")",
";",
"local_irq_restore",
"(",
"flags",
")",
";",
"}"
] | kfree - free previously allocated memory
@objp: pointer returned by kmalloc. | [
"kfree",
"-",
"free",
"previously",
"allocated",
"memory",
"@objp",
":",
"pointer",
"returned",
"by",
"kmalloc",
"."
] | [] | [
{
"param": "objp",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "objp",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | alloc_kmemlist | int | static int alloc_kmemlist(struct kmem_cache *cachep, gfp_t gfp)
{
int node;
struct kmem_cache_node *n;
struct array_cache *new_shared;
struct array_cache **new_alien = NULL;
//for_each_online_node(node) {
if (use_alien_caches) {
new_alien = alloc_alien_cache(node, cachep->limit, gfp);
if (!new_alien)
goto fail;
}
new_shared = NULL;
if (cachep->shared) {
new_shared = alloc_arraycache(node,
cachep->shared*cachep->batchcount,
0xbaadf00d, gfp);
if (!new_shared) {
free_alien_cache(new_alien);
goto fail;
}
}
n = cachep->node[node];
if (n) {
struct array_cache *shared = n->shared;
spin_lock_irq(&n->list_lock);
if (shared)
free_block(cachep, shared->entry,
shared->avail, node);
n->shared = new_shared;
if (!n->alien) {
n->alien = new_alien;
new_alien = NULL;
}
n->free_limit = (1 + nr_cpus_node(node)) *
cachep->batchcount + cachep->num;
spin_unlock_irq(&n->list_lock);
kfree(shared);
free_alien_cache(new_alien);
continue;
}
n = kmalloc_node(sizeof(struct kmem_cache_node), gfp, node);
if (!n) {
free_alien_cache(new_alien);
kfree(new_shared);
goto fail;
}
kmem_cache_node_init(n);
n->next_reap = jiffies + REAPTIMEOUT_LIST3 +
((unsigned long)cachep) % REAPTIMEOUT_LIST3;
n->shared = new_shared;
n->alien = new_alien;
n->free_limit = (1 + nr_cpus_node(node)) *
cachep->batchcount + cachep->num;
cachep->node[node] = n;
//}
return 0;
fail:
if (!cachep->list.next) {
/* Cache is not active yet. Roll back what we did */
node--;
while (node >= 0) {
if (cachep->node[node]) {
n = cachep->node[node];
kfree(n->shared);
free_alien_cache(n->alien);
kfree(n);
cachep->node[node] = NULL;
}
node--;
}
}
return -ENOMEM;
} | /*
* This initializes kmem_cache_node or resizes various caches for all nodes.
*/ | This initializes kmem_cache_node or resizes various caches for all nodes. | [
"This",
"initializes",
"kmem_cache_node",
"or",
"resizes",
"various",
"caches",
"for",
"all",
"nodes",
"."
] | static int alloc_kmemlist(struct kmem_cache *cachep, gfp_t gfp)
{
int node;
struct kmem_cache_node *n;
struct array_cache *new_shared;
struct array_cache **new_alien = NULL;
if (use_alien_caches) {
new_alien = alloc_alien_cache(node, cachep->limit, gfp);
if (!new_alien)
goto fail;
}
new_shared = NULL;
if (cachep->shared) {
new_shared = alloc_arraycache(node,
cachep->shared*cachep->batchcount,
0xbaadf00d, gfp);
if (!new_shared) {
free_alien_cache(new_alien);
goto fail;
}
}
n = cachep->node[node];
if (n) {
struct array_cache *shared = n->shared;
spin_lock_irq(&n->list_lock);
if (shared)
free_block(cachep, shared->entry,
shared->avail, node);
n->shared = new_shared;
if (!n->alien) {
n->alien = new_alien;
new_alien = NULL;
}
n->free_limit = (1 + nr_cpus_node(node)) *
cachep->batchcount + cachep->num;
spin_unlock_irq(&n->list_lock);
kfree(shared);
free_alien_cache(new_alien);
continue;
}
n = kmalloc_node(sizeof(struct kmem_cache_node), gfp, node);
if (!n) {
free_alien_cache(new_alien);
kfree(new_shared);
goto fail;
}
kmem_cache_node_init(n);
n->next_reap = jiffies + REAPTIMEOUT_LIST3 +
((unsigned long)cachep) % REAPTIMEOUT_LIST3;
n->shared = new_shared;
n->alien = new_alien;
n->free_limit = (1 + nr_cpus_node(node)) *
cachep->batchcount + cachep->num;
cachep->node[node] = n;
return 0;
fail:
if (!cachep->list.next) {
node--;
while (node >= 0) {
if (cachep->node[node]) {
n = cachep->node[node];
kfree(n->shared);
free_alien_cache(n->alien);
kfree(n);
cachep->node[node] = NULL;
}
node--;
}
}
return -ENOMEM;
} | [
"static",
"int",
"alloc_kmemlist",
"(",
"struct",
"kmem_cache",
"*",
"cachep",
",",
"gfp_t",
"gfp",
")",
"{",
"int",
"node",
";",
"struct",
"kmem_cache_node",
"*",
"n",
";",
"struct",
"array_cache",
"*",
"new_shared",
";",
"struct",
"array_cache",
"*",
"*",
"new_alien",
"=",
"NULL",
";",
"if",
"(",
"use_alien_caches",
")",
"{",
"new_alien",
"=",
"alloc_alien_cache",
"(",
"node",
",",
"cachep",
"->",
"limit",
",",
"gfp",
")",
";",
"if",
"(",
"!",
"new_alien",
")",
"goto",
"fail",
";",
"}",
"new_shared",
"=",
"NULL",
";",
"if",
"(",
"cachep",
"->",
"shared",
")",
"{",
"new_shared",
"=",
"alloc_arraycache",
"(",
"node",
",",
"cachep",
"->",
"shared",
"*",
"cachep",
"->",
"batchcount",
",",
"0xbaadf00d",
",",
"gfp",
")",
";",
"if",
"(",
"!",
"new_shared",
")",
"{",
"free_alien_cache",
"(",
"new_alien",
")",
";",
"goto",
"fail",
";",
"}",
"}",
"n",
"=",
"cachep",
"->",
"node",
"[",
"node",
"]",
";",
"if",
"(",
"n",
")",
"{",
"struct",
"array_cache",
"*",
"shared",
"=",
"n",
"->",
"shared",
";",
"spin_lock_irq",
"(",
"&",
"n",
"->",
"list_lock",
")",
";",
"if",
"(",
"shared",
")",
"free_block",
"(",
"cachep",
",",
"shared",
"->",
"entry",
",",
"shared",
"->",
"avail",
",",
"node",
")",
";",
"n",
"->",
"shared",
"=",
"new_shared",
";",
"if",
"(",
"!",
"n",
"->",
"alien",
")",
"{",
"n",
"->",
"alien",
"=",
"new_alien",
";",
"new_alien",
"=",
"NULL",
";",
"}",
"n",
"->",
"free_limit",
"=",
"(",
"1",
"+",
"nr_cpus_node",
"(",
"node",
")",
")",
"*",
"cachep",
"->",
"batchcount",
"+",
"cachep",
"->",
"num",
";",
"spin_unlock_irq",
"(",
"&",
"n",
"->",
"list_lock",
")",
";",
"kfree",
"(",
"shared",
")",
";",
"free_alien_cache",
"(",
"new_alien",
")",
";",
"continue",
";",
"}",
"n",
"=",
"kmalloc_node",
"(",
"sizeof",
"(",
"struct",
"kmem_cache_node",
")",
",",
"gfp",
",",
"node",
")",
";",
"if",
"(",
"!",
"n",
")",
"{",
"free_alien_cache",
"(",
"new_alien",
")",
";",
"kfree",
"(",
"new_shared",
")",
";",
"goto",
"fail",
";",
"}",
"kmem_cache_node_init",
"(",
"n",
")",
";",
"n",
"->",
"next_reap",
"=",
"jiffies",
"+",
"REAPTIMEOUT_LIST3",
"+",
"(",
"(",
"unsigned",
"long",
")",
"cachep",
")",
"%",
"REAPTIMEOUT_LIST3",
";",
"n",
"->",
"shared",
"=",
"new_shared",
";",
"n",
"->",
"alien",
"=",
"new_alien",
";",
"n",
"->",
"free_limit",
"=",
"(",
"1",
"+",
"nr_cpus_node",
"(",
"node",
")",
")",
"*",
"cachep",
"->",
"batchcount",
"+",
"cachep",
"->",
"num",
";",
"cachep",
"->",
"node",
"[",
"node",
"]",
"=",
"n",
";",
"return",
"0",
";",
"fail",
":",
"if",
"(",
"!",
"cachep",
"->",
"list",
".",
"next",
")",
"{",
"node",
"--",
";",
"while",
"(",
"node",
">=",
"0",
")",
"{",
"if",
"(",
"cachep",
"->",
"node",
"[",
"node",
"]",
")",
"{",
"n",
"=",
"cachep",
"->",
"node",
"[",
"node",
"]",
";",
"kfree",
"(",
"n",
"->",
"shared",
")",
";",
"free_alien_cache",
"(",
"n",
"->",
"alien",
")",
";",
"kfree",
"(",
"n",
")",
";",
"cachep",
"->",
"node",
"[",
"node",
"]",
"=",
"NULL",
";",
"}",
"node",
"--",
";",
"}",
"}",
"return",
"-",
"ENOMEM",
";",
"}"
] | This initializes kmem_cache_node or resizes various caches for all nodes. | [
"This",
"initializes",
"kmem_cache_node",
"or",
"resizes",
"various",
"caches",
"for",
"all",
"nodes",
"."
] | [
"//for_each_online_node(node) {",
"//}",
"/* Cache is not active yet. Roll back what we did */"
] | [
{
"param": "cachep",
"type": "struct kmem_cache"
},
{
"param": "gfp",
"type": "gfp_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cachep",
"type": "struct kmem_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gfp",
"type": "gfp_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | __do_tune_cpucache | int | static int __do_tune_cpucache(struct kmem_cache *cachep, int limit,
int batchcount, int shared, gfp_t gfp)
{
struct ccupdate_struct *new;
int i;
new = kzalloc(sizeof(*new) + nr_cpu_ids * sizeof(struct array_cache *),
gfp);
if (!new)
return -ENOMEM;
for_each_online_cpu(i) {
new->new[i] = alloc_arraycache(cpu_to_mem(i), limit,
batchcount, gfp);
if (!new->new[i]) {
for (i--; i >= 0; i--)
kfree(new->new[i]);
kfree(new);
return -ENOMEM;
}
}
new->cachep = cachep;
on_each_cpu(do_ccupdate_local, (void *)new, 1);
check_irq_on();
cachep->batchcount = batchcount;
cachep->limit = limit;
cachep->shared = shared;
for_each_online_cpu(i) {
struct array_cache *ccold = new->new[i];
if (!ccold)
continue;
spin_lock_irq(&cachep->node[cpu_to_mem(i)]->list_lock);
free_block(cachep, ccold->entry, ccold->avail, cpu_to_mem(i));
spin_unlock_irq(&cachep->node[cpu_to_mem(i)]->list_lock);
kfree(ccold);
}
kfree(new);
return alloc_kmemlist(cachep, gfp);
} | /* Always called with the slab_mutex held */ | Always called with the slab_mutex held | [
"Always",
"called",
"with",
"the",
"slab_mutex",
"held"
] | static int __do_tune_cpucache(struct kmem_cache *cachep, int limit,
int batchcount, int shared, gfp_t gfp)
{
struct ccupdate_struct *new;
int i;
new = kzalloc(sizeof(*new) + nr_cpu_ids * sizeof(struct array_cache *),
gfp);
if (!new)
return -ENOMEM;
for_each_online_cpu(i) {
new->new[i] = alloc_arraycache(cpu_to_mem(i), limit,
batchcount, gfp);
if (!new->new[i]) {
for (i--; i >= 0; i--)
kfree(new->new[i]);
kfree(new);
return -ENOMEM;
}
}
new->cachep = cachep;
on_each_cpu(do_ccupdate_local, (void *)new, 1);
check_irq_on();
cachep->batchcount = batchcount;
cachep->limit = limit;
cachep->shared = shared;
for_each_online_cpu(i) {
struct array_cache *ccold = new->new[i];
if (!ccold)
continue;
spin_lock_irq(&cachep->node[cpu_to_mem(i)]->list_lock);
free_block(cachep, ccold->entry, ccold->avail, cpu_to_mem(i));
spin_unlock_irq(&cachep->node[cpu_to_mem(i)]->list_lock);
kfree(ccold);
}
kfree(new);
return alloc_kmemlist(cachep, gfp);
} | [
"static",
"int",
"__do_tune_cpucache",
"(",
"struct",
"kmem_cache",
"*",
"cachep",
",",
"int",
"limit",
",",
"int",
"batchcount",
",",
"int",
"shared",
",",
"gfp_t",
"gfp",
")",
"{",
"struct",
"ccupdate_struct",
"*",
"new",
";",
"int",
"i",
";",
"new",
"=",
"kzalloc",
"(",
"sizeof",
"(",
"*",
"new",
")",
"+",
"nr_cpu_ids",
"*",
"sizeof",
"(",
"struct",
"array_cache",
"*",
")",
",",
"gfp",
")",
";",
"if",
"(",
"!",
"new",
")",
"return",
"-",
"ENOMEM",
";",
"for_each_online_cpu",
"(",
"i",
")",
"{",
"new",
"->",
"new",
"[",
"i",
"]",
"=",
"alloc_arraycache",
"(",
"cpu_to_mem",
"(",
"i",
")",
",",
"limit",
",",
"batchcount",
",",
"gfp",
")",
";",
"if",
"(",
"!",
"new",
"->",
"new",
"[",
"i",
"]",
")",
"{",
"for",
"(",
"i",
"--",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"kfree",
"(",
"new",
"->",
"new",
"[",
"i",
"]",
")",
";",
"kfree",
"(",
"new",
")",
";",
"return",
"-",
"ENOMEM",
";",
"}",
"}",
"new",
"->",
"cachep",
"=",
"cachep",
";",
"on_each_cpu",
"(",
"do_ccupdate_local",
",",
"(",
"void",
"*",
")",
"new",
",",
"1",
")",
";",
"check_irq_on",
"(",
")",
";",
"cachep",
"->",
"batchcount",
"=",
"batchcount",
";",
"cachep",
"->",
"limit",
"=",
"limit",
";",
"cachep",
"->",
"shared",
"=",
"shared",
";",
"for_each_online_cpu",
"(",
"i",
")",
"{",
"struct",
"array_cache",
"*",
"ccold",
"=",
"new",
"->",
"new",
"[",
"i",
"]",
";",
"if",
"(",
"!",
"ccold",
")",
"continue",
";",
"spin_lock_irq",
"(",
"&",
"cachep",
"->",
"node",
"[",
"cpu_to_mem",
"(",
"i",
")",
"]",
"->",
"list_lock",
")",
";",
"free_block",
"(",
"cachep",
",",
"ccold",
"->",
"entry",
",",
"ccold",
"->",
"avail",
",",
"cpu_to_mem",
"(",
"i",
")",
")",
";",
"spin_unlock_irq",
"(",
"&",
"cachep",
"->",
"node",
"[",
"cpu_to_mem",
"(",
"i",
")",
"]",
"->",
"list_lock",
")",
";",
"kfree",
"(",
"ccold",
")",
";",
"}",
"kfree",
"(",
"new",
")",
";",
"return",
"alloc_kmemlist",
"(",
"cachep",
",",
"gfp",
")",
";",
"}"
] | Always called with the slab_mutex held | [
"Always",
"called",
"with",
"the",
"slab_mutex",
"held"
] | [] | [
{
"param": "cachep",
"type": "struct kmem_cache"
},
{
"param": "limit",
"type": "int"
},
{
"param": "batchcount",
"type": "int"
},
{
"param": "shared",
"type": "int"
},
{
"param": "gfp",
"type": "gfp_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cachep",
"type": "struct kmem_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "limit",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "batchcount",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "shared",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gfp",
"type": "gfp_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | drain_array | void | static void drain_array(struct kmem_cache *cachep, struct kmem_cache_node *n,
struct array_cache *ac, int force, int node)
{
int tofree;
if (!ac || !ac->avail)
return;
if (ac->touched && !force) {
ac->touched = 0;
} else {
spin_lock_irq(&n->list_lock);
if (ac->avail) {
tofree = force ? ac->avail : (ac->limit + 4) / 5;
if (tofree > ac->avail)
tofree = (ac->avail + 1) / 2;
free_block(cachep, ac->entry, tofree, node);
ac->avail -= tofree;
memmove(ac->entry, &(ac->entry[tofree]),
sizeof(void *) * ac->avail);
}
spin_unlock_irq(&n->list_lock);
}
} | /*
* Drain an array if it contains any elements taking the node lock only if
* necessary. Note that the node listlock also protects the array_cache
* if drain_array() is used on the shared array.
*/ | Drain an array if it contains any elements taking the node lock only if
necessary. Note that the node listlock also protects the array_cache
if drain_array() is used on the shared array. | [
"Drain",
"an",
"array",
"if",
"it",
"contains",
"any",
"elements",
"taking",
"the",
"node",
"lock",
"only",
"if",
"necessary",
".",
"Note",
"that",
"the",
"node",
"listlock",
"also",
"protects",
"the",
"array_cache",
"if",
"drain_array",
"()",
"is",
"used",
"on",
"the",
"shared",
"array",
"."
] | static void drain_array(struct kmem_cache *cachep, struct kmem_cache_node *n,
struct array_cache *ac, int force, int node)
{
int tofree;
if (!ac || !ac->avail)
return;
if (ac->touched && !force) {
ac->touched = 0;
} else {
spin_lock_irq(&n->list_lock);
if (ac->avail) {
tofree = force ? ac->avail : (ac->limit + 4) / 5;
if (tofree > ac->avail)
tofree = (ac->avail + 1) / 2;
free_block(cachep, ac->entry, tofree, node);
ac->avail -= tofree;
memmove(ac->entry, &(ac->entry[tofree]),
sizeof(void *) * ac->avail);
}
spin_unlock_irq(&n->list_lock);
}
} | [
"static",
"void",
"drain_array",
"(",
"struct",
"kmem_cache",
"*",
"cachep",
",",
"struct",
"kmem_cache_node",
"*",
"n",
",",
"struct",
"array_cache",
"*",
"ac",
",",
"int",
"force",
",",
"int",
"node",
")",
"{",
"int",
"tofree",
";",
"if",
"(",
"!",
"ac",
"||",
"!",
"ac",
"->",
"avail",
")",
"return",
";",
"if",
"(",
"ac",
"->",
"touched",
"&&",
"!",
"force",
")",
"{",
"ac",
"->",
"touched",
"=",
"0",
";",
"}",
"else",
"{",
"spin_lock_irq",
"(",
"&",
"n",
"->",
"list_lock",
")",
";",
"if",
"(",
"ac",
"->",
"avail",
")",
"{",
"tofree",
"=",
"force",
"?",
"ac",
"->",
"avail",
":",
"(",
"ac",
"->",
"limit",
"+",
"4",
")",
"/",
"5",
";",
"if",
"(",
"tofree",
">",
"ac",
"->",
"avail",
")",
"tofree",
"=",
"(",
"ac",
"->",
"avail",
"+",
"1",
")",
"/",
"2",
";",
"free_block",
"(",
"cachep",
",",
"ac",
"->",
"entry",
",",
"tofree",
",",
"node",
")",
";",
"ac",
"->",
"avail",
"-=",
"tofree",
";",
"memmove",
"(",
"ac",
"->",
"entry",
",",
"&",
"(",
"ac",
"->",
"entry",
"[",
"tofree",
"]",
")",
",",
"sizeof",
"(",
"void",
"*",
")",
"*",
"ac",
"->",
"avail",
")",
";",
"}",
"spin_unlock_irq",
"(",
"&",
"n",
"->",
"list_lock",
")",
";",
"}",
"}"
] | Drain an array if it contains any elements taking the node lock only if
necessary. | [
"Drain",
"an",
"array",
"if",
"it",
"contains",
"any",
"elements",
"taking",
"the",
"node",
"lock",
"only",
"if",
"necessary",
"."
] | [] | [
{
"param": "cachep",
"type": "struct kmem_cache"
},
{
"param": "n",
"type": "struct kmem_cache_node"
},
{
"param": "ac",
"type": "struct array_cache"
},
{
"param": "force",
"type": "int"
},
{
"param": "node",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cachep",
"type": "struct kmem_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "struct kmem_cache_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ac",
"type": "struct array_cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "force",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | cache_reap | void | static void cache_reap(struct work_struct *w)
{
struct kmem_cache *searchp;
struct kmem_cache_node *n;
int node = numa_mem_id();
struct delayed_work *work = to_delayed_work(w);
if (!mutex_trylock(&slab_mutex))
/* Give up. Setup the next iteration. */
goto out;
//list_for_each_entry(searchp, &slab_caches, list) {
check_irq_on();
/*
* We only take the node lock if absolutely necessary and we
* have established with reasonable certainty that
* we can do some work if the lock was obtained.
*/
n = searchp->node[node];
reap_alien(searchp, n);
drain_array(searchp, n, cpu_cache_get(searchp), 0, node);
/*
* These are racy checks but it does not matter
* if we skip one check or scan twice.
*/
if (time_after(n->next_reap, jiffies))
goto next;
n->next_reap = jiffies + REAPTIMEOUT_LIST3;
drain_array(searchp, n, n->shared, 0, node);
if (n->free_touched)
n->free_touched = 0;
else {
int freed;
freed = drain_freelist(searchp, n, (n->free_limit +
5 * searchp->num - 1) / (5 * searchp->num));
STATS_ADD_REAPED(searchp, freed);
}
next:
cond_resched();
//}
check_irq_on();
mutex_unlock(&slab_mutex);
next_reap_node();
out:
/* Set up the next iteration */
schedule_delayed_work(work, round_jiffies_relative(REAPTIMEOUT_CPUC));
} | /**
* cache_reap - Reclaim memory from caches.
* @w: work descriptor
*
* Called from workqueue/eventd every few seconds.
* Purpose:
* - clear the per-cpu caches for this CPU.
* - return freeable pages to the main free memory pool.
*
* If we cannot acquire the cache chain mutex then just give up - we'll try
* again on the next iteration.
*/ | Reclaim memory from caches.
@w: work descriptor
Called from workqueue/eventd every few seconds.
Purpose:
- clear the per-cpu caches for this CPU.
- return freeable pages to the main free memory pool.
If we cannot acquire the cache chain mutex then just give up - we'll try
again on the next iteration. | [
"Reclaim",
"memory",
"from",
"caches",
".",
"@w",
":",
"work",
"descriptor",
"Called",
"from",
"workqueue",
"/",
"eventd",
"every",
"few",
"seconds",
".",
"Purpose",
":",
"-",
"clear",
"the",
"per",
"-",
"cpu",
"caches",
"for",
"this",
"CPU",
".",
"-",
"return",
"freeable",
"pages",
"to",
"the",
"main",
"free",
"memory",
"pool",
".",
"If",
"we",
"cannot",
"acquire",
"the",
"cache",
"chain",
"mutex",
"then",
"just",
"give",
"up",
"-",
"we",
"'",
"ll",
"try",
"again",
"on",
"the",
"next",
"iteration",
"."
] | static void cache_reap(struct work_struct *w)
{
struct kmem_cache *searchp;
struct kmem_cache_node *n;
int node = numa_mem_id();
struct delayed_work *work = to_delayed_work(w);
if (!mutex_trylock(&slab_mutex))
goto out;
check_irq_on();
n = searchp->node[node];
reap_alien(searchp, n);
drain_array(searchp, n, cpu_cache_get(searchp), 0, node);
if (time_after(n->next_reap, jiffies))
goto next;
n->next_reap = jiffies + REAPTIMEOUT_LIST3;
drain_array(searchp, n, n->shared, 0, node);
if (n->free_touched)
n->free_touched = 0;
else {
int freed;
freed = drain_freelist(searchp, n, (n->free_limit +
5 * searchp->num - 1) / (5 * searchp->num));
STATS_ADD_REAPED(searchp, freed);
}
next:
cond_resched();
check_irq_on();
mutex_unlock(&slab_mutex);
next_reap_node();
out:
schedule_delayed_work(work, round_jiffies_relative(REAPTIMEOUT_CPUC));
} | [
"static",
"void",
"cache_reap",
"(",
"struct",
"work_struct",
"*",
"w",
")",
"{",
"struct",
"kmem_cache",
"*",
"searchp",
";",
"struct",
"kmem_cache_node",
"*",
"n",
";",
"int",
"node",
"=",
"numa_mem_id",
"(",
")",
";",
"struct",
"delayed_work",
"*",
"work",
"=",
"to_delayed_work",
"(",
"w",
")",
";",
"if",
"(",
"!",
"mutex_trylock",
"(",
"&",
"slab_mutex",
")",
")",
"goto",
"out",
";",
"check_irq_on",
"(",
")",
";",
"n",
"=",
"searchp",
"->",
"node",
"[",
"node",
"]",
";",
"reap_alien",
"(",
"searchp",
",",
"n",
")",
";",
"drain_array",
"(",
"searchp",
",",
"n",
",",
"cpu_cache_get",
"(",
"searchp",
")",
",",
"0",
",",
"node",
")",
";",
"if",
"(",
"time_after",
"(",
"n",
"->",
"next_reap",
",",
"jiffies",
")",
")",
"goto",
"next",
";",
"n",
"->",
"next_reap",
"=",
"jiffies",
"+",
"REAPTIMEOUT_LIST3",
";",
"drain_array",
"(",
"searchp",
",",
"n",
",",
"n",
"->",
"shared",
",",
"0",
",",
"node",
")",
";",
"if",
"(",
"n",
"->",
"free_touched",
")",
"n",
"->",
"free_touched",
"=",
"0",
";",
"else",
"{",
"int",
"freed",
";",
"freed",
"=",
"drain_freelist",
"(",
"searchp",
",",
"n",
",",
"(",
"n",
"->",
"free_limit",
"+",
"5",
"*",
"searchp",
"->",
"num",
"-",
"1",
")",
"/",
"(",
"5",
"*",
"searchp",
"->",
"num",
")",
")",
";",
"STATS_ADD_REAPED",
"(",
"searchp",
",",
"freed",
")",
";",
"}",
"next",
":",
"cond_resched",
"(",
")",
";",
"check_irq_on",
"(",
")",
";",
"mutex_unlock",
"(",
"&",
"slab_mutex",
")",
";",
"next_reap_node",
"(",
")",
";",
"out",
":",
"schedule_delayed_work",
"(",
"work",
",",
"round_jiffies_relative",
"(",
"REAPTIMEOUT_CPUC",
")",
")",
";",
"}"
] | cache_reap - Reclaim memory from caches. | [
"cache_reap",
"-",
"Reclaim",
"memory",
"from",
"caches",
"."
] | [
"/* Give up. Setup the next iteration. */",
"//list_for_each_entry(searchp, &slab_caches, list) {",
"/*\n\t\t * We only take the node lock if absolutely necessary and we\n\t\t * have established with reasonable certainty that\n\t\t * we can do some work if the lock was obtained.\n\t\t */",
"/*\n\t\t * These are racy checks but it does not matter\n\t\t * if we skip one check or scan twice.\n\t\t */",
"//}",
"/* Set up the next iteration */"
] | [
{
"param": "w",
"type": "struct work_struct"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "w",
"type": "struct work_struct",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31d702e462500fc09f0d782245e8d470ee2e504f | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/mm/slab.c | [
"Apache-2.0"
] | C | ksize | size_t | size_t ksize(const void *objp)
{
BUG_ON(!objp);
if (unlikely(objp == ZERO_SIZE_PTR))
return 0;
return virt_to_cache(objp)->object_size;
} | /**
* ksize - get the actual amount of memory allocated for a given object
* @objp: Pointer to the object
*
* kmalloc may internally round up allocations and return more memory
* than requested. ksize() can be used to determine the actual amount of
* memory allocated. The caller may use this additional memory, even though
* a smaller amount of memory was initially specified with the kmalloc call.
* The caller must guarantee that objp points to a valid object previously
* allocated with either kmalloc() or kmem_cache_alloc(). The object
* must not be freed during the duration of the call.
*/ | get the actual amount of memory allocated for a given object
@objp: Pointer to the object
kmalloc may internally round up allocations and return more memory
than requested. ksize() can be used to determine the actual amount of
memory allocated. The caller may use this additional memory, even though
a smaller amount of memory was initially specified with the kmalloc call.
The caller must guarantee that objp points to a valid object previously
allocated with either kmalloc() or kmem_cache_alloc(). The object
must not be freed during the duration of the call. | [
"get",
"the",
"actual",
"amount",
"of",
"memory",
"allocated",
"for",
"a",
"given",
"object",
"@objp",
":",
"Pointer",
"to",
"the",
"object",
"kmalloc",
"may",
"internally",
"round",
"up",
"allocations",
"and",
"return",
"more",
"memory",
"than",
"requested",
".",
"ksize",
"()",
"can",
"be",
"used",
"to",
"determine",
"the",
"actual",
"amount",
"of",
"memory",
"allocated",
".",
"The",
"caller",
"may",
"use",
"this",
"additional",
"memory",
"even",
"though",
"a",
"smaller",
"amount",
"of",
"memory",
"was",
"initially",
"specified",
"with",
"the",
"kmalloc",
"call",
".",
"The",
"caller",
"must",
"guarantee",
"that",
"objp",
"points",
"to",
"a",
"valid",
"object",
"previously",
"allocated",
"with",
"either",
"kmalloc",
"()",
"or",
"kmem_cache_alloc",
"()",
".",
"The",
"object",
"must",
"not",
"be",
"freed",
"during",
"the",
"duration",
"of",
"the",
"call",
"."
] | size_t ksize(const void *objp)
{
BUG_ON(!objp);
if (unlikely(objp == ZERO_SIZE_PTR))
return 0;
return virt_to_cache(objp)->object_size;
} | [
"size_t",
"ksize",
"(",
"const",
"void",
"*",
"objp",
")",
"{",
"BUG_ON",
"(",
"!",
"objp",
")",
";",
"if",
"(",
"unlikely",
"(",
"objp",
"==",
"ZERO_SIZE_PTR",
")",
")",
"return",
"0",
";",
"return",
"virt_to_cache",
"(",
"objp",
")",
"->",
"object_size",
";",
"}"
] | ksize - get the actual amount of memory allocated for a given object
@objp: Pointer to the object | [
"ksize",
"-",
"get",
"the",
"actual",
"amount",
"of",
"memory",
"allocated",
"for",
"a",
"given",
"object",
"@objp",
":",
"Pointer",
"to",
"the",
"object"
] | [] | [
{
"param": "objp",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "objp",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2 | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/block/cfq-iosched.c | [
"Apache-2.0"
] | C | cfqg_stats_update_group_wait_time | void | static void cfqg_stats_update_group_wait_time(struct cfqg_stats *stats)
{
unsigned long long now;
if (!cfqg_stats_waiting(stats))
return;
now = sched_clock();
if (time_after64(now, stats->start_group_wait_time))
blkg_stat_add(&stats->group_wait_time,
now - stats->start_group_wait_time);
cfqg_stats_clear_waiting(stats);
} | /* This should be called with the queue_lock held. */ | This should be called with the queue_lock held. | [
"This",
"should",
"be",
"called",
"with",
"the",
"queue_lock",
"held",
"."
] | static void cfqg_stats_update_group_wait_time(struct cfqg_stats *stats)
{
unsigned long long now;
if (!cfqg_stats_waiting(stats))
return;
now = sched_clock();
if (time_after64(now, stats->start_group_wait_time))
blkg_stat_add(&stats->group_wait_time,
now - stats->start_group_wait_time);
cfqg_stats_clear_waiting(stats);
} | [
"static",
"void",
"cfqg_stats_update_group_wait_time",
"(",
"struct",
"cfqg_stats",
"*",
"stats",
")",
"{",
"unsigned",
"long",
"long",
"now",
";",
"if",
"(",
"!",
"cfqg_stats_waiting",
"(",
"stats",
")",
")",
"return",
";",
"now",
"=",
"sched_clock",
"(",
")",
";",
"if",
"(",
"time_after64",
"(",
"now",
",",
"stats",
"->",
"start_group_wait_time",
")",
")",
"blkg_stat_add",
"(",
"&",
"stats",
"->",
"group_wait_time",
",",
"now",
"-",
"stats",
"->",
"start_group_wait_time",
")",
";",
"cfqg_stats_clear_waiting",
"(",
"stats",
")",
";",
"}"
] | This should be called with the queue_lock held. | [
"This",
"should",
"be",
"called",
"with",
"the",
"queue_lock",
"held",
"."
] | [] | [
{
"param": "stats",
"type": "struct cfqg_stats"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stats",
"type": "struct cfqg_stats",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2 | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/block/cfq-iosched.c | [
"Apache-2.0"
] | C | cfqg_stats_set_start_group_wait_time | void | static void cfqg_stats_set_start_group_wait_time(struct cfq_group *cfqg,
struct cfq_group *curr_cfqg)
{
struct cfqg_stats *stats = &cfqg->stats;
if (cfqg_stats_waiting(stats))
return;
if (cfqg == curr_cfqg)
return;
stats->start_group_wait_time = sched_clock();
cfqg_stats_mark_waiting(stats);
} | /* This should be called with the queue_lock held. */ | This should be called with the queue_lock held. | [
"This",
"should",
"be",
"called",
"with",
"the",
"queue_lock",
"held",
"."
] | static void cfqg_stats_set_start_group_wait_time(struct cfq_group *cfqg,
struct cfq_group *curr_cfqg)
{
struct cfqg_stats *stats = &cfqg->stats;
if (cfqg_stats_waiting(stats))
return;
if (cfqg == curr_cfqg)
return;
stats->start_group_wait_time = sched_clock();
cfqg_stats_mark_waiting(stats);
} | [
"static",
"void",
"cfqg_stats_set_start_group_wait_time",
"(",
"struct",
"cfq_group",
"*",
"cfqg",
",",
"struct",
"cfq_group",
"*",
"curr_cfqg",
")",
"{",
"struct",
"cfqg_stats",
"*",
"stats",
"=",
"&",
"cfqg",
"->",
"stats",
";",
"if",
"(",
"cfqg_stats_waiting",
"(",
"stats",
")",
")",
"return",
";",
"if",
"(",
"cfqg",
"==",
"curr_cfqg",
")",
"return",
";",
"stats",
"->",
"start_group_wait_time",
"=",
"sched_clock",
"(",
")",
";",
"cfqg_stats_mark_waiting",
"(",
"stats",
")",
";",
"}"
] | This should be called with the queue_lock held. | [
"This",
"should",
"be",
"called",
"with",
"the",
"queue_lock",
"held",
"."
] | [] | [
{
"param": "cfqg",
"type": "struct cfq_group"
},
{
"param": "curr_cfqg",
"type": "struct cfq_group"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cfqg",
"type": "struct cfq_group",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "curr_cfqg",
"type": "struct cfq_group",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2 | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/block/cfq-iosched.c | [
"Apache-2.0"
] | C | cfqg_stats_end_empty_time | void | static void cfqg_stats_end_empty_time(struct cfqg_stats *stats)
{
unsigned long long now;
if (!cfqg_stats_empty(stats))
return;
now = sched_clock();
if (time_after64(now, stats->start_empty_time))
blkg_stat_add(&stats->empty_time,
now - stats->start_empty_time);
cfqg_stats_clear_empty(stats);
} | /* This should be called with the queue_lock held. */ | This should be called with the queue_lock held. | [
"This",
"should",
"be",
"called",
"with",
"the",
"queue_lock",
"held",
"."
] | static void cfqg_stats_end_empty_time(struct cfqg_stats *stats)
{
unsigned long long now;
if (!cfqg_stats_empty(stats))
return;
now = sched_clock();
if (time_after64(now, stats->start_empty_time))
blkg_stat_add(&stats->empty_time,
now - stats->start_empty_time);
cfqg_stats_clear_empty(stats);
} | [
"static",
"void",
"cfqg_stats_end_empty_time",
"(",
"struct",
"cfqg_stats",
"*",
"stats",
")",
"{",
"unsigned",
"long",
"long",
"now",
";",
"if",
"(",
"!",
"cfqg_stats_empty",
"(",
"stats",
")",
")",
"return",
";",
"now",
"=",
"sched_clock",
"(",
")",
";",
"if",
"(",
"time_after64",
"(",
"now",
",",
"stats",
"->",
"start_empty_time",
")",
")",
"blkg_stat_add",
"(",
"&",
"stats",
"->",
"empty_time",
",",
"now",
"-",
"stats",
"->",
"start_empty_time",
")",
";",
"cfqg_stats_clear_empty",
"(",
"stats",
")",
";",
"}"
] | This should be called with the queue_lock held. | [
"This",
"should",
"be",
"called",
"with",
"the",
"queue_lock",
"held",
"."
] | [] | [
{
"param": "stats",
"type": "struct cfqg_stats"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stats",
"type": "struct cfqg_stats",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2 | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/block/cfq-iosched.c | [
"Apache-2.0"
] | C | cfq_schedule_dispatch | void | static inline void cfq_schedule_dispatch(struct cfq_data *cfqd)
{
if (cfqd->busy_queues) {
cfq_log(cfqd, "schedule dispatch");
kblockd_schedule_work(cfqd->queue, &cfqd->unplug_work);
}
} | /*
* scheduler run of queue, if there are requests pending and no one in the
* driver that will restart queueing
*/ | scheduler run of queue, if there are requests pending and no one in the
driver that will restart queueing | [
"scheduler",
"run",
"of",
"queue",
"if",
"there",
"are",
"requests",
"pending",
"and",
"no",
"one",
"in",
"the",
"driver",
"that",
"will",
"restart",
"queueing"
] | static inline void cfq_schedule_dispatch(struct cfq_data *cfqd)
{
if (cfqd->busy_queues) {
cfq_log(cfqd, "schedule dispatch");
kblockd_schedule_work(cfqd->queue, &cfqd->unplug_work);
}
} | [
"static",
"inline",
"void",
"cfq_schedule_dispatch",
"(",
"struct",
"cfq_data",
"*",
"cfqd",
")",
"{",
"if",
"(",
"cfqd",
"->",
"busy_queues",
")",
"{",
"cfq_log",
"(",
"cfqd",
",",
"\"",
"\"",
")",
";",
"kblockd_schedule_work",
"(",
"cfqd",
"->",
"queue",
",",
"&",
"cfqd",
"->",
"unplug_work",
")",
";",
"}",
"}"
] | scheduler run of queue, if there are requests pending and no one in the
driver that will restart queueing | [
"scheduler",
"run",
"of",
"queue",
"if",
"there",
"are",
"requests",
"pending",
"and",
"no",
"one",
"in",
"the",
"driver",
"that",
"will",
"restart",
"queueing"
] | [] | [
{
"param": "cfqd",
"type": "struct cfq_data"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cfqd",
"type": "struct cfq_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2 | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/block/cfq-iosched.c | [
"Apache-2.0"
] | C | cfq_prio_slice | int | static inline int cfq_prio_slice(struct cfq_data *cfqd, bool sync,
unsigned short prio)
{
const int base_slice = cfqd->cfq_slice[sync];
WARN_ON(prio >= IOPRIO_BE_NR);
return base_slice + (base_slice/CFQ_SLICE_SCALE * (4 - prio));
} | /*
* Scale schedule slice based on io priority. Use the sync time slice only
* if a queue is marked sync and has sync io queued. A sync queue with async
* io only, should not get full sync slice length.
*/ | Scale schedule slice based on io priority. Use the sync time slice only
if a queue is marked sync and has sync io queued. A sync queue with async
io only, should not get full sync slice length. | [
"Scale",
"schedule",
"slice",
"based",
"on",
"io",
"priority",
".",
"Use",
"the",
"sync",
"time",
"slice",
"only",
"if",
"a",
"queue",
"is",
"marked",
"sync",
"and",
"has",
"sync",
"io",
"queued",
".",
"A",
"sync",
"queue",
"with",
"async",
"io",
"only",
"should",
"not",
"get",
"full",
"sync",
"slice",
"length",
"."
] | static inline int cfq_prio_slice(struct cfq_data *cfqd, bool sync,
unsigned short prio)
{
const int base_slice = cfqd->cfq_slice[sync];
WARN_ON(prio >= IOPRIO_BE_NR);
return base_slice + (base_slice/CFQ_SLICE_SCALE * (4 - prio));
} | [
"static",
"inline",
"int",
"cfq_prio_slice",
"(",
"struct",
"cfq_data",
"*",
"cfqd",
",",
"bool",
"sync",
",",
"unsigned",
"short",
"prio",
")",
"{",
"const",
"int",
"base_slice",
"=",
"cfqd",
"->",
"cfq_slice",
"[",
"sync",
"]",
";",
"WARN_ON",
"(",
"prio",
">=",
"IOPRIO_BE_NR",
")",
";",
"return",
"base_slice",
"+",
"(",
"base_slice",
"/",
"CFQ_SLICE_SCALE",
"*",
"(",
"4",
"-",
"prio",
")",
")",
";",
"}"
] | Scale schedule slice based on io priority. | [
"Scale",
"schedule",
"slice",
"based",
"on",
"io",
"priority",
"."
] | [] | [
{
"param": "cfqd",
"type": "struct cfq_data"
},
{
"param": "sync",
"type": "bool"
},
{
"param": "prio",
"type": "unsigned short"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cfqd",
"type": "struct cfq_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sync",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "prio",
"type": "unsigned short",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2 | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/block/cfq-iosched.c | [
"Apache-2.0"
] | C | cfq_group_get_avg_queues | null | static inline unsigned cfq_group_get_avg_queues(struct cfq_data *cfqd,
struct cfq_group *cfqg, bool rt)
{
unsigned min_q, max_q;
unsigned mult = cfq_hist_divisor - 1;
unsigned round = cfq_hist_divisor / 2;
unsigned busy = cfq_group_busy_queues_wl(rt, cfqd, cfqg);
min_q = min(cfqg->busy_queues_avg[rt], busy);
max_q = max(cfqg->busy_queues_avg[rt], busy);
cfqg->busy_queues_avg[rt] = (mult * max_q + min_q + round) /
cfq_hist_divisor;
return cfqg->busy_queues_avg[rt];
} | /*
* get averaged number of queues of RT/BE priority.
* average is updated, with a formula that gives more weight to higher numbers,
* to quickly follows sudden increases and decrease slowly
*/ | get averaged number of queues of RT/BE priority.
average is updated, with a formula that gives more weight to higher numbers,
to quickly follows sudden increases and decrease slowly | [
"get",
"averaged",
"number",
"of",
"queues",
"of",
"RT",
"/",
"BE",
"priority",
".",
"average",
"is",
"updated",
"with",
"a",
"formula",
"that",
"gives",
"more",
"weight",
"to",
"higher",
"numbers",
"to",
"quickly",
"follows",
"sudden",
"increases",
"and",
"decrease",
"slowly"
] | static inline unsigned cfq_group_get_avg_queues(struct cfq_data *cfqd,
struct cfq_group *cfqg, bool rt)
{
unsigned min_q, max_q;
unsigned mult = cfq_hist_divisor - 1;
unsigned round = cfq_hist_divisor / 2;
unsigned busy = cfq_group_busy_queues_wl(rt, cfqd, cfqg);
min_q = min(cfqg->busy_queues_avg[rt], busy);
max_q = max(cfqg->busy_queues_avg[rt], busy);
cfqg->busy_queues_avg[rt] = (mult * max_q + min_q + round) /
cfq_hist_divisor;
return cfqg->busy_queues_avg[rt];
} | [
"static",
"inline",
"unsigned",
"cfq_group_get_avg_queues",
"(",
"struct",
"cfq_data",
"*",
"cfqd",
",",
"struct",
"cfq_group",
"*",
"cfqg",
",",
"bool",
"rt",
")",
"{",
"unsigned",
"min_q",
",",
"max_q",
";",
"unsigned",
"mult",
"=",
"cfq_hist_divisor",
"-",
"1",
";",
"unsigned",
"round",
"=",
"cfq_hist_divisor",
"/",
"2",
";",
"unsigned",
"busy",
"=",
"cfq_group_busy_queues_wl",
"(",
"rt",
",",
"cfqd",
",",
"cfqg",
")",
";",
"min_q",
"=",
"min",
"(",
"cfqg",
"->",
"busy_queues_avg",
"[",
"rt",
"]",
",",
"busy",
")",
";",
"max_q",
"=",
"max",
"(",
"cfqg",
"->",
"busy_queues_avg",
"[",
"rt",
"]",
",",
"busy",
")",
";",
"cfqg",
"->",
"busy_queues_avg",
"[",
"rt",
"]",
"=",
"(",
"mult",
"*",
"max_q",
"+",
"min_q",
"+",
"round",
")",
"/",
"cfq_hist_divisor",
";",
"return",
"cfqg",
"->",
"busy_queues_avg",
"[",
"rt",
"]",
";",
"}"
] | get averaged number of queues of RT/BE priority. | [
"get",
"averaged",
"number",
"of",
"queues",
"of",
"RT",
"/",
"BE",
"priority",
"."
] | [] | [
{
"param": "cfqd",
"type": "struct cfq_data"
},
{
"param": "cfqg",
"type": "struct cfq_group"
},
{
"param": "rt",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cfqd",
"type": "struct cfq_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cfqg",
"type": "struct cfq_group",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rt",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2 | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/block/cfq-iosched.c | [
"Apache-2.0"
] | C | cfq_slice_used | bool | static inline bool cfq_slice_used(struct cfq_queue *cfqq)
{
if (cfq_cfqq_slice_new(cfqq))
return false;
if (time_before(jiffies, cfqq->slice_end))
return false;
return true;
} | /*
* We need to wrap this check in cfq_cfqq_slice_new(), since ->slice_end
* isn't valid until the first request from the dispatch is activated
* and the slice time set.
*/ | We need to wrap this check in cfq_cfqq_slice_new(), since ->slice_end
isn't valid until the first request from the dispatch is activated
and the slice time set. | [
"We",
"need",
"to",
"wrap",
"this",
"check",
"in",
"cfq_cfqq_slice_new",
"()",
"since",
"-",
">",
"slice_end",
"isn",
"'",
"t",
"valid",
"until",
"the",
"first",
"request",
"from",
"the",
"dispatch",
"is",
"activated",
"and",
"the",
"slice",
"time",
"set",
"."
] | static inline bool cfq_slice_used(struct cfq_queue *cfqq)
{
if (cfq_cfqq_slice_new(cfqq))
return false;
if (time_before(jiffies, cfqq->slice_end))
return false;
return true;
} | [
"static",
"inline",
"bool",
"cfq_slice_used",
"(",
"struct",
"cfq_queue",
"*",
"cfqq",
")",
"{",
"if",
"(",
"cfq_cfqq_slice_new",
"(",
"cfqq",
")",
")",
"return",
"false",
";",
"if",
"(",
"time_before",
"(",
"jiffies",
",",
"cfqq",
"->",
"slice_end",
")",
")",
"return",
"false",
";",
"return",
"true",
";",
"}"
] | We need to wrap this check in cfq_cfqq_slice_new(), since ->slice_end
isn't valid until the first request from the dispatch is activated
and the slice time set. | [
"We",
"need",
"to",
"wrap",
"this",
"check",
"in",
"cfq_cfqq_slice_new",
"()",
"since",
"-",
">",
"slice_end",
"isn",
"'",
"t",
"valid",
"until",
"the",
"first",
"request",
"from",
"the",
"dispatch",
"is",
"activated",
"and",
"the",
"slice",
"time",
"set",
"."
] | [] | [
{
"param": "cfqq",
"type": "struct cfq_queue"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cfqq",
"type": "struct cfq_queue",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2 | Gu-Youngfeng/TenSamplingStudy2 | bugs/linux/block/cfq-iosched.c | [
"Apache-2.0"
] | C | cfq_choose_req | null | static struct request *
cfq_choose_req(struct cfq_data *cfqd, struct request *rq1, struct request *rq2, sector_t last)
{
sector_t s1, s2, d1 = 0, d2 = 0;
unsigned long back_max;
#define CFQ_RQ1_WRAP 0x01 /* request 1 wraps */
#define CFQ_RQ2_WRAP 0x02 /* request 2 wraps */
unsigned wrap = 0; /* bit mask: requests behind the disk head? */
if (rq1 == NULL || rq1 == rq2)
return rq2;
if (rq2 == NULL)
return rq1;
if (rq_is_sync(rq1) != rq_is_sync(rq2))
return rq_is_sync(rq1) ? rq1 : rq2;
if ((rq1->cmd_flags ^ rq2->cmd_flags) & REQ_PRIO)
return rq1->cmd_flags & REQ_PRIO ? rq1 : rq2;
s1 = blk_rq_pos(rq1);
s2 = blk_rq_pos(rq2);
/*
* by definition, 1KiB is 2 sectors
*/
back_max = cfqd->cfq_back_max * 2;
/*
* Strict one way elevator _except_ in the case where we allow
* short backward seeks which are biased as twice the cost of a
* similar forward seek.
*/
if (s1 >= last)
d1 = s1 - last;
else if (s1 + back_max >= last)
d1 = (last - s1) * cfqd->cfq_back_penalty;
else
wrap |= CFQ_RQ1_WRAP;
if (s2 >= last)
d2 = s2 - last;
else if (s2 + back_max >= last)
d2 = (last - s2) * cfqd->cfq_back_penalty;
else
wrap |= CFQ_RQ2_WRAP;
/* Found required data */
/*
* By doing switch() on the bit mask "wrap" we avoid having to
* check two variables for all permutations: --> faster!
*/
switch (wrap) {
case 0: /* common case for CFQ: rq1 and rq2 not wrapped */
if (d1 < d2)
return rq1;
else if (d2 < d1)
return rq2;
else {
if (s1 >= s2)
return rq1;
else
return rq2;
}
case CFQ_RQ2_WRAP:
return rq1;
case CFQ_RQ1_WRAP:
return rq2;
case (CFQ_RQ1_WRAP|CFQ_RQ2_WRAP): /* both rqs wrapped */
default:
/*
* Since both rqs are wrapped,
* start with the one that's further behind head
* (--> only *one* back seek required),
* since back seek takes more time than forward.
*/
if (s1 <= s2)
return rq1;
else
return rq2;
}
} | /*
* Lifted from AS - choose which of rq1 and rq2 that is best served now.
* We choose the request that is closest to the head right now. Distance
* behind the head is penalized and only allowed to a certain extent.
*/ | Lifted from AS - choose which of rq1 and rq2 that is best served now.
We choose the request that is closest to the head right now. Distance
behind the head is penalized and only allowed to a certain extent. | [
"Lifted",
"from",
"AS",
"-",
"choose",
"which",
"of",
"rq1",
"and",
"rq2",
"that",
"is",
"best",
"served",
"now",
".",
"We",
"choose",
"the",
"request",
"that",
"is",
"closest",
"to",
"the",
"head",
"right",
"now",
".",
"Distance",
"behind",
"the",
"head",
"is",
"penalized",
"and",
"only",
"allowed",
"to",
"a",
"certain",
"extent",
"."
] | static struct request *
cfq_choose_req(struct cfq_data *cfqd, struct request *rq1, struct request *rq2, sector_t last)
{
sector_t s1, s2, d1 = 0, d2 = 0;
unsigned long back_max;
#define CFQ_RQ1_WRAP 0x01 /* request 1 wraps */
#define CFQ_RQ2_WRAP 0x02 /* request 2 wraps */
unsigned wrap = 0;
if (rq1 == NULL || rq1 == rq2)
return rq2;
if (rq2 == NULL)
return rq1;
if (rq_is_sync(rq1) != rq_is_sync(rq2))
return rq_is_sync(rq1) ? rq1 : rq2;
if ((rq1->cmd_flags ^ rq2->cmd_flags) & REQ_PRIO)
return rq1->cmd_flags & REQ_PRIO ? rq1 : rq2;
s1 = blk_rq_pos(rq1);
s2 = blk_rq_pos(rq2);
back_max = cfqd->cfq_back_max * 2;
if (s1 >= last)
d1 = s1 - last;
else if (s1 + back_max >= last)
d1 = (last - s1) * cfqd->cfq_back_penalty;
else
wrap |= CFQ_RQ1_WRAP;
if (s2 >= last)
d2 = s2 - last;
else if (s2 + back_max >= last)
d2 = (last - s2) * cfqd->cfq_back_penalty;
else
wrap |= CFQ_RQ2_WRAP;
switch (wrap) {
case 0:
if (d1 < d2)
return rq1;
else if (d2 < d1)
return rq2;
else {
if (s1 >= s2)
return rq1;
else
return rq2;
}
case CFQ_RQ2_WRAP:
return rq1;
case CFQ_RQ1_WRAP:
return rq2;
case (CFQ_RQ1_WRAP|CFQ_RQ2_WRAP):
default:
if (s1 <= s2)
return rq1;
else
return rq2;
}
} | [
"static",
"struct",
"request",
"*",
"cfq_choose_req",
"(",
"struct",
"cfq_data",
"*",
"cfqd",
",",
"struct",
"request",
"*",
"rq1",
",",
"struct",
"request",
"*",
"rq2",
",",
"sector_t",
"last",
")",
"{",
"sector_t",
"s1",
",",
"s2",
",",
"d1",
"=",
"0",
",",
"d2",
"=",
"0",
";",
"unsigned",
"long",
"back_max",
";",
"#define",
"CFQ_RQ1_WRAP",
"\t0x01 /* request 1 wraps */",
"\n",
"#define",
"CFQ_RQ2_WRAP",
"\t0x02 /* request 2 wraps */",
"\n",
"unsigned",
"wrap",
"=",
"0",
";",
"if",
"(",
"rq1",
"==",
"NULL",
"||",
"rq1",
"==",
"rq2",
")",
"return",
"rq2",
";",
"if",
"(",
"rq2",
"==",
"NULL",
")",
"return",
"rq1",
";",
"if",
"(",
"rq_is_sync",
"(",
"rq1",
")",
"!=",
"rq_is_sync",
"(",
"rq2",
")",
")",
"return",
"rq_is_sync",
"(",
"rq1",
")",
"?",
"rq1",
":",
"rq2",
";",
"if",
"(",
"(",
"rq1",
"->",
"cmd_flags",
"^",
"rq2",
"->",
"cmd_flags",
")",
"&",
"REQ_PRIO",
")",
"return",
"rq1",
"->",
"cmd_flags",
"&",
"REQ_PRIO",
"?",
"rq1",
":",
"rq2",
";",
"s1",
"=",
"blk_rq_pos",
"(",
"rq1",
")",
";",
"s2",
"=",
"blk_rq_pos",
"(",
"rq2",
")",
";",
"back_max",
"=",
"cfqd",
"->",
"cfq_back_max",
"*",
"2",
";",
"if",
"(",
"s1",
">=",
"last",
")",
"d1",
"=",
"s1",
"-",
"last",
";",
"else",
"if",
"(",
"s1",
"+",
"back_max",
">=",
"last",
")",
"d1",
"=",
"(",
"last",
"-",
"s1",
")",
"*",
"cfqd",
"->",
"cfq_back_penalty",
";",
"else",
"wrap",
"|=",
"CFQ_RQ1_WRAP",
";",
"if",
"(",
"s2",
">=",
"last",
")",
"d2",
"=",
"s2",
"-",
"last",
";",
"else",
"if",
"(",
"s2",
"+",
"back_max",
">=",
"last",
")",
"d2",
"=",
"(",
"last",
"-",
"s2",
")",
"*",
"cfqd",
"->",
"cfq_back_penalty",
";",
"else",
"wrap",
"|=",
"CFQ_RQ2_WRAP",
";",
"switch",
"(",
"wrap",
")",
"{",
"case",
"0",
":",
"if",
"(",
"d1",
"<",
"d2",
")",
"return",
"rq1",
";",
"else",
"if",
"(",
"d2",
"<",
"d1",
")",
"return",
"rq2",
";",
"else",
"{",
"if",
"(",
"s1",
">=",
"s2",
")",
"return",
"rq1",
";",
"else",
"return",
"rq2",
";",
"}",
"case",
"CFQ_RQ2_WRAP",
":",
"return",
"rq1",
";",
"case",
"CFQ_RQ1_WRAP",
":",
"return",
"rq2",
";",
"case",
"(",
"CFQ_RQ1_WRAP",
"|",
"CFQ_RQ2_WRAP",
")",
":",
"default",
":",
"if",
"(",
"s1",
"<=",
"s2",
")",
"return",
"rq1",
";",
"else",
"return",
"rq2",
";",
"}",
"}"
] | Lifted from AS - choose which of rq1 and rq2 that is best served now. | [
"Lifted",
"from",
"AS",
"-",
"choose",
"which",
"of",
"rq1",
"and",
"rq2",
"that",
"is",
"best",
"served",
"now",
"."
] | [
"/* bit mask: requests behind the disk head? */",
"/*\n\t * by definition, 1KiB is 2 sectors\n\t */",
"/*\n\t * Strict one way elevator _except_ in the case where we allow\n\t * short backward seeks which are biased as twice the cost of a\n\t * similar forward seek.\n\t */",
"/* Found required data */",
"/*\n\t * By doing switch() on the bit mask \"wrap\" we avoid having to\n\t * check two variables for all permutations: --> faster!\n\t */",
"/* common case for CFQ: rq1 and rq2 not wrapped */",
"/* both rqs wrapped */",
"/*\n\t\t * Since both rqs are wrapped,\n\t\t * start with the one that's further behind head\n\t\t * (--> only *one* back seek required),\n\t\t * since back seek takes more time than forward.\n\t\t */"
] | [
{
"param": "cfqd",
"type": "struct cfq_data"
},
{
"param": "rq1",
"type": "struct request"
},
{
"param": "rq2",
"type": "struct request"
},
{
"param": "last",
"type": "sector_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cfqd",
"type": "struct cfq_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rq1",
"type": "struct request",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rq2",
"type": "struct request",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "last",
"type": "sector_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.