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

@ -119,8 +119,7 @@ void irq_handler_set(unsigned int vector,
/* does the encoded offset match <oldRoutine> ? */
if (opcodeOff == opcodeOffToMatch) {
/* match found -> write new routine and parameter */
/* match found -> write new routine and parameter */
UNALIGNED_WRITE(
(unsigned int *)&pIntStubMem[ix + 1],

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,23 +33,24 @@
#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]);
return -1;
}
printf("%X\n", atoi(argv[1]));
return 0;
}
}

View file

@ -85,7 +85,7 @@ static void clean_exit(const int exit_code);
typedef struct s_isrList {
void *fnc;
unsigned int dpl;
} ISR_LIST;
} ISR_LIST;
static ISR_LIST idt[256];
@ -95,7 +95,7 @@ enum {
NUSERFILES, /* number of user-provided file names */
EXECFILE=NUSERFILES, /* for name of executable */
NFILES /* total number of files open */
};
};
enum { SHORT_USAGE, LONG_USAGE };
static int fds[NUSERFILES] = {-1, -1};
@ -104,17 +104,17 @@ static unsigned int numVecs = (unsigned int)-1;
static struct version version = {KERNEL_VERSION, 1, 1, 0};
int main(int argc, char *argv[])
{
{
get_exec_name(argv[0]);
get_options(argc, argv); /* may exit */
open_files(); /* may exit */
genIdt();
close_files();
return 0;
}
}
static void get_options(int argc, char *argv[])
{
{
char *endptr;
int ii, opt;
@ -158,10 +158,10 @@ static void get_options(int argc, char *argv[])
exit(-1);
}
}
}
}
static void get_exec_name(char *pathname)
{
{
int end = strlen(pathname)-1;
while(end != -1) {
@ -179,10 +179,10 @@ static void get_exec_name(char *pathname)
--end;
}
filenames[EXECFILE] = &pathname[end];
}
}
static void open_files(void)
{
{
int ii;
fds[IFILE] = open(filenames[IFILE], O_RDONLY|O_BINARY);
@ -199,10 +199,10 @@ static void open_files(void)
exit(-1);
}
}
}
}
static void genIdt(void)
{
{
unsigned int i;
unsigned int size;
void *spurAddr;
@ -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;
@ -283,28 +291,26 @@ static void genIdt(void)
readError:
fprintf(stderr, "Error occured while reading input file. Aborting...\n");
clean_exit(-1);
}
}
static void close_files(void)
{
{
int ii;
for(ii = 0; ii < NUSERFILES; ii++) {
close(fds[ii]);
}
}
}
static void clean_exit(const int exit_code)
{
{
close_files();
exit(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;
@ -323,4 +329,4 @@ static void usage(const int len)
" -v Display version.\n\n"
" -h Display this help.\n\n"
"\nReturns -1 on error, 0 on success\n\n");
}
}

View file

@ -71,7 +71,7 @@ typedef struct {
Elf32_Half e_shentsize;
Elf32_Half e_shnum;
Elf32_Half e_shstrndx;
} Elf32_Ehdr;
} Elf32_Ehdr;
#define EHDRSZ sizeof(Elf32_Ehdr)
@ -245,7 +245,7 @@ typedef struct {
unsigned char st_info;
unsigned char st_other;
Elf32_Half st_shndx;
} Elf32_Sym;
} Elf32_Sym;
#define STN_UNDEF 0
@ -289,13 +289,13 @@ typedef struct {
typedef struct {
Elf32_Addr r_offset;
Elf32_Word r_info;
} Elf32_Rel;
} Elf32_Rel;
typedef struct {
Elf32_Addr r_offset;
Elf32_Word r_info;
Elf32_Sword r_addend;
} Elf32_Rela;
} Elf32_Rela;
#define ELF32_R_SYM(info) ((info)>>8)
#define ELF32_R_TYPE(info) ((unsigned char)(info))
@ -313,7 +313,7 @@ typedef struct {
Elf32_Word p_memsz;
Elf32_Word p_flags;
Elf32_Word p_align;
} Elf32_Phdr;
} Elf32_Phdr;
#define PHDRSZ sizeof(Elf32_Phdr)
@ -344,7 +344,7 @@ typedef struct {
Elf32_Word d_val;
Elf32_Addr d_ptr;
} d_un;
} Elf32_Dyn;
} Elf32_Dyn;
#define DT_NULL 0
#define DT_NEEDED 1

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

@ -122,7 +122,7 @@ static void get_options(int argc, char *argv[])
exit(-1);
}
}
for(ii = IFILE; ii < NUSERFILES; ii++) {
for (ii = IFILE; ii < NUSERFILES; ii++) {
if (!filenames[ii]) {
usage(SHORT_USAGE);
exit(-1);
@ -139,12 +139,12 @@ static void open_files(void)
fds[IFILE] = open_binary(filenames[IFILE], O_RDONLY);
fds[OFILE] = open(filenames[OFILE], open_w_flags, open_mode);
for(ii = 0; ii < NUSERFILES; ii++) {
for (ii = 0; ii < NUSERFILES; ii++) {
int invalid = fds[ii] == -1;
if (invalid) {
const char *invalid = filenames[ii];
fprintf(stderr, "invalid file %s\n", invalid);
for(--ii; ii >= 0; ii--) {
for (--ii; ii >= 0; ii--) {
close(fds[ii]);
}
exit(-1);
@ -229,7 +229,7 @@ static void close_files(void)
{
int ii;
for(ii = 0; ii < NUSERFILES; ii++) {
for (ii = 0; ii < NUSERFILES; ii++) {
close(fds[ii]);
}
}

View file

@ -40,21 +40,23 @@ 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);
}
}
#define EVENT_STR " EVENT _TaskIrqEvt%d NULL\n"
int main(
int argc,
char *argv[]
)
{
int main(int argc, char *argv[])
{
int i, j;
if (argc != 2) {
@ -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

@ -248,7 +248,7 @@ void _int_latency_stop(void);
static inline __attribute__((always_inline))
unsigned int irq_lock_inline(void)
{
{
unsigned int key = _do_irq_lock_inline();
#ifdef CONFIG_INT_LATENCY_BENCHMARK
@ -256,7 +256,7 @@ static inline __attribute__((always_inline))
#endif
return key;
}
}
/*******************************************************************************
@ -276,15 +276,16 @@ 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
_do_irq_unlock_inline();
return;
}
}
#endif /* CONFIG_NO_ISRS */
/* interrupt/exception/error related definitions */

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,13 +253,15 @@ 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;
}
}
}
/**********************/
@ -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,13 +387,15 @@ 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,8 +111,9 @@ 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,10 +177,12 @@ 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,16 +425,18 @@ 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,8 +516,9 @@ 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,8 +639,9 @@ 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,13 +69,17 @@ 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,12 +101,15 @@ 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)
@ -110,8 +117,9 @@ 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

@ -96,15 +96,15 @@ static char sw_isr_trigger_1[] = {
#if defined(CONFIG_CPU_CORTEXM)
#include <nanokernel.h>
static inline void sw_isr_trigger_0(void)
{
{
_NvicSwInterruptTrigger(0);
}
}
#if NUM_SW_IRQS >= 2
static inline void sw_isr_trigger_1(void)
{
{
_NvicSwInterruptTrigger(1);
}
}
#endif /* NUM_SW_IRQS >= 2 */
#endif /* CONFIG_CPU_CORTEXM */
#endif
@ -112,7 +112,7 @@ static inline void sw_isr_trigger_1(void)
struct isrInitInfo {
vvpfn isr[2];
void *arg[2];
};
};
/*******************************************************************************
*
@ -120,11 +120,8 @@ 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 */
@ -161,6 +158,6 @@ static int initIRQ
#endif /* VXMICRO_ARCH_x86 */
return 0;
}
}
#endif /* _IRQ_TEST_COMMON__H_ */

View file

@ -71,30 +71,28 @@ 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);
}
}
/*******************************************************************************
*
* 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);
#else
@ -104,7 +102,7 @@ static void myDelay
nano_fiber_timer_start(&timer, ticks);
nano_fiber_timer_wait(&timer);
#endif
}
}
/*******************************************************************************
*
@ -117,7 +115,7 @@ static void myDelay
*/
void philEntry(void)
{
{
#ifdef CONFIG_NANOKERNEL
struct nano_sem *f1; /* fork #1 */
struct nano_sem *f2; /* fork #2 */
@ -154,4 +152,4 @@ void philEntry(void)
PRINT(id, "THINKING");
RANDDELAY(id);
}
}
}

View file

@ -74,7 +74,7 @@ struct nano_sem forks[N_PHILOSOPHERS];
*/
int main(void)
{
{
int i;
PRINTF(DEMO_DESCRIPTION, "fibers", "nanokernel");
@ -85,16 +85,17 @@ 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) {
extern void nano_cpu_idle(void);
nano_cpu_idle();
}
}
}
#else
/*******************************************************************************
@ -105,7 +106,7 @@ int main(void)
*/
void philDemo(void)
{
{
PRINTF(DEMO_DESCRIPTION, "tasks", "microkernel");
task_group_start(PHI);
@ -114,5 +115,5 @@ void philDemo(void)
while (1) {
task_sleep(10000);
}
}
}
#endif

View file

@ -66,7 +66,7 @@ int example_handler (int event);
*/
void event_test(void)
{
{
int nReturn;
int nCounter;
uint32_t et; /* elapsed time */
@ -174,7 +174,7 @@ void event_test(void)
output_file);
return; /* success */
}
}
/*******************************************************************************
@ -190,10 +190,10 @@ void event_test(void)
*/
int example_handler (int event)
{
{
nEventValue = event + 1;
return 1;
}
}
#endif /* EVENT_BENCH */

View file

@ -44,7 +44,7 @@
*/
void queue_test(void)
{
{
uint32_t et; /* elapsed time */
int i;
@ -111,6 +111,6 @@ void queue_test(void)
PRINT_F(output_file, FORMAT,
"enqueue 4 bytes in FIFO to a waiting higher priority task",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
}
}
#endif /* FIFO_BENCH */

View file

@ -46,7 +46,7 @@
*/
void dequtask(void)
{
{
int x, i;
for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
@ -56,6 +56,6 @@ void dequtask(void)
for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
task_fifo_get_wait(DEMOQX4, &x);
}
}
}
#endif /* FIFO_BENCH */

View file

@ -100,7 +100,7 @@ void mailbox_put(uint32_t size, int count, uint32_t *time);
*/
void mailbox_test(void)
{
{
uint32_t putsize;
uint32_t puttime;
int putcount;
@ -138,7 +138,7 @@ void mailbox_test(void)
PRINT_STRING(dashline, output_file);
PRINT_OVERHEAD();
PRINT_XFER_RATE();
}
}
/*******************************************************************************
@ -147,15 +147,15 @@ 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;
@ -172,6 +172,6 @@ void mailbox_put(
t = TIME_STAMP_DELTA_GET(t);
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);
check_result();
}
}
#endif /* MAILBOX_BENCH */

View file

@ -56,7 +56,7 @@ int mailbox_get(kmbox_t mailbox,int size,int count,unsigned int* time);
*/
void mailrecvtask(void)
{
{
int getsize;
unsigned int gettime;
int getcount;
@ -78,7 +78,7 @@ void mailrecvtask(void)
getinfo.count = getcount;
task_fifo_put_wait(MB_COMM, &getinfo); /* acknowledge to master */
}
}
}
/*******************************************************************************
@ -87,16 +87,16 @@ 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;
struct k_msg Message;
@ -114,9 +114,10 @@ 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;
}
return 0;
}
#endif /* MAILBOX_BENCH */

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,14 +82,14 @@ 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);
@ -98,7 +97,7 @@ void init_output(
* send all printf and fprintf to console
*/
output_file = stdout;
}
}
/*******************************************************************************
*
@ -110,8 +109,8 @@ void init_output(
*/
void output_close(void)
{
}
{
}
/* no need to wait for user key press when using console */
#define WAIT_FOR_USER() {}
@ -128,7 +127,7 @@ void output_close(void)
/* see config.h to select or to unselect*/
void BenchTask(void)
{
{
int autorun = 0, continuously = 0;
init_output(&continuously, &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,11 +163,12 @@ 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();
}
}
/*******************************************************************************
@ -182,6 +181,6 @@ void BenchTask(void)
*/
void dummy_test(void)
{
{
return;
}
}

View file

@ -149,32 +149,30 @@ extern void event_test(void);
*/
#define PRINT_F(stream, fmt, ...) \
{ \
{ \
snprintf(sline, SLINE_LEN, fmt, ##__VA_ARGS__); \
PRINT_STRING(sline, stream); \
}
}
#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)
{
{
uint32_t et;
bench_test_start();
et = TIME_STAMP_DELTA_GET(0);
return et;
}
}
#define check_result() \
{ \
if (bench_test_end() < 0) \
{ \
{ \
if (bench_test_end() < 0) { \
PRINT_OVERFLOW_ERROR(); \
return; /* error */ \
} \
}
}
#endif /* _MASTER_H */

View file

@ -46,7 +46,7 @@
*/
void memorymap_test(void)
{
{
uint32_t et; /* elapsed time */
int i;
void* p;
@ -62,6 +62,6 @@ void memorymap_test(void)
PRINT_F(output_file, FORMAT, "average alloc and dealloc memory page",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MAP_RUNS)));
}
}
#endif /* MEMMAP_BENCH */

View file

@ -44,7 +44,7 @@
*/
void mempool_test(void)
{
{
uint32_t et; /* elapsed time */
int i;
struct k_block block;
@ -61,6 +61,6 @@ void mempool_test(void)
PRINT_F(output_file, FORMAT,
"average alloc and dealloc memory pool block",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_POOL_RUNS)));
}
}
#endif /* MEMPOOL_BENCH */

View file

@ -44,7 +44,7 @@
*/
void mutex_test(void)
{
{
uint32_t et; /* elapsed time */
int i;
@ -59,6 +59,6 @@ void mutex_test(void)
PRINT_F(output_file, FORMAT, "average lock and unlock mutex",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MUTEX_RUNS)));
}
}
#endif /* MUTEX_BENCH */

View file

@ -48,7 +48,7 @@ extern void _task_nop(void);
*/
void call_test(void)
{
{
uint32_t et; /* Elapsed Time */
int i;
@ -61,6 +61,6 @@ void call_test(void)
PRINT_F(output_file, FORMAT, "minimum VxMicro call time",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_NOP_RUNS));
}
}
#endif /* MICROKERNEL_CALL_BENCH */

View file

@ -117,7 +117,7 @@ int pipeput(kpipe_t pipe, K_PIPE_OPTION
*/
void pipe_test(void)
{
{
uint32_t putsize;
int getsize;
uint32_t puttime[3];
@ -199,7 +199,7 @@ void pipe_test(void)
PRINT_STRING(dashline, output_file);
task_priority_set(task_id_get(), TaskPrio);
}
}
}
/*******************************************************************************
@ -208,17 +208,17 @@ 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;
int sizexferd_total = 0;
@ -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,10 +262,9 @@ int pipeput(
PRINT_STRING("| Tick occured. Results may be inaccurate ",
output_file);
}
PRINT_STRING(" |\n",
output_file);
PRINT_STRING(" |\n", output_file);
}
return 0;
}
}
#endif /* PIPE_BENCH */

View file

@ -57,7 +57,7 @@ int pipeget(kpipe_t pipe, K_PIPE_OPTION option,
*/
void piperecvtask(void)
{
{
int getsize;
unsigned int gettime;
int getcount;
@ -95,7 +95,7 @@ void piperecvtask(void)
}
}
}
}
/*******************************************************************************
@ -104,17 +104,18 @@ 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;
int sizexferd_total = 0;
@ -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);
@ -159,6 +164,6 @@ int pipeget(
output_file);
}
return 0;
}
}
#endif /* PIPE_BENCH */

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);
@ -60,7 +58,7 @@ void piperecvtask(void);
*/
void recvtask(void)
{
{
/* order must be compatible with master.c ! */
#ifdef FIFO_BENCH
task_sem_take_wait(STARTRCV);
@ -78,4 +76,4 @@ void recvtask(void)
task_sem_take_wait(STARTRCV);
piperecvtask();
#endif
}
}

View file

@ -42,7 +42,7 @@ typedef struct {
int count;
unsigned int time;
int size;
} GetInfo;
} GetInfo;
/* global data */
extern char data_recv[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)];

View file

@ -45,7 +45,7 @@
*/
void sema_test(void)
{
{
uint32_t et; /* elapsed Time */
int i;
@ -143,6 +143,6 @@ void sema_test(void)
PRINT_F(output_file, FORMAT, "signal to waitm (4), with timeout",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
}
}
#endif /* SEMA_BENCH */

View file

@ -47,7 +47,7 @@
*/
void waittask(void)
{
{
int i;
ksem_t slist[5];
@ -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

@ -56,7 +56,7 @@ extern uint64_t __main_tsc; /* timestamp when main() begins executing */
extern uint64_t __idle_tsc; /* timestamp when CPU went idle */
void bootTimeTask(void)
{
{
uint64_t task_tsc; /* timestamp at beginning of first task */
uint64_t _start_us; /* being of __start timestamp in us */
uint64_t main_us; /* begin of main timestamp in us */
@ -117,7 +117,7 @@ void bootTimeTask(void)
TC_END_RESULT(TC_PASS);
TC_END_REPORT(TC_PASS);
}
}
#ifdef CONFIG_NANOKERNEL
@ -131,13 +131,13 @@ char fiberStack[512];
*/
void main(void)
{
{
/* record timestamp for nanokernel's main() function */
__main_tsc = _NanoTscRead();
/* create bootTime fibers */
task_fiber_start(fiberStack, 512,
(nano_fiber_entry_t) bootTimeTask, 0, 0, 6, 0);
}
}
#endif /* CONFIG_NANOKERNEL */

View file

@ -142,7 +142,7 @@ static pfunc func_array[] = {
(pfunc)task_sleep,
(pfunc)task_yield,
#endif /* TEST_max */
};
};
/*******************************************************************************
*
@ -152,9 +152,9 @@ static pfunc func_array[] = {
*/
void dummyIsr(void *unused)
{
{
ARG_UNUSED(unused);
}
}
#ifdef TEST_reg
/*******************************************************************************
@ -169,13 +169,13 @@ void dummyIsr(void *unused)
*/
static void isrDummyIntStub(void *unused)
{
{
ARG_UNUSED(unused);
isr_dummy();
CODE_UNREACHABLE;
}
}
#endif /* TEST_reg */
/*******************************************************************************
@ -191,7 +191,7 @@ static void isrDummyIntStub(void *unused)
*/
void fgTaskEntry(void)
{
{
#ifdef TEST_max
/* dynamically link in dummy ISR */
irq_connect(NANO_SOFT_IRQ, IRQ_PRIORITY, dummyIsr,
@ -208,6 +208,6 @@ void fgTaskEntry(void)
while (1) {
i++;
}
}
}
#endif /* TEST_min */

View file

@ -54,7 +54,7 @@ int errorCount = 0; /* track number of errors */
*/
void nanoTest(void)
{
{
PRINT_NANO_BANNER();
PRINT_TIME_BANNER();
@ -72,7 +72,7 @@ void nanoTest(void)
nanoIntLockUnlock();
printDashLine();
}
}
#ifdef CONFIG_NANOKERNEL
/*******************************************************************************
@ -85,14 +85,14 @@ void nanoTest(void)
*/
void main(void)
{
{
bench_test_init();
nanoTest();
PRINT_END_BANNER();
TC_END_REPORT(errorCount);
}
}
#else
@ -112,7 +112,7 @@ void microTaskSwitchYield(void);
*/
void microTest(void)
{
{
PRINT_MICRO_BANNER();
PRINT_TIME_BANNER();
@ -130,7 +130,7 @@ void microTest(void)
microTaskSwitchYield();
printDashLine();
}
}
/*******************************************************************************
*
@ -142,7 +142,7 @@ void microTest(void)
*/
void microMain(void)
{
{
bench_test_init();
nanoTest();
@ -150,5 +150,5 @@ void microMain(void)
PRINT_END_BANNER();
TC_END_REPORT(errorCount);
}
}
#endif /* CONFIG_NANOKERNEL */

View file

@ -58,12 +58,12 @@ static uint32_t timestamp;
*/
static void latencyTestIsr(void *unused)
{
{
ARG_UNUSED(unused);
flagVar = 1;
timestamp = TIME_STAMP_DELTA_GET(0);
}
}
/*******************************************************************************
*
@ -78,16 +78,17 @@ static void latencyTestIsr(void *unused)
*/
static void makeInt(void)
{
{
initSwInterrupt(latencyTestIsr);
flagVar = 0;
raiseIntFunc();
if (flagVar != 1) {
PRINT_FORMAT(" Flag variable has not changed. FAILED\n");
}
else
else {
timestamp = TIME_STAMP_DELTA_GET(timestamp);
}
}
/*******************************************************************************
*
@ -99,7 +100,7 @@ static void makeInt(void)
*/
int microIntToTask(void)
{
{
PRINT_FORMAT(" 1- Measure time to switch from ISR to back to"
" interrupted task");
TICK_SYNCH();
@ -109,6 +110,6 @@ int microIntToTask(void)
timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
}
return 0;
}
}
#endif /* MICROKERNEL */

View file

@ -60,12 +60,12 @@ static uint32_t timestamp = 0;
*/
static void latencyTestIsr(void *unused)
{
{
ARG_UNUSED(unused);
isr_event_send(EVENT0);
timestamp = TIME_STAMP_DELTA_GET(0);
}
}
/*******************************************************************************
*
@ -81,12 +81,12 @@ static void latencyTestIsr(void *unused)
*/
void microInt(void)
{
{
task_sem_take_wait(INTSEMA);
setSwInterrupt(latencyTestIsr);
raiseIntFunc();
task_suspend(task_id_get());
}
}
/*******************************************************************************
*
@ -98,7 +98,7 @@ void microInt(void)
*/
int microIntToTaskEvt(void)
{
{
PRINT_FORMAT(" 2- Measure time from ISR to executing a different task"
" (rescheduled)");
TICK_SYNCH();
@ -108,6 +108,6 @@ int microIntToTaskEvt(void)
PRINT_FORMAT(" switch time is %lu tcs = %lu nsec",
timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
return 0;
}
}
#endif /* CONFIG_MICROKERNEL */

View file

@ -66,7 +66,7 @@ static uint32_t timestamp;
*/
int microSemaLockUnlock(void)
{
{
int i;
PRINT_FORMAT(" 3- Measure average time to signal a sema then test"
@ -103,7 +103,7 @@ int microSemaLockUnlock(void)
PRINT_OVERFLOW_ERROR();
}
return 0;
}
}
/*******************************************************************************
*
@ -118,7 +118,7 @@ int microSemaLockUnlock(void)
*/
int microMutexLockUnlock(void)
{
{
int i;
PRINT_FORMAT(" 4- Measure average time to lock a mutex then"
@ -140,6 +140,6 @@ int microMutexLockUnlock(void)
timestamp / N_TEST_MUTEX,
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_MUTEX));
return 0;
}
}
#endif /* CONFIG_MICROKERNEL */

View file

@ -62,12 +62,12 @@ static uint32_t helper_task_iterations = 0;
*/
void yieldingTask(void)
{
{
while (helper_task_iterations < NB_OF_YIELD) {
task_yield();
helper_task_iterations++;
}
}
}
/*******************************************************************************
*
@ -79,7 +79,7 @@ void yieldingTask(void)
*/
void microTaskSwitchYield(void)
{
{
uint32_t iterations = 0;
int32_t delta;
uint32_t timestamp;
@ -133,6 +133,6 @@ void microTaskSwitchYield(void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp,
(iterations + helper_task_iterations)));
}
}
}
#endif

View file

@ -77,7 +77,7 @@ static volatile int ctxSwitchBalancer = 0;
*/
static void fiberOne(void)
{
{
nano_fiber_sem_take_wait(&syncSema);
timestamp = TIME_STAMP_DELTA_GET(0);
while (ctxSwitchCounter < NCTXSWITCH) {
@ -86,7 +86,7 @@ static void fiberOne(void)
ctxSwitchBalancer--;
}
timestamp = TIME_STAMP_DELTA_GET(timestamp);
}
}
/*******************************************************************************
*
@ -101,14 +101,14 @@ static void fiberOne(void)
*/
static void fiberTwo(void)
{
{
nano_fiber_sem_give(&syncSema);
while (ctxSwitchCounter < NCTXSWITCH) {
fiber_yield();
ctxSwitchCounter++;
ctxSwitchBalancer++;
}
}
}
/*******************************************************************************
*
@ -120,7 +120,7 @@ static void fiberTwo(void)
*/
int nanoCtxSwitch(void)
{
{
PRINT_FORMAT(" 4- Measure average context switch time between fibers");
nano_sem_init(&syncSema);
ctxSwitchCounter = 0;
@ -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;
}
return 0;
}

View file

@ -60,11 +60,11 @@ static uint32_t timestamp;
*/
static void latencyTestIsr(void *unused)
{
{
ARG_UNUSED(unused);
timestamp = TIME_STAMP_DELTA_GET(timestamp);
}
}
/*******************************************************************************
*
@ -79,11 +79,11 @@ static void latencyTestIsr(void *unused)
*/
static void fiberInt(void)
{
{
initSwInterrupt(latencyTestIsr);
timestamp = TIME_STAMP_DELTA_GET(0);
raiseIntFunc();
}
}
/*******************************************************************************
*
@ -95,7 +95,7 @@ static void fiberInt(void)
*/
int nanoIntLatency(void)
{
{
PRINT_FORMAT(" 1- Measure time to switch from fiber to ISR execution");
TICK_SYNCH();
task_fiber_start(&fiberStack[0], STACKSIZE,
@ -103,4 +103,4 @@ int nanoIntLatency(void)
PRINT_FORMAT(" switching time is %lu tcs = %lu nsec",
timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
return 0;
}
}

View file

@ -59,7 +59,7 @@ static uint32_t timestamp = 0;
*/
int nanoIntLockUnlock(void)
{
{
int i;
unsigned int mask;
@ -103,4 +103,4 @@ int nanoIntLockUnlock(void)
PRINT_OVERFLOW_ERROR();
}
return 0;
}
}

View file

@ -62,12 +62,12 @@ static uint32_t timestamp;
*/
static void latencyTestIsr(void *unused)
{
{
ARG_UNUSED(unused);
flagVar = 1;
timestamp = TIME_STAMP_DELTA_GET(0);
}
}
/*******************************************************************************
*
@ -82,16 +82,17 @@ static void latencyTestIsr(void *unused)
*/
static void fiberInt(void)
{
{
setSwInterrupt(latencyTestIsr);
flagVar = 0;
raiseIntFunc();
if (flagVar != 1) {
PRINT_FORMAT(" Flag variable has not changed. FAILED");
}
else
else {
timestamp = TIME_STAMP_DELTA_GET(timestamp);
}
}
/*******************************************************************************
*
@ -103,7 +104,7 @@ static void fiberInt(void)
*/
int nanoIntToFiber(void)
{
{
PRINT_FORMAT(" 2- Measure time to switch from ISR back to interrupted"
" fiber");
TICK_SYNCH();
@ -114,4 +115,4 @@ int nanoIntToFiber(void)
timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
}
return 0;
}
}

View file

@ -73,12 +73,12 @@ static uint32_t timestamp = 0;
*/
static void latencyTestIsr(void *unused)
{
{
ARG_UNUSED(unused);
nano_isr_sem_give(&testSema);
timestamp = TIME_STAMP_DELTA_GET(0);
}
}
/*******************************************************************************
*
@ -93,11 +93,11 @@ static void latencyTestIsr(void *unused)
*/
static void fiberInt(void)
{
{
setSwInterrupt(latencyTestIsr);
raiseIntFunc();
fiber_yield();
}
}
/*******************************************************************************
*
@ -112,10 +112,10 @@ static void fiberInt(void)
*/
static void fiberWaiter(void)
{
{
nano_fiber_sem_take_wait(&testSema);
timestamp = TIME_STAMP_DELTA_GET(timestamp);
}
}
/*******************************************************************************
*
@ -127,7 +127,7 @@ static void fiberWaiter(void)
*/
int nanoIntToFiberSem(void)
{
{
PRINT_FORMAT(" 3- Measure time from ISR to executing a different fiber"
" (rescheduled)");
nano_sem_init(&testSema);
@ -141,4 +141,4 @@ int nanoIntToFiberSem(void)
PRINT_FORMAT(" switching time is %lu tcs = %lu nsec",
timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
return 0;
}
}

View file

@ -85,7 +85,7 @@ typedef int64_t TICK_TYPE;
extern uint32_t tm_off;
static inline uint32_t TIME_STAMP_DELTA_GET(uint32_t ts)
{
{
uint32_t t;
/* serialize so OS_GET_TIME() is not reordered */
@ -93,21 +93,22 @@ 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;
}
return res;
}
/*
* Routine initializes the benchmark timing measurement
* The function sets up the global variable tm_off
*/
static inline void bench_test_init(void)
{
{
uint32_t t = OS_GET_TIME();
tm_off = OS_GET_TIME() - t;
}
}
#if defined(CONFIG_MICROKERNEL) && defined(KERNEL)
@ -127,23 +128,23 @@ static TICK_TYPE tCheck;
* Functions modify the tCheck global variable.
*/
static inline void bench_test_start(void)
{
{
tCheck = 0;
/* before reading time we synchronize to the start of the timer tick */
TICK_SYNCH();
tCheck = TICK_GET(&tCheck);
}
}
/* returns 0 if the number of ticks is valid and -1 if not */
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;
}
return 0;
}
/*
* Returns -1 if number of ticks cause high precision timer counter
@ -152,12 +153,12 @@ static inline int bench_test_end(void)
* results or is it completely invalid
*/
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;
}
return 0;
}
#endif /* CONFIG_NANOKERNEL || CONFIG_MICROKERNEL */
#endif /* _TIMESTAMP_H_ */

View file

@ -73,13 +73,13 @@ char tmpString[TMP_STRING_SIZE];
*/
int initSwInterrupt(ptestIsr pIsrHdlr)
{
{
vector = irq_connect(NANO_SOFT_IRQ, IRQ_PRIORITY, pIsrHdlr,
(void *) 0, isrLatencyHandlerStub);
pcurrIsrFunc = pIsrHdlr;
return vector;
}
}
/*******************************************************************************
*
@ -95,10 +95,10 @@ int initSwInterrupt(ptestIsr pIsrHdlr)
*/
void setSwInterrupt(ptestIsr pIsrHdlr)
{
{
irq_handler_set(vector, pcurrIsrFunc, pIsrHdlr, (void *)0);
pcurrIsrFunc = pIsrHdlr;
}
}
/*******************************************************************************
*
@ -114,6 +114,6 @@ void setSwInterrupt(ptestIsr pIsrHdlr)
* \NOMANUAL
*/
void raiseIntFunc(void)
{
{
raiseInt(vector);
}
}

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)
/*******************************************************************************
*
@ -69,10 +67,10 @@ extern int errorCount;
*/
static inline void printDashLine(void)
{
{
PRINTF("|-----------------------------------------------------------------"
"------------|\n");
}
}
#define PRINT_END_BANNER() \
PRINTF("| E N D "\
@ -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

@ -64,7 +64,7 @@ static char fiberStack[FIBER_STACK_SIZE]; /* test fiber stack size */
* RETURNS: N/A
*/
static void testFiberEntry(void)
{
{
/* signal event for eventWaitTest() */
/* single test */
nano_fiber_sem_take_wait(&fiberSem);
@ -84,7 +84,7 @@ static void testFiberEntry(void)
nano_fiber_sem_take_wait(&fiberSem);
fiber_event_send(EVENT_ID);
fiber_event_send(EVENT_ID);
}
}
/*******************************************************************************
*
@ -94,8 +94,8 @@ static void testFiberEntry(void)
*/
void testFiberInit(void)
{
{
nano_sem_init(&fiberSem);
task_fiber_start(fiberStack, FIBER_STACK_SIZE, (nano_fiber_entry_t)testFiberEntry,
0, 0, FIBER_PRIORITY, 0);
}
}

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

@ -165,15 +165,15 @@ char buffer[BUFSIZE];
int memset_test(void)
{
TC_PRINT ("\tmemset ...\t");
TC_PRINT("\tmemset ...\t");
memset (buffer, 'a', BUFSIZE);
memset(buffer, 'a', BUFSIZE);
if (buffer[0] != 'a' || buffer[BUFSIZE-1] != 'a') {
TC_PRINT ("failed\n");
TC_PRINT("failed\n");
return TC_FAIL;
}
TC_PRINT ("passed\n");
TC_PRINT("passed\n");
return TC_PASS;
}
@ -186,16 +186,16 @@ int memset_test(void)
int strlen_test(void)
{
TC_PRINT ("\tstrlen ...\t");
TC_PRINT("\tstrlen ...\t");
memset (buffer, '\0', BUFSIZE);
memset (buffer, 'b', 5); /* 5 is BUFSIZE / 2 */
memset(buffer, '\0', BUFSIZE);
memset(buffer, 'b', 5); /* 5 is BUFSIZE / 2 */
if (strlen(buffer) != 5) {
TC_PRINT ("failed\n");
TC_PRINT("failed\n");
return TC_FAIL;
}
TC_PRINT ("passed\n");
TC_PRINT("passed\n");
return TC_PASS;
}
@ -206,32 +206,32 @@ int strlen_test(void)
* RETURNS: TC_PASS or TC_FAIL
*/
int strcmp_test (void)
int strcmp_test(void)
{
strcpy(buffer, "eeeee");
TC_PRINT ("\tstrcmp less ...\t");
TC_PRINT("\tstrcmp less ...\t");
if (strcmp(buffer, "fffff") >= 0) {
TC_PRINT ("failed\n");
TC_PRINT("failed\n");
return TC_FAIL;
} else {
TC_PRINT ("passed\n");
TC_PRINT("passed\n");
}
TC_PRINT ("\tstrcmp equal ...\t");
TC_PRINT("\tstrcmp equal ...\t");
if (strcmp(buffer, "eeeee") != 0) {
TC_PRINT ("failed\n");
TC_PRINT("failed\n");
return TC_FAIL;
} else {
TC_PRINT ("passed\n");
TC_PRINT("passed\n");
}
TC_PRINT ("\tstrcmp greater ...\t");
TC_PRINT("\tstrcmp greater ...\t");
if (strcmp(buffer, "ddddd") <= 0) {
TC_PRINT ("failed\n");
TC_PRINT("failed\n");
return TC_FAIL;
} else {
TC_PRINT ("passed\n");
TC_PRINT("passed\n");
}
return TC_PASS;
@ -244,32 +244,32 @@ int strcmp_test (void)
* RETURNS: TC_PASS or TC_FAIL
*/
int strncmp_test (void)
int strncmp_test(void)
{
strncpy(buffer, "eeeeeeeeeeee", BUFSIZE);
TC_PRINT ("\tstrncmp 0 ...\t");
TC_PRINT("\tstrncmp 0 ...\t");
if (strncmp(buffer, "fffff", 0) != 0) {
TC_PRINT ("failed\n");
TC_PRINT("failed\n");
return TC_FAIL;
} else {
TC_PRINT ("passed\n");
TC_PRINT("passed\n");
}
TC_PRINT ("\tstrncmp 3 ...\t");
TC_PRINT("\tstrncmp 3 ...\t");
if (strncmp(buffer, "eeeff", 3) != 0) {
TC_PRINT ("failed\n");
TC_PRINT("failed\n");
return TC_FAIL;
} else {
TC_PRINT ("passed\n");
TC_PRINT("passed\n");
}
TC_PRINT ("\tstrncmp 10 ...\t");
TC_PRINT("\tstrncmp 10 ...\t");
if (strncmp(buffer, "eeeeeeeeeeeff", BUFSIZE) != 0) {
TC_PRINT ("failed\n");
TC_PRINT("failed\n");
return TC_FAIL;
} else {
TC_PRINT ("passed\n");
TC_PRINT("passed\n");
}
return TC_PASS;
@ -283,19 +283,19 @@ int strncmp_test (void)
* RETURNS: TC_PASS or TC_FAIL
*/
int strcpy_test (void)
int strcpy_test(void)
{
TC_PRINT ("\tstrcpy ...\t");
TC_PRINT("\tstrcpy ...\t");
memset (buffer, '\0', BUFSIZE);
memset(buffer, '\0', BUFSIZE);
strcpy(buffer, "10 chars!!\0");
if (strcmp(buffer, "10 chars!!\0") != 0) {
TC_PRINT ("failed\n");
TC_PRINT("failed\n");
return TC_FAIL;
}
TC_PRINT ("passed\n");
TC_PRINT("passed\n");
return TC_PASS;
}
@ -306,20 +306,20 @@ int strcpy_test (void)
* RETURNS: TC_PASS or TC_FAIL
*/
int strncpy_test (void)
int strncpy_test(void)
{
TC_PRINT ("\tstrncpy ...\t");
TC_PRINT("\tstrncpy ...\t");
memset (buffer, '\0', BUFSIZE);
memset(buffer, '\0', BUFSIZE);
strncpy(buffer, "This is over 10 characters", BUFSIZE);
/* Purposely different values */
if (strncmp(buffer, "This is over 20 characters", BUFSIZE) != 0) {
TC_PRINT ("failed\n");
TC_PRINT("failed\n");
return TC_FAIL;
}
TC_PRINT ("passed\n");
TC_PRINT("passed\n");
return TC_PASS;
}
@ -330,27 +330,27 @@ int strncpy_test (void)
* RETURNS: TC_PASS or TC_FAIL
*/
int strchr_test (void)
int strchr_test(void)
{
char *rs = NULL;
TC_PRINT ("\tstrchr ...\t");
TC_PRINT("\tstrchr ...\t");
memset (buffer, '\0', BUFSIZE);
memset(buffer, '\0', BUFSIZE);
strncpy(buffer, "Copy 10", BUFSIZE);
rs = strchr(buffer, '1');
if (!rs) {
TC_PRINT ("failed\n");
TC_PRINT("failed\n");
return TC_FAIL;
}
if (strncmp(rs, "10", 2) != 0) {
TC_PRINT ("failed\n");
TC_PRINT("failed\n");
return TC_FAIL;
}
TC_PRINT ("passed\n");
TC_PRINT("passed\n");
return TC_PASS;
}
@ -388,8 +388,8 @@ int RegressionTask(void)
{
TC_PRINT("Validating access to supported libraries\n");
if (limitsTest () || stdboolTest () || stddefTest () ||
stdintTest () || stringTest ()) {
if (limitsTest() || stdboolTest() || stddefTest() ||
stdintTest() || stringTest()) {
TC_PRINT("Library validation failed\n");
return TC_FAIL;
}

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

@ -88,11 +88,11 @@ kmemory_pool_t smallBlkszPool = SMALLBLKSZPOOL;
*/
void MsgSenderTaskEntry(void)
{
{
extern int MsgSenderTask(void);
task_sem_give(resultSems[MsgSenderTask()]);
}
}
/*******************************************************************************
*
@ -105,11 +105,11 @@ void MsgSenderTaskEntry(void)
*/
void MsgRcvrTaskEntry(void)
{
{
extern int MsgRcvrTask(void);
task_sem_give(resultSems[MsgRcvrTask()]);
}
}
/*******************************************************************************
*
@ -122,7 +122,7 @@ void MsgRcvrTaskEntry(void)
*/
void MonitorTaskEntry(void)
{
{
ksem_t result;
int tasksDone;
@ -149,4 +149,4 @@ void MonitorTaskEntry(void)
TC_END_RESULT(TC_PASS);
TC_END_REPORT(TC_PASS);
}
}

View file

@ -89,7 +89,7 @@ static int tcRC = TC_PASS; /* test case return code */
*/
void Task10(void)
{
{
int rv;
task_sleep(3 * ONE_SECOND + HALF_SECOND);
@ -101,7 +101,7 @@ void Task10(void)
TC_ERROR("Failed to timeout on mutex 0x%x\n", Mutex4);
return;
}
} /* Task10 */
} /* Task10 */
/*******************************************************************************
@ -112,7 +112,7 @@ void Task10(void)
*/
void Task15(void)
{
{
int rv;
task_sleep(3 * ONE_SECOND + 3 * FOURTH_SECOND);
@ -134,7 +134,7 @@ void Task15(void)
}
task_mutex_unlock(Mutex4);
}
}
/*******************************************************************************
*
@ -144,7 +144,7 @@ void Task15(void)
*/
void Task20(void)
{
{
int rv;
task_sleep(2 * ONE_SECOND + HALF_SECOND);
@ -164,7 +164,7 @@ void Task20(void)
return;
}
} /* Task20 */
} /* Task20 */
/*******************************************************************************
*
@ -174,7 +174,7 @@ void Task20(void)
*/
void Task25(void)
{
{
int rv;
task_sleep(ONE_SECOND + HALF_SECOND);
@ -187,7 +187,7 @@ void Task25(void)
}
task_mutex_unlock(Mutex2);
} /* Task25 */
} /* Task25 */
/*******************************************************************************
*
@ -197,7 +197,7 @@ void Task25(void)
*/
void Task30(void)
{
{
int rv;
task_sleep(HALF_SECOND); /* Allow lower priority task to run */
@ -218,7 +218,7 @@ void Task30(void)
}
task_mutex_unlock(Mutex1);
}
}
/*******************************************************************************
*
@ -228,7 +228,7 @@ void Task30(void)
*/
void Task45(void)
{
{
int rv;
task_sleep(3 * ONE_SECOND + HALF_SECOND);
@ -239,7 +239,7 @@ void Task45(void)
return;
}
task_mutex_unlock(Mutex3);
}
}
/*******************************************************************************
*
@ -251,7 +251,7 @@ void Task45(void)
*/
void RegressionTask(void)
{
{
int rv;
int i;
kmutex_t mutexes[4] = {Mutex1, Mutex2, Mutex3, Mutex4};
@ -350,4 +350,4 @@ void RegressionTask(void)
errorReturn:
TC_END_RESULT(tcRC);
TC_END_REPORT(tcRC);
} /* RegressionTask */
} /* RegressionTask */

View file

@ -82,11 +82,11 @@ kpipe_t pipeId = PIPE_ID;
*/
void RegressionTaskEntry(void)
{
{
extern int RegressionTask(void);
task_sem_give(resultSems[RegressionTask()]);
}
}
/*******************************************************************************
*
@ -99,11 +99,11 @@ void RegressionTaskEntry(void)
*/
void AlternateTaskEntry(void)
{
{
extern int AlternateTask(void);
task_sem_give(resultSems[AlternateTask()]);
}
}
/*******************************************************************************
*
@ -116,7 +116,7 @@ void AlternateTaskEntry(void)
*/
void MonitorTaskEntry(void)
{
{
ksem_t result;
int tasksDone;
@ -143,4 +143,4 @@ void MonitorTaskEntry(void)
TC_END_RESULT(TC_PASS);
TC_END_REPORT(TC_PASS);
}
}

View file

@ -64,7 +64,7 @@ typedef struct {
K_PIPE_OPTION options; /* options for task_pipe_XXX() APIs */
int sent; /* expected # of bytes sent */
int rcode; /* expected return code */
} SIZE_EXPECT;
} SIZE_EXPECT;
/* locals */
@ -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

@ -58,7 +58,7 @@ This modules tests the following secure routines:
*/
void MainTask(void)
{
{
int result;
/* wait for the first task to start */
result = task_sem_take_wait_timeout(SEMA1, WAIT_TOUT);
@ -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;
@ -102,7 +105,7 @@ void MainTask(void)
fail:
TC_END_RESULT(TC_FAIL);
TC_END_REPORT(TC_FAIL);
}
}
/*******************************************************************************
*
@ -113,7 +116,7 @@ fail:
* RETURNS: N/A
*/
void MemcpyTask(void)
{
{
uint8_t buf1[BUFSIZE];
uint8_t buf2[BUFSIZE + 1];
@ -121,10 +124,11 @@ 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);
}
}
/*******************************************************************************
*
@ -135,10 +139,9 @@ void MemcpyTask(void)
* RETURNS: N/A
*/
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,7 +153,8 @@ 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

@ -81,7 +81,7 @@ extern ksem_t semList[];
*/
int simpleSemaTest(void)
{
{
int signalCount;
int i;
int status;
@ -164,7 +164,7 @@ int simpleSemaTest(void)
}
return TC_PASS;
}
}
/*******************************************************************************
*
@ -174,7 +174,7 @@ int simpleSemaTest(void)
*/
int simpleSemaWaitTest(void)
{
{
int status;
int i;
@ -222,7 +222,7 @@ int simpleSemaWaitTest(void)
}
return TC_PASS;
}
}
/*******************************************************************************
*
@ -232,7 +232,7 @@ int simpleSemaWaitTest(void)
*/
int simpleGroupTest(void)
{
{
int i;
int j;
int status;
@ -302,7 +302,7 @@ int simpleGroupTest(void)
}
return TC_PASS;
}
}
/*******************************************************************************
*
@ -315,7 +315,7 @@ int simpleGroupTest(void)
*/
int simpleGroupWaitTest(void)
{
{
int i;
ksem_t sema;
@ -365,7 +365,7 @@ int simpleGroupWaitTest(void)
}
return TC_PASS;
}
}
/*******************************************************************************
*
@ -382,7 +382,7 @@ int simpleGroupWaitTest(void)
* RETURNS: TC_PASS on success or TC_FAIL on failure
*/
static int simpleFiberSemTest(void)
{
{
int signalCount;
int status;
int i;
@ -420,7 +420,7 @@ static int simpleFiberSemTest(void)
}
}
return TC_PASS;
}
}
/*******************************************************************************
*
@ -430,7 +430,7 @@ static int simpleFiberSemTest(void)
*/
int HighPriTask(void)
{
{
int status;
/* Wait until task is activated */
@ -454,7 +454,7 @@ int HighPriTask(void)
return TC_PASS;
}
}
/*******************************************************************************
*
@ -464,7 +464,7 @@ int HighPriTask(void)
*/
int LowPriTask(void)
{
{
int status;
/* Wait on a semaphore along with other tasks */
@ -479,7 +479,7 @@ int LowPriTask(void)
task_sem_give(blockLpSem);
return TC_PASS;
}
}
/*******************************************************************************
*
@ -491,7 +491,7 @@ int LowPriTask(void)
*/
int AlternateTask(void)
{
{
int status;
int i;
@ -558,7 +558,7 @@ int AlternateTask(void)
}
return TC_PASS;
}
}
/*******************************************************************************
*
@ -570,7 +570,7 @@ int AlternateTask(void)
*/
int RegressionTask(void)
{
{
int tcRC;
int value;
ksem_t semBlockList[4];
@ -670,4 +670,4 @@ int RegressionTask(void)
}
return TC_PASS;
}
}

View file

@ -72,7 +72,7 @@ static CMD_PKT_SET_INSTANCE(cmdPktSet, N_TESTS + 1)
* RETURNS: N/A
*/
static void testFiberEntry(void)
{
{
int i;
/* release semaphore test task is waiting for */
nano_fiber_sem_take_wait(&fiberSem);
@ -89,7 +89,7 @@ static void testFiberEntry(void)
nano_fiber_sem_take_wait(&fiberSem);
fiber_sem_give(semList[i], &CMD_PKT_SET(cmdPktSet));
}
}
}
/*******************************************************************************
*
@ -99,8 +99,8 @@ static void testFiberEntry(void)
*/
void testFiberInit(void)
{
{
nano_sem_init(&fiberSem);
task_fiber_start(fiberStack, FIBER_STACK_SIZE, (nano_fiber_entry_t)testFiberEntry,
0, 0, FIBER_PRIORITY, 0);
}
}

View file

@ -76,7 +76,7 @@ typedef union {
uint32_t u1; /* This part contains the exponent */
uint32_t u2; /* This part contains the fraction */
};
} raw_double_u;
} raw_double_u;
#ifdef CONFIG_FLOAT
/*******************************************************************************
@ -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

@ -65,7 +65,7 @@ This module tests the following task APIs:
typedef struct {
int cmd;
int data;
} ISR_INFO;
} ISR_INFO;
/* locals */

View file

@ -64,10 +64,10 @@ static ksem_t rdySem = SEM_RDY;
*/
void taskAMain(void)
{
{
extern int taskA(ksem_t semRdy);
task_sem_give(resultSems[taskA(rdySem)]);
}
}
/*******************************************************************************
*
@ -80,10 +80,10 @@ void taskAMain(void)
*/
void taskBMain(void)
{
{
extern int taskB(ksem_t semRdy);
task_sem_give(resultSems[taskB(rdySem)]);
}
}
/*******************************************************************************
*
@ -96,7 +96,7 @@ void taskBMain(void)
* RETURNS: N/A
*/
void registerWait(void)
{
{
extern void raiseInt(uint8_t id);
int tasksDone;
int irq_obj;
@ -113,12 +113,13 @@ 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]);
}
}
/*******************************************************************************
*
@ -131,7 +132,7 @@ void registerWait(void)
*/
void MonitorTaskEntry(void)
{
{
extern struct task_irq_info task_irq_object[NUM_TASK_IRQS];
ksem_t result;
int tasksDone;
@ -159,4 +160,4 @@ void MonitorTaskEntry(void)
TC_END_RESULT(TC_PASS);
TC_END_REPORT(TC_PASS);
}
}

File diff suppressed because it is too large Load diff

View file

@ -77,7 +77,7 @@ exercises the task_irq_free() API.
*/
int taskA(ksem_t semRdy)
{
{
if (task_irq_alloc(DEV1_ID, DEV1_IRQ, 1) == INVALID_VECTOR) {
TC_ERROR("Not able to allocate IRQ object\n");
return TC_FAIL;
@ -133,7 +133,7 @@ int taskA(ksem_t semRdy)
task_sem_give(semRdy);
return TC_PASS;
}
}
/*******************************************************************************
*
@ -147,7 +147,7 @@ int taskA(ksem_t semRdy)
*/
int taskB(ksem_t semRdy)
{
{
if (task_irq_alloc(DEV3_ID, DEV3_IRQ, 1) == INVALID_VECTOR) {
TC_ERROR("Not able to allocate IRQ object\n");
return TC_FAIL;
@ -195,4 +195,4 @@ int taskB(ksem_t semRdy)
TC_PRINT("IRQ object %d freed\n", DEV3_ID);
return TC_PASS;
}
}

View file

@ -88,7 +88,7 @@ extern void _TimestampClose(void);
#endif
void ticklessTestTask(void)
{
{
int32_t start_ticks;
int32_t end_ticks;
int32_t diff_ticks;
@ -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);
@ -201,4 +203,4 @@ void ticklessTestTask(void)
while(1);
}
}

View file

@ -82,7 +82,7 @@ BSP-specific timestamp support for the tickless idle test.
*/
void _TimestampOpen(void)
{
{
/* QEMU does not currently support the 32-bit timer modes of the GPTM */
printk("WARNING! Timestamp is not supported for this target!\n");
@ -100,7 +100,7 @@ void _TimestampOpen(void)
_TIMESTAMP_ICLEAR = 0x70F; /* clear all interrupt status */
_TIMESTAMP_CTRL = 0x1; /* enable timer */
}
}
/*******************************************************************************
*
@ -114,7 +114,7 @@ void _TimestampOpen(void)
*/
uint32_t _TimestampRead(void)
{
{
static uint32_t lastTimerVal = 0;
static uint32_t cnt = 0;
uint32_t timerVal = _TIMESTAMP_VAL;
@ -137,7 +137,7 @@ uint32_t _TimestampRead(void)
cnt++;
return timerVal;
}
}
/*******************************************************************************
*
@ -151,7 +151,7 @@ uint32_t _TimestampRead(void)
*/
void _TimestampClose(void)
{
{
/* disable/reset timer */
_TIMESTAMP_CTRL = 0x0;
@ -159,7 +159,7 @@ void _TimestampClose(void)
/* disable timer access */
_CLKGATECTRL &= ~_CLKGATECTRL_TIMESTAMP_EN;
}
}
#elif defined(CONFIG_BSP_FSL_FRDM_K64F)
/* Freescale FRDM-K64F target - use RTC (prescale value) */
@ -198,7 +198,7 @@ void _TimestampClose(void)
*/
void _TimestampOpen(void)
{
{
/* enable timer access */
_CLKGATECTRL |= _CLKGATECTRL_TIMESTAMP_EN;
@ -221,7 +221,7 @@ void _TimestampOpen(void)
_TIMESTAMP_VAL = 0x0; /* clear invalid time flag in status register */
_TIMESTAMP_STATUS = 0x10; /* enable counter */
}
}
/*******************************************************************************
*
@ -235,7 +235,7 @@ void _TimestampOpen(void)
*/
uint32_t _TimestampRead(void)
{
{
static uint32_t lastPrescale = 0;
static uint32_t cnt = 0;
uint32_t prescale1 = _TIMESTAMP_PRESCALE;
@ -258,7 +258,7 @@ uint32_t _TimestampRead(void)
cnt++;
return prescale1;
}
}
/*******************************************************************************
*
@ -272,10 +272,10 @@ uint32_t _TimestampRead(void)
*/
void _TimestampClose(void)
{
{
_TIMESTAMP_STATUS = 0x0; /* disable counter */
_TIMESTAMP_CTRL = 0x0; /* disable oscillator */
}
}
#else
#error "Unknown BSP"

View file

@ -66,7 +66,7 @@ void main(void)
void RegressionTaskEntry(void)
#endif
{
{
int tcRC = TC_PASS;
int i;
@ -89,4 +89,4 @@ void RegressionTaskEntry(void)
exitRtn:
TC_END_RESULT(tcRC);
TC_END_REPORT(tcRC);
}
}

View file

@ -119,9 +119,9 @@ volatile pfunc func_array[] = {
*/
void dummyIsr(void *unused)
{
{
ARG_UNUSED(unused);
}
}
#ifdef TEST_reg
/*******************************************************************************
@ -136,28 +136,27 @@ void dummyIsr(void *unused)
*/
static void isrDummyIntStub(void *unused)
{
{
ARG_UNUSED(unused);
isr_dummy();
CODE_UNREACHABLE;
}
}
#endif /* TEST_reg */
/*******************************************************************************
*
* 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);
#ifdef TEST_max
@ -165,7 +164,7 @@ static void fiberEntry
#else
printk((char *)message);
#endif /* TEST_max */
}
}
#endif /* !TEST_min */
@ -180,7 +179,7 @@ static void fiberEntry
*/
void main(void)
{
{
#ifdef TEST_max
/* dynamically link in dummy ISR */
irq_connect(NANO_SOFT_IRQ, IRQ_PRIORITY, dummyIsr,
@ -195,4 +194,4 @@ void main(void)
while (1) {
i++;
}
}
}

View file

@ -47,26 +47,26 @@ static struct nano_fifo nanoFifo_sync; /* for synchronization */
*/
void lifo_test_init(void)
{
{
nano_lifo_init(&nanoLifo1);
nano_lifo_init(&nanoLifo2);
}
}
/*******************************************************************************
*
* 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];
int element_b[2];
@ -76,35 +76,37 @@ 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);
}
/* wait till it is safe to end: */
nano_fiber_fifo_get_wait(&nanoFifo_sync);
}
}
/*******************************************************************************
*
* 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];
int * pelement;
@ -114,28 +116,29 @@ 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: */
nano_fiber_fifo_get_wait(&nanoFifo_sync);
}
}
/*******************************************************************************
*
* 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];
int * pelement;
@ -144,15 +147,17 @@ 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: */
nano_fiber_fifo_get_wait(&nanoFifo_sync);
}
}
/*******************************************************************************
*
@ -164,7 +169,7 @@ void lifo_fiber3(
*/
int lifo_test(void)
{
{
uint32_t t;
int i = 0;
int return_value = 0;
@ -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

@ -48,10 +48,10 @@ static struct nano_fifo nanoFifo_sync; /* for synchronization */
*/
void fifo_test_init(void)
{
{
nano_fifo_init(&nanoFifo1);
nano_fifo_init(&nanoFifo2);
}
}
/*******************************************************************************
@ -60,14 +60,14 @@ 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];
int * pelement;
@ -75,14 +75,15 @@ 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);
}
/* wait till it is safe to end: */
nano_fiber_fifo_get_wait(&nanoFifo_sync);
}
}
/*******************************************************************************
@ -91,14 +92,14 @@ 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];
int * pelement;
@ -108,13 +109,14 @@ 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: */
nano_fiber_fifo_get_wait(&nanoFifo_sync);
}
}
/*******************************************************************************
@ -123,14 +125,14 @@ 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];
int * pelement;
@ -139,15 +141,17 @@ 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: */
nano_fiber_fifo_get_wait(&nanoFifo_sync);
}
}
/*******************************************************************************
@ -160,7 +164,7 @@ void fifo_fiber3(
*/
int fifo_test(void)
{
{
uint32_t t;
int i = 0;
int return_value = 0;
@ -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

@ -45,26 +45,26 @@ struct nano_sem nanoSem2;
*/
void sema_test_init(void)
{
{
nano_sem_init(&nanoSem1);
nano_sem_init(&nanoSem2);
}
}
/*******************************************************************************
*
* 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;
ARG_UNUSED(par1);
@ -73,23 +73,23 @@ void sema_fiber1(
nano_fiber_sem_take_wait(&nanoSem1);
nano_fiber_sem_give(&nanoSem2);
}
}
}
/*******************************************************************************
*
* 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;
@ -98,32 +98,33 @@ void sema_fiber2(
nano_fiber_sem_take_wait(&nanoSem2);
(*pcounter)++;
}
}
}
/*******************************************************************************
*
* 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)++;
}
}
}
/*******************************************************************************
@ -136,7 +137,7 @@ void sema_fiber3(
*/
int sema_test(void)
{
{
uint32_t t;
int i = 0;
int return_value = 0;
@ -207,4 +208,4 @@ int sema_test(void)
return_value += check_result(i, t);
return return_value;
}
}

View file

@ -48,26 +48,26 @@ uint32_t stack2[2];
*/
void stack_test_init(void)
{
{
nano_stack_init(&nanoChannel1, stack1);
nano_stack_init(&nanoChannel2, stack2);
}
}
/*******************************************************************************
*
* 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,33 +75,35 @@ 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);
}
}
}
/*******************************************************************************
*
* 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;
int * pcounter = (int *) par1;
@ -110,27 +112,28 @@ 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)++;
}
}
}
/*******************************************************************************
*
* 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;
int * pcounter = (int *) par1;
@ -139,13 +142,15 @@ 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)++;
}
}
}
/*******************************************************************************
@ -158,7 +163,7 @@ void stack_fiber3(
*/
int stack_test(void)
{
{
uint32_t t;
int i = 0;
int return_value = 0;
@ -232,16 +237,18 @@ 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);
return_value += check_result(i * 2, t);
return return_value;
}
}

View file

@ -87,13 +87,13 @@ uint32_t tm_off;
* \NOMANUAL
*/
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);
@ -135,7 +135,7 @@ int check_result(
fprintf(output_file, sz_case_end_fmt);
return 1;
}
}
/*******************************************************************************
@ -159,20 +159,20 @@ 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);
/*
* send all printf and fprintf to console
*/
output_file = stdout;
}
}
/*******************************************************************************
@ -185,8 +185,8 @@ void init_output(
*/
void output_close(void)
{
}
{
}
/*******************************************************************************
*
@ -202,7 +202,7 @@ void SysKernelBench(void)
#else
void main(void)
#endif
{
{
int continuously = 0;
int test_result;
@ -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

@ -74,12 +74,12 @@ int stack_test(void);
void begin_test(void);
static inline uint32_t BENCH_START(void)
{
{
uint32_t et;
begin_test();
et = TIME_STAMP_DELTA_GET(0);
return et;
}
}
#endif /* SYSKERNEK_H */

View file

@ -59,11 +59,11 @@ struct nano_sem sem[3];
*/
void isr0(void)
{
{
printk("%s ran!\n", __FUNCTION__);
nano_isr_sem_give(&sem[0]);
_IntExit();
}
}
/*******************************************************************************
*
@ -73,11 +73,11 @@ void isr0(void)
*/
void isr1(void)
{
{
printk("%s ran!\n", __FUNCTION__);
nano_isr_sem_give(&sem[1]);
_IntExit();
}
}
/*******************************************************************************
*
@ -87,11 +87,11 @@ void isr1(void)
*/
void isr2(void)
{
{
printk("%s ran!\n", __FUNCTION__);
nano_isr_sem_give(&sem[2]);
_IntExit();
}
}
/*******************************************************************************
*
@ -101,7 +101,7 @@ void isr2(void)
*/
void main(void)
{
{
TC_START("Test Cortex-M3 IRQ installed directly in vector table");
for (int ii = 0; ii < 3; ii++) {
@ -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]) &&
@ -128,7 +130,7 @@ void main(void)
get_out:
TC_END_RESULT(rv);
TC_END_REPORT(rv);
}
}
typedef void (*vth)(void); /* Vector Table Handler */
vth __irq_vector_table _irq_vector_table[CONFIG_NUM_IRQS] = {

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

@ -87,7 +87,7 @@ in ISR context.
typedef struct {
struct nano_fifo *channel; /* FIFO channel */
void *data; /* pointer to data to add */
} ISR_FIFO_INFO;
} ISR_FIFO_INFO;
/* globals */
@ -226,7 +226,7 @@ void fiber1(void)
/* Get all FIFOs */
while ((pData = nano_fiber_fifo_get(&nanoFifoObj)) != NULL) {
TC_PRINT("FIBER FIFO Get: count = %d, ptr is %p\n", count, pData);
if((count >= NUM_FIFO_ELEMENT) || (pData != pPutList1[count])) {
if ((count >= NUM_FIFO_ELEMENT) || (pData != pPutList1[count])) {
TCERR1(count);
retCode = TC_FAIL;
return;

View file

@ -73,12 +73,12 @@ These scenarios will be tested using a combinations of tasks, fibers and ISRs.
typedef struct {
struct nano_lifo *channel; /* LIFO channel */
void *data; /* pointer to data to add */
} ISR_LIFO_INFO;
} ISR_LIFO_INFO;
typedef struct {
uint32_t link; /* 32-bit word for LIFO to use as a link */
uint32_t data; /* miscellaneous data put on LIFO (not important) */
} LIFO_ITEM;
} LIFO_ITEM;
/* locals */

View file

@ -71,14 +71,14 @@ Scenario #3:
typedef struct {
struct nano_sem *sem; /* ptr to semaphore */
int data; /* data */
} ISR_SEM_INFO;
} ISR_SEM_INFO;
typedef enum {
STS_INIT = -1,
STS_TASK_WOKE_FIBER,
STS_FIBER_WOKE_TASK,
STS_ISR_WOKE_TASK
} SEM_TEST_STATE;
} SEM_TEST_STATE;
/* locals */
@ -252,8 +252,9 @@ 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

@ -88,7 +88,7 @@ these are run in ISR context.
typedef struct {
struct nano_stack *channel; /* STACK channel */
uint32_t data; /* data to add */
} ISR_STACK_INFO;
} ISR_STACK_INFO;
/* globals */
@ -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);