Fix coding style issues.

Some checkpatch issues were solved by scripts leaving other problems
such as alignment and indentation issues.  In order to comply with the
defined coding style the following fixes were made:

- Fixed the function declaration moving the parameters' comments above
  the function in accordance to the doxygen format.
- Fixed functions' opening and closing brackets. These brackets should
  not be indented.
- Fixed the 'if', 'for' and 'while' statements adding the brackets
  around the sentence.
- Fixed comments' alignment.
- Fixed indentation.

The work was done manually and submitted as one commit. I didn't
separate these changes in different commits because they were fixed all
at once. Basically, all errors were fixed in every file at once.

Change-Id: Icc94a10bfd2cff82007ce60df23b2ccd4c30268d
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
This commit is contained in:
Yonattan Louise 2015-05-14 16:30:48 -05:00 committed by Anas Nashif
commit dbada63eee
95 changed files with 4179 additions and 4030 deletions

View file

@ -121,7 +121,6 @@ void irq_handler_set(unsigned int vector,
if (opcodeOff == opcodeOffToMatch) {
/* match found -> write new routine and parameter */
UNALIGNED_WRITE(
(unsigned int *)&pIntStubMem[ix + 1],
(unsigned int)newRoutine -

View file

@ -58,14 +58,16 @@ This module implements the PCI config space access functions
*
* pci_config_out_long - write a 32bit data to pci reg in offset
*
* @param bus_no Bus number.
* @param device_no Device number
* @param func_no Function number
* @param offset Offset into the configuration space.
* @param data Data written to the offset.
*
* RETURNS: N/A
*/
void pci_config_out_long(uint32_t bus_no, /* bus number */
uint32_t device_no, /* device number */
uint32_t func_no, /* function number */
uint32_t offset, /* offset into the configuration space */
uint32_t data /* data written to the offset */
)
void pci_config_out_long(uint32_t bus_no, uint32_t device_no, uint32_t func_no,
uint32_t offset, uint32_t data)
{
union pci_addr_reg pci_addr;
@ -86,14 +88,16 @@ void pci_config_out_long(uint32_t bus_no, /* bus number */
*
* pci_config_out_word - write a 16bit data to pci reg in offset
*
* @param bus_no Bus number.
* @param device_no Device number.
* @param func_no Function number.
* @param offset Offset into the configuration space.
* @param data Data written to the offset.
*
* RETURNS: N/A
*/
void pci_config_out_word(uint32_t bus_no, /* bus number */
uint32_t device_no, /* device number */
uint32_t func_no, /* function number */
uint32_t offset, /* offset into the configuration space */
uint16_t data /* data written to the offset */
)
void pci_config_out_word(uint32_t bus_no, uint32_t device_no, uint32_t func_no,
uint32_t offset, uint16_t data)
{
union pci_addr_reg pci_addr;
@ -114,14 +118,16 @@ void pci_config_out_word(uint32_t bus_no, /* bus number */
*
* pci_config_out_byte - write a 8bit data to pci reg in offset
*
* @param bus_no Bus number.
* @param device_no Device number.
* @param func_no Function number.
* @param offset Offset into the configuration space.
* @param data Data written to the offset.
*
* RETURNS: N/A
*/
void pci_config_out_byte(uint32_t bus_no, /* bus number */
uint32_t device_no, /* device number */
uint32_t func_no, /* function number */
uint32_t offset, /* offset into the configuration space */
uint8_t data /* data written to the offset */
)
void pci_config_out_byte(uint32_t bus_no, uint32_t device_no, uint32_t func_no,
uint32_t offset, uint8_t data)
{
union pci_addr_reg pci_addr;
@ -142,15 +148,17 @@ void pci_config_out_byte(uint32_t bus_no, /* bus number */
*
* pci_config_in_long - read a 32bit data from pci reg in offset
*
* @param bus_no Bus number.
* @param device_no Device number.
* @param func_no Function number.
* @param offset Offset into the configuration space.
* @param data Data read from the offset.
*
* RETURNS: N/A
*
*/
void pci_config_in_long(uint32_t bus_no, /* bus number */
uint32_t device_no, /* device number */
uint32_t func_no, /* function number */
uint32_t offset, /* offset into the configuration space */
uint32_t *data /* data read from the offset */
)
void pci_config_in_long(uint32_t bus_no, uint32_t device_no, uint32_t func_no,
uint32_t offset, uint32_t *data)
{
union pci_addr_reg pci_addr;
@ -171,16 +179,18 @@ void pci_config_in_long(uint32_t bus_no, /* bus number */
*
* pci_config_in_word - read in a 16bit data from a pci reg in offset
*
* @param bus_no Bus number.
* @param device_no Device number.
* @param func_no Function number.
* @param offset Offset into the configuration space.
* @param data Data read from the offset.
*
* RETURNS: N/A
*
*/
void pci_config_in_word(uint32_t bus_no, /* bus number */
uint32_t device_no, /* device number */
uint32_t func_no, /* function number */
uint32_t offset, /* offset into the configuration space */
uint16_t *data /* data read from the offset */
)
void pci_config_in_word(uint32_t bus_no, uint32_t device_no, uint32_t func_no,
uint32_t offset, uint16_t *data)
{
union pci_addr_reg pci_addr;
uint32_t pci_data;
@ -206,16 +216,18 @@ void pci_config_in_word(uint32_t bus_no, /* bus number */
*
* pci_config_in_byte - read in a 8bit data from a pci reg in offset
*
* @param bus_no Bus number.
* @param device_no Device number.
* @param func_no Function number.
* @param offset Offset into the configuration space.
* @param data Data read from the offset.
*
* RETURNS: N/A
*
*/
void pci_config_in_byte(uint32_t bus_no, /* bus number */
uint32_t device_no, /* device number */
uint32_t func_no, /* function number */
uint32_t offset, /* offset into the configuration space */
uint8_t *data /* data read from the offset */
)
void pci_config_in_byte(uint32_t bus_no, uint32_t device_no, uint32_t func_no,
uint32_t offset, uint8_t *data)
{
union pci_addr_reg pci_addr;
uint32_t pci_data;
@ -245,17 +257,19 @@ void pci_config_in_byte(uint32_t bus_no, /* bus number */
* capabilities in config space. If found, the offset of the first byte
* of the capability of interest in config space is returned via pOffset.
*
* @param ext_cap_find_id Extended capabilities ID to search for.
* @param bus PCI bus number.
* @param device PCI device number.
* @param function PCI function number.
* @param p_offset Returned config space offset.
*
* RETURNS: 0 if Extended Capability found, -1 otherwise
*
*/
int pci_config_ext_cap_ptr_find(
uint8_t ext_cap_find_id, /* Extended capabilities ID to search for */
uint32_t bus, /* PCI bus number */
uint32_t device, /* PCI device number */
uint32_t function, /* PCI function number */
uint8_t *p_offset /* returned config space offset */
)
int pci_config_ext_cap_ptr_find(uint8_t ext_cap_find_id, uint32_t bus,
uint32_t device, uint32_t function,
uint8_t *p_offset)
{
uint16_t tmp_stat;
uint8_t tmp_offset;
@ -266,8 +280,9 @@ int pci_config_ext_cap_ptr_find(
pci_config_in_word(bus, device, function, PCI_CFG_STATUS, &tmp_stat);
if ((tmp_stat & PCI_STATUS_NEW_CAP) == 0)
if ((tmp_stat & PCI_STATUS_NEW_CAP) == 0) {
return -1;
}
/* Get the initial ECP offset and make longword aligned */
@ -276,8 +291,9 @@ int pci_config_ext_cap_ptr_find(
/* Bounds check the ECP offset */
if (cap_offset < 0x40)
if (cap_offset < 0x40) {
return -1;
}
/* Look for the specified Extended Cap item in the linked list */
@ -294,8 +310,7 @@ int pci_config_ext_cap_ptr_find(
/* Get the offset to the next New Capabilities item */
tmp_offset = cap_offset + (uint8_t)0x01;
pci_config_in_byte(
bus, device, function, (int)tmp_offset, &cap_offset);
pci_config_in_byte(bus, device, function, (int)tmp_offset, &cap_offset);
}
return -1;

View file

@ -33,18 +33,19 @@
#include <stdio.h>
#include <stdlib.h>
void usage(
char *progname /* name of the program to use */
)
/*
*
* @param progname Name of the program to use.
*
*/
void usage(char *progname)
{
fprintf(stderr, "Utility converts decimal numbers to hexadecimal\n");
fprintf(stderr, "Usage: %s <decimal number>\n", progname);
}
int main(
int argc,
char *argv[]
)
int main(int argc, char *argv[])
{
if (argc != 2) {
usage(argv[0]);

View file

@ -212,30 +212,35 @@ static void genIdt(void)
* First find the address of the spurious interrupt handlers. They are the
* contained in the first 8 bytes of the input file.
*/
if (read(fds[IFILE], &spurAddr, 4) < 4)
if (read(fds[IFILE], &spurAddr, 4) < 4) {
goto readError;
}
if (read(fds[IFILE], &spurNoErrAddr, 4) < 4)
if (read(fds[IFILE], &spurNoErrAddr, 4) < 4) {
goto readError;
}
PRINTF("Spurious int handlers found at %p and %p\n",
spurAddr, spurNoErrAddr);
/* Initially fill in the IDT array with the spurious handlers */
for (i = 0; i < numVecs; i++) {
if ((((1 << i) & _EXC_ERROR_CODE_FAULTS)) && (i < 32))
if ((((1 << i) & _EXC_ERROR_CODE_FAULTS)) && (i < 32)) {
idt[i].fnc = spurAddr;
else
}
else {
idt[i].fnc = spurNoErrAddr;
}
}
/*
* Now parse the rest of the input file for the other ISRs. The number of
* entries is the next 4 bytes
*/
if (read(fds[IFILE], &size, 4) < 4)
if (read(fds[IFILE], &size, 4) < 4) {
goto readError;
}
PRINTF("There are %d ISR(s)\n", size);
@ -251,14 +256,17 @@ static void genIdt(void)
unsigned int dpl;
/* Get address */
if (read(fds[IFILE], &addr, 4) < 4)
if (read(fds[IFILE], &addr, 4) < 4) {
goto readError;
}
/* Get vector */
if (read(fds[IFILE], &vec, 4) < 4)
if (read(fds[IFILE], &vec, 4) < 4) {
goto readError;
}
/* Get dpl */
if (read(fds[IFILE], &dpl, 4) < 4)
if (read(fds[IFILE], &dpl, 4) < 4) {
goto readError;
}
PRINTF("ISR @ %p on Vector %d: dpl %d\n", addr, vec, dpl);
idt[vec].fnc = addr;
@ -302,9 +310,7 @@ static void clean_exit(const int exit_code)
static void usage(const int len)
{
fprintf(stderr,
"\n%s -i <input file> -n <n>\n",
filenames[EXECFILE]);
fprintf(stderr, "\n%s -i <input file> -n <n>\n", filenames[EXECFILE]);
if (len == SHORT_USAGE) {
return;

View file

@ -265,11 +265,12 @@ static void swabElfSym(Elf32_Sym *pHdrToSwab)
*
* ehdrLoad - load the ELF header
*
* @param fd File descriptor of file from which to read.
*
* RETURNS: 0 on success, -1 on failure
*/
static int ehdrLoad(int fd /* file descriptor of file from which to read */
)
static int ehdrLoad(int fd)
{
unsigned ix = 0x12345678; /* used to auto-detect endian-ness */
size_t nBytes; /* number of bytes read from file */
@ -324,11 +325,12 @@ static int ehdrLoad(int fd /* file descriptor of file from which to read */
*
* shdrsLoad - load the section headers
*
* @param fd File descriptor of file from which to read.
*
* RETURNS: 0 on success, -1 on failure
*/
int shdrsLoad(int fd /* file descriptor of file from which to read */
)
int shdrsLoad(int fd)
{
size_t nBytes; /* number of bytes read from file */
unsigned ix; /* loop index */
@ -363,12 +365,13 @@ int shdrsLoad(int fd /* file descriptor of file from which to read */
* This routine searches the section headers for the symbol table. There is
* expected to be only one symbol table in the section headers.
*
* @param pSymTblOffset Pointer to symbol table offset.
* @param pSymTblSize Pointer to symbol table size.
*
* RETURNS: 0 if found, -1 if not
*/
int symTblFind(unsigned *pSymTblOffset, /* ptr to symbol table offset */
unsigned *pSymTblSize /* ptr to symbol table size */
)
int symTblFind(unsigned *pSymTblOffset, unsigned *pSymTblSize)
{
unsigned ix; /* loop index */
@ -404,11 +407,12 @@ int symTblFind(unsigned *pSymTblOffset, /* ptr to symbol table offset */
* 2. If another string table is found, use that only if its section header
* index does not match the index for ".shstrtbl" stored in the ELF header.
*
* @param pStrTblIx Pointer to string table's index.
*
* RETURNS 0 if found, -1 if not
*/
int strTblFind(unsigned *pStrTblIx /* ptr to string table's index */
)
int strTblFind(unsigned *pStrTblIx)
{
unsigned strTblIx = 0xffffffff;
unsigned ix;
@ -436,13 +440,14 @@ int strTblFind(unsigned *pStrTblIx /* ptr to string table's index */
*
* strTblLoad - load the string table
*
* @param fd File descriptor of file from which to read.
* @param strTblIx String table's index.
* @param ppStringTable Pointer to ptr to string table.
*
* RETURNS: 0 on success, -1 on failure
*/
int strTblLoad(int fd, /* file descriptor of file from which to read */
unsigned strTblIx, /* string table's index */
char **ppStringTable /* ptr to ptr to string table */
)
int strTblLoad(int fd, unsigned strTblIx, char **ppStringTable)
{
char *pTable;
int nBytes;
@ -474,12 +479,13 @@ int strTblLoad(int fd, /* file descriptor of file from which to read */
*
* headerPreambleDump - dump the header preamble to the header file
*
* @param fp File pointer to which to write.
* @param filename Name of the output file.
*
* RETURNS: N/A
*/
void headerPreambleDump(FILE *fp, /* file pointer to which to write */
char *filename /* name of the output file */
)
void headerPreambleDump(FILE *fp, char *filename)
{
unsigned hash = 5381; /* hash value */
size_t ix; /* loop counter */
@ -508,15 +514,17 @@ void headerPreambleDump(FILE *fp, /* file pointer to which to write */
*
* headerAbsoluteSymbolsDump - dump the absolute symbols to the header file
*
* @param fd File descriptor of file from which to read.
* @param fp File pointer to which to write.
* @param symTblOffset Symbol table offset.
* @param symTblSize Size of the symbol table.
* @param pStringTable Pointer to the string table.
*
* RETURNS: N/A
*/
void headerAbsoluteSymbolsDump(int fd, /* file descriptor of file from which to read */
FILE *fp, /* file pointer to which to write */
Elf32_Off symTblOffset, /* symbol table offset */
Elf32_Word symTblSize, /* size of the symbol table */
char *pStringTable /* ptr to the string table */
)
void headerAbsoluteSymbolsDump(int fd, FILE *fp, Elf32_Off symTblOffset,
Elf32_Word symTblSize, char *pStringTable)
{
Elf32_Sym aSym; /* absolute symbol */
unsigned ix; /* loop counter */
@ -556,11 +564,12 @@ void headerAbsoluteSymbolsDump(int fd, /* file descriptor of file from which t
*
* headerPostscriptDump - dump the header postscript to the header file
*
* @param fp File pointer to which to write.
*
* RETURNS: N/A
*/
void headerPostscriptDump(FILE *fp /* file pointer to which to write */
)
void headerPostscriptDump(FILE *fp)
{
fputs(postscript, fp);
}

View file

@ -40,9 +40,14 @@ in decimal notation. Each event object is outputted on stdout.
#include <stdio.h>
#include <stdlib.h>
void usage(
char *progname /* name of the program to use */
)
/*******************************************************************************
*
* @param progname Name of the program to use.
*
* RETURNS: N/A
*/
void usage(char *progname)
{
fprintf(stderr, "Utility creates a series of microkernel VPF event objects. Output is sent to stdout.\n");
fprintf(stderr, "Usage: %s <decimal number>\n", progname);
@ -50,10 +55,7 @@ void usage(
#define EVENT_STR " EVENT _TaskIrqEvt%d NULL\n"
int main(
int argc,
char *argv[]
)
int main(int argc, char *argv[])
{
int i, j;
@ -63,8 +65,9 @@ int main(
}
j = atoi(argv[1]);
for (i = 0; i < j; i++)
for (i = 0; i < j; i++) {
printf(EVENT_STR, i);
}
return 0;
}

View file

@ -277,8 +277,9 @@ static inline __attribute__((always_inline))
static inline __attribute__((always_inline))
void irq_unlock_inline(unsigned int key)
{
if (!(key & 0x200))
if (!(key & 0x200)) {
return;
}
#ifdef CONFIG_INT_LATENCY_BENCHMARK
_int_latency_stop();
#endif

View file

@ -97,8 +97,7 @@ void BuffReset(struct chbuff *pChBuff)
ReadMarkersClear(pChBuff);
}
void BuffGetFreeSpaceTotal(struct chbuff *pChBuff,
int *piFreeSpaceTotal)
void BuffGetFreeSpaceTotal(struct chbuff *pChBuff, int *piFreeSpaceTotal)
{
int dummy1, dummy2;
*piFreeSpaceTotal = CalcFreeSpace(pChBuff, &dummy1, &dummy2);
@ -106,10 +105,8 @@ void BuffGetFreeSpaceTotal(struct chbuff *pChBuff,
__ASSERT_NO_MSG(dummy2 == pChBuff->iFreeSpaceAWA);
}
void BuffGetFreeSpace(struct chbuff *pChBuff,
int *piFreeSpaceTotal,
int *piFreeSpaceCont,
int *piFreeSpaceAWA)
void BuffGetFreeSpace(struct chbuff *pChBuff, int *piFreeSpaceTotal,
int *piFreeSpaceCont, int *piFreeSpaceAWA)
{
int iFreeSpaceCont;
int iFreeSpaceAWA;
@ -124,8 +121,7 @@ void BuffGetFreeSpace(struct chbuff *pChBuff,
*piFreeSpaceAWA = pChBuff->iFreeSpaceAWA;
}
void BuffGetAvailDataTotal(struct chbuff *pChBuff,
int *piAvailDataTotal)
void BuffGetAvailDataTotal(struct chbuff *pChBuff, int *piAvailDataTotal)
{
int dummy1, dummy2;
*piAvailDataTotal = CalcAvailData(pChBuff, &dummy1, &dummy2);
@ -133,10 +129,8 @@ void BuffGetAvailDataTotal(struct chbuff *pChBuff,
__ASSERT_NO_MSG(dummy2 == pChBuff->iAvailDataAWA);
}
void BuffGetAvailData(struct chbuff *pChBuff,
int *piAvailDataTotal,
int *piAvailDataCont,
int *piAvailDataAWA)
void BuffGetAvailData(struct chbuff *pChBuff, int *piAvailDataTotal,
int *piAvailDataCont, int *piAvailDataAWA)
{
int iAvailDataCont;
int iAvailDataAWA;
@ -159,23 +153,25 @@ int BuffEnQ(struct chbuff *pChBuff, int iSize, unsigned char **ppWrite)
{
int iTransferID;
/* int ret;*/
if (0 == BuffEnQA(pChBuff, iSize, ppWrite, &iTransferID))
if (0 == BuffEnQA(pChBuff, iSize, ppWrite, &iTransferID)) {
return 0;
BuffEnQA_End(pChBuff, iTransferID, iSize /*optional */); /* check ret
value */
}
/* check ret value */
BuffEnQA_End(pChBuff, iTransferID, iSize /*optional */);
return iSize;
}
int BuffEnQA(struct chbuff *pChBuff,
int iSize,
unsigned char **ppWrite,
int BuffEnQA(struct chbuff *pChBuff, int iSize, unsigned char **ppWrite,
int *piTransferID)
{
if (iSize > pChBuff->iFreeSpaceCont)
if (iSize > pChBuff->iFreeSpaceCont) {
return 0;
}
*piTransferID = AsyncEnQRegstr(pChBuff, iSize);
if (-1 == *piTransferID)
if (-1 == *piTransferID) {
return 0;
}
*ppWrite = pChBuff->pWrite;
@ -193,18 +189,19 @@ int BuffEnQA(struct chbuff *pChBuff,
pChBuff->iFreeSpaceCont -= iSize;
}
if (pChBuff->pWrite == pChBuff->pRead)
if (pChBuff->pWrite == pChBuff->pRead) {
pChBuff->BuffState = BUFF_FULL;
else
}
else {
pChBuff->BuffState = BUFF_OTHER;
}
CHECK_CHBUFF_POINTER(pChBuff->pWrite);
return iSize;
}
void BuffEnQA_End(struct chbuff *pChBuff,
int iTransferID,
void BuffEnQA_End(struct chbuff *pChBuff, int iTransferID,
int iSize /*optional */)
{
ARG_UNUSED(iSize);
@ -228,15 +225,17 @@ int AsyncEnQRegstr(struct chbuff *pChBuff, int iSize)
__ASSERT_NO_MSG(0 <= pChBuff->iNbrPendingWrites);
(pChBuff->iNbrPendingWrites)++;
/* pReadGuard changes? */
if (NULL == pChBuff->pReadGuard)
if (NULL == pChBuff->pReadGuard) {
pChBuff->pReadGuard = pChBuff->pWrite;
}
__ASSERT_NO_MSG(pChBuff->WriteMarkers.aMarkers
[pChBuff->WriteMarkers.iFirstMarker]
.pointer == pChBuff->pReadGuard);
/* iAWAMarker changes? */
if (-1 == pChBuff->WriteMarkers.iAWAMarker && pChBuff->bWriteWA)
if (-1 == pChBuff->WriteMarkers.iAWAMarker && pChBuff->bWriteWA) {
pChBuff->WriteMarkers.iAWAMarker = i;
}
}
return i;
}
@ -254,14 +253,16 @@ void AsyncEnQFinished(struct chbuff *pChBuff, int iTransferID)
&(pChBuff->iNbrPendingWrites));
/*pChBuff->iAvailDataCont +=iSizeCont;
pChBuff->iAvailDataAWA +=iSizeAWA; */
if (-1 != iNewFirstMarker)
if (-1 != iNewFirstMarker) {
pChBuff->pReadGuard =
pChBuff->WriteMarkers.aMarkers[iNewFirstMarker]
.pointer;
else
}
else {
pChBuff->pReadGuard = NULL;
}
}
}
/**********************/
/* Buffer de-queuing: */
@ -271,27 +272,27 @@ int BuffDeQ(struct chbuff *pChBuff, int iSize, unsigned char **ppRead)
{
int iTransferID;
/* int ret;*/
if (0 == BuffDeQA(pChBuff, iSize, ppRead, &iTransferID))
if (0 == BuffDeQA(pChBuff, iSize, ppRead, &iTransferID)) {
return 0;
}
BuffDeQA_End(pChBuff, iTransferID, iSize /*optional */);
return iSize;
}
int BuffDeQA(struct chbuff *pChBuff,
int iSize,
unsigned char **ppRead,
int BuffDeQA(struct chbuff *pChBuff, int iSize, unsigned char **ppRead,
int *piTransferID)
{
/* asynchronous data transfer
read guard pointers must be set
* read guard pointers must be set
*/
if (iSize >
pChBuff->iAvailDataCont) /* free space is from read to guard
pointer/end pointer */
if (iSize > pChBuff->iAvailDataCont) {
/* free space is from read to guard pointer/end pointer */
return 0;
}
*piTransferID = AsyncDeQRegstr(pChBuff, iSize);
if (-1 == *piTransferID)
if (-1 == *piTransferID) {
return 0;
}
*ppRead = pChBuff->pRead;
@ -309,18 +310,19 @@ int BuffDeQA(struct chbuff *pChBuff,
pChBuff->iAvailDataCont -= iSize;
}
if (pChBuff->pWrite == pChBuff->pRead)
if (pChBuff->pWrite == pChBuff->pRead) {
pChBuff->BuffState = BUFF_EMPTY;
else
}
else {
pChBuff->BuffState = BUFF_OTHER;
}
CHECK_CHBUFF_POINTER(pChBuff->pRead);
return iSize;
}
void BuffDeQA_End(struct chbuff *pChBuff,
int iTransferID,
void BuffDeQA_End(struct chbuff *pChBuff, int iTransferID,
int iSize /*optional */)
{
ARG_UNUSED(iSize);
@ -358,15 +360,17 @@ int AsyncDeQRegstr(struct chbuff *pChBuff, int iSize)
__ASSERT_NO_MSG(0 <= pChBuff->iNbrPendingReads);
(pChBuff->iNbrPendingReads)++;
/* pWriteGuard changes? */
if (NULL == pChBuff->pWriteGuard)
if (NULL == pChBuff->pWriteGuard) {
pChBuff->pWriteGuard = pChBuff->pRead;
}
__ASSERT_NO_MSG(pChBuff->ReadMarkers.aMarkers
[pChBuff->ReadMarkers.iFirstMarker]
.pointer == pChBuff->pWriteGuard);
/* iAWAMarker changes? */
if (-1 == pChBuff->ReadMarkers.iAWAMarker && pChBuff->bReadWA)
if (-1 == pChBuff->ReadMarkers.iAWAMarker && pChBuff->bReadWA) {
pChBuff->ReadMarkers.iAWAMarker = i;
}
}
return i;
}
@ -383,14 +387,16 @@ void AsyncDeQFinished(struct chbuff *pChBuff, int iTransferID)
&(pChBuff->iNbrPendingReads));
/*pChBuff->iFreeSpaceCont +=iSizeCont;
pChBuff->iFreeSpaceAWA +=iSizeAWA; */
if (-1 != iNewFirstMarker)
if (-1 != iNewFirstMarker) {
pChBuff->pWriteGuard =
pChBuff->ReadMarkers.aMarkers[iNewFirstMarker]
.pointer;
else
}
else {
pChBuff->pWriteGuard = NULL;
}
}
}
/**********************************************************/
@ -430,10 +436,8 @@ available
(either for writing xor reading).
Note: such a series of areas starts from the beginning.
*/
int ScanMarkers(struct marker_list *pMarkerList,
int *piSizeBWA,
int *piSizeAWA,
int *piNbrPendingXfers)
int ScanMarkers(struct marker_list *pMarkerList, int *piSizeBWA,
int *piSizeAWA, int *piNbrPendingXfers)
{
struct marker *pM;
BOOL bMarkersAreNowAWA;
@ -458,17 +462,20 @@ int ScanMarkers(struct marker_list *pMarkerList,
pM = &(pMarkerList->aMarkers[index]);
if (pM->bXferBusy == TRUE)
if (pM->bXferBusy == TRUE) {
break;
}
if (!bMarkersAreNowAWA)
if (!bMarkersAreNowAWA) {
*piSizeBWA += pM->size;
else
}
else {
*piSizeAWA += pM->size;
}
index_next = pM->Next;
MarkerDelete(pMarkerList, index); /* pMarkerList->iFirstMarker
will be updated */
/* pMarkerList->iFirstMarker will be updated */
MarkerDelete(pMarkerList, index);
/* adjust *piNbrPendingXfers */
if (piNbrPendingXfers) {
__ASSERT_NO_MSG(0 <= *piNbrPendingXfers);
@ -479,8 +486,9 @@ int ScanMarkers(struct marker_list *pMarkerList,
__ASSERT_NO_MSG(index == pMarkerList->iFirstMarker);
if (bMarkersAreNowAWA)
if (bMarkersAreNowAWA) {
pMarkerList->iAWAMarker = pMarkerList->iFirstMarker;
}
#ifdef STORE_NBR_MARKERS
if (0 == pMarkerList->iNbrMarkers) {
@ -495,15 +503,15 @@ int ScanMarkers(struct marker_list *pMarkerList,
/**********************************************************/
int CalcAvailData(struct chbuff *pChBuff,
int *piAvailDataCont,
int CalcAvailData(struct chbuff *pChBuff, int *piAvailDataCont,
int *piAvailDataAWA)
{
unsigned char *pStart = pChBuff->pRead;
unsigned char *pStop = pChBuff->pWrite;
if (NULL != pChBuff->pReadGuard)
if (NULL != pChBuff->pReadGuard) {
pStop = pChBuff->pReadGuard;
}
else {
/* else:
if BuffState==BUFF_FULL but we have a ReadGuard, we still
@ -532,15 +540,15 @@ int CalcAvailData(struct chbuff *pChBuff,
return (*piAvailDataCont + *piAvailDataAWA);
}
int CalcFreeSpace(struct chbuff *pChBuff,
int *piFreeSpaceCont,
int CalcFreeSpace(struct chbuff *pChBuff, int *piFreeSpaceCont,
int *piFreeSpaceAWA)
{
unsigned char *pStart = pChBuff->pWrite;
unsigned char *pStop = pChBuff->pRead;
if (NULL != pChBuff->pWriteGuard)
if (NULL != pChBuff->pWriteGuard) {
pStop = pChBuff->pWriteGuard;
}
else {
/* else:
if BuffState==BUFF_EMPTY but we have a WriteGuard, we still

View file

@ -266,10 +266,12 @@ int task_workload_get(void)
void workload_time_slice_set(int32_t t)
{
#ifdef CONFIG_WORKLOAD_MONITOR
if (t < 10)
if (t < 10) {
t = 10;
if (t > 1000)
}
if (t > 1000) {
t = 1000;
}
_k_workload_slice = t;
#else
ARG_UNUSED(t);
@ -386,8 +388,9 @@ void _sys_power_save_idle_exit(int32_t ticks)
static inline int32_t _get_next_timer_expiry(void)
{
if (_k_timer_list_head)
if (_k_timer_list_head) {
return _k_timer_list_head->duration;
}
return TICKS_UNLIMITED;
}

View file

@ -66,10 +66,12 @@ static void signal_semaphore(int n, struct sem_struct *S)
#endif
{
S->Level--;
if (Y)
if (Y) {
Y->Forw = X;
else
}
else {
S->Waiters = X;
}
#ifdef CONFIG_SYS_CLOCK_EXISTS
if (A->Time.timer) {
force_timeout(A);
@ -90,8 +92,9 @@ static void signal_semaphore(int n, struct sem_struct *S)
SENDARGS(Y);
Y = A;
}
else
else {
Y = A;
}
A = X;
}
}
@ -108,9 +111,10 @@ void _k_sem_group_wait(struct k_args *R)
struct k_args *A = R->Ctxt.args;
FREEARGS(R);
if (--(A->Args.s1.nsem) == 0)
if (--(A->Args.s1.nsem) == 0) {
reset_state_bit(A->Ctxt.proc, TF_LIST);
}
}
/*******************************************************************************
*
@ -132,10 +136,12 @@ void _k_sem_group_wait_cancel(struct k_args *A)
while (X && (X->Prio <= A->Prio)) {
if (X->Ctxt.args == A->Ctxt.args) {
if (Y)
if (Y) {
Y->Forw = X->Forw;
else
}
else {
S->Waiters = X->Forw;
}
if (X->Comm == WAITMREQ || X->Comm == WAITMRDY) {
if (X->Comm == WAITMRDY) {
/* obtain struct k_args of waiting task */
@ -150,18 +156,19 @@ void _k_sem_group_wait_cancel(struct k_args *A)
* timer expiry occurs between the update of the packet state
* and the processing of the WAITMRDY packet.
*/
if (unlikely(waitTaskArgs->Args.s1
.sema ==
ENDLIST))
waitTaskArgs->Args.s1.sema =
A->Args.s1.sema;
else
if (unlikely(waitTaskArgs->Args.s1.sema ==
ENDLIST)) {
waitTaskArgs->Args.s1.sema = A->Args.s1.sema;
}
else {
signal_semaphore(1, S);
}
}
_k_sem_group_wait(X);
} else
} else {
FREEARGS(X); /* ERROR */
}
FREEARGS(A);
return;
} else {
@ -170,11 +177,13 @@ void _k_sem_group_wait_cancel(struct k_args *A)
}
}
A->Forw = X;
if (Y)
if (Y) {
Y->Forw = A;
else
}
else {
S->Waiters = A;
}
}
/*******************************************************************************
*
@ -195,14 +204,17 @@ void _k_sem_group_wait_accept(struct k_args *A)
while (X && (X->Prio <= A->Prio)) {
if (X->Ctxt.args == A->Ctxt.args) {
if (Y)
if (Y) {
Y->Forw = X->Forw;
else
}
else {
S->Waiters = X->Forw;
}
if (X->Comm == WAITMRDY) {
_k_sem_group_wait(X);
} else
} else {
FREEARGS(X); /* ERROR */
}
FREEARGS(A);
return;
} else {
@ -225,8 +237,9 @@ void _k_sem_group_wait_timeout(struct k_args *A)
ksem_t *L;
#ifdef CONFIG_SYS_CLOCK_EXISTS
if (A->Time.timer)
if (A->Time.timer) {
FREETIMER(A->Time.timer);
}
#endif
L = A->Args.s1.list;
@ -262,8 +275,9 @@ void _k_sem_group_ready(struct k_args *R)
A->Args.s1.sema = R->Args.s1.sema;
A->Comm = WAITMTMO;
#ifdef CONFIG_SYS_CLOCK_EXISTS
if (A->Time.timer)
if (A->Time.timer) {
force_timeout(A);
}
else
#endif
_k_sem_group_wait_timeout(A);
@ -281,8 +295,9 @@ void _k_sem_group_ready(struct k_args *R)
void _k_sem_wait_reply(struct k_args *A)
{
#ifdef CONFIG_SYS_CLOCK_EXISTS
if (A->Time.timer)
if (A->Time.timer) {
FREETIMER(A->Time.timer);
}
if (A->Comm == WAITSTMO) {
REMOVE_ELM(A);
A->Time.rcode = RC_TIME;
@ -308,14 +323,17 @@ void _k_sem_group_wait_request(struct k_args *A)
while (X && (X->Prio <= A->Prio)) {
if (X->Ctxt.args == A->Ctxt.args) {
if (Y)
if (Y) {
Y->Forw = X->Forw;
else
}
else {
S->Waiters = X->Forw;
}
if (X->Comm == WAITMCAN) {
_k_sem_group_wait(X);
} else
} else {
FREEARGS(X); /* ERROR */
}
FREEARGS(A);
return;
} else {
@ -324,10 +342,12 @@ void _k_sem_group_wait_request(struct k_args *A)
}
}
A->Forw = X;
if (Y)
if (Y) {
Y->Forw = A;
else
}
else {
S->Waiters = A;
}
signal_semaphore(0, S);
}
@ -349,8 +369,9 @@ void _k_sem_group_wait_any(struct k_args *A)
A->Args.s1.sema = ENDLIST;
A->Args.s1.nsem = 0;
if (*L == ENDLIST)
if (*L == ENDLIST) {
return;
}
while (*L != ENDLIST) {
struct k_args *R;
@ -369,8 +390,9 @@ void _k_sem_group_wait_any(struct k_args *A)
#ifdef CONFIG_SYS_CLOCK_EXISTS
if (A->Time.ticks != TICKS_NONE) {
if (A->Time.ticks == TICKS_UNLIMITED)
if (A->Time.ticks == TICKS_UNLIMITED) {
A->Time.timer = NULL;
}
else {
A->Comm = WAITMTMO;
enlist_timeout(A);
@ -403,17 +425,19 @@ void _k_sem_wait_request(struct k_args *A)
set_state_bit(_k_current_task, TF_SEMA);
INSERT_ELM(S->Waiters, A);
#ifdef CONFIG_SYS_CLOCK_EXISTS
if (A->Time.ticks == TICKS_UNLIMITED)
if (A->Time.ticks == TICKS_UNLIMITED) {
A->Time.timer = NULL;
}
else {
A->Comm = WAITSTMO;
enlist_timeout(A);
}
#endif
return;
} else
} else {
A->Time.rcode = RC_FAIL;
}
}
/*******************************************************************************
*
@ -422,12 +446,13 @@ void _k_sem_wait_request(struct k_args *A)
* This routine tests a semaphore to see if it has been signaled. If the signal
* count is greater than zero, it is decremented.
*
* @param sema Semaphore to test.
* @param time Maximum number of ticks to wait.
*
* RETURNS: RC_OK, RC_FAIL, RC_TIME on success, failure, timeout respectively
*/
int _task_sem_take(ksem_t sema, /* semaphore to test */
int32_t time /* maximum number of ticks to wait */
)
int _task_sem_take(ksem_t sema, int32_t time)
{
struct k_args A;
@ -448,12 +473,13 @@ int _task_sem_take(ksem_t sema, /* semaphore to test */
* It returns the ID of the first semaphore in the group whose signal count is
* greater than zero, and decrements the signal count.
*
* @param group Group of semaphores to test.
* @param time Maximum number of ticks to wait.
*
* RETURNS: N/A
*/
ksem_t _task_sem_group_take(ksemg_t group, /* group of semaphores to test */
int32_t time /* maximum number of ticks to wait */
)
ksem_t _task_sem_group_take(ksemg_t group, int32_t time)
{
struct k_args A;
@ -490,9 +516,10 @@ void _k_sem_group_signal(struct k_args *A)
{
ksem_t *L = A->Args.s1.list;
while ((A->Args.s1.sema = *L++) != ENDLIST)
while ((A->Args.s1.sema = *L++) != ENDLIST) {
_k_sem_signal(A);
}
}
/*******************************************************************************
*
@ -500,11 +527,12 @@ void _k_sem_group_signal(struct k_args *A)
*
* This routine signals the specified semaphore.
*
* @param sema Semaphore to signal.
*
* RETURNS: N/A
*/
void task_sem_give(ksem_t sema /* semaphore to signal */
)
void task_sem_give(ksem_t sema)
{
struct k_args A;
@ -526,11 +554,12 @@ void task_sem_give(ksem_t sema /* semaphore to signal */
* Using task_sem_group_give() is faster than using multiple single signals,
* and ensures all signals take place before other tasks run.
*
* @param group Group of semaphores to signal.
*
* RETURNS: N/A
*/
void task_sem_group_give(ksemg_t group /* group of semaphores to signal */
)
void task_sem_group_give(ksemg_t group)
{
struct k_args A;
@ -562,13 +591,13 @@ FUNC_ALIAS(isr_sem_give, fiber_sem_give, void);
* that is implicitly released once the command packet has been processed.
* To signal a semaphore from a task, task_sem_give() should be used instead.
*
* @param sema Semaphore to signal.
* @param pSet Pointer to command packet set.
*
* RETURNS: N/A
*/
void isr_sem_give(ksem_t sema, /* semaphore to signal */
struct cmd_pkt_set *pSet /* ptr to command
packet set */
)
void isr_sem_give(ksem_t sema, struct cmd_pkt_set *pSet)
{
struct k_args *pCommand; /* ptr to command packet */
@ -610,9 +639,10 @@ void _k_sem_group_reset(struct k_args *A)
{
ksem_t *L = A->Args.s1.list;
while ((A->Args.s1.sema = *L++) != ENDLIST)
while ((A->Args.s1.sema = *L++) != ENDLIST) {
_k_sem_reset(A);
}
}
/*******************************************************************************
*
@ -620,11 +650,12 @@ void _k_sem_group_reset(struct k_args *A)
*
* This routine resets the signal count of the specified semaphore to zero.
*
* @param sema Semaphore to reset.
*
* RETURNS: N/A
*/
void task_sem_reset(ksem_t sema /* semaphore to reset */
)
void task_sem_reset(ksem_t sema)
{
struct k_args A;
@ -641,11 +672,12 @@ void task_sem_reset(ksem_t sema /* semaphore to reset */
* group is an array of semaphore names terminated by the predefined constant
* ENDLIST.
*
* @param group Group of semaphores to reset.
*
* RETURNS: N/A
*/
void task_sem_group_reset(ksemg_t group /* group of semaphores to reset */
)
void task_sem_group_reset(ksemg_t group)
{
struct k_args A;
@ -677,11 +709,12 @@ void _k_sem_inquiry(struct k_args *A)
*
* This routine reads the signal count of the specified semaphore.
*
* @param sema Semaphore to query.
*
* RETURNS: signal count
*/
int task_sem_count_get(ksem_t sema /* semaphore to query */
)
int task_sem_count_get(ksem_t sema)
{
struct k_args A;

View file

@ -98,12 +98,15 @@ void enlist_timer(struct k_timer *T)
if (P) {
P->duration -= T->duration;
P->Back = T;
} else
} else {
_k_timer_list_tail = T;
if (Q)
}
if (Q) {
Q->Forw = T;
else
}
else {
_k_timer_list_head = T;
}
T->Forw = P;
T->Back = Q;
}
@ -239,12 +242,12 @@ void _k_timer_list_update(int ticks)
* This routine, called by K_swapper(), handles the request for allocating a
* timer.
*
* @param P Pointer to timer allocation request arguments.
*
* RETURNS: N/A
*/
void _k_timer_alloc(
struct k_args *P /* pointer to timer allocation request arguments */
)
void _k_timer_alloc(struct k_args *P)
{
struct k_timer *T;
struct k_args *A;
@ -309,11 +312,12 @@ void _k_timer_dealloc(struct k_args *P)
* This routine frees the resources associated with the timer. If a timer was
* started, it has to be stopped using task_timer_stop() before it can be freed.
*
* @param timer Timer to deallocate.
*
* RETURNS: N/A
*/
void task_timer_free(ktimer_t timer /* timer to deallocate */
)
void task_timer_free(ktimer_t timer)
{
struct k_args A;
@ -329,17 +333,18 @@ void task_timer_free(ktimer_t timer /* timer to deallocate */
* This routine, called by K_swapper(), handles the start timer request from
* both task_timer_start() and task_timer_restart().
*
* @param P Pointer to timer start request arguments.
*
* RETURNS: N/A
*/
void _k_timer_start(struct k_args *P /* pointer to timer start
request arguments */
)
void _k_timer_start(struct k_args *P)
{
struct k_timer *T = P->Args.c1.timer; /* ptr to the timer to start */
if (T->duration != -1) /* Stop the timer if it is active */
if (T->duration != -1) { /* Stop the timer if it is active */
delist_timer(T);
}
T->duration = (int32_t)P->Args.c1.time1; /* Set the initial delay */
T->period = P->Args.c1.time2; /* Set the period */
@ -362,9 +367,8 @@ void _k_timer_start(struct k_args *P /* pointer to timer start
}
}
if (P->Args.c1.sema != ENDLIST) { /* Track the semaphore to
* signal for when the timer
* expires. */
/* Track the semaphore to signal for when the timer expires. */
if (P->Args.c1.sema != ENDLIST) {
T->Args->Comm = SIGNALS;
T->Args->Args.s1.sema = P->Args.c1.sema;
}
@ -388,14 +392,16 @@ void _k_timer_start(struct k_args *P /* pointer to timer start
* task_timer_stop(): if the allocated timer was still running (from a
* previous call), it will be cancelled; if not, nothing will happen.
*
* @param timer Timer to start.
* @param duration Initial delay in ticks.
* @param period Repetition interval in ticks.
* @param sema Semaphore to signal.
*
* RETURNS: N/A
*/
void task_timer_start(ktimer_t timer, /* timer to start */
int32_t duration, /* initial delay in ticks */
int32_t period, /* repetition interval in ticks */
ksem_t sema /* semaphore to signal */
)
void task_timer_start(ktimer_t timer, int32_t duration, int32_t period,
ksem_t sema)
{
struct k_args A;
@ -413,13 +419,14 @@ void task_timer_start(ktimer_t timer, /* timer to start */
*
* This routine restarts the timer specified by <timer>.
*
* @param timer Timer to restart.
* @param duration Initial delay.
* @param period Repetition interval.
*
* RETURNS: N/A
*/
void task_timer_restart(ktimer_t timer, /* timer to restart */
int32_t duration, /* initial delay */
int32_t period /* repetition interval */
)
void task_timer_restart(ktimer_t timer, int32_t duration, int32_t period)
{
struct k_args A;
@ -456,11 +463,12 @@ void _k_timer_stop(struct k_args *P)
* This routine stops the specified timer. If the timer period has already
* elapsed, the call has no effect.
*
* @param timer Timer to stop.
*
* RETURNS: N/A
*/
void task_timer_stop(ktimer_t timer /* timer to stop */
)
void task_timer_stop(ktimer_t timer)
{
struct k_args A;
@ -505,8 +513,9 @@ void _k_task_sleep(struct k_args *P)
{
struct k_timer *T;
if ((P->Time.ticks) <= 0)
if ((P->Time.ticks) <= 0) {
return;
}
GETTIMER(T);
T->duration = P->Time.ticks;
@ -529,11 +538,12 @@ void _k_task_sleep(struct k_args *P)
* ticks. When the task is awakened, it is rescheduled according to its
* priority.
*
* @param ticks Number of ticks for which to sleep.
*
* RETURNS: N/A
*/
void task_sleep(int32_t ticks /* number of ticks for which to sleep */
)
void task_sleep(int32_t ticks)
{
struct k_args A;

View file

@ -69,14 +69,18 @@ void _k_task_monitor(struct k_proc *X, uint32_t D)
if (++K_monitor_wind == k_monitor_capacity) {
K_monitor_wind = 0;
k_monitor_wptr = k_monitor_buff;
} else
}
else {
++k_monitor_wptr;
if (k_monitor_nrec < k_monitor_capacity)
}
if (k_monitor_nrec < k_monitor_capacity) {
k_monitor_nrec++;
}
if ((_k_task_switch_callback != NULL) && (D == 0))
}
if ((_k_task_switch_callback != NULL) && (D == 0)) {
(_k_task_switch_callback)(X->Ident, timer_read());
}
}
void _k_task_monitor_args(struct k_args *A)
{
@ -97,21 +101,25 @@ void _k_task_monitor_args(struct k_args *A)
if (++K_monitor_wind == k_monitor_capacity) {
K_monitor_wind = 0;
k_monitor_wptr = k_monitor_buff;
} else
}
else {
++k_monitor_wptr;
}
if (k_monitor_nrec < k_monitor_capacity)
if (k_monitor_nrec < k_monitor_capacity) {
k_monitor_nrec++;
}
}
}
void _k_task_monitor_read(struct k_args *A)
{
A->Args.z4.nrec = k_monitor_nrec;
if (A->Args.z4.rind < k_monitor_nrec) {
int i = K_monitor_wind - k_monitor_nrec + A->Args.z4.rind;
if (i < 0)
if (i < 0) {
i += k_monitor_capacity;
}
A->Args.z4.mrec = k_monitor_buff[i];
}
}

View file

@ -97,8 +97,9 @@ size_t __strlen_s(const char *str, size_t maxElem)
{
size_t len = 0; /* the calculated string length */
if (str == NULL)
if (str == NULL) {
return 0;
}
while ((len < maxElem) && (str[len] != '\0')) {
len++;

View file

@ -75,10 +75,12 @@ void main(void)
driver_init();
ret = bt_init();
if (ret == EXPECTED_ERROR)
if (ret == EXPECTED_ERROR) {
ret_code = TC_PASS;
else
}
else {
ret_code = TC_FAIL;
}
TC_END(ret_code, "%s - %s.\n", ret_code == TC_PASS ? PASS : FAIL,
__func__);

View file

@ -120,10 +120,7 @@ struct isrInitInfo {
*
*/
static int initIRQ
(
struct isrInitInfo *i
)
static int initIRQ(struct isrInitInfo *i)
{
#if defined(VXMICRO_ARCH_x86)
int vector; /* vector to which interrupt is connected */

View file

@ -71,14 +71,13 @@ kmutex_t forks[] = {forkMutex0, forkMutex1, forkMutex2, forkMutex3, forkMutex4,
*
* myPrint - print a philosophers state
*
* @param id Philosopher ID.
* @param str EATING or THINKING.
*
* RETURNS: N/A
*/
static void myPrint
(
int id, /* philosopher ID */
char *str /* EATING or THINKING */
)
static void myPrint(int id, char *str)
{
PRINTF("\x1b[%d;%dHPhilosopher %d %s\n", id + 1, 1, id, str);
}
@ -87,13 +86,12 @@ static void myPrint
*
* myDelay - wait for a number of ticks to elapse
*
* @param ticks Number of ticks to delay.
*
* RETURNS: N/A
*/
static void myDelay
(
int ticks /* # of ticks to delay */
)
static void myDelay(int ticks)
{
#ifdef CONFIG_MICROKERNEL
task_sleep(ticks);

View file

@ -85,9 +85,10 @@ int main(void)
}
/* create philosopher fibers */
for (i = 0; i < N_PHILOSOPHERS; i++)
for (i = 0; i < N_PHILOSOPHERS; i++) {
task_fiber_start(&philStack[i][0], STSIZE,
(nano_fiber_entry_t) philEntry, 0, 0, 6, 0);
}
/* wait forever */
while (1) {

View file

@ -147,14 +147,14 @@ void mailbox_test(void)
*
* RETURNS: N/A
*
* @param size The size of the data chunk.
* @param count Number of data chunks.
* @param time The total time.
*
* \NOMANUAL
*/
void mailbox_put(
uint32_t size, /* the size of the data chunk */
int count, /* number of data chunks */
uint32_t *time /* the total time */
)
void mailbox_put(uint32_t size, int count, uint32_t *time)
{
int i;
unsigned int t;

View file

@ -87,15 +87,15 @@ void mailrecvtask(void)
*
* RETURNS: 0
*
* @param mailbox The mailbox to read data from.
* @param size Size of each data portion.
* @param count Number of data portions.
* @param time Resulting time.
*
* \NOMANUAL
*/
int mailbox_get(
kmbox_t mailbox, /* the mailbox to read data from */
int size, /* size of each data portion */
int count, /* number of data portions */
unsigned int* time /* resulting time */
)
int mailbox_get(kmbox_t mailbox, int size, int count, unsigned int* time)
{
int i;
unsigned int t;
@ -114,8 +114,9 @@ int mailbox_get(
t = TIME_STAMP_DELTA_GET(t);
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);
if (bench_test_end() < 0)
if (bench_test_end() < 0) {
PRINT_OVERFLOW_ERROR();
}
return 0;
}

View file

@ -45,8 +45,7 @@ char Msg[MAX_MSG];
char data_bench[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)];
#ifdef PIPE_BENCH
kpipe_t TestPipes[] = {
PIPE_NOBUFF, PIPE_SMALLBUFF, PIPE_BIGBUFF};
kpipe_t TestPipes[] = {PIPE_NOBUFF, PIPE_SMALLBUFF, PIPE_BIGBUFF};
#endif
const char dashline[] =
"|--------------------------------------"
@ -83,13 +82,13 @@ int kbhit(void)
*
* RETURNS: N/A
*
* @param continuously Run test till the user presses the key.
* @param autorun Expect user input.
*
* \NOMANUAL
*/
void init_output(
int *continuously, /* run test till the user presses the key */
int *autorun /* expect user input */
)
void init_output(int *continuously, int *autorun)
{
ARG_UNUSED(continuously);
ARG_UNUSED(autorun);
@ -156,8 +155,7 @@ void BenchTask(void)
output_file);
PRINT_STRING(dashline, output_file);
PRINT_STRING("VXMICRO PROJECT EXECUTION SUCCESSFUL\n",output_file);
}
while (continuously && !kbhit());
} while (continuously && !kbhit());
WAIT_FOR_USER();
@ -165,8 +163,9 @@ void BenchTask(void)
* Make a 2 second delay. sys_clock_ticks_per_sec in this context is
* a number of system times ticks in a second.
*/
if (autorun)
if (autorun) {
task_sleep(2 * sys_clock_ticks_per_sec);
}
output_close();
}

View file

@ -155,8 +155,7 @@ extern void event_test(void);
}
#define PRINT_OVERFLOW_ERROR() \
PRINT_F(output_file, \
__FILE__":%d Error: tick occured\n", __LINE__)
PRINT_F(output_file, __FILE__":%d Error: tick occured\n", __LINE__)
static inline uint32_t BENCH_START(void)
{
@ -169,8 +168,7 @@ static inline uint32_t BENCH_START(void)
#define check_result() \
{ \
if (bench_test_end() < 0) \
{ \
if (bench_test_end() < 0) { \
PRINT_OVERFLOW_ERROR(); \
return; /* error */ \
} \

View file

@ -208,16 +208,16 @@ void pipe_test(void)
*
* RETURNS: 0 on success, 1 on error
*
* @param pipe The pipe to be tested.
* @param option _ALL_TO_N or _1_TO_N.
* @param size Data chunk size.
* @param count Number of data chunks.
* @param time Total write time.
*
* \NOMANUAL
*/
int pipeput(
kpipe_t pipe, /* The pipe to be tested */
K_PIPE_OPTION option, /* _ALL_TO_N or _1_TO_N */
int size, /* data chunk size */
int count, /* number of data chunks */
uint32_t *time /* total write time */
)
int pipeput(kpipe_t pipe, K_PIPE_OPTION option, int size, int count, uint32_t *time)
{
int i;
unsigned int t;
@ -234,18 +234,22 @@ int pipeput(
ret = task_pipe_put_wait(pipe, data_bench, size2xfer,
&sizexferd, option);
if (RC_OK != ret)
if (RC_OK != ret) {
return 1;
if (_ALL_N == option && sizexferd != size2xfer)
}
if (_ALL_N == option && sizexferd != size2xfer) {
return 1;
}
sizexferd_total += sizexferd;
if (size2xfer_total == sizexferd_total)
if (size2xfer_total == sizexferd_total) {
break;
}
if (size2xfer_total < sizexferd_total)
if (size2xfer_total < sizexferd_total) {
return 1;
}
}
t = TIME_STAMP_DELTA_GET(t);
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);
@ -258,8 +262,7 @@ int pipeput(
PRINT_STRING("| Tick occured. Results may be inaccurate ",
output_file);
}
PRINT_STRING(" |\n",
output_file);
PRINT_STRING(" |\n", output_file);
}
return 0;
}

View file

@ -104,16 +104,17 @@ void piperecvtask(void)
*
* RETURNS: 0 on success, 1 on error
*
* @param pipe Pipe to read data from.
* @param option _ALL_TO_N or _1_TO_N.
* @param size Data chunk size.
* @param count Number of data chunks.
* @param time Total write time.
*
* \NOMANUAL
*/
int pipeget(
kpipe_t pipe, /* pipe to read data from */
K_PIPE_OPTION option, /* _ALL_TO_N or _1_TO_N */
int size, /* data chunk size */
int count, /* number of data chunks */
unsigned int* time /* total write time */
)
int pipeget(kpipe_t pipe, K_PIPE_OPTION option, int size, int count,
unsigned int* time)
{
int i;
unsigned int t;
@ -130,19 +131,23 @@ int pipeget(
ret = task_pipe_get_wait(pipe, data_recv, size2xfer,
&sizexferd, option);
if (RC_OK != ret)
if (RC_OK != ret) {
return 1;
}
if (_ALL_N == option && sizexferd != size2xfer)
if (_ALL_N == option && sizexferd != size2xfer) {
return 1;
}
sizexferd_total += sizexferd;
if (size2xfer_total == sizexferd_total)
if (size2xfer_total == sizexferd_total) {
break;
}
if (size2xfer_total < sizexferd_total)
if (size2xfer_total < sizexferd_total) {
return 1;
}
}
t = TIME_STAMP_DELTA_GET(t);
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);

View file

@ -41,9 +41,7 @@
#include "receiver.h"
char data_recv[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)] = {
0
};
char data_recv[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)] = { 0 };
void dequtask(void);
void waittask(void);

View file

@ -58,27 +58,35 @@ void waittask(void)
slist[3] = ENDLIST;
slist[4] = ENDLIST;
for (i = 0; i < NR_OF_SEMA_RUNS; i++)
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_take_wait(SEM1);
for (i = 0; i < NR_OF_SEMA_RUNS; i++)
}
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_take_wait_timeout(SEM1, SEMA_WAIT_TIME);
}
for (i = 0; i < NR_OF_SEMA_RUNS; i++)
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_group_take_wait(slist);
for (i = 0; i < NR_OF_SEMA_RUNS; i++)
task_sem_group_take_wait_timeout(slist, SEMA_WAIT_TIME);
slist[2] = SEM3;
for (i = 0; i < NR_OF_SEMA_RUNS; i++)
task_sem_group_take_wait(slist);
for (i = 0; i < NR_OF_SEMA_RUNS; i++)
task_sem_group_take_wait_timeout(slist, SEMA_WAIT_TIME);
slist[3] = SEM4;
for (i = 0; i < NR_OF_SEMA_RUNS; i++)
task_sem_group_take_wait(slist);
for (i = 0; i < NR_OF_SEMA_RUNS; i++)
}
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_group_take_wait_timeout(slist, SEMA_WAIT_TIME);
}
slist[2] = SEM3;
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_group_take_wait(slist);
}
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_group_take_wait_timeout(slist, SEMA_WAIT_TIME);
}
slist[3] = SEM4;
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_group_take_wait(slist);
}
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_group_take_wait_timeout(slist, SEMA_WAIT_TIME);
}
}
#endif /* SEMA_BENCH */

View file

@ -85,9 +85,10 @@ static void makeInt(void)
if (flagVar != 1) {
PRINT_FORMAT(" Flag variable has not changed. FAILED\n");
}
else
else {
timestamp = TIME_STAMP_DELTA_GET(timestamp);
}
}
/*******************************************************************************
*

View file

@ -138,9 +138,10 @@ int nanoCtxSwitch(void)
errorCount++;
PRINT_OVERFLOW_ERROR();
}
else
else {
PRINT_FORMAT(" Average context switch time is %lu tcs = %lu nsec",
timestamp / ctxSwitchCounter,
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, ctxSwitchCounter));
}
return 0;
}

View file

@ -89,9 +89,10 @@ static void fiberInt(void)
if (flagVar != 1) {
PRINT_FORMAT(" Flag variable has not changed. FAILED");
}
else
else {
timestamp = TIME_STAMP_DELTA_GET(timestamp);
}
}
/*******************************************************************************
*

View file

@ -93,8 +93,9 @@ static inline uint32_t TIME_STAMP_DELTA_GET(uint32_t ts)
t = OS_GET_TIME();
uint32_t res = (t >= ts)? (t - ts): (ULONG_MAX - ts + t);
if (ts > 0)
if (ts > 0) {
res -= tm_off;
}
return res;
}
@ -139,9 +140,9 @@ static inline void bench_test_start(void)
static inline int bench_test_end(void)
{
tCheck = TICK_GET(&tCheck);
if (tCheck > BENCH_MAX_TICKS)
if (tCheck > BENCH_MAX_TICKS) {
return -1;
else
}
return 0;
}
@ -153,9 +154,9 @@ static inline int bench_test_end(void)
*/
static inline int high_timer_overflow(void)
{
if (tCheck >= (UINT_MAX / sys_clock_hw_cycles_per_tick))
if (tCheck >= (UINT_MAX / sys_clock_hw_cycles_per_tick)) {
return -1;
else
}
return 0;
}
#endif /* CONFIG_NANOKERNEL || CONFIG_MICROKERNEL */

View file

@ -52,12 +52,10 @@ extern int errorCount;
#define PRINTF(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define PRINT_FORMAT(fmt, ...) \
do \
{ \
do { \
snprintf(tmpString, TMP_STRING_SIZE, fmt, ##__VA_ARGS__); \
PRINTF("|%-77s|\n", tmpString); \
} \
while (0)
} while (0)
/*******************************************************************************
*
@ -92,7 +90,8 @@ static inline void printDashLine(void)
printDashLine();
#define PRINT_TIME_BANNER() \
PRINT_FORMAT(" tcs = timer clock cycles: 1 tcs is %lu nsec", SYS_CLOCK_HW_CYCLES_TO_NS(1));\
PRINT_FORMAT(" tcs = timer clock cycles: 1 tcs is %lu nsec", \
SYS_CLOCK_HW_CYCLES_TO_NS(1)); \
printDashLine();
#define PRINT_OVERFLOW_ERROR() \

View file

@ -207,8 +207,9 @@ void load_store_low(void)
*/
floatRegInitByte = MAIN_FLOAT_REG_CHECK_BYTE;
for (bufIx = 0; bufIx < SIZEOF_FP_REG_SET; ++bufIx)
for (bufIx = 0; bufIx < SIZEOF_FP_REG_SET; ++bufIx) {
((unsigned char *)&floatRegSetLoad)[bufIx] = floatRegInitByte++;
}
/* Keep cranking forever, or until an error is detected. */
@ -353,8 +354,9 @@ void load_store_high(void)
floatRegInitByte = FIBER_FLOAT_REG_CHECK_BYTE;
for (bufIx = 0; bufIx < SIZEOF_FP_REG_SET; ++bufIx)
for (bufIx = 0; bufIx < SIZEOF_FP_REG_SET; ++bufIx) {
floatRegisterSetBytePtr[bufIx] = floatRegInitByte++;
}
/*
* Utilize an architecture specific function to load all the floating
@ -395,9 +397,10 @@ void load_store_high(void)
/* periodically issue progress report */
if ((++load_store_high_count % 100) == 0)
if ((++load_store_high_count % 100) == 0) {
PRINT_DATA("Load and store OK after %u (high) + %u (low) tests\n",
load_store_high_count, load_store_low_count);
}
#if (MAX_TESTS != 0)
/* terminate testing if specified limit has been reached */

View file

@ -99,18 +99,18 @@ extern kmemory_pool_t smallBlkszPool;
* rx_task to receiverTask - destination for the message
* mailbox to inMbox
*
* @param inMsg The message being received.
* @param inMbox Mail box to receive the message.
* @param receiverTask Destination for the message.
* @param dataArea Pointer to (optional) buffer to send.
* @param dataSize Size of (optional) buffer to send.
* @param info Additional (optional) info to send.
*
* RETURNS: N/A
*/
static void setMsg_Sender
(
struct k_msg *inMsg, /* the message being received */
kmbox_t inMbox, /* mail box to receive the message */
ktask_t receiverTask, /* destination for the message */
void *dataArea, /* pointer to (optional) buffer to send */
uint32_t dataSize, /* size of (optional) buffer to send */
uint32_t info /* additional (optional) info to send */
)
static void setMsg_Sender(struct k_msg *inMsg, kmbox_t inMbox, ktask_t receiverTask,
void *dataArea, uint32_t dataSize, uint32_t info)
{
inMsg->rx_task = receiverTask;
inMsg->mailbox = inMbox;
@ -129,17 +129,17 @@ static void setMsg_Sender
* tx_task to senderTask - receiver tries to get message from this source
* mailbox to inMbox
*
* @param inMsg Message descriptor.
* @param inMbox Mail box to receive from.
* @param senderTask Sending task to receive from.
* @param inBuffer Incoming data area
* @param inBufferSize Size of incoming data area.
*
* RETURNS: N/A
*/
static void setMsg_Receiver
(
struct k_msg *inMsg, /* message descriptor */
kmbox_t inMbox, /* mail box to receive from */
ktask_t senderTask, /* sending task to receive from */
void *inBuffer, /* incoming data area */
uint32_t inBufferSize /* size of incoming data area */
)
static void setMsg_Receiver(struct k_msg *inMsg, kmbox_t inMbox, ktask_t senderTask,
void *inBuffer, uint32_t inBufferSize)
{
inMsg->mailbox = inMbox;
inMsg->tx_task = senderTask;
@ -154,15 +154,14 @@ static void setMsg_Receiver
*
* setMsg_RecvBuf - sets rx_data field in msg and clears buffer
*
* @param inMsg The message being received.
* @param inBuffer Incoming data area.
* @param inBufferSize Size of incoming data area.
*
* RETURNS: N/A
*/
static void setMsg_RecvBuf
(
struct k_msg *inMsg, /* the message being received */
char *inBuffer, /* incoming data area */
uint32_t inBufferSize /* size of incoming data area */
)
static void setMsg_RecvBuf(struct k_msg *inMsg, char *inBuffer, uint32_t inBufferSize)
{
inMsg->rx_data = inBuffer;
inMsg->size = inBufferSize;

View file

@ -705,7 +705,9 @@ int pipePutTimeoutTest(void)
if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) {
TC_ERROR("Return code: expected %d, got %d\n"
"Bytes written: expected %d, got %d\n",
RC_OK, rv, PIPE_SIZE, bytesWritten); return TC_FAIL; }
RC_OK, rv, PIPE_SIZE, bytesWritten);
return TC_FAIL;
}
/* 3. task_pipe_put_wait() will force a context switch to AlternateTask(). */
rv = task_pipe_put_wait_timeout(pipeId, txBuffer, PIPE_SIZE,

View file

@ -66,6 +66,7 @@ void MainTask(void)
TC_ERROR("Test task 1 did not start properly\n");
goto fail;
}
/* now we check the first task to perform the test and die */
result = task_sem_take_wait_timeout(SEMA1, WAIT_TOUT);
if (result == RC_TIME) {
@ -84,6 +85,7 @@ void MainTask(void)
TC_ERROR("Test task 2 did not start properly\n");
goto fail;
}
/* now we check the second task to perform the test and die */
result = task_sem_take_wait_timeout(SEMA2, WAIT_TOUT);
if (result == RC_TIME) {
@ -95,6 +97,7 @@ void MainTask(void)
"after calling memcpy_s with incorrect parameters\n");
goto fail;
}
TC_END_RESULT(TC_PASS);
TC_END_REPORT(TC_PASS);
return;
@ -121,6 +124,7 @@ void MemcpyTask(void)
k_memcpy_s(buf2, sizeof(buf2), buf1, sizeof(buf1));
task_sem_give(SEMA1);
task_yield();
/* do incorrect memory copy */
k_memcpy_s(buf1, sizeof(buf1), buf2, sizeof(buf2));
task_sem_give(SEMA1);
@ -137,8 +141,7 @@ void MemcpyTask(void)
void StrcpyTask(void)
{
char buf1[BUFSIZE];
char buf2[BUFSIZE] = { '1', '2', '3', '4', '5',
'6', '7', '8', '9', 0 };
char buf2[BUFSIZE] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', 0 };
/* do correct string copy */
strcpy_s(buf1, sizeof(buf1), buf2);
@ -150,6 +153,7 @@ void StrcpyTask(void)
* strcpy_s has to make an error
*/
buf2[BUFSIZE - 1] = '0';
/* do incorrect string copy */
strcpy_s(buf1, sizeof(buf1), buf2);
task_sem_give(SEMA2);

View file

@ -227,8 +227,7 @@ int sprintfDoubleTest(void)
sprintf(buffer, "%Lf", (long double) 1234567.0);
if (strcmp("-0.000000", buffer) != 0) {
TC_ERROR("sprintf(%%Lf). Expected '-0.000000', got '%s'\n",
buffer);
TC_ERROR("sprintf(%%Lf). Expected '-0.000000', got '%s'\n", buffer);
status = TC_FAIL;
}

View file

@ -135,8 +135,7 @@ void fiber1(void)
#endif /* ! CONFIG_MICROKERNEL */
{
TC_PRINT("Starts %s\n", __func__);
check_input(__func__,
"Input string is too long and stack overflowed!\n");
check_input(__func__, "Input string is too long and stack overflowed!\n");
/*
* Expect this task to terminate due to stack check fail and will not
* execute pass here.

View file

@ -142,15 +142,15 @@ int nanoIdtStubTest(void)
offset = (uint16_t)((uint32_t)(&nanoIntStub) & 0xFFFF);
if (pIdtEntry->lowOffset != offset) {
TC_ERROR("Failed to find low offset of nanoIntStub \
(0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT);
TC_ERROR("Failed to find low offset of nanoIntStub "
"(0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT);
return TC_FAIL;
}
offset = (uint16_t)((uint32_t)(&nanoIntStub) >> 16);
if (pIdtEntry->hiOffset != offset) {
TC_ERROR("Failed to find high offset of nanoIntStub \
(0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT);
TC_ERROR("Failed to find high offset of nanoIntStub "
"(0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT);
return TC_FAIL;
}
@ -159,15 +159,15 @@ int nanoIdtStubTest(void)
offset = (uint16_t)((uint32_t)(&exc_divide_error_handlerStub) & 0xFFFF);
if (pIdtEntry->lowOffset != offset) {
TC_ERROR("Failed to find low offset of exc stub \
(0x%x) at vector %d\n", (uint32_t)offset, IV_DIVIDE_ERROR);
TC_ERROR("Failed to find low offset of exc stub "
"(0x%x) at vector %d\n", (uint32_t)offset, IV_DIVIDE_ERROR);
return TC_FAIL;
}
offset = (uint16_t)((uint32_t)(&exc_divide_error_handlerStub) >> 16);
if (pIdtEntry->hiOffset != offset) {
TC_ERROR("Failed to find high offset of exc stub \
(0x%x) at vector %d\n", (uint32_t)offset, IV_DIVIDE_ERROR);
TC_ERROR("Failed to find high offset of exc stub "
"(0x%x) at vector %d\n", (uint32_t)offset, IV_DIVIDE_ERROR);
return TC_FAIL;
}

View file

@ -113,9 +113,10 @@ void registerWait(void)
TC_PRINT("Generating interrupts for all allocated IRQ objects...\n");
for (irq_obj = 0; irq_obj < NUM_TASK_IRQS; irq_obj++) {
if (task_irq_object[irq_obj].irq != INVALID_VECTOR)
if (task_irq_object[irq_obj].irq != INVALID_VECTOR) {
raiseInt((uint8_t)task_irq_object[irq_obj].vector);
}
}
task_sem_give(resultSems[TC_PASS]);
}

View file

@ -181,10 +181,12 @@ void ticklessTestTask(void)
#endif
/* Calculate percentage difference between calibrated TSC diff and measured result */
if (diff_tsc > cal_tsc)
if (diff_tsc > cal_tsc) {
diff_per = (100 * (diff_tsc - cal_tsc)) / cal_tsc;
else
}
else {
diff_per = (100 * (cal_tsc - diff_tsc)) / cal_tsc;
}
printk("variance in time stamp diff: %d percent\n", (int32_t)diff_per);

View file

@ -149,14 +149,13 @@ static void isrDummyIntStub(void *unused)
*
* fiberEntry - trivial fiber
*
* @param message Message to be printed.
* @param arg1 Unused.
*
* RETURNS: N/A
*/
static void fiberEntry
(
int message, /* message to be printed */
int arg1 /* unused */
)
static void fiberEntry(int message, int arg1)
{
ARG_UNUSED(arg1);

View file

@ -57,15 +57,15 @@ void lifo_test_init(void)
*
* lifo_fiber1 - lifo test context
*
* @param par1 Ignored parameter.
* @param par2 Number of test loops.
*
* RETURNS: N/A
*
* \NOMANUAL
*/
void lifo_fiber1(
int par1, /* ignored parameter */
int par2 /* number of test loops */
)
void lifo_fiber1(int par1, int par2)
{
int i;
int element_a[2];
@ -76,13 +76,15 @@ void lifo_fiber1(
for (i = 0; i < par2 / 2; i++) {
pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo1);
if (pelement[1] != 2 * i)
if (pelement[1] != 2 * i) {
break;
}
element_a[1] = 2 * i;
nano_fiber_lifo_put(&nanoLifo2, element_a);
pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo1);
if (pelement[1] != 2 * i + 1)
if (pelement[1] != 2 * i + 1) {
break;
}
element_b[1] = 2 * i + 1;
nano_fiber_lifo_put(&nanoLifo2, element_b);
}
@ -95,15 +97,15 @@ void lifo_fiber1(
*
* lifo_fiber2 - lifo test context
*
* @param par1 Address of the counter.
* @param par2 Number of test cycles.
*
* RETURNS: N/A
*
* \NOMANUAL
*/
void lifo_fiber2(
int par1, /* address of the counter */
int par2 /* number of test cycles */
)
void lifo_fiber2(int par1, int par2)
{
int i;
int element[2];
@ -114,8 +116,9 @@ void lifo_fiber2(
element[1] = i;
nano_fiber_lifo_put(&nanoLifo1, element);
pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo2);
if (pelement[1] != i)
if (pelement[1] != i) {
break;
}
(*pcounter)++;
}
/* wait till it is safe to end: */
@ -126,15 +129,15 @@ void lifo_fiber2(
*
* lifo_fiber3 - lifo test context
*
* @param par1 Address of the counter.
* @param par2 Number of test loops.
*
* RETURNS: N/A
*
* \NOMANUAL
*/
void lifo_fiber3(
int par1, /* address of the counter */
int par2 /* number of test loops */
)
void lifo_fiber3(int par1, int par2)
{
int i;
int element[2];
@ -144,10 +147,12 @@ void lifo_fiber3(
for (i = 0; i < par2; i++) {
element[1] = i;
nano_fiber_lifo_put(&nanoLifo1, element);
while (NULL == (pelement = (int *) nano_fiber_lifo_get(&nanoLifo2)))
while (NULL == (pelement = (int *) nano_fiber_lifo_get(&nanoLifo2))) {
fiber_yield();
if (pelement[1] != i)
}
if (pelement[1] != i) {
break;
}
(*pcounter)++;
}
/* wait till it is safe to end: */
@ -195,8 +200,9 @@ int lifo_test(void)
return_value += check_result(i, t);
/* fiber contexts have done their job, they can stop now safely: */
for (j = 0; j < 2; j++)
for (j = 0; j < 2; j++) {
nano_task_fifo_put(&nanoFifo_sync, (void *) element);
}
/* test get/yield & put fiber functions */
fprintf(output_file, sz_test_case_fmt,
@ -223,8 +229,9 @@ int lifo_test(void)
return_value += check_result(i, t);
/* fiber contexts have done their job, they can stop now safely: */
for (j = 0; j < 2; j++)
for (j = 0; j < 2; j++) {
nano_task_fifo_put(&nanoFifo_sync, (void *) element);
}
/* test get wait & put fiber/task functions */
fprintf(output_file, sz_test_case_fmt,
@ -250,20 +257,23 @@ int lifo_test(void)
nano_task_lifo_put(&nanoLifo1, element);
pelement = (int *) nano_task_lifo_get_wait(&nanoLifo2);
if (pelement[1] != 2 * i + 1)
if (pelement[1] != 2 * i + 1) {
break;
}
pelement = (int *) nano_task_lifo_get_wait(&nanoLifo2);
if (pelement[1] != 2 * i)
if (pelement[1] != 2 * i) {
break;
}
}
t = TIME_STAMP_DELTA_GET(t);
return_value += check_result(i * 2, t);
/* fiber contexts have done their job, they can stop now safely: */
for (j = 0; j < 2; j++)
for (j = 0; j < 2; j++) {
nano_task_fifo_put(&nanoFifo_sync, (void *) element);
}
return return_value;
}

View file

@ -60,13 +60,13 @@ void fifo_test_init(void)
*
* RETURNS: N/A
*
* @param par1 Ignored parameter.
* @param par2 Number of test loops.
*
* \NOMANUAL
*/
void fifo_fiber1(
int par1, /* ignored parameter */
int par2 /* number of test loops */
)
void fifo_fiber1(int par1, int par2)
{
int i;
int element[2];
@ -75,8 +75,9 @@ void fifo_fiber1(
ARG_UNUSED(par1);
for (i = 0; i < par2; i++) {
pelement = (int *) nano_fiber_fifo_get_wait(&nanoFifo1);
if (pelement[1] != i)
if (pelement[1] != i) {
break;
}
element[1] = i;
nano_fiber_fifo_put(&nanoFifo2, element);
}
@ -91,13 +92,13 @@ void fifo_fiber1(
*
* RETURNS: N/A
*
* @param par1 Address of the counter.
* @param par2 Number of test cycles.
*
* \NOMANUAL
*/
void fifo_fiber2(
int par1, /* address of the counter */
int par2 /* number of test cycles */
)
void fifo_fiber2(int par1, int par2)
{
int i;
int element[2];
@ -108,8 +109,9 @@ void fifo_fiber2(
element[1] = i;
nano_fiber_fifo_put(&nanoFifo1, element);
pelement = (int *) nano_fiber_fifo_get_wait(&nanoFifo2);
if (pelement[1] != i)
if (pelement[1] != i) {
break;
}
(*pcounter)++;
}
/* wait till it is safe to end: */
@ -123,13 +125,13 @@ void fifo_fiber2(
*
* RETURNS: N/A
*
* @param par1 Address of the counter.
* @param par2 Number of test cycles.
*
* \NOMANUAL
*/
void fifo_fiber3(
int par1, /* address of the counter */
int par2 /* number of test cycles */
)
void fifo_fiber3(int par1, int par2)
{
int i;
int element[2];
@ -139,10 +141,12 @@ void fifo_fiber3(
for (i = 0; i < par2; i++) {
element[1] = i;
nano_fiber_fifo_put(&nanoFifo1, element);
while (NULL == (pelement = (int *) nano_fiber_fifo_get(&nanoFifo2)))
while (NULL == (pelement = (int *) nano_fiber_fifo_get(&nanoFifo2))) {
fiber_yield();
if (pelement[1] != i)
}
if (pelement[1] != i) {
break;
}
(*pcounter)++;
}
/* wait till it is safe to end: */
@ -191,8 +195,9 @@ int fifo_test(void)
return_value += check_result(i, t);
/* fiber contexts have done their job, they can stop now safely: */
for (j = 0; j < 2; j++)
for (j = 0; j < 2; j++) {
nano_task_fifo_put(&nanoFifo_sync, (void *) element);
}
/* test get/yield & put fiber functions */
fprintf(output_file, sz_test_case_fmt,
@ -219,8 +224,9 @@ int fifo_test(void)
return_value += check_result(i, t);
/* fiber contexts have done their job, they can stop now safely: */
for (j = 0; j < 2; j++)
for (j = 0; j < 2; j++) {
nano_task_fifo_put(&nanoFifo_sync, (void *) element);
}
/* test get wait & put fiber/task functions */
fprintf(output_file, sz_test_case_fmt,
@ -249,19 +255,22 @@ int fifo_test(void)
nano_task_fifo_put(&nanoFifo1, element);
pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2);
if (pelement[1] != i)
if (pelement[1] != i) {
break;
}
pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2);
if (pelement[1] != i)
if (pelement[1] != i) {
break;
}
}
t = TIME_STAMP_DELTA_GET(t);
return_value += check_result(i * 2, t);
/* fiber contexts have done their job, they can stop now safely: */
for (j = 0; j < 2; j++)
for (j = 0; j < 2; j++) {
nano_task_fifo_put(&nanoFifo_sync, (void *) element);
}
return return_value;
}

View file

@ -55,15 +55,15 @@ void sema_test_init(void)
*
* sema_fiber1 - semaphore test context
*
* @param par1 Ignored parameter.
* @param par2 Number of test loops.
*
* RETURNS: N/A
*
* \NOMANUAL
*/
void sema_fiber1(
int par1, /* ignored parameter */
int par2 /* number of test loops */
)
void sema_fiber1(int par1, int par2)
{
int i;
@ -80,15 +80,15 @@ void sema_fiber1(
*
* sema_fiber2 - semaphore test context
*
* @param par1 Address of the counter.
* @param par2 Number of test cycles.
*
* RETURNS: N/A
*
* \NOMANUAL
*/
void sema_fiber2(
int par1, /* address of the counter */
int par2 /* number of test cycles */
)
void sema_fiber2(int par1, int par2)
{
int i;
int * pcounter = (int *) par1;
@ -104,23 +104,24 @@ void sema_fiber2(
*
* sema_fiber3 - semaphore test context
*
* @param par1 Address of the counter.
* @param par2 Number of test cycles.
*
* RETURNS: N/A
*
* \NOMANUAL
*/
void sema_fiber3(
int par1, /* address of the counter */
int par2 /* number of test cycles */
)
void sema_fiber3(int par1, int par2)
{
int i;
int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) {
nano_fiber_sem_give(&nanoSem1);
while (!nano_fiber_sem_take(&nanoSem2))
while (!nano_fiber_sem_take(&nanoSem2)) {
fiber_yield();
}
(*pcounter)++;
}
}

View file

@ -58,15 +58,15 @@ void stack_test_init(void)
*
* stack_fiber1 - stack test context
*
* @param par1 Ignored parameter.
* @param par2 Number of test loops.
*
* RETURNS: N/A
*
* \NOMANUAL
*/
void stack_fiber1(
int par1, /* ignored parameter */
int par2 /* number of test loops */
)
void stack_fiber1(int par1, int par2)
{
int i;
uint32_t data;
@ -75,13 +75,15 @@ void stack_fiber1(
for (i = 0; i < par2 / 2; i++) {
data = nano_fiber_stack_pop_wait(&nanoChannel1);
if (data != 2 * i)
if (data != 2 * i) {
break;
}
data = 2 * i;
nano_fiber_stack_push(&nanoChannel2, data);
data = nano_fiber_stack_pop_wait(&nanoChannel1);
if (data != 2 * i + 1)
if (data != 2 * i + 1) {
break;
}
data = 2 * i + 1;
nano_fiber_stack_push(&nanoChannel2, data);
}
@ -92,15 +94,15 @@ void stack_fiber1(
*
* stack_fiber2 - stack test context
*
* @param par1 Address of the counter.
* @param par2 Number of test cycles.
*
* RETURNS: N/A
*
* \NOMANUAL
*/
void stack_fiber2(
int par1, /* address of the counter */
int par2 /* number of test cycles */
)
void stack_fiber2(int par1, int par2)
{
int i;
uint32_t data;
@ -110,8 +112,9 @@ void stack_fiber2(
data = i;
nano_fiber_stack_push(&nanoChannel1, data);
data = nano_fiber_stack_pop_wait(&nanoChannel2);
if (data != i)
if (data != i) {
break;
}
(*pcounter)++;
}
}
@ -121,15 +124,15 @@ void stack_fiber2(
*
* stack_fiber2 - stack test context
*
* @param par1 Address of the counter.
* @param par2 Number of test cycles.
*
* RETURNS: N/A
*
* \NOMANUAL
*/
void stack_fiber3(
int par1, /* address of the counter */
int par2 /* number of test cycles */
)
void stack_fiber3(int par1, int par2)
{
int i;
uint32_t data;
@ -139,10 +142,12 @@ void stack_fiber3(
data = i;
nano_fiber_stack_push(&nanoChannel1, data);
data = 0xffffffff;
while (!nano_fiber_stack_pop(&nanoChannel2, &data))
while (!nano_fiber_stack_pop(&nanoChannel2, &data)) {
fiber_yield();
if (data != i)
}
if (data != i) {
break;
}
(*pcounter)++;
}
}
@ -232,12 +237,14 @@ int stack_test(void)
nano_task_stack_push(&nanoChannel1, data);
data = nano_task_stack_pop_wait(&nanoChannel2);
if (data != 2 * i + 1)
if (data != 2 * i + 1) {
break;
}
data = nano_task_stack_pop_wait(&nanoChannel2);
if (data != 2 * i)
if (data != 2 * i) {
break;
}
}
t = TIME_STAMP_DELTA_GET(t);

View file

@ -89,8 +89,8 @@ uint32_t tm_off;
void begin_test(void)
{
/*
Invoke bench_test_start in order to be able to use
tCheck static variable.
* Invoke bench_test_start in order to be able to use
* tCheck static variable.
*/
bench_test_start();
}
@ -101,17 +101,17 @@ void begin_test(void)
*
* RETURNS: 1 if success and 0 on failure
*
* @param i Number of tests.
* @param t Time in ticks for the whole test.
*
* \NOMANUAL
*/
int check_result(
int i, /* number of tests */
uint32_t t /* time in ticks for the whole test */
)
int check_result(int i, uint32_t t)
{
/*
bench_test_end checks tCheck static variable.
bench_test_start modifies it
* bench_test_end checks tCheck static variable.
* bench_test_start modifies it
*/
if (bench_test_end() != 0) {
fprintf(output_file, sz_case_result_fmt, sz_fail);
@ -159,12 +159,12 @@ int kbhit(void)
*
* RETURNS: N/A
*
* @param continuously Run test till the user presses the key.
*
* \NOMANUAL
*/
void init_output(
int *continuously /* run test till the user presses the key */
)
void init_output(int *continuously)
{
ARG_UNUSED(continuously);
@ -225,16 +225,18 @@ void main(void)
if (test_result) {
/* sema, lifo, fifo, stack account for twelve tests in total */
if (test_result == 12)
if (test_result == 12) {
fprintf(output_file, sz_module_result_fmt, sz_success);
else
}
else {
fprintf(output_file, sz_module_result_fmt, sz_partial);
}
else
fprintf(output_file, sz_module_result_fmt, sz_fail);
}
while (continuously && !kbhit());
else {
fprintf(output_file, sz_module_result_fmt, sz_fail);
}
} while (continuously && !kbhit());
output_close();
}

View file

@ -115,11 +115,13 @@ void main(void)
nano_task_sem_take(&sem[1]) ||
nano_task_sem_take(&sem[2]) ? TC_FAIL : TC_PASS;
if (TC_FAIL == rv)
if (TC_FAIL == rv) {
goto get_out;
}
for (int ii = 0; ii < 3; ii++)
for (int ii = 0; ii < 3; ii++) {
_NvicSwInterruptTrigger(ii);
}
rv = nano_task_sem_take(&sem[0]) &&
nano_task_sem_take(&sem[1]) &&

View file

@ -97,8 +97,7 @@ typedef struct {
void *data; /* pointer to data to use or return */
int value; /* value to be passed or returned */
};
}
ISR_INFO;
} ISR_INFO;
typedef int (* disable_interrupt_func)(int);
typedef void (* enable_interrupt_func)(int);

View file

@ -252,9 +252,10 @@ static void fiberEntry(int arg1, int arg2)
isrSemInfo.sem = &testSem;
_trigger_nano_isr_sem_give();
if (isrSemInfo.data == 1)
if (isrSemInfo.data == 1) {
semTestState = STS_ISR_WOKE_TASK;
}
}
/*******************************************************************************
*

View file

@ -340,9 +340,9 @@ void testIsrStackFromFiber(void)
_trigger_nano_isr_stack_push();
}
TC_PRINT("\n");
isrStackInfo.data = INVALID_DATA; /* Set variable to INVALID_DATA to ensure
* [data] changes
*/
/* Set variable to INVALID_DATA to ensure [data] changes */
isrStackInfo.data = INVALID_DATA;
TC_END_RESULT(retCode);