summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYonattan Louise <yonattan.a.louise.mendoza@intel.com>2015-05-14 16:30:48 -0500
committerAnas Nashif <anas.nashif@intel.com>2016-02-05 20:13:59 -0500
commitdbada63eee8516d35d11c1543788e742b70172e1 (patch)
tree6f6556441918eecadd2495e4e2944138422accf5
parentd133f9661d670ca5340dd032ba3630f44d995af9 (diff)
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>
-rw-r--r--arch/x86/core/inthndlset.c3
-rw-r--r--drivers/pci/pci_config.c109
-rw-r--r--host/src/dec2hex/dec2hex.c27
-rw-r--r--host/src/genIdt/genIdt.c218
-rw-r--r--host/src/genOffsetHeader/elf.h18
-rw-r--r--host/src/genOffsetHeader/genOffsetHeader.c283
-rw-r--r--host/src/gen_config_abssym/gen_config_abssym.c8
-rw-r--r--host/src/mkEvents/mkevents.c33
-rw-r--r--include/drivers/pci/pci_mgr.h6
-rw-r--r--include/nanokernel/x86/arch.h11
-rw-r--r--include/nanokernel/x86/asm_inline_gcc.h18
-rw-r--r--kernel/microkernel/channel/ch_buff.c160
-rw-r--r--kernel/microkernel/idle.c9
-rw-r--r--kernel/microkernel/k_sema.c143
-rw-r--r--kernel/microkernel/k_timer.c76
-rw-r--r--kernel/microkernel/task_monitor.c20
-rw-r--r--kernel/nanokernel/string_s.c15
-rw-r--r--samples/bluetooth/test_bluetooth/bluetooth.c14
-rw-r--r--samples/include/irq_test_common.h51
-rw-r--r--samples/microkernel/apps/hello_world/src/hello.c50
-rw-r--r--samples/microkernel/apps/philosophers/src/phil_fiber.c56
-rw-r--r--samples/microkernel/apps/philosophers/src/phil_task.c31
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/event_b.c110
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/fifo_b.c32
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/fifo_r.c8
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/mailbox_b.c38
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/mailbox_r.c39
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/master.c89
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/master.h28
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/memmap_b.c10
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/mempool_b.c12
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/mutex_b.c10
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/nop_b.c8
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/pipe_b.c169
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/pipe_r.c125
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/receiver.c10
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/receiver.h2
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/sema_b.c42
-rw-r--r--samples/microkernel/benchmark/app_kernel/src/sema_r.c42
-rw-r--r--samples/microkernel/benchmark/boot_time/src/boot_time.c40
-rw-r--r--samples/microkernel/benchmark/footprint/src/microkernel_footprint.c42
-rw-r--r--samples/microkernel/benchmark/footprint/src/test_asm_inline_gcc.h2
-rw-r--r--samples/microkernel/benchmark/latency_measure/src/main.c16
-rw-r--r--samples/microkernel/benchmark/latency_measure/src/micro_int_to_task.c23
-rw-r--r--samples/microkernel/benchmark/latency_measure/src/micro_int_to_task_evt.c16
-rw-r--r--samples/microkernel/benchmark/latency_measure/src/micro_sema_lock_release.c48
-rw-r--r--samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c70
-rw-r--r--samples/microkernel/benchmark/latency_measure/src/nano_ctx_switch.c43
-rw-r--r--samples/microkernel/benchmark/latency_measure/src/nano_int.c16
-rw-r--r--samples/microkernel/benchmark/latency_measure/src/nano_int_lock_unlock.c36
-rw-r--r--samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber.c25
-rw-r--r--samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber_sem.c24
-rw-r--r--samples/microkernel/benchmark/latency_measure/src/timestamp.h41
-rw-r--r--samples/microkernel/benchmark/latency_measure/src/utils.c12
-rw-r--r--samples/microkernel/benchmark/latency_measure/src/utils.h33
-rw-r--r--samples/microkernel/test/test_critical/src/critical.c18
-rw-r--r--samples/microkernel/test/test_events/src/test_fiber.c26
-rw-r--r--samples/microkernel/test/test_fp_sharing/src/main.c9
-rw-r--r--samples/microkernel/test/test_libs/src/libraries.c96
-rw-r--r--samples/microkernel/test/test_mail/src/mail.c53
-rw-r--r--samples/microkernel/test/test_mail/src/main.c50
-rw-r--r--samples/microkernel/test/test_mutex/src/mutex.c132
-rw-r--r--samples/microkernel/test/test_pipe/src/main.c38
-rw-r--r--samples/microkernel/test/test_pipe/src/pipe.c528
-rw-r--r--samples/microkernel/test/test_pool/src/pool.c2
-rw-r--r--samples/microkernel/test/test_secure_string_api/src/secure.c72
-rw-r--r--samples/microkernel/test/test_sema/src/main.c26
-rw-r--r--samples/microkernel/test/test_sema/src/sema.c430
-rw-r--r--samples/microkernel/test/test_sema/src/test_fiber.c20
-rw-r--r--samples/microkernel/test/test_sprintf/src/test_sprintf.c327
-rw-r--r--samples/microkernel/test/test_stackprot/src/stackprot.c25
-rw-r--r--samples/microkernel/test/test_static_idt/src/static_idt.c96
-rw-r--r--samples/microkernel/test/test_task/src/task.c112
-rw-r--r--samples/microkernel/test/test_task_irq/src/main.c55
-rw-r--r--samples/microkernel/test/test_task_irq/src/raise_int.c1160
-rw-r--r--samples/microkernel/test/test_task_irq/src/test_device.c80
-rw-r--r--samples/microkernel/test/test_tickless/src/test_tickless.c74
-rw-r--r--samples/microkernel/test/test_tickless/src/timestamps.c62
-rw-r--r--samples/microkernel/test/test_timer/src/timer.c2
-rw-r--r--samples/microkernel/test/test_xip/src/test_xip.c18
-rw-r--r--samples/nanokernel/benchmark/footprint/src/nanokernel_footprint.c45
-rw-r--r--samples/nanokernel/benchmark/footprint/src/test_asm_inline_gcc.h2
-rw-r--r--samples/nanokernel/benchmark/sys_kernel/src/lifo.c186
-rw-r--r--samples/nanokernel/benchmark/sys_kernel/src/mwfifo.c179
-rw-r--r--samples/nanokernel/benchmark/sys_kernel/src/sema.c95
-rw-r--r--samples/nanokernel/benchmark/sys_kernel/src/stack.c161
-rw-r--r--samples/nanokernel/benchmark/sys_kernel/src/syskernel.c132
-rw-r--r--samples/nanokernel/benchmark/sys_kernel/src/syskernel.h4
-rw-r--r--samples/nanokernel/test/test_arm_m3_irq_vector_table/src/main.c28
-rw-r--r--samples/nanokernel/test/test_context/src/context.c231
-rw-r--r--samples/nanokernel/test/test_fifo/src/fifo.c324
-rw-r--r--samples/nanokernel/test/test_lifo/src/lifo.c174
-rw-r--r--samples/nanokernel/test/test_sema/src/sema.c137
-rw-r--r--samples/nanokernel/test/test_stack/src/stack.c172
-rw-r--r--samples/nanokernel/test/test_timer/src/timer.c174
95 files changed, 4162 insertions, 4013 deletions
diff --git a/arch/x86/core/inthndlset.c b/arch/x86/core/inthndlset.c
index 83588c279..75b9da479 100644
--- a/arch/x86/core/inthndlset.c
+++ b/arch/x86/core/inthndlset.c
@@ -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],
diff --git a/drivers/pci/pci_config.c b/drivers/pci/pci_config.c
index d2259ece9..f07e09a59 100644
--- a/drivers/pci/pci_config.c
+++ b/drivers/pci/pci_config.c
@@ -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;
diff --git a/host/src/dec2hex/dec2hex.c b/host/src/dec2hex/dec2hex.c
index 46145fcea..db89531f3 100644
--- a/host/src/dec2hex/dec2hex.c
+++ b/host/src/dec2hex/dec2hex.c
@@ -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;
+ usage(argv[0]);
+ return -1;
}
printf("%X\n", atoi(argv[1]));
return 0;
- }
+}
diff --git a/host/src/genIdt/genIdt.c b/host/src/genIdt/genIdt.c
index e1ff67b39..e89786fc2 100644
--- a/host/src/genIdt/genIdt.c
+++ b/host/src/genIdt/genIdt.c
@@ -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,105 +104,105 @@ 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;
while ((opt = getopt(argc, argv, "hi:o:n:v")) != -1) {
- switch(opt) {
- case 'i':
- filenames[IFILE] = optarg;
- break;
- case 'o':
- {
- filenames[OFILE] = optarg;
- break;
- }
- case 'h':
- usage(LONG_USAGE);
- exit(0);
- case 'n':
- numVecs = (unsigned int)strtoul(optarg, &endptr, 10);
- if (*optarg == '\0' || *endptr != '\0') {
- usage(SHORT_USAGE);
- exit(-1);
- }
- break;
- case 'v':
- show_version(filenames[EXECFILE], &version);
- exit(0);
- default:
- usage(SHORT_USAGE);
- exit(-1);
+ switch(opt) {
+ case 'i':
+ filenames[IFILE] = optarg;
+ break;
+ case 'o':
+ {
+ filenames[OFILE] = optarg;
+ break;
+ }
+ case 'h':
+ usage(LONG_USAGE);
+ exit(0);
+ case 'n':
+ numVecs = (unsigned int)strtoul(optarg, &endptr, 10);
+ if (*optarg == '\0' || *endptr != '\0') {
+ usage(SHORT_USAGE);
+ exit(-1);
+ }
+ break;
+ case 'v':
+ show_version(filenames[EXECFILE], &version);
+ exit(0);
+ default:
+ usage(SHORT_USAGE);
+ exit(-1);
}
}
if ((unsigned int)-1 == numVecs) {
- usage(SHORT_USAGE);
- exit(-1);
+ usage(SHORT_USAGE);
+ exit(-1);
}
for(ii = IFILE; ii < NUSERFILES; ii++) {
- if (!filenames[ii]) {
- usage(SHORT_USAGE);
- exit(-1);
- }
- }
+ if (!filenames[ii]) {
+ usage(SHORT_USAGE);
+ exit(-1);
+ }
}
+}
static void get_exec_name(char *pathname)
- {
+{
int end = strlen(pathname)-1;
while(end != -1) {
- #if defined(WINDOWS) /* Might have both slashes in path */
- if (pathname[end] == '/' || pathname[end] == '\\')
- #else
- if (pathname[end] == '/')
- #endif
- {
- if (0 == end || pathname[end-1] != '\\') {
- ++end;
- break;
+ #if defined(WINDOWS) /* Might have both slashes in path */
+ if (pathname[end] == '/' || pathname[end] == '\\')
+ #else
+ if (pathname[end] == '/')
+ #endif
+ {
+ if (0 == end || pathname[end-1] != '\\') {
+ ++end;
+ break;
+ }
}
- }
- --end;
+ --end;
}
filenames[EXECFILE] = &pathname[end];
- }
+}
static void open_files(void)
- {
+{
int ii;
fds[IFILE] = open(filenames[IFILE], O_RDONLY|O_BINARY);
fds[OFILE] = open(filenames[OFILE], O_WRONLY|O_CREAT|O_TRUNC|O_BINARY,
S_IWUSR|S_IRUSR);
for(ii = 0; ii < NUSERFILES; ii++) {
- int invalid = fds[ii] == -1;
- if (invalid) {
- char *invalid = filenames[ii];
- fprintf(stderr, "invalid file %s\n", invalid);
- for(--ii; ii >= 0; ii--) {
- close(fds[ii]);
+ int invalid = fds[ii] == -1;
+ if (invalid) {
+ char *invalid = filenames[ii];
+ fprintf(stderr, "invalid file %s\n", invalid);
+ for(--ii; ii >= 0; ii--) {
+ close(fds[ii]);
+ }
+ exit(-1);
}
- exit(-1);
- }
- }
}
+}
static void genIdt(void)
- {
+{
unsigned int i;
unsigned int size;
void *spurAddr;
@@ -212,21 +212,25 @@ 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)
- goto readError;
+ if (read(fds[IFILE], &spurAddr, 4) < 4) {
+ goto readError;
+ }
- if (read(fds[IFILE], &spurNoErrAddr, 4) < 4)
- goto readError;
+ 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 */
+ /* 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))
- idt[i].fnc = spurAddr;
- else
- idt[i].fnc = spurNoErrAddr;
+ if ((((1 << i) & _EXC_ERROR_CODE_FAULTS)) && (i < 32)) {
+ idt[i].fnc = spurAddr;
+ }
+ else {
+ idt[i].fnc = spurNoErrAddr;
+ }
}
/*
@@ -234,35 +238,39 @@ static void genIdt(void)
* entries is the next 4 bytes
*/
- if (read(fds[IFILE], &size, 4) < 4)
- goto readError;
+ if (read(fds[IFILE], &size, 4) < 4) {
+ goto readError;
+ }
PRINTF("There are %d ISR(s)\n", size);
if (size > numVecs) {
- fprintf(stderr, "Too many ISRs found. Got %u. Expected less than %u."
- " Malformed input file?\n", size, numVecs);
- clean_exit(-1);
+ fprintf(stderr, "Too many ISRs found. Got %u. Expected less than %u."
+ " Malformed input file?\n", size, numVecs);
+ clean_exit(-1);
}
while (size--) {
- void *addr;
- unsigned int vec;
- unsigned int dpl;
+ void *addr;
+ unsigned int vec;
+ unsigned int dpl;
- /* Get address */
- if (read(fds[IFILE], &addr, 4) < 4)
- goto readError;
- /* Get vector */
- if (read(fds[IFILE], &vec, 4) < 4)
- goto readError;
- /* Get dpl */
- 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;
- idt[vec].dpl = dpl;
+ /* Get address */
+ if (read(fds[IFILE], &addr, 4) < 4) {
+ goto readError;
+ }
+ /* Get vector */
+ if (read(fds[IFILE], &vec, 4) < 4) {
+ goto readError;
+ }
+ /* Get dpl */
+ 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;
+ idt[vec].dpl = dpl;
}
/*
@@ -271,11 +279,11 @@ static void genIdt(void)
*/
for (i = 0; i < numVecs; i++) {
- unsigned long long idtEnt;
+ unsigned long long idtEnt;
- _IdtEntCreate(&idtEnt, idt[i].fnc, idt[i].dpl);
+ _IdtEntCreate(&idtEnt, idt[i].fnc, idt[i].dpl);
- write(fds[OFILE], &idtEnt, 8);
+ write(fds[OFILE], &idtEnt, 8);
}
return;
@@ -283,31 +291,29 @@ 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]);
- }
+ 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;
+ return;
}
fprintf(stderr,
@@ -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");
- }
+}
diff --git a/host/src/genOffsetHeader/elf.h b/host/src/genOffsetHeader/elf.h
index f4f9f0ba1..f18c265d3 100644
--- a/host/src/genOffsetHeader/elf.h
+++ b/host/src/genOffsetHeader/elf.h
@@ -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)
@@ -341,10 +341,10 @@ typedef struct {
typedef struct {
Elf32_Sword d_tag;
union {
- Elf32_Word d_val;
- Elf32_Addr d_ptr;
- } d_un;
- } Elf32_Dyn;
+ Elf32_Word d_val;
+ Elf32_Addr d_ptr;
+ } d_un;
+} Elf32_Dyn;
#define DT_NULL 0
#define DT_NEEDED 1
diff --git a/host/src/genOffsetHeader/genOffsetHeader.c b/host/src/genOffsetHeader/genOffsetHeader.c
index b7fae76c5..47d25a868 100644
--- a/host/src/genOffsetHeader/genOffsetHeader.c
+++ b/host/src/genOffsetHeader/genOffsetHeader.c
@@ -198,8 +198,8 @@ static Elf32_Shdr *shdr; /* pointer to array ELF section headers */
static void swabElfHdr(Elf32_Ehdr *pHdrToSwab)
{
if (swabRequired == 0) {
- return; /* do nothing */
- }
+ return; /* do nothing */
+ }
pHdrToSwab->e_type = SWAB_Elf32_Half(pHdrToSwab->e_type);
pHdrToSwab->e_machine = SWAB_Elf32_Half(pHdrToSwab->e_machine);
@@ -226,8 +226,8 @@ static void swabElfHdr(Elf32_Ehdr *pHdrToSwab)
static void swabElfSectionHdr(Elf32_Shdr *pHdrToSwab)
{
if (swabRequired == 0) {
- return; /* do nothing */
- }
+ return; /* do nothing */
+ }
pHdrToSwab->sh_name = SWAB_Elf32_Word(pHdrToSwab->sh_name);
pHdrToSwab->sh_type = SWAB_Elf32_Word(pHdrToSwab->sh_type);
@@ -252,8 +252,8 @@ static void swabElfSectionHdr(Elf32_Shdr *pHdrToSwab)
static void swabElfSym(Elf32_Sym *pHdrToSwab)
{
if (swabRequired == 0) {
- return; /* do nothing */
- }
+ return; /* do nothing */
+ }
pHdrToSwab->st_name = SWAB_Elf32_Word(pHdrToSwab->st_name);
pHdrToSwab->st_value = SWAB_Elf32_Addr(pHdrToSwab->st_value);
@@ -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 */
@@ -280,37 +281,37 @@ static int ehdrLoad(int fd /* file descriptor of file from which to read */
if (nBytes != sizeof(ehdr)) {
fprintf(stderr, "Failed to read ELF header\n");
return -1;
- }
+ }
- /* perform some rudimentary ELF file validation */
+ /* perform some rudimentary ELF file validation */
if (strncmp((char *)ehdr.e_ident, ELFMAG, 4) != 0) {
- fprintf(stderr, "Input object module not ELF format\n");
- return -1;
+ fprintf(stderr, "Input object module not ELF format\n");
+ return -1;
}
- /* 64-bit ELF module not supported (for now) */
+ /* 64-bit ELF module not supported (for now) */
if (ehdr.e_ident[EI_CLASS] != ELFCLASS32) {
fprintf(stderr, "ELF64 class not supported\n");
- return -1;
+ return -1;
}
- /*
- * Dynamically determine the endianess of the host (in the absence of
- * a compile time macro ala _BYTE_ORDER). The ELF structures will require
- * byte swapping if the host and target have different byte ordering.
- */
+ /*
+ * Dynamically determine the endianess of the host (in the absence of
+ * a compile time macro ala _BYTE_ORDER). The ELF structures will require
+ * byte swapping if the host and target have different byte ordering.
+ */
if (((*(char *)&ix == 0x78) && (ehdr.e_ident[EI_DATA] == ELFDATA2MSB)) ||
((*(char *)&ix == 0x12) && (ehdr.e_ident[EI_DATA] == ELFDATA2LSB))) {
- swabRequired = 1;
- DBG_PRINT("Swab required\n");
+ swabRequired = 1;
+ DBG_PRINT("Swab required\n");
}
swabElfHdr(&ehdr); /* swap bytes (if required) */
- /* debugging: dump some important ELF header fields */
+ /* debugging: dump some important ELF header fields */
DBG_PRINT("Elf header Magic = %s\n", ehdr.e_ident);
DBG_PRINT("Elf header e_type = %d\n", ehdr.e_type);
@@ -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 */
@@ -337,22 +339,22 @@ int shdrsLoad(int fd /* file descriptor of file from which to read */
if (shdr == NULL) {
fprintf(stderr, "No memory for section headers!\n");
return -1;
- }
+ }
- /* Seek to the start of the table of section headers */
+ /* Seek to the start of the table of section headers */
lseek(fd, ehdr.e_shoff, SEEK_SET);
for (ix = 0; ix < ehdr.e_shnum; ix++) {
- nBytes = read(fd, &shdr[ix], sizeof(Elf32_Shdr));
- if (nBytes != sizeof(Elf32_Shdr)) {
- fprintf(stderr, "Unable to read entire section header (#%d)\n",
- ix);
- return -1;
- }
-
- swabElfSectionHdr(&shdr[ix]); /* swap bytes (if required) */
+ nBytes = read(fd, &shdr[ix], sizeof(Elf32_Shdr));
+ if (nBytes != sizeof(Elf32_Shdr)) {
+ fprintf(stderr, "Unable to read entire section header (#%d)\n",
+ ix);
+ return -1;
}
+ swabElfSectionHdr(&shdr[ix]); /* swap bytes (if required) */
+ }
+
return 0;
}
@@ -363,23 +365,24 @@ 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 */
for (ix = 0; ix < ehdr.e_shnum; ++ix) {
- if (shdr[ix].sh_type == SHT_SYMTAB) {
- *pSymTblOffset = shdr[ix].sh_offset;
- *pSymTblSize = shdr[ix].sh_size;
+ if (shdr[ix].sh_type == SHT_SYMTAB) {
+ *pSymTblOffset = shdr[ix].sh_offset;
+ *pSymTblSize = shdr[ix].sh_size;
- return 0;
- }
+ return 0;
}
+ }
fprintf(stderr, "Object module missing symbol table!\n");
@@ -404,28 +407,29 @@ 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;
for (ix = 0; ix < ehdr.e_shnum; ++ix) {
if (shdr[ix].sh_type == SHT_STRTAB) {
- if ((strTblIx == 0xffffffff) ||
- (ix != ehdr.e_shstrndx)) {
- strTblIx = ix;
- }
- }
+ if ((strTblIx == 0xffffffff) ||
+ (ix != ehdr.e_shstrndx)) {
+ strTblIx = ix;
+ }
}
+ }
if (strTblIx == 0xffffffff) {
fprintf(stderr, "Object module missing string table!\n");
return -1;
- }
+ }
*pStrTblIx = strTblIx;
@@ -436,25 +440,26 @@ 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;
DBG_PRINT("Allocating %d bytes for string table\n",
- shdr[strTblIx].sh_size);
+ shdr[strTblIx].sh_size);
pTable = malloc(shdr[strTblIx].sh_size);
if (pTable == NULL) {
fprintf(stderr, "No memory for string table!");
return -1;
- }
+ }
lseek(fd, shdr[strTblIx].sh_offset, SEEK_SET);
@@ -474,31 +479,32 @@ 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 */
char fileNameHash[20]; /* '_HGUARD_' + 8 character hash + '\0' */
- /* dump header file preamble1[] */
+ /* dump header file preamble1[] */
fprintf(fp, preamble1, filename, filename, filename);
- /*
- * Dump header file preamble2[]. Hash file name into something that
- * is small enough to be a C macro name and does not have invalid
- * characters for a macro name to use as a header guard. The result
- * of the hash should be unique enough for our purposes.
- */
+ /*
+ * Dump header file preamble2[]. Hash file name into something that
+ * is small enough to be a C macro name and does not have invalid
+ * characters for a macro name to use as a header guard. The result
+ * of the hash should be unique enough for our purposes.
+ */
for (ix = 0; ix < sizeof(filename); ++ix) {
hash = (hash * 33) + (unsigned int) filename[ix];
- }
+ }
sprintf(fileNameHash, "_HGUARD_%08x", hash);
fprintf(fp, preamble2, fileNameHash, fileNameHash);
@@ -508,47 +514,49 @@ 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 */
unsigned numSyms; /* number of symbols in the symbol table */
- /* context the symbol table: pick out absolute syms */
+ /* context the symbol table: pick out absolute syms */
numSyms = symTblSize / sizeof(Elf32_Sym);
lseek(fd, symTblOffset, SEEK_SET);
for (ix = 0; ix < numSyms; ++ix) {
- /* read in a single symbol structure */
-
- read(fd, &aSym, sizeof(Elf32_Sym));
-
- swabElfSym(&aSym); /* swap bytes (if required) */
-
- /*
- * Only generate definitions for global absolute symbols
- * of the form *_OFFSET
- */
-
- if ((aSym.st_shndx == SHN_ABS) &&
- (ELF_ST_BIND(aSym.st_info) == STB_GLOBAL)) {
- if ((strstr(&pStringTable[aSym.st_name],
- STRUCT_OFF_SUFFIX) != NULL) ||
- (strstr(&pStringTable[aSym.st_name],
- STRUCT_SIZ_SUFFIX) != NULL)) {
- fprintf(fp, "#define\t%s\t0x%X\n",
- &pStringTable[aSym.st_name], aSym.st_value);
- }
- }
+ /* read in a single symbol structure */
+
+ read(fd, &aSym, sizeof(Elf32_Sym));
+
+ swabElfSym(&aSym); /* swap bytes (if required) */
+
+ /*
+ * Only generate definitions for global absolute symbols
+ * of the form *_OFFSET
+ */
+
+ if ((aSym.st_shndx == SHN_ABS) &&
+ (ELF_ST_BIND(aSym.st_info) == STB_GLOBAL)) {
+ if ((strstr(&pStringTable[aSym.st_name],
+ STRUCT_OFF_SUFFIX) != NULL) ||
+ (strstr(&pStringTable[aSym.st_name],
+ STRUCT_SIZ_SUFFIX) != NULL)) {
+ fprintf(fp, "#define\t%s\t0x%X\n",
+ &pStringTable[aSym.st_name], aSym.st_value);
+ }
+ }
}
}
@@ -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);
}
@@ -586,52 +595,52 @@ int main(int argc, char *argv[])
FILE *outFile = NULL;
unsigned strTblIx;
- /* argument parsing */
+ /* argument parsing */
if (argc != 5) {
fprintf(stderr, usage, argv[0]);
- goto errorReturn;
+ goto errorReturn;
}
while ((option = getopt(argc, argv, "i:o:")) != -1) {
- switch (option) {
- case 'i':
- inFileName = optarg;
- break;
- case 'o':
- outFileName = optarg;
- break;
- default:
- fprintf(stderr, usage, argv[0]);
- goto errorReturn;
- }
+ switch (option) {
+ case 'i':
+ inFileName = optarg;
+ break;
+ case 'o':
+ outFileName = optarg;
+ break;
+ default:
+ fprintf(stderr, usage, argv[0]);
+ goto errorReturn;
+ }
}
- /* open input object ELF module and output header file */
+ /* open input object ELF module and output header file */
inFd = open(inFileName, OPEN_FLAGS);
if (inFd == -1) {
- fprintf(stderr, "Cannot open input object module");
- goto errorReturn;
+ fprintf(stderr, "Cannot open input object module");
+ goto errorReturn;
}
outFile = fopen(outFileName, "w");
if (outFile == NULL) {
- fprintf(stderr, "Cannot open output header file");
- goto errorReturn;
+ fprintf(stderr, "Cannot open output header file");
+ goto errorReturn;
}
- /*
- * In the following order, attempt to ...
- * 1. Load the ELF header
- * 2. Load the section headers
- * 3. Find the symbol table
- * 4. Find the string table
- * 5. Load the string table
- * Bail if any of those steps fail.
- */
+ /*
+ * In the following order, attempt to ...
+ * 1. Load the ELF header
+ * 2. Load the section headers
+ * 3. Find the symbol table
+ * 4. Find the string table
+ * 5. Load the string table
+ * Bail if any of those steps fail.
+ */
if ((ehdrLoad(inFd) != 0) ||
(shdrsLoad(inFd) != 0) ||
@@ -639,22 +648,22 @@ int main(int argc, char *argv[])
(strTblFind(&strTblIx) != 0) ||
(strTblLoad(inFd, strTblIx, &pStringTable) != 0)) {
goto errorReturn;
- }
+ }
- /*
- * Dump the following to the header file ...
- * 1. Header file preamble
- * 2. Absolute symbols
- * 3. Header file postscript
- */
+ /*
+ * Dump the following to the header file ...
+ * 1. Header file preamble
+ * 2. Absolute symbols
+ * 3. Header file postscript
+ */
headerPreambleDump(outFile, outFileName);
headerAbsoluteSymbolsDump(inFd, outFile,
- symTblOffset, symTblSize, pStringTable);
+ symTblOffset, symTblSize, pStringTable);
headerPostscriptDump(outFile);
- /* done: cleanup */
+ /* done: cleanup */
close(inFd);
fclose(outFile);
@@ -666,19 +675,19 @@ int main(int argc, char *argv[])
errorReturn:
if (inFd != -1) {
close(inFd);
- }
+ }
if (outFile != NULL) {
fclose(outFile);
- }
+ }
if (shdr != NULL) {
free(shdr);
- }
+ }
if (pStringTable != NULL) {
free(pStringTable);
- }
+ }
return 1;
}
diff --git a/host/src/gen_config_abssym/gen_config_abssym.c b/host/src/gen_config_abssym/gen_config_abssym.c
index 0d1b9dff5..9a7e6c1be 100644
--- a/host/src/gen_config_abssym/gen_config_abssym.c
+++ b/host/src/gen_config_abssym/gen_config_abssym.c
@@ -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]);
}
}
diff --git a/host/src/mkEvents/mkevents.c b/host/src/mkEvents/mkevents.c
index f539c1701..f0c3c7a12 100644
--- a/host/src/mkEvents/mkevents.c
+++ b/host/src/mkEvents/mkevents.c
@@ -40,31 +40,34 @@ 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) {
- usage(argv[0]);
- return -1;
+ usage(argv[0]);
+ return -1;
}
j = atoi(argv[1]);
- for (i = 0; i < j; i++)
- printf(EVENT_STR, i);
+ for (i = 0; i < j; i++) {
+ printf(EVENT_STR, i);
+ }
return 0;
- }
+}
diff --git a/include/drivers/pci/pci_mgr.h b/include/drivers/pci/pci_mgr.h
index f31748f7e..b25b47616 100644
--- a/include/drivers/pci/pci_mgr.h
+++ b/include/drivers/pci/pci_mgr.h
@@ -665,7 +665,7 @@ struct _pci_msi_hdr {
struct {
/* offset 04: */
uint32_t addr; /* message address register */
- /* offset 08: */
+ /* offset 08: */
uint32_t data : 16; /* message data register
*/
uint32_t spare
@@ -1017,7 +1017,7 @@ extern int pci_config_ext_cap_ptr_find(
/* Fixed addr */
#define HT_MSI_FIXED_ADDR 0x00000000FEE00000ULL
#define HT_MSI_ADDR_LO 0x04 /* Offset to low addr bits */
- /* Low address bit mask */
+ /* Low address bit mask */
#define HT_MSI_ADDR_LO_MASK 0xFFF00000
#define HT_MSI_ADDR_HI 0x08 /* Offset to high addr bits */
#define HT_CAPTYPE_DIRECT_ROUTE 0xB0 /* Direct routing configuration */
@@ -1045,7 +1045,7 @@ extern int pci_config_ext_cap_ptr_find(
#define PCIE_ATS_MAX_QDEP 32 /* Max Invalidate Queue Depth */
#define PCIE_ATS_CTRL 0x06 /* ATS Control Register */
#define PCIE_ATS_CTRL_ENABLE 0x8000 /* ATS Enable */
- /* Smallest Translation Unit */
+ /* Smallest Translation Unit */
#define PCIE_ATS_CTRL_STU(x) ((x) & 0x1f)
#define PCIE_ATS_MIN_STU 12 /* shift of minimum STU block */
diff --git a/include/nanokernel/x86/arch.h b/include/nanokernel/x86/arch.h
index d931a7f24..1155b7de3 100644
--- a/include/nanokernel/x86/arch.h
+++ b/include/nanokernel/x86/arch.h
@@ -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 */
diff --git a/include/nanokernel/x86/asm_inline_gcc.h b/include/nanokernel/x86/asm_inline_gcc.h
index e1dd0b31f..943a1ff96 100644
--- a/include/nanokernel/x86/asm_inline_gcc.h
+++ b/include/nanokernel/x86/asm_inline_gcc.h
@@ -407,16 +407,16 @@ static inline void k_memcpy(void *_d, const void *_s, size_t _n)
/* _d & _s must be aligned to use movsl. */
#ifndef CONFIG_UNALIGNED_WRITE_UNSUPPORTED
if ((_n&3) == 0) {
- /* _n is multiple of words, much more efficient to do word moves */
- _n >>= 2;
- __asm__ volatile ("rep movsl" :
+ /* _n is multiple of words, much more efficient to do word moves */
+ _n >>= 2;
+ __asm__ volatile ("rep movsl" :
"+D" (_d), "+S" (_s), "+c" (_n) :
:
"cc", "memory");
} else
#endif /* CONFIG_UNALIGNED_WRITE_UNSUPPORTED */
{
- __asm__ volatile ("rep movsb" :
+ __asm__ volatile ("rep movsb" :
"+D" (_d), "+S" (_s), "+c" (_n) :
:
"cc", "memory");
@@ -440,11 +440,11 @@ static inline void k_memset(void *_d, int _v, size_t _n)
/* _d must be aligned to use stosl. */
#ifndef CONFIG_UNALIGNED_WRITE_UNSUPPORTED
if ((_n&3) == 0) {
- /* _n is multiple of words, much more efficient to do word stores */
- _n >>= 2;
- _v |= _v<<8;
- _v |= _v<<16;
- __asm__ volatile ("rep stosl" :
+ /* _n is multiple of words, much more efficient to do word stores */
+ _n >>= 2;
+ _v |= _v<<8;
+ _v |= _v<<16;
+ __asm__ volatile ("rep stosl" :
"+D" (_d), "+c" (_n) :
"a" (_v) :
"cc", "memory");
diff --git a/kernel/microkernel/channel/ch_buff.c b/kernel/microkernel/channel/ch_buff.c
index 4d5368ee4..176a9e8d3 100644
--- a/kernel/microkernel/channel/ch_buff.c
+++ b/kernel/microkernel/channel/ch_buff.c
@@ -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 *piTransferID)
+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,19 +189,20 @@ 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,
- int iSize /*optional */)
+void BuffEnQA_End(struct chbuff *pChBuff, int iTransferID,
+ int iSize /*optional */)
{
ARG_UNUSED(iSize);
@@ -228,14 +225,16 @@ 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);
+ [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;
}
@@ -249,17 +248,19 @@ void AsyncEnQFinished(struct chbuff *pChBuff, int iTransferID)
int isizeAWA=0; */
int iNewFirstMarker =
ScanMarkers(&(pChBuff->WriteMarkers),
- &(pChBuff->iAvailDataCont),
- &(pChBuff->iAvailDataAWA),
- &(pChBuff->iNbrPendingWrites));
+ &(pChBuff->iAvailDataCont),
+ &(pChBuff->iAvailDataAWA),
+ &(pChBuff->iNbrPendingWrites));
/*pChBuff->iAvailDataCont +=iSizeCont;
pChBuff->iAvailDataAWA +=iSizeAWA; */
- if (-1 != iNewFirstMarker)
+ if (-1 != iNewFirstMarker) {
pChBuff->pReadGuard =
pChBuff->WriteMarkers.aMarkers[iNewFirstMarker]
- .pointer;
- else
+ .pointer;
+ }
+ 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 *piTransferID)
+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,19 +310,20 @@ 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,
- int iSize /*optional */)
+void BuffDeQA_End(struct chbuff *pChBuff, int iTransferID,
+ int iSize /*optional */)
{
ARG_UNUSED(iSize);
@@ -358,14 +360,16 @@ 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);
+ [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,12 +387,14 @@ 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
+ .pointer;
+ }
+ 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 *piAvailDataAWA)
+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 *piFreeSpaceAWA)
+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
diff --git a/kernel/microkernel/idle.c b/kernel/microkernel/idle.c
index 0f837cd77..12ffe8c45 100644
--- a/kernel/microkernel/idle.c
+++ b/kernel/microkernel/idle.c
@@ -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;
}
diff --git a/kernel/microkernel/k_sema.c b/kernel/microkernel/k_sema.c
index 17da96abd..4ef989137 100644
--- a/kernel/microkernel/k_sema.c
+++ b/kernel/microkernel/k_sema.c
@@ -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);
@@ -77,7 +79,7 @@ static void signal_semaphore(int n, struct sem_struct *S)
} else {
#endif
A->Time.rcode = RC_OK;
- reset_state_bit(A->Ctxt.proc, TF_SEMA);
+ reset_state_bit(A->Ctxt.proc, TF_SEMA);
#ifdef CONFIG_SYS_CLOCK_EXISTS
}
#endif
@@ -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
+ _k_sem_group_wait(X);
+ } 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,15 +295,16 @@ 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;
} else
#endif
A->Time.rcode = RC_OK;
- reset_state_bit(A->Ctxt.proc, TF_SEMA);
+ reset_state_bit(A->Ctxt.proc, TF_SEMA);
}
/*******************************************************************************
@@ -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;
diff --git a/kernel/microkernel/k_timer.c b/kernel/microkernel/k_timer.c
index 1aedd4001..76aa69558 100644
--- a/kernel/microkernel/k_timer.c
+++ b/kernel/microkernel/k_timer.c
@@ -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,25 +333,26 @@ 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 */
- /*
- * Either the initial delay and/or the period is invalid. Mark
- * the timer as inactive.
- */
+ /*
+ * Either the initial delay and/or the period is invalid. Mark
+ * the timer as inactive.
+ */
if ((T->duration < 0) || (T->period < 0)) {
T->duration = -1;
return;
@@ -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;
diff --git a/kernel/microkernel/task_monitor.c b/kernel/microkernel/task_monitor.c
index 8ef17003a..db7e0e469 100644
--- a/kernel/microkernel/task_monitor.c
+++ b/kernel/microkernel/task_monitor.c
@@ -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,11 +101,14 @@ 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++;
+ }
}
}
@@ -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];
}
}
diff --git a/kernel/nanokernel/string_s.c b/kernel/nanokernel/string_s.c
index 5135bf787..554037bc4 100644
--- a/kernel/nanokernel/string_s.c
+++ b/kernel/nanokernel/string_s.c
@@ -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++;
@@ -145,12 +146,12 @@ errno_t __strcpy_s(char *dest, size_t nDestElem, const char *src)
_NanoFatalErrorHandler(_NANO_ERR_INVALID_STRING_OP, &_default_esf);
- /*
- * the following statement is included in case the compiler
- * doesn't recognize that _NanoFatalErrorHandler() never returns
- * and complains about "missing return value for non-void function"
- * (should be optimized away if compiler recognizes the non-return)
- */
+ /*
+ * the following statement is included in case the compiler
+ * doesn't recognize that _NanoFatalErrorHandler() never returns
+ * and complains about "missing return value for non-void function"
+ * (should be optimized away if compiler recognizes the non-return)
+ */
return 1;
}
diff --git a/samples/bluetooth/test_bluetooth/bluetooth.c b/samples/bluetooth/test_bluetooth/bluetooth.c
index 9896aa957..7cd7839ad 100644
--- a/samples/bluetooth/test_bluetooth/bluetooth.c
+++ b/samples/bluetooth/test_bluetooth/bluetooth.c
@@ -54,9 +54,9 @@ static int driver_send(struct bt_buf *buf)
}
static struct bt_driver drv = {
- .head_reserve = 0,
- .open = driver_open,
- .send = driver_send,
+ .head_reserve = 0,
+ .open = driver_open,
+ .send = driver_send,
};
static void driver_init(void)
@@ -75,13 +75,15 @@ 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__);
+ __func__);
TC_END_REPORT(ret_code);
}
diff --git a/samples/include/irq_test_common.h b/samples/include/irq_test_common.h
index 6489f719e..a2805c01d 100644
--- a/samples/include/irq_test_common.h
+++ b/samples/include/irq_test_common.h
@@ -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,47 +120,44 @@ 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 */
if (i->isr[0]) {
- vector = irq_connect(NANO_SOFT_IRQ, IRQ_PRIORITY, i->isr[0],
- i->arg[0], nanoIntStub1);
- if (-1 == vector) {
- return -1;
- }
- sw_isr_trigger_0[1] = vector;
+ vector = irq_connect(NANO_SOFT_IRQ, IRQ_PRIORITY, i->isr[0],
+ i->arg[0], nanoIntStub1);
+ if (-1 == vector) {
+ return -1;
+ }
+ sw_isr_trigger_0[1] = vector;
}
#if NUM_SW_IRQS >= 2
if (i->isr[1]) {
- vector = irq_connect(NANO_SOFT_IRQ, IRQ_PRIORITY, i->isr[1],
- i->arg[1], nanoIntStub2);
- if (-1 == vector) {
- return -1;
- }
- sw_isr_trigger_1[1] = vector;
+ vector = irq_connect(NANO_SOFT_IRQ, IRQ_PRIORITY, i->isr[1],
+ i->arg[1], nanoIntStub2);
+ if (-1 == vector) {
+ return -1;
+ }
+ sw_isr_trigger_1[1] = vector;
}
#endif /* NUM_SW_IRQS >= 2 */
#elif defined(VXMICRO_ARCH_arm)
#if defined(CONFIG_CPU_CORTEXM)
if (i->isr[0]) {
- (void) irq_connect(0, IRQ_PRIORITY, i->isr[0], i->arg[0]);
- irq_enable(0);
+ (void) irq_connect(0, IRQ_PRIORITY, i->isr[0], i->arg[0]);
+ irq_enable(0);
}
if (i->isr[1]) {
- (void) irq_connect(1, IRQ_PRIORITY, i->isr[1], i->arg[1]);
- irq_enable(1);
+ (void) irq_connect(1, IRQ_PRIORITY, i->isr[1], i->arg[1]);
+ irq_enable(1);
}
#endif /* CONFIG_CPU_CORTEXM */
#endif /* VXMICRO_ARCH_x86 */
return 0;
- }
+}
#endif /* _IRQ_TEST_COMMON__H_ */
diff --git a/samples/microkernel/apps/hello_world/src/hello.c b/samples/microkernel/apps/hello_world/src/hello.c
index b3ec83d3c..79daad612 100644
--- a/samples/microkernel/apps/hello_world/src/hello.c
+++ b/samples/microkernel/apps/hello_world/src/hello.c
@@ -63,29 +63,29 @@
void helloLoop(const char *taskname, ksem_t mySem, ksem_t otherSem)
{
while (1) {
- task_sem_take_wait(mySem);
+ task_sem_take_wait(mySem);
- /* say "hello" */
- PRINT("%s: Hello World!\n", taskname);
+ /* say "hello" */
+ PRINT("%s: Hello World!\n", taskname);
- /* wait a while, then let other task have a turn */
- task_sleep(SLEEPTICKS);
- task_sem_give(otherSem);
+ /* wait a while, then let other task have a turn */
+ task_sleep(SLEEPTICKS);
+ task_sem_give(otherSem);
}
}
void taskA(void)
{
- /* taskA gives its own semaphore, allowing it to say hello right away */
+ /* taskA gives its own semaphore, allowing it to say hello right away */
task_sem_give(TASKASEM);
- /* invoke routine that allows task to ping-pong hello messages with taskB */
+ /* invoke routine that allows task to ping-pong hello messages with taskB */
helloLoop(__FUNCTION__, TASKASEM, TASKBSEM);
}
void taskB(void)
{
- /* invoke routine that allows task to ping-pong hello messages with taskA */
+ /* invoke routine that allows task to ping-pong hello messages with taskA */
helloLoop(__FUNCTION__, TASKBSEM, TASKASEM);
}
@@ -121,16 +121,16 @@ void fiberEntry(void)
nano_timer_init(&timer, data);
while (1) {
- /* wait for task to let us have a turn */
- nano_fiber_sem_take_wait(&nanoSemFiber);
+ /* wait for task to let us have a turn */
+ nano_fiber_sem_take_wait(&nanoSemFiber);
- /* say "hello" */
- PRINT("%s: Hello World!\n", __FUNCTION__);
+ /* say "hello" */
+ PRINT("%s: Hello World!\n", __FUNCTION__);
- /* wait a while, then let task have a turn */
- nano_fiber_timer_start(&timer, SLEEPTICKS);
- nano_fiber_timer_wait(&timer);
- nano_fiber_sem_give(&nanoSemTask);
+ /* wait a while, then let task have a turn */
+ nano_fiber_timer_start(&timer, SLEEPTICKS);
+ nano_fiber_timer_wait(&timer);
+ nano_fiber_sem_give(&nanoSemTask);
}
}
@@ -146,16 +146,16 @@ void main(void)
nano_timer_init(&timer, data);
while (1) {
- /* say "hello" */
- PRINT("%s: Hello World!\n", __FUNCTION__);
+ /* say "hello" */
+ PRINT("%s: Hello World!\n", __FUNCTION__);
- /* wait a while, then let fiber have a turn */
- nano_task_timer_start(&timer, SLEEPTICKS);
- nano_task_timer_wait(&timer);
- nano_task_sem_give(&nanoSemFiber);
+ /* wait a while, then let fiber have a turn */
+ nano_task_timer_start(&timer, SLEEPTICKS);
+ nano_task_timer_wait(&timer);
+ nano_task_sem_give(&nanoSemFiber);
- /* now wait for fiber to let us have a turn */
- nano_task_sem_take_wait(&nanoSemTask);
+ /* now wait for fiber to let us have a turn */
+ nano_task_sem_take_wait(&nanoSemTask);
}
}
diff --git a/samples/microkernel/apps/philosophers/src/phil_fiber.c b/samples/microkernel/apps/philosophers/src/phil_fiber.c
index 7d1fed633..1380766f5 100644
--- a/samples/microkernel/apps/philosophers/src/phil_fiber.c
+++ b/samples/microkernel/apps/philosophers/src/phil_fiber.c
@@ -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 */
@@ -125,33 +123,33 @@ void philEntry(void)
kmutex_t f1; /* fork #1 */
kmutex_t f2; /* fork #2 */
#endif
- static int myId; /* next philosopher ID */
- int pri = irq_lock(); /* interrupt lock level */
- int id = myId++; /* current philosopher ID */
+ static int myId; /* next philosopher ID */
+ int pri = irq_lock(); /* interrupt lock level */
+ int id = myId++; /* current philosopher ID */
irq_unlock(pri);
- /* always take the lowest fork first */
+ /* always take the lowest fork first */
if ((id+1) != N_PHILOSOPHERS) {
- f1 = FORK(id);
- f2 = FORK(id + 1);
+ f1 = FORK(id);
+ f2 = FORK(id + 1);
}
else {
- f1 = FORK(0);
- f2 = FORK(id);
+ f1 = FORK(0);
+ f2 = FORK(id);
}
while (1) {
- TAKE(f1);
- TAKE(f2);
+ TAKE(f1);
+ TAKE(f2);
PRINT(id, "EATING ");
- RANDDELAY(id);
+ RANDDELAY(id);
- GIVE(f2);
- GIVE(f1);
+ GIVE(f2);
+ GIVE(f1);
PRINT(id, "THINKING");
- RANDDELAY(id);
- }
+ RANDDELAY(id);
}
+}
diff --git a/samples/microkernel/apps/philosophers/src/phil_task.c b/samples/microkernel/apps/philosophers/src/phil_task.c
index b21a0fc18..7ae6eba82 100644
--- a/samples/microkernel/apps/philosophers/src/phil_task.c
+++ b/samples/microkernel/apps/philosophers/src/phil_task.c
@@ -74,27 +74,28 @@ struct nano_sem forks[N_PHILOSOPHERS];
*/
int main(void)
- {
+{
int i;
PRINTF(DEMO_DESCRIPTION, "fibers", "nanokernel");
for (i = 0; i < N_PHILOSOPHERS; i++) {
- nano_sem_init(&forks[i]);
- nano_task_sem_give(&forks[i]);
+ nano_sem_init(&forks[i]);
+ nano_task_sem_give(&forks[i]);
}
- /* create philosopher fibers */
- for (i = 0; i < N_PHILOSOPHERS; i++)
+ /* create philosopher fibers */
+ for (i = 0; i < N_PHILOSOPHERS; i++) {
task_fiber_start(&philStack[i][0], STSIZE,
- (nano_fiber_entry_t) philEntry, 0, 0, 6, 0);
+ (nano_fiber_entry_t) philEntry, 0, 0, 6, 0);
+ }
- /* wait forever */
+ /* wait forever */
while (1) {
- extern void nano_cpu_idle(void);
- nano_cpu_idle();
- }
+ extern void nano_cpu_idle(void);
+ nano_cpu_idle();
}
+}
#else
/*******************************************************************************
@@ -105,14 +106,14 @@ int main(void)
*/
void philDemo(void)
- {
+{
PRINTF(DEMO_DESCRIPTION, "tasks", "microkernel");
- task_group_start(PHI);
+ task_group_start(PHI);
- /* wait forever */
+ /* wait forever */
while (1) {
- task_sleep(10000);
- }
+ task_sleep(10000);
}
+}
#endif
diff --git a/samples/microkernel/benchmark/app_kernel/src/event_b.c b/samples/microkernel/benchmark/app_kernel/src/event_b.c
index 0c5c77f00..b78443997 100644
--- a/samples/microkernel/benchmark/app_kernel/src/event_b.c
+++ b/samples/microkernel/benchmark/app_kernel/src/event_b.c
@@ -66,7 +66,7 @@ int example_handler (int event);
*/
void event_test(void)
- {
+{
int nReturn;
int nCounter;
uint32_t et; /* elapsed time */
@@ -74,107 +74,107 @@ void event_test(void)
PRINT_STRING(dashline, output_file);
et = BENCH_START();
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
- nReturn = task_event_send(TEST_EVENT);
+ nReturn = task_event_send(TEST_EVENT);
#ifdef EVENT_CHECK
- if (nReturn != RC_OK) {
- PRINT_STRING(EventSignalErr, output_file);
- return; /* error */
- }
+ if (nReturn != RC_OK) {
+ PRINT_STRING(EventSignalErr, output_file);
+ return; /* error */
+ }
#endif /* EVENT_CHECK */
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "Signal enabled event",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS));
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS));
et = BENCH_START();
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
- nReturn = task_event_send(TEST_EVENT);
+ nReturn = task_event_send(TEST_EVENT);
#ifdef EVENT_CHECK
- if (nReturn != RC_OK) {
- PRINT_STRING(EventSignalErr, output_file);
- task_sleep(SLEEP_TIME);
- return; /* error */
- }
+ if (nReturn != RC_OK) {
+ PRINT_STRING(EventSignalErr, output_file);
+ task_sleep(SLEEP_TIME);
+ return; /* error */
+ }
#endif /* EVENT_CHECK */
- nReturn = task_event_recv(TEST_EVENT);
+ nReturn = task_event_recv(TEST_EVENT);
#ifdef EVENT_CHECK
- if (nReturn != RC_OK) {
- PRINT_STRING(EventTestErr, output_file);
- task_sleep(SLEEP_TIME);
- return; /* error */
- }
+ if (nReturn != RC_OK) {
+ PRINT_STRING(EventTestErr, output_file);
+ task_sleep(SLEEP_TIME);
+ return; /* error */
+ }
#endif /* EVENT_CHECK */
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "Signal event & Test event",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS));
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS));
et = BENCH_START();
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
- nReturn = task_event_send(TEST_EVENT);
+ nReturn = task_event_send(TEST_EVENT);
#ifdef EVENT_CHECK
- if (nReturn != RC_OK) {
- PRINT_STRING(EventSignalErr, output_file);
- return; /* error */
- }
+ if (nReturn != RC_OK) {
+ PRINT_STRING(EventSignalErr, output_file);
+ return; /* error */
+ }
#endif /* EVENT_CHECK */
- nReturn = task_event_recv_wait(TEST_EVENT);
+ nReturn = task_event_recv_wait(TEST_EVENT);
#ifdef EVENT_CHECK
- if (nReturn != RC_OK) {
- PRINT_STRING(EventTestErr, output_file);
- return; /* error */
- }
+ if (nReturn != RC_OK) {
+ PRINT_STRING(EventTestErr, output_file);
+ return; /* error */
+ }
#endif /* EVENT_CHECK */
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "Signal event & TestW event",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS));
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS));
PRINT_STRING("| Signal event with installed handler"
- " |\n", output_file);
+ " |\n", output_file);
nReturn = task_event_set_handler (TEST_EVENT, example_handler);
if (nReturn != RC_OK) {
- PRINT_F(output_file, "-------- Error installing event handler.\n");
- task_sleep(SLEEP_TIME);
- return; /* error */
+ PRINT_F(output_file, "-------- Error installing event handler.\n");
+ task_sleep(SLEEP_TIME);
+ return; /* error */
}
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
- nReturn = task_event_send(TEST_EVENT);
+ nReturn = task_event_send(TEST_EVENT);
#ifdef EVENT_CHECK
- if (nReturn != RC_OK) {
- PRINT_STRING(EventSignalErr, output_file);
- task_sleep(SLEEP_TIME);
- return; /* error */
- }
- if (nEventValue != TEST_EVENT + 1) {
- PRINT_STRING(EventHandlerErr, output_file);
- task_sleep(SLEEP_TIME);
- return; /* error */
- }
+ if (nReturn != RC_OK) {
+ PRINT_STRING(EventSignalErr, output_file);
+ task_sleep(SLEEP_TIME);
+ return; /* error */
+ }
+ if (nEventValue != TEST_EVENT + 1) {
+ PRINT_STRING(EventHandlerErr, output_file);
+ task_sleep(SLEEP_TIME);
+ return; /* error */
+ }
#endif /* EVENT_CHECK */
- nEventValue = 0;
+ nEventValue = 0;
}
nReturn = task_event_set_handler (TEST_EVENT, NULL);
if (nReturn != RC_OK) {
- PRINT_F(output_file, "Error removing event handler.\n");
- task_sleep(SLEEP_TIME);
- return; /* error */
+ PRINT_F(output_file, "Error removing event handler.\n");
+ task_sleep(SLEEP_TIME);
+ return; /* error */
}
PRINT_STRING("| Handler responds OK"
- " |\n",
- output_file);
+ " |\n",
+ 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 */
diff --git a/samples/microkernel/benchmark/app_kernel/src/fifo_b.c b/samples/microkernel/benchmark/app_kernel/src/fifo_b.c
index a133bbf53..57b2ebd5e 100644
--- a/samples/microkernel/benchmark/app_kernel/src/fifo_b.c
+++ b/samples/microkernel/benchmark/app_kernel/src/fifo_b.c
@@ -44,73 +44,73 @@
*/
void queue_test(void)
- {
+{
uint32_t et; /* elapsed time */
int i;
PRINT_STRING(dashline, output_file);
et = BENCH_START();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
- task_fifo_put_wait(DEMOQX1, data_bench);
+ task_fifo_put_wait(DEMOQX1, data_bench);
}
et = TIME_STAMP_DELTA_GET(et);
PRINT_F(output_file, FORMAT, "enqueue 1 byte msg in FIFO",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
- task_fifo_get_wait(DEMOQX1, data_bench);
+ task_fifo_get_wait(DEMOQX1, data_bench);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "dequeue 1 byte msg in FIFO",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
- task_fifo_put_wait(DEMOQX4, data_bench);
+ task_fifo_put_wait(DEMOQX4, data_bench);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "enqueue 4 bytes msg in FIFO",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
- task_fifo_get_wait(DEMOQX4, data_bench);
+ task_fifo_get_wait(DEMOQX4, data_bench);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "dequeue 4 bytes msg in FIFO",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
task_sem_give(STARTRCV);
et = BENCH_START();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
- task_fifo_put_wait(DEMOQX1, data_bench);
+ task_fifo_put_wait(DEMOQX1, data_bench);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT,
- "enqueue 1 byte msg in FIFO to a waiting higher priority task",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
+ "enqueue 1 byte msg in FIFO to a waiting higher priority task",
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
- task_fifo_put_wait(DEMOQX4, data_bench);
+ task_fifo_put_wait(DEMOQX4, data_bench);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
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));
- }
+ "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 */
diff --git a/samples/microkernel/benchmark/app_kernel/src/fifo_r.c b/samples/microkernel/benchmark/app_kernel/src/fifo_r.c
index 7d3c4e6ad..185794740 100644
--- a/samples/microkernel/benchmark/app_kernel/src/fifo_r.c
+++ b/samples/microkernel/benchmark/app_kernel/src/fifo_r.c
@@ -46,16 +46,16 @@
*/
void dequtask(void)
- {
+{
int x, i;
for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
- task_fifo_get_wait(DEMOQX1, &x);
+ task_fifo_get_wait(DEMOQX1, &x);
}
for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
- task_fifo_get_wait(DEMOQX4, &x);
- }
+ task_fifo_get_wait(DEMOQX4, &x);
}
+}
#endif /* FIFO_BENCH */
diff --git a/samples/microkernel/benchmark/app_kernel/src/mailbox_b.c b/samples/microkernel/benchmark/app_kernel/src/mailbox_b.c
index 867cd971c..1af847cae 100644
--- a/samples/microkernel/benchmark/app_kernel/src/mailbox_b.c
+++ b/samples/microkernel/benchmark/app_kernel/src/mailbox_b.c
@@ -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;
@@ -109,14 +109,14 @@ void mailbox_test(void)
PRINT_STRING(dashline, output_file);
PRINT_STRING("| "
- "M A I L B O X M E A S U R E M E N T S"
- " |\n", output_file);
+ "M A I L B O X M E A S U R E M E N T S"
+ " |\n", output_file);
PRINT_STRING(dashline, output_file);
PRINT_STRING("| Send mailbox message to waiting high "
- "priority task and wait |\n", output_file);
+ "priority task and wait |\n", output_file);
PRINT_F(output_file, "| repeat for %4d times and take the "
- "average |\n",
- NR_OF_MBOX_RUNS);
+ "average |\n",
+ NR_OF_MBOX_RUNS);
PRINT_STRING(dashline, output_file);
PRINT_HEADER();
PRINT_STRING(dashline, output_file);
@@ -131,14 +131,14 @@ void mailbox_test(void)
PRINT_ONE_RESULT();
EmptyMsgPutTime = puttime;
for (putsize = 8; putsize <= MESSAGE_SIZE; putsize <<= 1) {
- mailbox_put(putsize, putcount, &puttime);
- task_fifo_get_wait(MB_COMM, &getinfo); /* waiting for ack */
- PRINT_ONE_RESULT();
+ mailbox_put(putsize, putcount, &puttime);
+ task_fifo_get_wait(MB_COMM, &getinfo); /* waiting for ack */
+ PRINT_ONE_RESULT();
}
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;
@@ -163,15 +163,15 @@ void mailbox_put(
Message.tx_data = data_bench;
Message.size = size;
- /* first sync with the receiver */
+ /* first sync with the receiver */
task_sem_give(SEM0);
t = BENCH_START();
for (i = 0; i < count; i++) {
- task_mbox_put_wait(MAILB1, 1, &Message);
+ task_mbox_put_wait(MAILB1, 1, &Message);
}
t = TIME_STAMP_DELTA_GET(t);
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);
check_result();
- }
+}
#endif /* MAILBOX_BENCH */
diff --git a/samples/microkernel/benchmark/app_kernel/src/mailbox_r.c b/samples/microkernel/benchmark/app_kernel/src/mailbox_r.c
index edf598a0d..3723d5676 100644
--- a/samples/microkernel/benchmark/app_kernel/src/mailbox_r.c
+++ b/samples/microkernel/benchmark/app_kernel/src/mailbox_r.c
@@ -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;
@@ -72,13 +72,13 @@ void mailrecvtask(void)
task_fifo_put_wait(MB_COMM, &getinfo); /* acknowledge to master */
for (getsize = 8; getsize <= MESSAGE_SIZE; getsize <<= 1) {
- mailbox_get(MAILB1, getsize, getcount, &gettime);
- getinfo.time = gettime;
- getinfo.size = getsize;
- getinfo.count = getcount;
- task_fifo_put_wait(MB_COMM, &getinfo); /* acknowledge to master */
- }
+ mailbox_get(MAILB1, getsize, getcount, &gettime);
+ getinfo.time = gettime;
+ getinfo.size = getsize;
+ 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;
@@ -105,18 +105,19 @@ int mailbox_get(
Message.rx_data = data_recv;
Message.size = size;
- /* sync with the sender */
+ /* sync with the sender */
task_sem_take_wait(SEM0);
t = BENCH_START();
for (i = 0; i < count; i++) {
- task_mbox_get_wait(mailbox, &Message);
+ task_mbox_get_wait(mailbox, &Message);
}
t = TIME_STAMP_DELTA_GET(t);
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);
- if (bench_test_end() < 0)
- PRINT_OVERFLOW_ERROR();
- return 0;
+ if (bench_test_end() < 0) {
+ PRINT_OVERFLOW_ERROR();
}
+ return 0;
+}
#endif /* MAILBOX_BENCH */
diff --git a/samples/microkernel/benchmark/app_kernel/src/master.c b/samples/microkernel/benchmark/app_kernel/src/master.c
index 3700ec70b..87ab14f3c 100644
--- a/samples/microkernel/benchmark/app_kernel/src/master.c
+++ b/samples/microkernel/benchmark/app_kernel/src/master.c
@@ -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,22 +82,22 @@ 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);
- /*
- * send all printf and fprintf to console
- */
+ /*
+ * 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);
@@ -136,40 +135,40 @@ void BenchTask(void)
PRINT_STRING(newline, output_file);
do {
- PRINT_STRING(dashline, output_file);
- PRINT_STRING("| S I M P L E S E R V I C E "
- "M E A S U R E M E N T S | nsec |\n",
- output_file);
- PRINT_STRING(dashline, output_file);
- task_start(RECVTASK);
- call_test();
- queue_test();
- sema_test();
- mutex_test();
- memorymap_test();
- mempool_test();
- event_test();
- mailbox_test();
- pipe_test();
- PRINT_STRING("| END OF TESTS "
- " |\n",
- output_file);
- PRINT_STRING(dashline, output_file);
- PRINT_STRING("VXMICRO PROJECT EXECUTION SUCCESSFUL\n",output_file);
- }
- while (continuously && !kbhit());
+ PRINT_STRING(dashline, output_file);
+ PRINT_STRING("| S I M P L E S E R V I C E "
+ "M E A S U R E M E N T S | nsec |\n",
+ output_file);
+ PRINT_STRING(dashline, output_file);
+ task_start(RECVTASK);
+ call_test();
+ queue_test();
+ sema_test();
+ mutex_test();
+ memorymap_test();
+ mempool_test();
+ event_test();
+ mailbox_test();
+ pipe_test();
+ PRINT_STRING("| END OF TESTS "
+ " |\n",
+ output_file);
+ PRINT_STRING(dashline, output_file);
+ PRINT_STRING("VXMICRO PROJECT EXECUTION SUCCESSFUL\n",output_file);
+ } while (continuously && !kbhit());
WAIT_FOR_USER();
- /*
- * 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)
- task_sleep(2 * sys_clock_ticks_per_sec);
+ /*
+ * 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) {
+ task_sleep(2 * sys_clock_ticks_per_sec);
+ }
output_close();
- }
+}
/*******************************************************************************
@@ -182,6 +181,6 @@ void BenchTask(void)
*/
void dummy_test(void)
- {
+{
return;
- }
+}
diff --git a/samples/microkernel/benchmark/app_kernel/src/master.h b/samples/microkernel/benchmark/app_kernel/src/master.h
index 33b2d3392..6adc1e1a2 100644
--- a/samples/microkernel/benchmark/app_kernel/src/master.h
+++ b/samples/microkernel/benchmark/app_kernel/src/master.h
@@ -148,33 +148,31 @@ extern void event_test(void);
* is defined in the main file
*/
-#define PRINT_F(stream, fmt, ...) \
- { \
+#define PRINT_F(stream, fmt, ...) \
+{ \
snprintf(sline, SLINE_LEN, fmt, ##__VA_ARGS__); \
- PRINT_STRING(sline, stream); \
- }
+ 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) \
- { \
- PRINT_OVERFLOW_ERROR(); \
- return; /* error */ \
- } \
- }
+{ \
+ if (bench_test_end() < 0) { \
+ PRINT_OVERFLOW_ERROR(); \
+ return; /* error */ \
+ } \
+}
#endif /* _MASTER_H */
diff --git a/samples/microkernel/benchmark/app_kernel/src/memmap_b.c b/samples/microkernel/benchmark/app_kernel/src/memmap_b.c
index 03e72be19..06777cb61 100644
--- a/samples/microkernel/benchmark/app_kernel/src/memmap_b.c
+++ b/samples/microkernel/benchmark/app_kernel/src/memmap_b.c
@@ -46,7 +46,7 @@
*/
void memorymap_test(void)
- {
+{
uint32_t et; /* elapsed time */
int i;
void* p;
@@ -54,14 +54,14 @@ void memorymap_test(void)
PRINT_STRING(dashline, output_file);
et = BENCH_START();
for (i = 0; i < NR_OF_MAP_RUNS; i++) {
- task_mem_map_alloc_wait(MAP1, &p);
- task_mem_map_free(MAP1, &p);
+ task_mem_map_alloc_wait(MAP1, &p);
+ task_mem_map_free(MAP1, &p);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "average alloc and dealloc memory page",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MAP_RUNS)));
- }
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MAP_RUNS)));
+}
#endif /* MEMMAP_BENCH */
diff --git a/samples/microkernel/benchmark/app_kernel/src/mempool_b.c b/samples/microkernel/benchmark/app_kernel/src/mempool_b.c
index 6130e3cdb..7401c1652 100644
--- a/samples/microkernel/benchmark/app_kernel/src/mempool_b.c
+++ b/samples/microkernel/benchmark/app_kernel/src/mempool_b.c
@@ -44,7 +44,7 @@
*/
void mempool_test(void)
- {
+{
uint32_t et; /* elapsed time */
int i;
struct k_block block;
@@ -52,15 +52,15 @@ void mempool_test(void)
PRINT_STRING(dashline, output_file);
et = BENCH_START();
for (i = 0; i < NR_OF_POOL_RUNS; i++) {
- task_mem_pool_alloc_wait(&block, DEMOPOOL, 16);
- task_mem_pool_free(&block);
+ task_mem_pool_alloc_wait(&block, DEMOPOOL, 16);
+ task_mem_pool_free(&block);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
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)));
- }
+ "average alloc and dealloc memory pool block",
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_POOL_RUNS)));
+}
#endif /* MEMPOOL_BENCH */
diff --git a/samples/microkernel/benchmark/app_kernel/src/mutex_b.c b/samples/microkernel/benchmark/app_kernel/src/mutex_b.c
index 4b05baf76..07fcce479 100644
--- a/samples/microkernel/benchmark/app_kernel/src/mutex_b.c
+++ b/samples/microkernel/benchmark/app_kernel/src/mutex_b.c
@@ -44,21 +44,21 @@
*/
void mutex_test(void)
- {
+{
uint32_t et; /* elapsed time */
int i;
PRINT_STRING(dashline, output_file);
et = BENCH_START();
for (i = 0; i < NR_OF_MUTEX_RUNS; i++) {
- task_mutex_lock_wait(DEMO_MUTEX);
- task_mutex_unlock(DEMO_MUTEX);
+ task_mutex_lock_wait(DEMO_MUTEX);
+ task_mutex_unlock(DEMO_MUTEX);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "average lock and unlock mutex",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MUTEX_RUNS)));
- }
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MUTEX_RUNS)));
+}
#endif /* MUTEX_BENCH */
diff --git a/samples/microkernel/benchmark/app_kernel/src/nop_b.c b/samples/microkernel/benchmark/app_kernel/src/nop_b.c
index 61e25b322..82c992a8b 100644
--- a/samples/microkernel/benchmark/app_kernel/src/nop_b.c
+++ b/samples/microkernel/benchmark/app_kernel/src/nop_b.c
@@ -48,19 +48,19 @@ extern void _task_nop(void);
*/
void call_test(void)
- {
+{
uint32_t et; /* Elapsed Time */
int i;
et = BENCH_START();
for (i = 0; i < NR_OF_NOP_RUNS; i++) {
- _task_nop();
+ _task_nop();
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "minimum VxMicro call time",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_NOP_RUNS));
- }
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_NOP_RUNS));
+}
#endif /* MICROKERNEL_CALL_BENCH */
diff --git a/samples/microkernel/benchmark/app_kernel/src/pipe_b.c b/samples/microkernel/benchmark/app_kernel/src/pipe_b.c
index 9a71bdc52..dba6168c3 100644
--- a/samples/microkernel/benchmark/app_kernel/src/pipe_b.c
+++ b/samples/microkernel/benchmark/app_kernel/src/pipe_b.c
@@ -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];
@@ -130,76 +130,76 @@ void pipe_test(void)
task_sem_reset(SEM0);
task_sem_give(STARTRCV);
- /* action: */
+ /* action: */
- /* non-buffered operation, matching (ALL_N) */
+ /* non-buffered operation, matching (ALL_N) */
PRINT_STRING(dashline, output_file);
PRINT_STRING("| "
- "C H A N N E L M E A S U R E M E N T S"
- " |\n", output_file);
+ "C H A N N E L M E A S U R E M E N T S"
+ " |\n", output_file);
PRINT_STRING(dashline, output_file);
PRINT_STRING("| Send data into a pipe towards a "
- "receiving high priority task and wait |\n",
- output_file);
+ "receiving high priority task and wait |\n",
+ output_file);
PRINT_STRING(dashline, output_file);
PRINT_STRING("| "
- "matching sizes (_ALL_N)"
- " |\n", output_file);
+ "matching sizes (_ALL_N)"
+ " |\n", output_file);
PRINT_STRING(dashline, output_file);
PRINT_ALL_TO_N_HEADER_UNIT();
PRINT_STRING(dashline, output_file);
PRINT_STRING("| put | get | no buf | small buf| big buf |"
- " no buf | small buf| big buf |\n", output_file);
+ " no buf | small buf| big buf |\n", output_file);
PRINT_STRING(dashline, output_file);
for (putsize = 8; putsize <= MESSAGE_SIZE_PIPE; putsize <<= 1) {
- for (pipe = 0; pipe < 3; pipe++) {
- putcount = NR_OF_PIPE_RUNS;
- pipeput(TestPipes[pipe], _ALL_N, putsize, putcount,
- &puttime[pipe]);
+ for (pipe = 0; pipe < 3; pipe++) {
+ putcount = NR_OF_PIPE_RUNS;
+ pipeput(TestPipes[pipe], _ALL_N, putsize, putcount,
+ &puttime[pipe]);
- task_fifo_get_wait(CH_COMM, &getinfo); /* waiting for ack */
- }
- PRINT_ALL_TO_N();
+ task_fifo_get_wait(CH_COMM, &getinfo); /* waiting for ack */
+ }
+ PRINT_ALL_TO_N();
}
PRINT_STRING(dashline, output_file);
- /* Test with two different sender priorities */
+ /* Test with two different sender priorities */
for (prio = 0; prio < 2; prio++) {
- /* non-buffered operation, non-matching (1_TO_N) */
- if (prio == 0) {
- PRINT_STRING("| "
- "non-matching sizes (1_TO_N) to higher priority"
- " |\n", output_file);
- TaskPrio = task_priority_get();
- }
- if (prio == 1) {
- PRINT_STRING("| "
- "non-matching sizes (1_TO_N) to lower priority"
- " |\n", output_file);
- task_priority_set(task_id_get(), TaskPrio - 2);
- }
- PRINT_STRING(dashline, output_file);
- PRINT_1_TO_N_HEADER();
- PRINT_STRING("| put | get | no buf | small buf| big buf | "
- "no buf | small buf| big buf |\n", output_file);
- PRINT_STRING(dashline, output_file);
+ /* non-buffered operation, non-matching (1_TO_N) */
+ if (prio == 0) {
+ PRINT_STRING("| "
+ "non-matching sizes (1_TO_N) to higher priority"
+ " |\n", output_file);
+ TaskPrio = task_priority_get();
+ }
+ if (prio == 1) {
+ PRINT_STRING("| "
+ "non-matching sizes (1_TO_N) to lower priority"
+ " |\n", output_file);
+ task_priority_set(task_id_get(), TaskPrio - 2);
+ }
+ PRINT_STRING(dashline, output_file);
+ PRINT_1_TO_N_HEADER();
+ PRINT_STRING("| put | get | no buf | small buf| big buf | "
+ "no buf | small buf| big buf |\n", output_file);
+ PRINT_STRING(dashline, output_file);
- for (putsize = 8; putsize <= (MESSAGE_SIZE_PIPE); putsize <<= 1) {
- putcount = MESSAGE_SIZE_PIPE / putsize;
- for (pipe = 0; pipe < 3; pipe++) {
- pipeput(TestPipes[pipe], _1_TO_N, putsize,
- putcount, &puttime[pipe]);
- /* size*count == MESSAGE_SIZE_PIPE */
- task_fifo_get_wait(CH_COMM, &getinfo); /* waiting for ack */
- getsize = getinfo.size;
+ for (putsize = 8; putsize <= (MESSAGE_SIZE_PIPE); putsize <<= 1) {
+ putcount = MESSAGE_SIZE_PIPE / putsize;
+ for (pipe = 0; pipe < 3; pipe++) {
+ pipeput(TestPipes[pipe], _1_TO_N, putsize,
+ putcount, &puttime[pipe]);
+ /* size*count == MESSAGE_SIZE_PIPE */
+ task_fifo_get_wait(CH_COMM, &getinfo); /* waiting for ack */
+ getsize = getinfo.size;
+ }
+ PRINT_1_TO_N();
}
- PRINT_1_TO_N();
- }
- PRINT_STRING(dashline, output_file);
- task_priority_set(task_id_get(), TaskPrio);
- }
+ PRINT_STRING(dashline, output_file);
+ task_priority_set(task_id_get(), TaskPrio);
}
+}
/*******************************************************************************
@@ -208,60 +208,63 @@ 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;
int size2xfer_total = size * count;
- /* first sync with the receiver */
+ /* first sync with the receiver */
task_sem_give(SEM0);
t = BENCH_START();
for (i = 0; _1_TO_N == option || (i < count); i++) {
- int sizexferd = 0;
- int size2xfer = min(size, size2xfer_total - sizexferd_total);
- int ret;
+ int sizexferd = 0;
+ int size2xfer = min(size, size2xfer_total - sizexferd_total);
+ int ret;
- ret = task_pipe_put_wait(pipe, data_bench, size2xfer,
- &sizexferd, option);
- if (RC_OK != ret)
- return 1;
- if (_ALL_N == option && sizexferd != size2xfer)
- return 1;
+ ret = task_pipe_put_wait(pipe, data_bench, size2xfer,
+ &sizexferd, option);
+ if (RC_OK != ret) {
+ return 1;
+ }
+ if (_ALL_N == option && sizexferd != size2xfer) {
+ return 1;
+ }
- sizexferd_total += sizexferd;
- if (size2xfer_total == sizexferd_total)
- break;
+ sizexferd_total += sizexferd;
+ if (size2xfer_total == sizexferd_total) {
+ break;
+ }
- if (size2xfer_total < sizexferd_total)
- return 1;
+ if (size2xfer_total < sizexferd_total) {
+ return 1;
+ }
}
t = TIME_STAMP_DELTA_GET(t);
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);
if (bench_test_end() < 0) {
- if (high_timer_overflow()) {
- PRINT_STRING("| Timer overflow. Results are invalid ",
- output_file);
- }
- else {
- PRINT_STRING("| Tick occured. Results may be inaccurate ",
- output_file);
- }
- PRINT_STRING(" |\n",
- output_file);
+ if (high_timer_overflow()) {
+ PRINT_STRING("| Timer overflow. Results are invalid ",
+ output_file);
+ }
+ else {
+ PRINT_STRING("| Tick occured. Results may be inaccurate ",
+ output_file);
+ }
+ PRINT_STRING(" |\n", output_file);
}
return 0;
- }
+}
#endif /* PIPE_BENCH */
diff --git a/samples/microkernel/benchmark/app_kernel/src/pipe_r.c b/samples/microkernel/benchmark/app_kernel/src/pipe_r.c
index 1737d4301..7aa8322cd 100644
--- a/samples/microkernel/benchmark/app_kernel/src/pipe_r.c
+++ b/samples/microkernel/benchmark/app_kernel/src/pipe_r.c
@@ -39,7 +39,7 @@
* Function prototypes.
*/
int pipeget(kpipe_t pipe, K_PIPE_OPTION option,
- int size, int count, unsigned int* time);
+ int size, int count, unsigned int* time);
/*
* Function declarations.
@@ -57,7 +57,7 @@ int pipeget(kpipe_t pipe, K_PIPE_OPTION option,
*/
void piperecvtask(void)
- {
+{
int getsize;
unsigned int gettime;
int getcount;
@@ -65,37 +65,37 @@ void piperecvtask(void)
int prio;
GetInfo getinfo;
- /* matching (ALL_N) */
+ /* matching (ALL_N) */
for (getsize = 8; getsize <= MESSAGE_SIZE_PIPE; getsize <<= 1) {
- for (pipe = 0; pipe < 3; pipe++) {
- getcount = NR_OF_PIPE_RUNS;
- pipeget(TestPipes[pipe], _ALL_N, getsize,
- getcount, &gettime);
- getinfo.time = gettime;
- getinfo.size = getsize;
- getinfo.count = getcount;
- task_fifo_put_wait(CH_COMM, &getinfo); /* acknowledge to master */
- }
+ for (pipe = 0; pipe < 3; pipe++) {
+ getcount = NR_OF_PIPE_RUNS;
+ pipeget(TestPipes[pipe], _ALL_N, getsize,
+ getcount, &gettime);
+ getinfo.time = gettime;
+ getinfo.size = getsize;
+ getinfo.count = getcount;
+ task_fifo_put_wait(CH_COMM, &getinfo); /* acknowledge to master */
+ }
}
for (prio = 0; prio < 2; prio++) {
- /* non-matching (1_TO_N) */
- for (getsize = (MESSAGE_SIZE_PIPE); getsize >= 8; getsize >>= 1) {
- getcount = MESSAGE_SIZE_PIPE / getsize;
- for (pipe = 0; pipe < 3; pipe++) {
- /* size*count == MESSAGE_SIZE_PIPE */
- pipeget(TestPipes[pipe], _1_TO_N,
- getsize, getcount, &gettime);
- getinfo.time = gettime;
- getinfo.size = getsize;
- getinfo.count = getcount;
- task_fifo_put_wait(CH_COMM, &getinfo); /* acknowledge to master */
+ /* non-matching (1_TO_N) */
+ for (getsize = (MESSAGE_SIZE_PIPE); getsize >= 8; getsize >>= 1) {
+ getcount = MESSAGE_SIZE_PIPE / getsize;
+ for (pipe = 0; pipe < 3; pipe++) {
+ /* size*count == MESSAGE_SIZE_PIPE */
+ pipeget(TestPipes[pipe], _1_TO_N,
+ getsize, getcount, &gettime);
+ getinfo.time = gettime;
+ getinfo.size = getsize;
+ getinfo.count = getcount;
+ task_fifo_put_wait(CH_COMM, &getinfo); /* acknowledge to master */
+ }
}
- }
}
- }
+}
/*******************************************************************************
@@ -104,61 +104,66 @@ 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;
int size2xfer_total = size * count;
- /* sync with the sender */
+ /* sync with the sender */
task_sem_take_wait(SEM0);
t = BENCH_START();
for (i = 0; _1_TO_N == option || (i < count); i++) {
- int sizexferd = 0;
- int size2xfer = min(size, size2xfer_total - sizexferd_total);
- int ret;
-
- ret = task_pipe_get_wait(pipe, data_recv, size2xfer,
- &sizexferd, option);
- if (RC_OK != ret)
- return 1;
+ int sizexferd = 0;
+ int size2xfer = min(size, size2xfer_total - sizexferd_total);
+ int ret;
+
+ ret = task_pipe_get_wait(pipe, data_recv, size2xfer,
+ &sizexferd, option);
+ if (RC_OK != ret) {
+ return 1;
+ }
- if (_ALL_N == option && sizexferd != size2xfer)
- return 1;
+ if (_ALL_N == option && sizexferd != size2xfer) {
+ return 1;
+ }
- sizexferd_total += sizexferd;
- if (size2xfer_total == sizexferd_total)
- break;
+ sizexferd_total += sizexferd;
+ if (size2xfer_total == sizexferd_total) {
+ break;
+ }
- if (size2xfer_total < sizexferd_total)
- return 1;
+ if (size2xfer_total < sizexferd_total) {
+ return 1;
+ }
}
t = TIME_STAMP_DELTA_GET(t);
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);
if (bench_test_end() < 0) {
- if (high_timer_overflow()) {
- PRINT_STRING("| Timer overflow. Results are invalid ",
- output_file);
- }
- else {
- PRINT_STRING("| Tick occured. Results may be inaccurate ",
- output_file);
- }
- PRINT_STRING(" |\n",
- output_file);
+ if (high_timer_overflow()) {
+ PRINT_STRING("| Timer overflow. Results are invalid ",
+ output_file);
+ }
+ else {
+ PRINT_STRING("| Tick occured. Results may be inaccurate ",
+ output_file);
+ }
+ PRINT_STRING(" |\n",
+ output_file);
}
return 0;
- }
+}
#endif /* PIPE_BENCH */
diff --git a/samples/microkernel/benchmark/app_kernel/src/receiver.c b/samples/microkernel/benchmark/app_kernel/src/receiver.c
index 8f543d9d6..1e51fe9f1 100644
--- a/samples/microkernel/benchmark/app_kernel/src/receiver.c
+++ b/samples/microkernel/benchmark/app_kernel/src/receiver.c
@@ -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,8 +58,8 @@ void piperecvtask(void);
*/
void recvtask(void)
- {
- /* order must be compatible with master.c ! */
+{
+ /* order must be compatible with master.c ! */
#ifdef FIFO_BENCH
task_sem_take_wait(STARTRCV);
dequtask();
@@ -78,4 +76,4 @@ void recvtask(void)
task_sem_take_wait(STARTRCV);
piperecvtask();
#endif
- }
+}
diff --git a/samples/microkernel/benchmark/app_kernel/src/receiver.h b/samples/microkernel/benchmark/app_kernel/src/receiver.h
index b1da20f7e..c025692c3 100644
--- a/samples/microkernel/benchmark/app_kernel/src/receiver.h
+++ b/samples/microkernel/benchmark/app_kernel/src/receiver.h
@@ -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)];
diff --git a/samples/microkernel/benchmark/app_kernel/src/sema_b.c b/samples/microkernel/benchmark/app_kernel/src/sema_b.c
index e63fd7592..94c085aa7 100644
--- a/samples/microkernel/benchmark/app_kernel/src/sema_b.c
+++ b/samples/microkernel/benchmark/app_kernel/src/sema_b.c
@@ -45,104 +45,104 @@
*/
void sema_test(void)
- {
+{
uint32_t et; /* elapsed Time */
int i;
PRINT_STRING(dashline, output_file);
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
- task_sem_give(SEM0);
+ task_sem_give(SEM0);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal semaphore",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
task_sem_reset(SEM1);
task_sem_give(STARTRCV);
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
- task_sem_give(SEM1);
+ task_sem_give(SEM1);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal to waiting high pri task",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
- task_sem_give(SEM1);
+ task_sem_give(SEM1);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT,
- "signal to waiting high pri task, with timeout",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
+ "signal to waiting high pri task, with timeout",
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
- task_sem_give(SEM2);
+ task_sem_give(SEM2);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal to waitm (2)",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
- task_sem_give(SEM2);
+ task_sem_give(SEM2);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal to waitm (2), with timeout",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
- task_sem_give(SEM3);
+ task_sem_give(SEM3);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal to waitm (3)",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
- task_sem_give(SEM3);
+ task_sem_give(SEM3);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal to waitm (3), with timeout",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
- task_sem_give(SEM4);
+ task_sem_give(SEM4);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal to waitm (4)",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
et = BENCH_START();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
- task_sem_give(SEM4);
+ task_sem_give(SEM4);
}
et = TIME_STAMP_DELTA_GET(et);
check_result();
PRINT_F(output_file, FORMAT, "signal to waitm (4), with timeout",
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
- }
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
+}
#endif /* SEMA_BENCH */
diff --git a/samples/microkernel/benchmark/app_kernel/src/sema_r.c b/samples/microkernel/benchmark/app_kernel/src/sema_r.c
index c08d27779..5b02dc263 100644
--- a/samples/microkernel/benchmark/app_kernel/src/sema_r.c
+++ b/samples/microkernel/benchmark/app_kernel/src/sema_r.c
@@ -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++)
- task_sem_take_wait(SEM1);
- 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++) {
+ task_sem_take_wait(SEM1);
+ }
+ 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++)
- 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);
+ 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);
+ 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);
+ 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 */
diff --git a/samples/microkernel/benchmark/boot_time/src/boot_time.c b/samples/microkernel/benchmark/boot_time/src/boot_time.c
index d3fb6606b..a0e4dcd2a 100644
--- a/samples/microkernel/benchmark/boot_time/src/boot_time.c
+++ b/samples/microkernel/benchmark/boot_time/src/boot_time.c
@@ -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 */
@@ -70,7 +70,7 @@ void bootTimeTask(void)
task_tsc = _NanoTscRead();
#ifndef CONFIG_NANOKERNEL
- /* Go to sleep for 1 tick in order to timestamp when IdleTask halts. */
+ /* Go to sleep for 1 tick in order to timestamp when IdleTask halts. */
task_sleep(1);
#endif /* ! CONFIG_NANOKERNEL */
@@ -84,30 +84,30 @@ void bootTimeTask(void)
idle_us = s_idle_tsc / CONFIG_CPU_CLOCK_FREQ_MHZ;
#endif
- /* Indicate start for sanity test suite */
+ /* Indicate start for sanity test suite */
TC_START("Boot Time Measurement");
- /* Only print lower 32bit of time result */
+ /* Only print lower 32bit of time result */
#ifdef CONFIG_NANOKERNEL
TC_PRINT("NanoKernel Boot Result: Clock Frequency: %d MHz\n",
- CONFIG_CPU_CLOCK_FREQ_MHZ);
+ CONFIG_CPU_CLOCK_FREQ_MHZ);
#else /* CONFIG_MICROKERNEL */
TC_PRINT("MicroKernel Boot Result: Clock Frequency: %d MHz\n",
- CONFIG_CPU_CLOCK_FREQ_MHZ);
+ CONFIG_CPU_CLOCK_FREQ_MHZ);
#endif
TC_PRINT("__start : %d cycles, %d us\n",
- (uint32_t)(__start_tsc & 0xFFFFFFFFULL),
- (uint32_t) (_start_us & 0xFFFFFFFFULL));
+ (uint32_t)(__start_tsc & 0xFFFFFFFFULL),
+ (uint32_t) (_start_us & 0xFFFFFFFFULL));
TC_PRINT("_start->main(): %d cycles, %d us\n",
- (uint32_t)(s_main_tsc & 0xFFFFFFFFULL),
- (uint32_t) (main_us & 0xFFFFFFFFULL));
+ (uint32_t)(s_main_tsc & 0xFFFFFFFFULL),
+ (uint32_t) (main_us & 0xFFFFFFFFULL));
TC_PRINT("_start->task : %d cycles, %d us\n",
- (uint32_t)(s_task_tsc & 0xFFFFFFFFULL),
- (uint32_t) (task_us & 0xFFFFFFFFULL));
+ (uint32_t)(s_task_tsc & 0xFFFFFFFFULL),
+ (uint32_t) (task_us & 0xFFFFFFFFULL));
#ifndef CONFIG_NANOKERNEL /* CONFIG_MICROKERNEL */
TC_PRINT("_start->idle : %d cycles, %d us\n",
- (uint32_t)(s_idle_tsc & 0xFFFFFFFFULL),
- (uint32_t) (idle_us & 0xFFFFFFFFULL));
+ (uint32_t)(s_idle_tsc & 0xFFFFFFFFULL),
+ (uint32_t) (idle_us & 0xFFFFFFFFULL));
#endif
@@ -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 */
+{
+ /* record timestamp for nanokernel's main() function */
__main_tsc = _NanoTscRead();
- /* create bootTime fibers */
+ /* create bootTime fibers */
task_fiber_start(fiberStack, 512,
- (nano_fiber_entry_t) bootTimeTask, 0, 0, 6, 0);
- }
+ (nano_fiber_entry_t) bootTimeTask, 0, 0, 6, 0);
+}
#endif /* CONFIG_NANOKERNEL */
diff --git a/samples/microkernel/benchmark/footprint/src/microkernel_footprint.c b/samples/microkernel/benchmark/footprint/src/microkernel_footprint.c
index e2997a463..8a4204fda 100644
--- a/samples/microkernel/benchmark/footprint/src/microkernel_footprint.c
+++ b/samples/microkernel/benchmark/footprint/src/microkernel_footprint.c
@@ -84,27 +84,27 @@ NANO_CPU_INT_REGISTER(isrDummyIntStub, TEST_SOFT_INT, 0);
/* pointer array ensures specified functions are linked into the image */
static pfunc func_array[] = {
- /* event functions */
+ /* event functions */
(pfunc)task_event_send,
(pfunc)_task_event_recv,
- /* mutex functions */
+ /* mutex functions */
(pfunc)_task_mutex_lock,
(pfunc)_task_mutex_unlock,
- /* FIFO functions */
+ /* FIFO functions */
(pfunc)_task_fifo_put,
(pfunc)_task_fifo_get,
(pfunc)_task_fifo_ioctl,
- /* memory map functions */
+ /* memory map functions */
(pfunc)task_mem_map_used_get,
(pfunc)_task_mem_map_alloc,
(pfunc)_task_mem_map_free,
#ifdef TEST_max
- /* task device interrupt functions */
+ /* task device interrupt functions */
(pfunc)task_irq_alloc,
(pfunc)_task_irq_test,
(pfunc)task_irq_ack,
(pfunc)task_irq_free,
- /* semaphore functions */
+ /* semaphore functions */
(pfunc)isr_sem_give,
(pfunc)task_sem_give,
(pfunc)task_sem_group_give,
@@ -113,7 +113,7 @@ static pfunc func_array[] = {
(pfunc)task_sem_group_reset,
(pfunc)_task_sem_take,
(pfunc)_task_sem_group_take,
- /* pipe functions */
+ /* pipe functions */
(pfunc)task_pipe_put,
(pfunc)task_pipe_put_wait,
(pfunc)task_pipe_put_wait_timeout,
@@ -123,17 +123,17 @@ static pfunc func_array[] = {
(pfunc)_task_pipe_put_async,
(pfunc)_task_pipe_put,
(pfunc)_task_pipe_get,
- /* mailbox functions */
+ /* mailbox functions */
(pfunc)_task_mbox_put,
(pfunc)_task_mbox_get,
(pfunc)_task_mbox_put_async,
(pfunc)_task_mbox_data_get,
(pfunc)_task_mbox_data_get_async_block,
- /* memory pool functions */
+ /* memory pool functions */
(pfunc)_task_mem_pool_alloc,
(pfunc)task_mem_pool_free,
(pfunc)task_mem_pool_defragment,
- /* task functions */
+ /* task functions */
(pfunc)_task_ioctl,
(pfunc)_task_group_ioctl,
(pfunc)task_abort_handler_set,
@@ -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,14 +191,14 @@ static void isrDummyIntStub(void *unused)
*/
void fgTaskEntry(void)
- {
+{
#ifdef TEST_max
- /* dynamically link in dummy ISR */
+ /* dynamically link in dummy ISR */
irq_connect(NANO_SOFT_IRQ, IRQ_PRIORITY, dummyIsr,
- (void *) 0, isrDummyHandlerStub);
+ (void *) 0, isrDummyHandlerStub);
#endif /* TEST_max */
- /* note: referencing "func_array" ensures it isn't optimized out */
+ /* note: referencing "func_array" ensures it isn't optimized out */
#ifdef TEST_max
printf((char *)MESSAGE, func_array);
#else
@@ -206,8 +206,8 @@ void fgTaskEntry(void)
#endif /* TEST_max */
while (1) {
- i++;
- }
+ i++;
}
+}
#endif /* TEST_min */
diff --git a/samples/microkernel/benchmark/footprint/src/test_asm_inline_gcc.h b/samples/microkernel/benchmark/footprint/src/test_asm_inline_gcc.h
index 427e32051..83570103f 100644
--- a/samples/microkernel/benchmark/footprint/src/test_asm_inline_gcc.h
+++ b/samples/microkernel/benchmark/footprint/src/test_asm_inline_gcc.h
@@ -42,7 +42,7 @@ static inline void isr_dummy(void)
extern void _IntEnt(void);
extern void _IntExit(void);
- /* compiler-generated preamble pushes & modifies EBP */
+ /* compiler-generated preamble pushes & modifies EBP */
__asm__ volatile (
"pop %%ebp;\n\t"
"call _IntEnt;\n\t"
diff --git a/samples/microkernel/benchmark/latency_measure/src/main.c b/samples/microkernel/benchmark/latency_measure/src/main.c
index b7d995015..d3f59bf5e 100644
--- a/samples/microkernel/benchmark/latency_measure/src/main.c
+++ b/samples/microkernel/benchmark/latency_measure/src/main.c
@@ -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 */
diff --git a/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task.c b/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task.c
index 83b83bf4e..4ebb8974c 100644
--- a/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task.c
+++ b/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task.c
@@ -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");
+ PRINT_FORMAT(" Flag variable has not changed. FAILED\n");
}
- else
- timestamp = TIME_STAMP_DELTA_GET(timestamp);
+ else {
+ timestamp = TIME_STAMP_DELTA_GET(timestamp);
}
+}
/*******************************************************************************
*
@@ -99,16 +100,16 @@ static void makeInt(void)
*/
int microIntToTask(void)
- {
+{
PRINT_FORMAT(" 1- Measure time to switch from ISR to back to"
- " interrupted task");
+ " interrupted task");
TICK_SYNCH();
makeInt();
if (flagVar == 1) {
- PRINT_FORMAT(" switching time is %lu tcs = %lu nsec",
- timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
+ PRINT_FORMAT(" switching time is %lu tcs = %lu nsec",
+ timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
}
return 0;
- }
+}
#endif /* MICROKERNEL */
diff --git a/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task_evt.c b/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task_evt.c
index f988c370c..f704fdaf7 100644
--- a/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task_evt.c
+++ b/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task_evt.c
@@ -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,16 +98,16 @@ void microInt(void)
*/
int microIntToTaskEvt(void)
- {
+{
PRINT_FORMAT(" 2- Measure time from ISR to executing a different task"
- " (rescheduled)");
+ " (rescheduled)");
TICK_SYNCH();
task_sem_give(INTSEMA);
task_event_recv_wait(EVENT0);
timestamp = TIME_STAMP_DELTA_GET(timestamp);
PRINT_FORMAT(" switch time is %lu tcs = %lu nsec",
- timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
+ timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
return 0;
- }
+}
#endif /* CONFIG_MICROKERNEL */
diff --git a/samples/microkernel/benchmark/latency_measure/src/micro_sema_lock_release.c b/samples/microkernel/benchmark/latency_measure/src/micro_sema_lock_release.c
index 06a572632..18f9ba51d 100644
--- a/samples/microkernel/benchmark/latency_measure/src/micro_sema_lock_release.c
+++ b/samples/microkernel/benchmark/latency_measure/src/micro_sema_lock_release.c
@@ -66,44 +66,44 @@ static uint32_t timestamp;
*/
int microSemaLockUnlock(void)
- {
+{
int i;
PRINT_FORMAT(" 3- Measure average time to signal a sema then test"
- " that sema");
+ " that sema");
bench_test_start();
timestamp = TIME_STAMP_DELTA_GET(0);
for (i = SEMASTART; i <= SEMAEND; i++) {
- task_sem_give(i);
+ task_sem_give(i);
}
timestamp = TIME_STAMP_DELTA_GET(timestamp);
if (bench_test_end() == 0) {
- PRINT_FORMAT(" Average semaphore signal time %lu tcs = %lu nsec",
- timestamp / N_TEST_SEMA,
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_SEMA));
+ PRINT_FORMAT(" Average semaphore signal time %lu tcs = %lu nsec",
+ timestamp / N_TEST_SEMA,
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_SEMA));
}
else {
- errorCount++;
- PRINT_OVERFLOW_ERROR();
+ errorCount++;
+ PRINT_OVERFLOW_ERROR();
}
bench_test_start();
timestamp = TIME_STAMP_DELTA_GET(0);
for (i = SEMASTART; i <= SEMAEND; i++) {
- task_sem_take_wait(i);
+ task_sem_take_wait(i);
}
timestamp = TIME_STAMP_DELTA_GET(timestamp);
if (bench_test_end() == 0) {
- PRINT_FORMAT(" Average semaphore test time %lu tcs = %lu nsec",
- timestamp / N_TEST_SEMA,
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_SEMA));
+ PRINT_FORMAT(" Average semaphore test time %lu tcs = %lu nsec",
+ timestamp / N_TEST_SEMA,
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_SEMA));
}
else {
- errorCount++;
- PRINT_OVERFLOW_ERROR();
+ errorCount++;
+ PRINT_OVERFLOW_ERROR();
}
return 0;
- }
+}
/*******************************************************************************
*
@@ -118,28 +118,28 @@ int microSemaLockUnlock(void)
*/
int microMutexLockUnlock(void)
- {
+{
int i;
PRINT_FORMAT(" 4- Measure average time to lock a mutex then"
- " unlock that mutex");
+ " unlock that mutex");
timestamp = TIME_STAMP_DELTA_GET(0);
for (i = 0; i < N_TEST_MUTEX; i++) {
- task_mutex_lock_wait(TEST_MUTEX);
+ task_mutex_lock_wait(TEST_MUTEX);
}
timestamp = TIME_STAMP_DELTA_GET(timestamp);
PRINT_FORMAT(" Average time to lock the mutex %lu tcs = %lu nsec",
- timestamp / N_TEST_MUTEX,
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_MUTEX));
+ timestamp / N_TEST_MUTEX,
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_MUTEX));
timestamp = TIME_STAMP_DELTA_GET(0);
for (i = 0; i <= N_TEST_MUTEX; i++) {
- task_mutex_unlock(TEST_MUTEX);
+ task_mutex_unlock(TEST_MUTEX);
}
timestamp = TIME_STAMP_DELTA_GET(timestamp);
PRINT_FORMAT(" Average time to unlock the mutex %lu tcs = %lu nsec",
- timestamp / N_TEST_MUTEX,
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_MUTEX));
+ timestamp / N_TEST_MUTEX,
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_MUTEX));
return 0;
- }
+}
#endif /* CONFIG_MICROKERNEL */
diff --git a/samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c b/samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c
index 15ee63d3b..88f37504b 100644
--- a/samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c
+++ b/samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c
@@ -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++;
- }
+ task_yield();
+ helper_task_iterations++;
}
+}
/*******************************************************************************
*
@@ -79,60 +79,60 @@ void yieldingTask(void)
*/
void microTaskSwitchYield(void)
- {
+{
uint32_t iterations = 0;
int32_t delta;
uint32_t timestamp;
PRINT_FORMAT(" 5- Measure average context switch time between tasks using"
- " (task_yield)");
+ " (task_yield)");
bench_test_start();
- /* launch helper task of the same priority than this routine */
+ /* launch helper task of the same priority than this routine */
task_start(YIELDTASK);
- /* get initial timestamp */
+ /* get initial timestamp */
timestamp = TIME_STAMP_DELTA_GET(0);
- /* loop until either helper or this routine reaches number of yields */
+ /* loop until either helper or this routine reaches number of yields */
while (iterations < NB_OF_YIELD && helper_task_iterations < NB_OF_YIELD) {
- task_yield();
- iterations++;
+ task_yield();
+ iterations++;
}
- /* get the number of cycles it took to do the test */
+ /* get the number of cycles it took to do the test */
timestamp = TIME_STAMP_DELTA_GET(timestamp);
- /* Ensure both helper and this routine were context switching back & forth.
- * For execution to reach the line below, either this routine or helper
- * routine reached NB_OF_YIELD. The other loop must be at most one
- * iteration away from reaching NB_OF_YIELD if execute was switching back
- * and forth.
- */
+ /* Ensure both helper and this routine were context switching back & forth.
+ * For execution to reach the line below, either this routine or helper
+ * routine reached NB_OF_YIELD. The other loop must be at most one
+ * iteration away from reaching NB_OF_YIELD if execute was switching back
+ * and forth.
+ */
delta = iterations - helper_task_iterations;
if (bench_test_end() < 0) {
- errorCount++;
- PRINT_OVERFLOW_ERROR();
+ errorCount++;
+ PRINT_OVERFLOW_ERROR();
}
else if (abs(delta) > 1) {
- /* expecting even alternating context switch, seems one routine
- * called yield without the other having chance to execute
- */
- errorCount++;
- PRINT_FORMAT(" Error, iteration:%lu, helper iteration:%lu",
- iterations, helper_task_iterations);
+ /* expecting even alternating context switch, seems one routine
+ * called yield without the other having chance to execute
+ */
+ errorCount++;
+ PRINT_FORMAT(" Error, iteration:%lu, helper iteration:%lu",
+ iterations, helper_task_iterations);
}
else {
- /* task_yield is called (iterations + helper_task_iterations)
- * times in total.
- */
- PRINT_FORMAT(" Average task context switch using "
- "yield %lu tcs = %lu nsec",
- timestamp / (iterations + helper_task_iterations),
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp,
- (iterations + helper_task_iterations)));
- }
+ /* task_yield is called (iterations + helper_task_iterations)
+ * times in total.
+ */
+ PRINT_FORMAT(" Average task context switch using "
+ "yield %lu tcs = %lu nsec",
+ timestamp / (iterations + helper_task_iterations),
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp,
+ (iterations + helper_task_iterations)));
}
+}
#endif
diff --git a/samples/microkernel/benchmark/latency_measure/src/nano_ctx_switch.c b/samples/microkernel/benchmark/latency_measure/src/nano_ctx_switch.c
index 736d6a05d..9e349e877 100644
--- a/samples/microkernel/benchmark/latency_measure/src/nano_ctx_switch.c
+++ b/samples/microkernel/benchmark/latency_measure/src/nano_ctx_switch.c
@@ -77,16 +77,16 @@ static volatile int ctxSwitchBalancer = 0;
*/
static void fiberOne(void)
- {
+{
nano_fiber_sem_take_wait(&syncSema);
timestamp = TIME_STAMP_DELTA_GET(0);
while (ctxSwitchCounter < NCTXSWITCH) {
- fiber_yield();
- ctxSwitchCounter++;
- ctxSwitchBalancer--;
+ fiber_yield();
+ ctxSwitchCounter++;
+ 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++;
- }
+ 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;
@@ -128,19 +128,20 @@ int nanoCtxSwitch(void)
bench_test_start();
task_fiber_start(&fiberOneStack[0], STACKSIZE,
- (nano_fiber_entry_t) fiberOne, 0, 0, 6, 0);
+ (nano_fiber_entry_t) fiberOne, 0, 0, 6, 0);
task_fiber_start(&fiberTwoStack[0], STACKSIZE,
- (nano_fiber_entry_t) fiberTwo, 0, 0, 6, 0);
+ (nano_fiber_entry_t) fiberTwo, 0, 0, 6, 0);
if (ctxSwitchBalancer > 3 || ctxSwitchBalancer < -3) {
- PRINT_FORMAT(" Balance is %d. FAILED", ctxSwitchBalancer);
+ PRINT_FORMAT(" Balance is %d. FAILED", ctxSwitchBalancer);
}
else if (bench_test_end() != 0) {
- errorCount++;
- PRINT_OVERFLOW_ERROR();
+ errorCount++;
+ PRINT_OVERFLOW_ERROR();
}
- 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;
+ 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;
+}
diff --git a/samples/microkernel/benchmark/latency_measure/src/nano_int.c b/samples/microkernel/benchmark/latency_measure/src/nano_int.c
index ff0c7158a..2d6322784 100644
--- a/samples/microkernel/benchmark/latency_measure/src/nano_int.c
+++ b/samples/microkernel/benchmark/latency_measure/src/nano_int.c
@@ -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,12 +95,12 @@ 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,
- (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0);
+ (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0);
PRINT_FORMAT(" switching time is %lu tcs = %lu nsec",
- timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
+ timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
return 0;
- }
+}
diff --git a/samples/microkernel/benchmark/latency_measure/src/nano_int_lock_unlock.c b/samples/microkernel/benchmark/latency_measure/src/nano_int_lock_unlock.c
index bc417bf4f..0ad1860a8 100644
--- a/samples/microkernel/benchmark/latency_measure/src/nano_int_lock_unlock.c
+++ b/samples/microkernel/benchmark/latency_measure/src/nano_int_lock_unlock.c
@@ -59,48 +59,48 @@ static uint32_t timestamp = 0;
*/
int nanoIntLockUnlock(void)
- {
+{
int i;
unsigned int mask;
PRINT_FORMAT(" 5- Measure average time to lock then unlock interrupts");
PRINT_FORMAT(" 5.1- When each lock and unlock is executed as a function"
- " call");
+ " call");
bench_test_start();
timestamp = TIME_STAMP_DELTA_GET(0);
for (i = 0; i < NTESTS; i++) {
- mask = irq_lock();
- irq_unlock(mask);
+ mask = irq_lock();
+ irq_unlock(mask);
}
timestamp = TIME_STAMP_DELTA_GET(timestamp);
if (bench_test_end() == 0) {
- PRINT_FORMAT(" Average time for lock then unlock "
- "is %lu tcs = %lu nsec",
- timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, NTESTS));
+ PRINT_FORMAT(" Average time for lock then unlock "
+ "is %lu tcs = %lu nsec",
+ timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, NTESTS));
}
else {
- errorCount++;
- PRINT_OVERFLOW_ERROR();
+ errorCount++;
+ PRINT_OVERFLOW_ERROR();
}
PRINT_FORMAT(" ");
PRINT_FORMAT(" 5.2- When each lock and unlock is executed as inline"
- " function call");
+ " function call");
bench_test_start();
timestamp = TIME_STAMP_DELTA_GET(0);
for (i = 0; i < NTESTS; i++) {
- mask = irq_lock_inline();
- irq_unlock_inline(mask);
+ mask = irq_lock_inline();
+ irq_unlock_inline(mask);
}
timestamp = TIME_STAMP_DELTA_GET(timestamp);
if (bench_test_end() == 0) {
- PRINT_FORMAT(" Average time for lock then unlock "
- "is %lu tcs = %lu nsec",
- timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, NTESTS));
+ PRINT_FORMAT(" Average time for lock then unlock "
+ "is %lu tcs = %lu nsec",
+ timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, NTESTS));
}
else {
- errorCount++;
- PRINT_OVERFLOW_ERROR();
+ errorCount++;
+ PRINT_OVERFLOW_ERROR();
}
return 0;
- }
+}
diff --git a/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber.c b/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber.c
index 12f61784c..67dd7c9a3 100644
--- a/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber.c
+++ b/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber.c
@@ -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");
+ PRINT_FORMAT(" Flag variable has not changed. FAILED");
}
- else
- timestamp = TIME_STAMP_DELTA_GET(timestamp);
+ else {
+ timestamp = TIME_STAMP_DELTA_GET(timestamp);
}
+}
/*******************************************************************************
*
@@ -103,15 +104,15 @@ static void fiberInt(void)
*/
int nanoIntToFiber(void)
- {
+{
PRINT_FORMAT(" 2- Measure time to switch from ISR back to interrupted"
- " fiber");
+ " fiber");
TICK_SYNCH();
task_fiber_start(&fiberStack[0], STACKSIZE,
- (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0);
+ (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0);
if (flagVar == 1) {
- PRINT_FORMAT(" switching time is %lu tcs = %lu nsec",
- timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
+ PRINT_FORMAT(" switching time is %lu tcs = %lu nsec",
+ timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
}
return 0;
- }
+}
diff --git a/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber_sem.c b/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber_sem.c
index 8aecaa4d9..c0d59cf1d 100644
--- a/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber_sem.c
+++ b/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber_sem.c
@@ -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,18 +127,18 @@ static void fiberWaiter(void)
*/
int nanoIntToFiberSem(void)
- {
+{
PRINT_FORMAT(" 3- Measure time from ISR to executing a different fiber"
- " (rescheduled)");
+ " (rescheduled)");
nano_sem_init(&testSema);
TICK_SYNCH();
task_fiber_start(&waiterStack[0], STACKSIZE,
- (nano_fiber_entry_t) fiberWaiter, 0, 0, 5, 0);
+ (nano_fiber_entry_t) fiberWaiter, 0, 0, 5, 0);
task_fiber_start(&intStack[0], STACKSIZE,
- (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0);
+ (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0);
PRINT_FORMAT(" switching time is %lu tcs = %lu nsec",
- timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
+ timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
return 0;
- }
+}
diff --git a/samples/microkernel/benchmark/latency_measure/src/timestamp.h b/samples/microkernel/benchmark/latency_measure/src/timestamp.h
index 51b553a28..d43ba703f 100644
--- a/samples/microkernel/benchmark/latency_measure/src/timestamp.h
+++ b/samples/microkernel/benchmark/latency_measure/src/timestamp.h
@@ -85,29 +85,30 @@ 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 */
+ /* serialize so OS_GET_TIME() is not reordered */
timestamp_serialize();
t = OS_GET_TIME();
uint32_t res = (t >= ts)? (t - ts): (ULONG_MAX - ts + t);
- if (ts > 0)
- res -= tm_off;
- return res;
+ if (ts > 0) {
+ res -= tm_off;
}
+ 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 */
+ /* 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)
- return -1;
- else
- return 0;
+ if (tCheck > BENCH_MAX_TICKS) {
+ return -1;
}
+ 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))
- return -1;
- else
- return 0;
+{
+ if (tCheck >= (UINT_MAX / sys_clock_hw_cycles_per_tick)) {
+ return -1;
}
+ return 0;
+}
#endif /* CONFIG_NANOKERNEL || CONFIG_MICROKERNEL */
#endif /* _TIMESTAMP_H_ */
diff --git a/samples/microkernel/benchmark/latency_measure/src/utils.c b/samples/microkernel/benchmark/latency_measure/src/utils.c
index 2a9df77ac..920ae2aa6 100644
--- a/samples/microkernel/benchmark/latency_measure/src/utils.c
+++ b/samples/microkernel/benchmark/latency_measure/src/utils.c
@@ -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);
- }
+}
diff --git a/samples/microkernel/benchmark/latency_measure/src/utils.h b/samples/microkernel/benchmark/latency_measure/src/utils.h
index 7f5cfd62e..6703c12fe 100644
--- a/samples/microkernel/benchmark/latency_measure/src/utils.h
+++ b/samples/microkernel/benchmark/latency_measure/src/utils.h
@@ -51,13 +51,11 @@ extern int errorCount;
#define PRINT(fmt, ...) printk(fmt, ##__VA_ARGS__)
#define PRINTF(fmt, ...) printf(fmt, ##__VA_ARGS__)
-#define PRINT_FORMAT(fmt, ...) \
- do \
- { \
+#define PRINT_FORMAT(fmt, ...) \
+ do { \
snprintf(tmpString, TMP_STRING_SIZE, fmt, ##__VA_ARGS__); \
PRINTF("|%-77s|\n", tmpString); \
- } \
- while (0)
+ } while (0)
/*******************************************************************************
*
@@ -69,33 +67,34 @@ extern int errorCount;
*/
static inline void printDashLine(void)
- {
+{
PRINTF("|-----------------------------------------------------------------"
- "------------|\n");
- }
+ "------------|\n");
+}
-#define PRINT_END_BANNER() \
+#define PRINT_END_BANNER() \
PRINTF("| E N D "\
- " |\n"); \
+ " |\n"); \
printDashLine();
-#define PRINT_NANO_BANNER() \
+#define PRINT_NANO_BANNER() \
printDashLine(); \
PRINTF("| VxMicro Nanokernel Latency Benchmark "\
- " |\n"); \
+ " |\n"); \
printDashLine();
-#define PRINT_MICRO_BANNER() \
+#define PRINT_MICRO_BANNER() \
printDashLine(); \
PRINTF("| VxMicro Microkernel Latency Benchmark "\
- " |\n"); \
+ " |\n"); \
printDashLine();
-#define PRINT_TIME_BANNER() \
- PRINT_FORMAT(" tcs = timer clock cycles: 1 tcs is %lu nsec", SYS_CLOCK_HW_CYCLES_TO_NS(1));\
+#define PRINT_TIME_BANNER() \
+ PRINT_FORMAT(" tcs = timer clock cycles: 1 tcs is %lu nsec", \
+ SYS_CLOCK_HW_CYCLES_TO_NS(1)); \
printDashLine();
-#define PRINT_OVERFLOW_ERROR() \
+#define PRINT_OVERFLOW_ERROR() \
PRINT_FORMAT(" Error: tick occured")
#else
diff --git a/samples/microkernel/test/test_critical/src/critical.c b/samples/microkernel/test/test_critical/src/critical.c
index eee77f0df..967da786f 100644
--- a/samples/microkernel/test/test_critical/src/critical.c
+++ b/samples/microkernel/test/test_critical/src/critical.c
@@ -87,7 +87,7 @@ uint32_t criticalLoop(uint32_t count)
while (task_tick_get_32() < ticks + NUM_TICKS) {
task_offload_to_fiber(criticalRtn, &criticalVar);
count++;
- }
+ }
return count;
}
@@ -138,18 +138,18 @@ void RegressionTask(void)
nCalls = criticalLoop(nCalls);
- /* Wait for AlternateTask() to complete */
+ /* Wait for AlternateTask() to complete */
status = task_sem_take_wait_timeout(REGRESS_SEM, TEST_TIMEOUT);
if (status != RC_OK) {
TC_ERROR("Timed out waiting for REGRESS_SEM\n");
goto errorReturn;
- }
+ }
if (criticalVar != nCalls + altTaskIterations) {
TC_ERROR("Unexpected value for <criticalVar>. Expected %d, got %d\n",
- nCalls + altTaskIterations, criticalVar);
+ nCalls + altTaskIterations, criticalVar);
goto errorReturn;
- }
+ }
TC_PRINT("Obtained expected <criticalVar> value of %u\n", criticalVar);
TC_PRINT("Enabling time slicing ...\n");
@@ -160,18 +160,18 @@ void RegressionTask(void)
nCalls = criticalLoop(nCalls);
- /* Wait for AlternateTask() to finish */
+ /* Wait for AlternateTask() to finish */
status = task_sem_take_wait_timeout(REGRESS_SEM, TEST_TIMEOUT);
if (status != RC_OK) {
TC_ERROR("Timed out waiting for REGRESS_SEM\n");
goto errorReturn;
- }
+ }
if (criticalVar != nCalls + altTaskIterations) {
TC_ERROR("Unexpected value for <criticalVar>. Expected %d, got %d\n",
- nCalls + altTaskIterations, criticalVar);
+ nCalls + altTaskIterations, criticalVar);
goto errorReturn;
- }
+ }
TC_PRINT("Obtained expected <criticalVar> value of %u\n", criticalVar);
TC_END_RESULT(TC_PASS);
diff --git a/samples/microkernel/test/test_events/src/test_fiber.c b/samples/microkernel/test/test_events/src/test_fiber.c
index bcf444b80..61db5233e 100644
--- a/samples/microkernel/test/test_events/src/test_fiber.c
+++ b/samples/microkernel/test/test_events/src/test_fiber.c
@@ -64,27 +64,27 @@ static char fiberStack[FIBER_STACK_SIZE]; /* test fiber stack size */
* RETURNS: N/A
*/
static void testFiberEntry(void)
- {
- /* signal event for eventWaitTest() */
- /* single test */
+{
+ /* signal event for eventWaitTest() */
+ /* single test */
nano_fiber_sem_take_wait(&fiberSem);
fiber_event_send(EVENT_ID);
- /* test in cycle */
+ /* test in cycle */
nano_fiber_sem_take_wait(&fiberSem);
fiber_event_send(EVENT_ID);
- /* signal event for eventTimeoutTest() */
+ /* signal event for eventTimeoutTest() */
nano_fiber_sem_take_wait(&fiberSem);
fiber_event_send(EVENT_ID);
- /*
- * Signal two events for fiberEventSignalTest ().
- * It has to detect only one
- */
+ /*
+ * Signal two events for fiberEventSignalTest ().
+ * It has to detect only one
+ */
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);
- }
+ 0, 0, FIBER_PRIORITY, 0);
+}
diff --git a/samples/microkernel/test/test_fp_sharing/src/main.c b/samples/microkernel/test/test_fp_sharing/src/main.c
index d4612ec1e..2ab4ffc11 100644
--- a/samples/microkernel/test/test_fp_sharing/src/main.c
+++ b/samples/microkernel/test/test_fp_sharing/src/main.c
@@ -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 */
diff --git a/samples/microkernel/test/test_libs/src/libraries.c b/samples/microkernel/test/test_libs/src/libraries.c
index 574e9432d..361a0fde0 100644
--- a/samples/microkernel/test/test_libs/src/libraries.c
+++ b/samples/microkernel/test/test_libs/src/libraries.c
@@ -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;
}
@@ -366,7 +366,7 @@ int stringTest(void)
TC_PRINT("Testing string.h library ...\n");
if (memset_test() || strlen_test() || strcmp_test() || strcpy_test() ||
- strncpy_test() || strncmp_test() || strchr_test()) {
+ strncpy_test() || strncmp_test() || strchr_test()) {
return TC_FAIL;
}
@@ -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;
}
diff --git a/samples/microkernel/test/test_mail/src/mail.c b/samples/microkernel/test/test_mail/src/mail.c
index d6457d8ab..320f9365e 100644
--- a/samples/microkernel/test/test_mail/src/mail.c
+++ b/samples/microkernel/test/test_mail/src/mail.c
@@ -65,10 +65,10 @@ are not (yet) tested include:
/* defines */
-#define MSGSIZE 16 /* Standard message data size */
-#define XFER_PRIO 5 /* standard message transfer priority */
-#define MSG_INFO1 1234 /* Message info test value */
-#define MSG_INFO2 666 /* Message info test value */
+#define MSGSIZE 16 /* Standard message data size */
+#define XFER_PRIO 5 /* standard message transfer priority */
+#define MSG_INFO1 1234 /* Message info test value */
+#define MSG_INFO2 666 /* Message info test value */
/* locals */
@@ -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;
diff --git a/samples/microkernel/test/test_mail/src/main.c b/samples/microkernel/test/test_mail/src/main.c
index 639acdf11..b3e1ce99a 100644
--- a/samples/microkernel/test/test_mail/src/main.c
+++ b/samples/microkernel/test/test_mail/src/main.c
@@ -66,15 +66,15 @@ static ksem_t resultSems[] = { SEM_TASKDONE, SEM_TASKFAIL, ENDLIST };
/* globals */
ktask_t msgSenderTask = MSGSENDERTASK;
-ktask_t msgRcvrTask = MSGRCVRTASK;
+ktask_t msgRcvrTask = MSGRCVRTASK;
-ksem_t semSync1 = SEM_SYNC1;
-ksem_t semSync2 = SEM_SYNC2;
+ksem_t semSync1 = SEM_SYNC1;
+ksem_t semSync2 = SEM_SYNC2;
-kmbox_t myMbox = MYMBOX;
-kmbox_t noRcvrMbox = NORCVRMBOX;
+kmbox_t myMbox = MYMBOX;
+kmbox_t noRcvrMbox = NORCVRMBOX;
-kmemory_pool_t testPool = TESTPOOL;
+kmemory_pool_t testPool = TESTPOOL;
kmemory_pool_t smallBlkszPool = SMALLBLKSZPOOL;
/*******************************************************************************
@@ -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,31 +122,31 @@ void MsgRcvrTaskEntry(void)
*/
void MonitorTaskEntry(void)
- {
+{
ksem_t result;
int tasksDone;
PRINT_DATA("Starting mailbox tests\n");
PRINT_LINE;
- /*
- * the various test tasks start executing automatically;
- * wait for all tasks to complete or a failure to occur,
- * then issue the appropriate test case summary message
- */
+ /*
+ * the various test tasks start executing automatically;
+ * wait for all tasks to complete or a failure to occur,
+ * then issue the appropriate test case summary message
+ */
for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) {
- result = task_sem_group_take_wait_timeout(resultSems, TIMEOUT);
- if (result != resultSems[TC_PASS]) {
- if (result != resultSems[TC_FAIL]) {
- TC_ERROR("Monitor task timed out\n");
+ result = task_sem_group_take_wait_timeout(resultSems, TIMEOUT);
+ if (result != resultSems[TC_PASS]) {
+ if (result != resultSems[TC_FAIL]) {
+ TC_ERROR("Monitor task timed out\n");
+ }
+ TC_END_RESULT(TC_FAIL);
+ TC_END_REPORT(TC_FAIL);
+ return;
}
- TC_END_RESULT(TC_FAIL);
- TC_END_REPORT(TC_FAIL);
- return;
- }
}
TC_END_RESULT(TC_PASS);
TC_END_REPORT(TC_PASS);
- }
+}
diff --git a/samples/microkernel/test/test_mutex/src/mutex.c b/samples/microkernel/test/test_mutex/src/mutex.c
index 7bd274cd0..dea0ca38c 100644
--- a/samples/microkernel/test/test_mutex/src/mutex.c
+++ b/samples/microkernel/test/test_mutex/src/mutex.c
@@ -89,19 +89,19 @@ static int tcRC = TC_PASS; /* test case return code */
*/
void Task10(void)
- {
+{
int rv;
task_sleep(3 * ONE_SECOND + HALF_SECOND);
- /* Wait and boost owner priority to 10 */
+ /* Wait and boost owner priority to 10 */
rv = task_mutex_lock_wait_timeout(Mutex4, ONE_SECOND);
if (rv != RC_TIME) {
tcRC = TC_FAIL;
TC_ERROR("Failed to timeout on mutex 0x%x\n", Mutex4);
return;
- }
- } /* Task10 */
+ }
+} /* Task10 */
/*******************************************************************************
@@ -112,29 +112,29 @@ void Task10(void)
*/
void Task15(void)
- {
+{
int rv;
task_sleep(3 * ONE_SECOND + 3 * FOURTH_SECOND);
- /*
- * Wait for the mutex. There is a higher priority level task waiting
- * on the mutex, so request will not immediately contribute to raising
- * the priority of the owning task (RegressionTask). When Task10 times out
- * this task will become the highest priority waiting task. The priority
- * of the owning task (RegressionTask) will not drop back to 20, but will
- * instead drop to 15.
- */
+ /*
+ * Wait for the mutex. There is a higher priority level task waiting
+ * on the mutex, so request will not immediately contribute to raising
+ * the priority of the owning task (RegressionTask). When Task10 times out
+ * this task will become the highest priority waiting task. The priority
+ * of the owning task (RegressionTask) will not drop back to 20, but will
+ * instead drop to 15.
+ */
rv = task_mutex_lock_wait_timeout(Mutex4, 2 * ONE_SECOND);
if (rv != RC_OK) {
tcRC = TC_FAIL;
TC_ERROR("Failed to take mutex 0x%x\n", Mutex4);
return;
- }
+ }
task_mutex_unlock(Mutex4);
- }
+}
/*******************************************************************************
*
@@ -144,27 +144,27 @@ void Task15(void)
*/
void Task20(void)
- {
+{
int rv;
task_sleep(2 * ONE_SECOND + HALF_SECOND);
- /*
- * Wait and boost owner priority to 20. While waiting, another task of
- * a very low priority level will also wait for the mutex. Task20 is
- * expected to time out around the 5.5 second mark. When it times out,
- * Task45 will become the only waiting task for this mutex and the
- * priority of the owning task RegressionTask will drop to 25.
- */
+ /*
+ * Wait and boost owner priority to 20. While waiting, another task of
+ * a very low priority level will also wait for the mutex. Task20 is
+ * expected to time out around the 5.5 second mark. When it times out,
+ * Task45 will become the only waiting task for this mutex and the
+ * priority of the owning task RegressionTask will drop to 25.
+ */
rv = task_mutex_lock_wait_timeout(Mutex3, 3 * ONE_SECOND);
if (rv != RC_TIME) {
tcRC = TC_FAIL;
TC_ERROR("Failed to timeout on mutex 0x%x\n", Mutex3);
return;
- }
+ }
- } /* Task20 */
+} /* Task20 */
/*******************************************************************************
*
@@ -174,7 +174,7 @@ void Task20(void)
*/
void Task25(void)
- {
+{
int rv;
task_sleep(ONE_SECOND + HALF_SECOND);
@@ -184,10 +184,10 @@ void Task25(void)
tcRC = TC_FAIL;
TC_ERROR("Failed to take mutex 0x%x\n", Mutex2);
return;
- }
+ }
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 */
@@ -208,17 +208,17 @@ void Task30(void)
tcRC = TC_FAIL;
TC_ERROR("Failed to NOT take locked mutex 0x%x\n", Mutex1);
return;
- }
+ }
rv = task_mutex_lock_wait(Mutex1); /* Wait and boost owner priority to 30 */
if (rv != RC_OK) {
tcRC = TC_FAIL;
TC_ERROR("Failed to take mutex 0x%x\n", Mutex1);
return;
- }
+ }
task_mutex_unlock(Mutex1);
- }
+}
/*******************************************************************************
*
@@ -228,7 +228,7 @@ void Task30(void)
*/
void Task45(void)
- {
+{
int rv;
task_sleep(3 * ONE_SECOND + HALF_SECOND);
@@ -237,9 +237,9 @@ void Task45(void)
tcRC = TC_FAIL;
TC_ERROR("Failed to take mutex 0x%x\n", Mutex2);
return;
- }
- task_mutex_unlock(Mutex3);
}
+ 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};
@@ -263,41 +263,41 @@ void RegressionTask(void)
PRINT_LINE;
- /*
- * 1st iteration: Take Mutex1; Task30 waits on Mutex1
- * 2nd iteration: Take Mutex2: Task25 waits on Mutex2
- * 3rd iteration: Take Mutex3; Task20 waits on Mutex3
- * 4th iteration: Take Mutex4; Task10 waits on Mutex4
- */
+ /*
+ * 1st iteration: Take Mutex1; Task30 waits on Mutex1
+ * 2nd iteration: Take Mutex2: Task25 waits on Mutex2
+ * 3rd iteration: Take Mutex3; Task20 waits on Mutex3
+ * 4th iteration: Take Mutex4; Task10 waits on Mutex4
+ */
for (i = 0; i < 4; i++) {
rv = task_mutex_lock(mutexes[i]);
if (rv != RC_OK) {
- TC_ERROR("Failed to lock mutex 0x%x\n", mutexes[i]);
- tcRC = TC_FAIL;
- goto errorReturn;
- }
+ TC_ERROR("Failed to lock mutex 0x%x\n", mutexes[i]);
+ tcRC = TC_FAIL;
+ goto errorReturn;
+ }
task_sleep(ONE_SECOND);
rv = task_priority_get();
if (rv != priority[i]) {
- TC_ERROR("Expected priority %d, not %d\n", priority[i], rv);
- tcRC = TC_FAIL;
- goto errorReturn;
- }
+ TC_ERROR("Expected priority %d, not %d\n", priority[i], rv);
+ tcRC = TC_FAIL;
+ goto errorReturn;
+ }
if (tcRC != TC_PASS) { /* Catch any errors from other tasks */
- goto errorReturn;
- }
+ goto errorReturn;
}
+ }
- /* ~ 4 seconds have passed */
+ /* ~ 4 seconds have passed */
TC_PRINT("Done LOCKING! Current priority = %d\n", task_priority_get());
task_sleep(ONE_SECOND); /* Task10 should time out */
- /* ~ 5 seconds have passed */
+ /* ~ 5 seconds have passed */
rv = task_priority_get();
if (rv != 15) {
@@ -305,7 +305,7 @@ void RegressionTask(void)
TC_ERROR("Expected priority %d, not %d\n", 15, rv);
tcRC = TC_FAIL;
goto errorReturn;
- }
+ }
task_mutex_unlock(Mutex4);
rv = task_priority_get();
@@ -314,40 +314,40 @@ void RegressionTask(void)
TC_ERROR("Expected priority %d, not %d\n", 20, rv);
tcRC = TC_FAIL;
goto errorReturn;
- }
+ }
task_sleep(ONE_SECOND); /* Task20 should time out */
- /* ~ 6 seconds have passed */
+ /* ~ 6 seconds have passed */
for (i = 0; i < 3; i++) {
rv = task_priority_get();
if (rv != dropPri[i]) {
- TC_ERROR("Expected priority %d, not %d\n", dropPri[i], rv);
- tcRC = TC_FAIL;
- goto errorReturn;
- }
+ TC_ERROR("Expected priority %d, not %d\n", dropPri[i], rv);
+ tcRC = TC_FAIL;
+ goto errorReturn;
+ }
task_mutex_unlock(giveMutex[i]);
if (tcRC != TC_PASS) {
- goto errorReturn;
- }
+ goto errorReturn;
}
+ }
rv = task_priority_get();
if (rv != 40) {
TC_ERROR("Expected priority %d, not %d\n", 40, rv);
tcRC = TC_FAIL;
goto errorReturn;
- }
+ }
task_sleep(ONE_SECOND); /* Give Task45 time to run */
if (tcRC != TC_PASS) {
goto errorReturn;
- }
+ }
errorReturn:
TC_END_RESULT(tcRC);
TC_END_REPORT(tcRC);
- } /* RegressionTask */
+} /* RegressionTask */
diff --git a/samples/microkernel/test/test_pipe/src/main.c b/samples/microkernel/test/test_pipe/src/main.c
index f52b32ee8..ce37a2cac 100644
--- a/samples/microkernel/test/test_pipe/src/main.c
+++ b/samples/microkernel/test/test_pipe/src/main.c
@@ -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,31 +116,31 @@ void AlternateTaskEntry(void)
*/
void MonitorTaskEntry(void)
- {
+{
ksem_t result;
int tasksDone;
PRINT_DATA("Starting pipe tests\n");
PRINT_LINE;
- /*
- * the various test tasks start executing automatically;
- * wait for all tasks to complete or a failure to occur,
- * then issue the appropriate test case summary message
- */
+ /*
+ * the various test tasks start executing automatically;
+ * wait for all tasks to complete or a failure to occur,
+ * then issue the appropriate test case summary message
+ */
for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) {
- result = task_sem_group_take_wait_timeout(resultSems, TIMEOUT);
- if (result != resultSems[TC_PASS]) {
- if (result != resultSems[TC_FAIL]) {
- TC_ERROR("Monitor task timed out\n");
+ result = task_sem_group_take_wait_timeout(resultSems, TIMEOUT);
+ if (result != resultSems[TC_PASS]) {
+ if (result != resultSems[TC_FAIL]) {
+ TC_ERROR("Monitor task timed out\n");
+ }
+ TC_END_RESULT(TC_FAIL);
+ TC_END_REPORT(TC_FAIL);
+ return;
}
- TC_END_RESULT(TC_FAIL);
- TC_END_REPORT(TC_FAIL);
- return;
- }
}
TC_END_RESULT(TC_PASS);
TC_END_REPORT(TC_PASS);
- }
+}
diff --git a/samples/microkernel/test/test_pipe/src/pipe.c b/samples/microkernel/test/test_pipe/src/pipe.c
index 871faf6df..256b208e8 100644
--- a/samples/microkernel/test/test_pipe/src/pipe.c
+++ b/samples/microkernel/test/test_pipe/src/pipe.c
@@ -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 */
@@ -180,7 +180,7 @@ void microObjectsInit(void)
for (i = 0; i < sizeof(rxBuffer); i++) {
txBuffer[i] = (char) i;
- }
+ }
}
/*******************************************************************************
@@ -199,9 +199,9 @@ int receiveBufferCheck(char *buffer, int size)
for (j = 0; j < size; j++) {
if (buffer[j] != (char) j) {
- return j;
- }
+ return j;
}
+ }
return size;
}
@@ -230,76 +230,76 @@ int pipePutHelperWork(SIZE_EXPECT *singleItems, int nSingles,
for (i = 0; i < nSingles; i++) {
(void)task_sem_take_wait(altSem);
for (j = 0; j < sizeof(rxBuffer); j++) {
- rxBuffer[j] = 0;
- }
+ rxBuffer[j] = 0;
+ }
rv = task_pipe_get(pipeId, rxBuffer, singleItems[i].size,
- &bytesReceived, singleItems[i].options);
+ &bytesReceived, singleItems[i].options);
if (rv != singleItems[i].rcode) {
- TC_ERROR("task_pipe_get(%d bytes) : Expected %d not %d.\n"
- " bytesReceived = %d\n",
- singleItems[i].size, singleItems[i].rcode,
- rv, bytesReceived);
- return TC_FAIL;
- }
+ TC_ERROR("task_pipe_get(%d bytes) : Expected %d not %d.\n"
+ " bytesReceived = %d\n",
+ singleItems[i].size, singleItems[i].rcode,
+ rv, bytesReceived);
+ return TC_FAIL;
+ }
if (bytesReceived != singleItems[i].sent) {
- TC_ERROR("task_pipe_get(%d) : "
- "Expected %d bytes to be received, not %d\n",
- singleItems[i].size, singleItems[i].sent, bytesReceived);
- return TC_FAIL;
- }
+ TC_ERROR("task_pipe_get(%d) : "
+ "Expected %d bytes to be received, not %d\n",
+ singleItems[i].size, singleItems[i].sent, bytesReceived);
+ return TC_FAIL;
+ }
index = receiveBufferCheck(rxBuffer, bytesReceived);
if (index != bytesReceived) {
- TC_ERROR("pipePutHelper: rxBuffer[%d] is %d, not %d\n",
- index, rxBuffer[index], index);
- return TC_FAIL;
- }
+ TC_ERROR("pipePutHelper: rxBuffer[%d] is %d, not %d\n",
+ index, rxBuffer[index], index);
+ return TC_FAIL;
+ }
task_sem_give(counterSem);
task_sem_give(regSem);
- }
+ }
- /*
- * Get items from the pipe. There should be more than one item
- * stored in it.
- */
+ /*
+ * Get items from the pipe. There should be more than one item
+ * stored in it.
+ */
(void)task_sem_take_wait(altSem);
for (i = 0; i < nMany; i++) {
for (j = 0; j < sizeof(rxBuffer); j++) {
- rxBuffer[j] = 0;
- }
+ rxBuffer[j] = 0;
+ }
rv = task_pipe_get(pipeId, rxBuffer, manyItems[i].size,
- &bytesReceived, manyItems[i].options);
+ &bytesReceived, manyItems[i].options);
if (rv != manyItems[i].rcode) {
- TC_ERROR("task_pipe_get(%d bytes) : Expected %d not %d.\n"
- " bytesReceived = %d, iteration: %d\n",
- manyItems[i].size, manyItems[i].rcode,
- rv, bytesReceived, i+1);
- return TC_FAIL;
- }
+ TC_ERROR("task_pipe_get(%d bytes) : Expected %d not %d.\n"
+ " bytesReceived = %d, iteration: %d\n",
+ manyItems[i].size, manyItems[i].rcode,
+ rv, bytesReceived, i+1);
+ return TC_FAIL;
+ }
if (bytesReceived != manyItems[i].sent) {
- TC_ERROR("task_pipe_get(%d) : "
- "Expected %d bytes to be received, not %d\n",
- manyItems[i].size, manyItems[i].sent, bytesReceived);
- return TC_FAIL;
- }
+ TC_ERROR("task_pipe_get(%d) : "
+ "Expected %d bytes to be received, not %d\n",
+ manyItems[i].size, manyItems[i].sent, bytesReceived);
+ return TC_FAIL;
+ }
index = receiveBufferCheck(rxBuffer, bytesReceived);
if (index != bytesReceived) {
- TC_ERROR("pipeGetHelper: rxBuffer[%d] is %d, not %d\n",
- index, rxBuffer[index], index);
- return TC_FAIL;
- }
+ TC_ERROR("pipeGetHelper: rxBuffer[%d] is %d, not %d\n",
+ index, rxBuffer[index], index);
+ return TC_FAIL;
+ }
task_sem_give(counterSem);
- }
+ }
task_sem_give(regSem); /* Wake the RegressionTask */
@@ -318,25 +318,25 @@ int pipePutHelper(void)
int rv; /* return value from pipePutHelperWork() */
rv = pipePutHelperWork(all_N, ARRAY_SIZE(all_N),
- many_all_N, ARRAY_SIZE(many_all_N));
+ many_all_N, ARRAY_SIZE(many_all_N));
if (rv != TC_PASS) {
TC_ERROR("Failed on all_N/many_all_N test\n");
return TC_FAIL;
- }
+ }
rv = pipePutHelperWork(one_to_N, ARRAY_SIZE(one_to_N),
- many_one_to_N, ARRAY_SIZE(many_one_to_N));
+ many_one_to_N, ARRAY_SIZE(many_one_to_N));
if (rv != TC_PASS) {
TC_ERROR("Failed on _1_TO_N/many_1_TO_N test\n");
return TC_FAIL;
- }
+ }
rv = pipePutHelperWork(zero_to_N, ARRAY_SIZE(zero_to_N),
- many_zero_to_N, ARRAY_SIZE(many_zero_to_N));
+ many_zero_to_N, ARRAY_SIZE(many_zero_to_N));
if (rv != TC_PASS) {
TC_ERROR("Failed on _0_TO_N/many_0_TO_N test\n");
return TC_FAIL;
- }
+ }
return TC_PASS;
}
@@ -367,65 +367,65 @@ int pipePutTestWork(SIZE_EXPECT *singleItems, int nSingles,
for (i = 0; i < nSingles; i++) {
rv = task_pipe_put(pipeId, txBuffer, singleItems[i].size,
- &bytesWritten, singleItems[i].options);
+ &bytesWritten, singleItems[i].options);
if (rv != singleItems[i].rcode) {
- TC_ERROR("task_pipe_put(%d) : Expected %d not %d.\n"
- " bytesWritten = %d, Iteration: %d\n",
- singleItems[i].size, singleItems[i].rcode,
- rv, bytesWritten, i + 1);
- return TC_FAIL;
- }
+ TC_ERROR("task_pipe_put(%d) : Expected %d not %d.\n"
+ " bytesWritten = %d, Iteration: %d\n",
+ singleItems[i].size, singleItems[i].rcode,
+ rv, bytesWritten, i + 1);
+ return TC_FAIL;
+ }
if (bytesWritten != singleItems[i].sent) {
- TC_ERROR("task_pipe_put(%d) : "
- "Expected %d bytes to be written, not %d\n",
- singleItems[i].size, singleItems[i].sent, bytesWritten);
- return TC_FAIL;
- }
+ TC_ERROR("task_pipe_put(%d) : "
+ "Expected %d bytes to be written, not %d\n",
+ singleItems[i].size, singleItems[i].sent, bytesWritten);
+ return TC_FAIL;
+ }
task_sem_give(altSem);
(void)task_sem_take_wait(regSem);
- nitem = task_sem_count_get(counterSem) - 1;
+ nitem = task_sem_count_get(counterSem) - 1;
if (nitem != i) {
- TC_ERROR("Expected item number is %d, not %d\n",
- i, nitem);
- return TC_FAIL;
- }
+ TC_ERROR("Expected item number is %d, not %d\n",
+ i, nitem);
+ return TC_FAIL;
}
+ }
- /* This time, more than one item will be in the pipe at a time */
+ /* This time, more than one item will be in the pipe at a time */
task_sem_reset(counterSem);
for (i = 0; i < nMany; i++) {
rv = task_pipe_put(pipeId, txBuffer, manyItems[i].size,
- &bytesWritten, manyItems[i].options);
+ &bytesWritten, manyItems[i].options);
if (rv != manyItems[i].rcode) {
- TC_ERROR("task_pipe_put(%d) : Expected %d not %d.\n"
- " bytesWritten = %d, iteration: %d\n",
- manyItems[i].size, manyItems[i].rcode,
- rv, bytesWritten, i + 1);
- return TC_FAIL;
- }
+ TC_ERROR("task_pipe_put(%d) : Expected %d not %d.\n"
+ " bytesWritten = %d, iteration: %d\n",
+ manyItems[i].size, manyItems[i].rcode,
+ rv, bytesWritten, i + 1);
+ return TC_FAIL;
+ }
if (bytesWritten != manyItems[i].sent) {
- TC_ERROR("task_pipe_put(%d) : "
- "Expected %d bytes to be written, not %d\n",
- manyItems[i].size, manyItems[i].sent, bytesWritten);
- return TC_FAIL;
- }
+ TC_ERROR("task_pipe_put(%d) : "
+ "Expected %d bytes to be written, not %d\n",
+ manyItems[i].size, manyItems[i].sent, bytesWritten);
+ return TC_FAIL;
}
+ }
task_sem_give(altSem); /* Wake the alternate task */
- /* wait for other task reading all the items from pipe */
+ /* wait for other task reading all the items from pipe */
(void)task_sem_take_wait(regSem);
if (task_sem_count_get(counterSem) != nMany) {
TC_ERROR("Expected number of items %d, not %d\n",
- nMany, task_sem_count_get(counterSem));
+ nMany, task_sem_count_get(counterSem));
return TC_FAIL;
- }
+ }
return TC_PASS;
}
@@ -444,25 +444,25 @@ int pipePutTest(void)
int rv; /* return value from pipePutTestWork() */
rv = pipePutTestWork(all_N, ARRAY_SIZE(all_N),
- many_all_N, ARRAY_SIZE(many_all_N));
+ many_all_N, ARRAY_SIZE(many_all_N));
if (rv != TC_PASS) {
TC_ERROR("Failed on _ALL_N/many_ALL_N test\n");
return TC_FAIL;
- }
+ }
rv = pipePutTestWork(one_to_N, ARRAY_SIZE(one_to_N),
- many_one_to_N, ARRAY_SIZE(many_one_to_N));
+ many_one_to_N, ARRAY_SIZE(many_one_to_N));
if (rv != TC_PASS) {
TC_ERROR("Failed on _1_TO_N/many_1_TO_N test\n");
return TC_FAIL;
- }
+ }
rv = pipePutTestWork(zero_to_N, ARRAY_SIZE(zero_to_N),
- many_zero_to_N, ARRAY_SIZE(many_zero_to_N));
+ many_zero_to_N, ARRAY_SIZE(many_zero_to_N));
if (rv != TC_PASS) {
TC_ERROR("Failed on _0_TO_N/many_0_TO_N test\n");
return TC_FAIL;
- }
+ }
return TC_PASS;
}
@@ -482,49 +482,49 @@ int pipePutWaitHelper(void)
(void)task_sem_take_wait(altSem); /* Wait until test is ready */
- /* 1. task_pipe_get_wait() will force a context switch to RegressionTask() */
+ /* 1. task_pipe_get_wait() will force a context switch to RegressionTask() */
rv = task_pipe_get_wait(pipeId, rxBuffer, PIPE_SIZE,
- &bytesRead, _ALL_N);
+ &bytesRead, _ALL_N);
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
TC_ERROR("Expected return code %d, not %d\n"
- "Expected %d bytes to be read, not %d\n",
- RC_OK, rv, PIPE_SIZE, bytesRead);
+ "Expected %d bytes to be read, not %d\n",
+ RC_OK, rv, PIPE_SIZE, bytesRead);
return TC_FAIL;
- }
+ }
- /* 2. task_pipe_get_wait() will force a context switch to RegressionTask(). */
+ /* 2. task_pipe_get_wait() will force a context switch to RegressionTask(). */
rv = task_pipe_get_wait(pipeId, rxBuffer, PIPE_SIZE,
- &bytesRead, _1_TO_N);
+ &bytesRead, _1_TO_N);
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
TC_ERROR("Expected return code %d, not %d\n"
- "Expected %d bytes to be read, not %d\n",
- RC_OK, rv, PIPE_SIZE, bytesRead);
+ "Expected %d bytes to be read, not %d\n",
+ RC_OK, rv, PIPE_SIZE, bytesRead);
return TC_FAIL;
- }
+ }
- /*
- * Before emptying the pipe, check that task_pipe_get_wait() fails when
- * using the _0_TO_N option.
- */
+ /*
+ * Before emptying the pipe, check that task_pipe_get_wait() fails when
+ * using the _0_TO_N option.
+ */
rv = task_pipe_get_wait(pipeId, rxBuffer, PIPE_SIZE / 2,
- &bytesRead, _0_TO_N);
+ &bytesRead, _0_TO_N);
if (rv != RC_FAIL) {
TC_ERROR("Expected return code %d, not %d\n", RC_FAIL, rv);
return TC_FAIL;
- }
+ }
- /* 3. Empty the pipe in two reads */
+ /* 3. Empty the pipe in two reads */
for (i = 0; i < 2; i++) {
rv = task_pipe_get(pipeId, rxBuffer, PIPE_SIZE / 2,
- &bytesRead, _0_TO_N);
+ &bytesRead, _0_TO_N);
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE / 2)) {
- TC_ERROR("Expected return code %d, not %d\n"
- "Expected %d bytes to be read, not %d\n",
- RC_OK, rv, PIPE_SIZE / 2, bytesRead);
- return TC_FAIL;
- }
+ TC_ERROR("Expected return code %d, not %d\n"
+ "Expected %d bytes to be read, not %d\n",
+ RC_OK, rv, PIPE_SIZE / 2, bytesRead);
+ return TC_FAIL;
}
+ }
task_sem_give(regSem);
@@ -543,49 +543,49 @@ int pipePutWaitTest(void)
int rv; /* return code from task_pipe_put_wait() */
int bytesWritten; /* # of bytes written to pipe */
- /* 1. Fill the pipe */
+ /* 1. Fill the pipe */
rv = task_pipe_put_wait(pipeId, txBuffer, PIPE_SIZE,
- &bytesWritten, _ALL_N);
+ &bytesWritten, _ALL_N);
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);
+ "Bytes written: expected %d, got %d\n",
+ RC_OK, rv, PIPE_SIZE, bytesWritten);
return TC_FAIL;
- }
+ }
task_sem_give(altSem); /* Wake the alternate task */
- /* 2. task_pipe_put_wait() will force a context switch to AlternateTask(). */
+ /* 2. task_pipe_put_wait() will force a context switch to AlternateTask(). */
rv = task_pipe_put_wait(pipeId, txBuffer, PIPE_SIZE,
- &bytesWritten, _ALL_N);
+ &bytesWritten, _ALL_N);
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);
+ "Bytes written: expected %d, got %d\n",
+ RC_OK, rv, PIPE_SIZE, bytesWritten);
return TC_FAIL;
- }
+ }
- /* 3. task_pipe_put_wait() will force a context switch to AlternateTask(). */
+ /* 3. task_pipe_put_wait() will force a context switch to AlternateTask(). */
rv = task_pipe_put_wait(pipeId, txBuffer, PIPE_SIZE,
- &bytesWritten, _1_TO_N);
+ &bytesWritten, _1_TO_N);
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);
+ "Bytes written: expected %d, got %d\n",
+ RC_OK, rv, PIPE_SIZE, bytesWritten);
return TC_FAIL;
- }
+ }
- /* This should return immediately as _0_TO_N with a wait is an error. */
+ /* This should return immediately as _0_TO_N with a wait is an error. */
rv = task_pipe_put_wait(pipeId, txBuffer, PIPE_SIZE,
- &bytesWritten, _0_TO_N);
+ &bytesWritten, _0_TO_N);
if ((rv != RC_FAIL) || (bytesWritten != 0)) {
TC_ERROR("Return code: expected %d, got %d\n"
- "Bytes written: expected %d, got %d\n",
- RC_FAIL, rv, 0, bytesWritten);
+ "Bytes written: expected %d, got %d\n",
+ RC_FAIL, rv, 0, bytesWritten);
return TC_FAIL;
- }
+ }
- /* Wait for AlternateTask()'s pipePutWaitHelper() to finish */
+ /* Wait for AlternateTask()'s pipePutWaitHelper() to finish */
(void)task_sem_take_wait(regSem);
return TC_PASS;
@@ -606,49 +606,49 @@ int pipePutTimeoutHelper(void)
(void)task_sem_take_wait(altSem); /* Wait until test is ready */
- /* 1. task_pipe_get_wait_timeout() will force a context switch to RegressionTask() */
+ /* 1. task_pipe_get_wait_timeout() will force a context switch to RegressionTask() */
rv = task_pipe_get_wait_timeout(pipeId, rxBuffer, PIPE_SIZE,
- &bytesRead, _ALL_N, ONE_SECOND);
+ &bytesRead, _ALL_N, ONE_SECOND);
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
TC_ERROR("Expected return code %d, not %d\n"
- "Expected %d bytes to be read, not %d\n",
- RC_OK, rv, PIPE_SIZE, bytesRead);
+ "Expected %d bytes to be read, not %d\n",
+ RC_OK, rv, PIPE_SIZE, bytesRead);
return TC_FAIL;
- }
+ }
- /* 2. task_pipe_get_wait_timeout() will force a context switch to RegressionTask(). */
+ /* 2. task_pipe_get_wait_timeout() will force a context switch to RegressionTask(). */
rv = task_pipe_get_wait_timeout(pipeId, rxBuffer, PIPE_SIZE,
- &bytesRead, _1_TO_N, ONE_SECOND);
+ &bytesRead, _1_TO_N, ONE_SECOND);
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
TC_ERROR("Expected return code %d, not %d\n"
- "Expected %d bytes to be read, not %d\n",
- RC_OK, rv, PIPE_SIZE, bytesRead);
+ "Expected %d bytes to be read, not %d\n",
+ RC_OK, rv, PIPE_SIZE, bytesRead);
return TC_FAIL;
- }
+ }
- /*
- * Before emptying the pipe, check that task_pipe_get_wait_timeout() fails when
- * using the _0_TO_N option.
- */
+ /*
+ * Before emptying the pipe, check that task_pipe_get_wait_timeout() fails when
+ * using the _0_TO_N option.
+ */
rv = task_pipe_get_wait_timeout(pipeId, rxBuffer, PIPE_SIZE / 2,
- &bytesRead, _0_TO_N, ONE_SECOND);
+ &bytesRead, _0_TO_N, ONE_SECOND);
if (rv != RC_FAIL) {
TC_ERROR("Expected return code %d, not %d\n", RC_FAIL, rv);
return TC_FAIL;
- }
+ }
- /* 3. Empty the pipe in two reads */
+ /* 3. Empty the pipe in two reads */
for (i = 0; i < 2; i++) {
rv = task_pipe_get(pipeId, rxBuffer, PIPE_SIZE / 2,
- &bytesRead, _0_TO_N);
+ &bytesRead, _0_TO_N);
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE / 2)) {
- TC_ERROR("Expected return code %d, not %d\n"
- "Expected %d bytes to be read, not %d\n",
- RC_OK, rv, PIPE_SIZE / 2, bytesRead);
- return TC_FAIL;
- }
+ TC_ERROR("Expected return code %d, not %d\n"
+ "Expected %d bytes to be read, not %d\n",
+ RC_OK, rv, PIPE_SIZE / 2, bytesRead);
+ return TC_FAIL;
}
+ }
task_sem_give(regSem);
@@ -667,67 +667,69 @@ int pipePutTimeoutTest(void)
int rv; /* return code from task_pipe_put_wait_timeout() */
int bytesWritten; /* # of bytes written to task_pipe_put_wait_timeout() */
- /* 1. Fill the pipe */
+ /* 1. Fill the pipe */
rv = task_pipe_put_wait_timeout(pipeId, txBuffer, PIPE_SIZE,
- &bytesWritten, _ALL_N, ONE_SECOND);
+ &bytesWritten, _ALL_N, ONE_SECOND);
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);
+ "Bytes written: expected %d, got %d\n",
+ RC_OK, rv, PIPE_SIZE, bytesWritten);
return TC_FAIL;
- }
+ }
- /* Timeout while waiting to put data into the pipe */
+ /* Timeout while waiting to put data into the pipe */
rv = task_pipe_put_wait_timeout(pipeId, txBuffer, PIPE_SIZE,
- &bytesWritten, _ALL_N, ONE_SECOND);
+ &bytesWritten, _ALL_N, ONE_SECOND);
if ((rv != RC_TIME) || (bytesWritten != 0)) {
TC_ERROR("Return code: expected %d, got %d\n"
- "Bytes written: expected %d, got %d\n",
- RC_TIME, rv, 0, bytesWritten);
+ "Bytes written: expected %d, got %d\n",
+ RC_TIME, rv, 0, bytesWritten);
return TC_FAIL;
- }
+ }
rv = task_pipe_put_wait_timeout(pipeId, txBuffer, PIPE_SIZE,
- &bytesWritten, _1_TO_N, ONE_SECOND);
+ &bytesWritten, _1_TO_N, ONE_SECOND);
if ((rv != RC_TIME) || (bytesWritten != 0)) {
TC_ERROR("Return code: expected %d, got %d\n"
- "Bytes written: expected %d, got %d\n",
- RC_TIME, rv, 0, bytesWritten);
+ "Bytes written: expected %d, got %d\n",
+ RC_TIME, rv, 0, bytesWritten);
return TC_FAIL;
- }
+ }
task_sem_give(altSem); /* Wake the alternate task */
- /* 2. task_pipe_put_wait() will force a context switch to AlternateTask(). */
+ /* 2. task_pipe_put_wait() will force a context switch to AlternateTask(). */
rv = task_pipe_put_wait_timeout(pipeId, txBuffer, PIPE_SIZE,
- &bytesWritten, _ALL_N, ONE_SECOND);
+ &bytesWritten, _ALL_N, ONE_SECOND);
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; }
+ "Bytes written: expected %d, got %d\n",
+ RC_OK, rv, PIPE_SIZE, bytesWritten);
+ return TC_FAIL;
+ }
- /* 3. task_pipe_put_wait() will force a context switch to AlternateTask(). */
+ /* 3. task_pipe_put_wait() will force a context switch to AlternateTask(). */
rv = task_pipe_put_wait_timeout(pipeId, txBuffer, PIPE_SIZE,
- &bytesWritten, _1_TO_N, ONE_SECOND);
+ &bytesWritten, _1_TO_N, ONE_SECOND);
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);
+ "Bytes written: expected %d, got %d\n",
+ RC_OK, rv, PIPE_SIZE, bytesWritten);
return TC_FAIL;
- }
+ }
- /* This should return immediately as _0_TO_N with a wait is an error. */
+ /* This should return immediately as _0_TO_N with a wait is an error. */
rv = task_pipe_put_wait(pipeId, txBuffer, PIPE_SIZE,
- &bytesWritten, _0_TO_N);
+ &bytesWritten, _0_TO_N);
if ((rv != RC_FAIL) || (bytesWritten != 0)) {
TC_ERROR("Return code: expected %d, got %d\n"
- "Bytes written: expected %d, got %d\n",
- RC_FAIL, rv, 0, bytesWritten);
+ "Bytes written: expected %d, got %d\n",
+ RC_FAIL, rv, 0, bytesWritten);
return TC_FAIL;
- }
+ }
- /* Wait for AlternateTask()'s pipePutWaitHelper() to finish */
+ /* Wait for AlternateTask()'s pipePutWaitHelper() to finish */
(void)task_sem_take_wait(regSem);
return TC_PASS;
@@ -756,28 +758,28 @@ int pipeGetTest(void)
for (j = 0; j < ARRAY_SIZE(options); j++) {
for (i = 0; i < ARRAY_SIZE(size); i++) {
- rv = task_pipe_get(pipeId, rxBuffer, size[i],
- &bytesRead, options[j]);
- if (rv != RC_FAIL) {
- TC_ERROR("Expected return code %d, not %d\n", RC_FAIL, rv);
- return TC_FAIL;
- }
- }
+ rv = task_pipe_get(pipeId, rxBuffer, size[i],
+ &bytesRead, options[j]);
+ if (rv != RC_FAIL) {
+ TC_ERROR("Expected return code %d, not %d\n", RC_FAIL, rv);
+ return TC_FAIL;
+ }
}
+ }
for (i = 0; i < ARRAY_SIZE(size); i++) {
rv = task_pipe_get(pipeId, rxBuffer, size[i],
- &bytesRead, _0_TO_N);
+ &bytesRead, _0_TO_N);
if (rv != RC_OK) {
- TC_ERROR("Expected return code %d, not %d\n", RC_OK, rv);
- return TC_FAIL;
- }
+ TC_ERROR("Expected return code %d, not %d\n", RC_OK, rv);
+ return TC_FAIL;
+ }
if (bytesRead != 0) {
- TC_ERROR("Expected <bytesRead> %d, not %d\n", 0, bytesRead);
- return TC_FAIL;
- }
+ TC_ERROR("Expected <bytesRead> %d, not %d\n", 0, bytesRead);
+ return TC_FAIL;
}
+ }
return TC_PASS;
}
@@ -799,22 +801,22 @@ int pipeGetWaitHelperWork(SIZE_EXPECT *items, int nItems)
int bytesSent; /* # of bytes sent to task_pipe_put_wait() */
for (i = 0; i < nItems; i++) {
- /*
- * Pipe should be empty. Most calls to task_pipe_get_wait() should
- * block until the call to task_pipe_put() is performed in the routine
- * pipeGetWaitHelperWork().
- */
+ /*
+ * Pipe should be empty. Most calls to task_pipe_get_wait() should
+ * block until the call to task_pipe_put() is performed in the routine
+ * pipeGetWaitHelperWork().
+ */
bytesSent = 0;
rv = task_pipe_put_wait(pipeId, rxBuffer, items[i].size,
- &bytesSent, items[i].options);
+ &bytesSent, items[i].options);
if ((rv != items[i].rcode) || (bytesSent != items[i].sent)) {
- TC_ERROR("Expected return value %d, got %d\n"
- "Expected bytesSent = %d, got %d\n",
- items[i].rcode, rv, 0, bytesSent);
- return TC_FAIL;
- }
+ TC_ERROR("Expected return value %d, got %d\n"
+ "Expected bytesSent = %d, got %d\n",
+ items[i].rcode, rv, 0, bytesSent);
+ return TC_FAIL;
}
+ }
return TC_PASS;
}
@@ -836,13 +838,13 @@ int pipeGetWaitHelper(void)
if (rv != TC_PASS) {
TC_ERROR("Failed on _ALL_N test\n");
return TC_FAIL;
- }
+ }
rv = pipeGetWaitHelperWork(wait_one_to_N, ARRAY_SIZE(wait_one_to_N));
if (rv != TC_PASS) {
TC_ERROR("Failed on _1_TO_N test\n");
return TC_FAIL;
- }
+ }
return TC_PASS;
}
@@ -864,21 +866,21 @@ int pipeGetWaitTestWork(SIZE_EXPECT *items, int nItems)
int bytesRead; /* # of bytes read from task_pipe_get_wait() */
for (i = 0; i < nItems; i++) {
- /*
- * Pipe should be empty. Most calls to task_pipe_get_wait() should
- * block until the call to task_pipe_put() is performed in the routine
- * pipeGetWaitHelperWork().
- */
+ /*
+ * Pipe should be empty. Most calls to task_pipe_get_wait() should
+ * block until the call to task_pipe_put() is performed in the routine
+ * pipeGetWaitHelperWork().
+ */
rv = task_pipe_get_wait(pipeId, rxBuffer, items[i].size,
- &bytesRead, items[i].options);
+ &bytesRead, items[i].options);
if ((rv != items[i].rcode) || (bytesRead != items[i].sent)) {
- TC_ERROR("Expected return value %d, got %d\n"
- "Expected bytesRead = %d, got %d\n",
- items[i].rcode, rv, 0, bytesRead);
- return TC_FAIL;
- }
+ TC_ERROR("Expected return value %d, got %d\n"
+ "Expected bytesRead = %d, got %d\n",
+ items[i].rcode, rv, 0, bytesRead);
+ return TC_FAIL;
}
+ }
return TC_PASS;
}
@@ -901,20 +903,20 @@ int pipeGetWaitTest(void)
if (rv != TC_PASS) {
TC_ERROR("Failed on _ALL_N test\n");
return TC_FAIL;
- }
+ }
rv = pipeGetWaitTestWork(wait_one_to_N, ARRAY_SIZE(wait_one_to_N));
if (rv != TC_PASS) {
TC_ERROR("Failed on _1_TO_N test\n");
return TC_FAIL;
- }
+ }
rv = task_pipe_get_wait(pipeId, rxBuffer, PIPE_SIZE,
- &bytesRead, _0_TO_N);
+ &bytesRead, _0_TO_N);
if (rv != RC_FAIL) {
TC_ERROR("Expected return code of %d, not %d\n", RC_FAIL, rv);
return TC_FAIL;
- }
+ }
return TC_PASS;
}
@@ -934,17 +936,17 @@ int pipeGetTimeoutTest(void)
for (i = 0; i < ARRAY_SIZE(timeout_cases); i++) {
rv = task_pipe_get_wait_timeout(pipeId, rxBuffer, timeout_cases[i].size,
- &bytesRead, timeout_cases[i].options, ONE_SECOND);
+ &bytesRead, timeout_cases[i].options, ONE_SECOND);
if ((rv != timeout_cases[i].rcode) ||
- (bytesRead != timeout_cases[i].sent)) {
- TC_ERROR("Expected return code %d, got %d\n"
- "Expected <bytesRead> %d, got %d\n"
- "Iteration %d\n",
- timeout_cases[i].rcode, rv, timeout_cases[i].sent,
- bytesRead, i + 1);
- return TC_FAIL;
- }
+ (bytesRead != timeout_cases[i].sent)) {
+ TC_ERROR("Expected return code %d, got %d\n"
+ "Expected <bytesRead> %d, got %d\n"
+ "Iteration %d\n",
+ timeout_cases[i].rcode, rv, timeout_cases[i].sent,
+ bytesRead, i + 1);
+ return TC_FAIL;
}
+ }
return TC_PASS;
}
@@ -965,33 +967,33 @@ int AlternateTask(void)
rv = pipePutHelper();
if (rv != TC_PASS) {
return TC_FAIL;
- }
+ }
rv = pipePutWaitHelper();
if (rv != TC_PASS) {
return TC_FAIL;
- }
+ }
rv = pipePutTimeoutHelper();
if (rv != TC_PASS) {
return TC_FAIL;
- }
+ }
- /*
- * There is no pipeGetHelper() as the task_pipe_get() checks have
- * either been done in pipePutHelper(), or pipeGetTest().
- */
+ /*
+ * There is no pipeGetHelper() as the task_pipe_get() checks have
+ * either been done in pipePutHelper(), or pipeGetTest().
+ */
rv = pipeGetWaitHelper();
if (rv != TC_PASS) {
return TC_FAIL;
- }
+ }
- /*
- * There is no pipeGetTimeoutHelper() as the task_pipe_get_wait_timeout() checks
- * have either been done in pipePutTimeoutHelper() or
- * pipeGetTimeoutTest().
- */
+ /*
+ * There is no pipeGetTimeoutHelper() as the task_pipe_get_wait_timeout() checks
+ * have either been done in pipePutTimeoutHelper() or
+ * pipeGetTimeoutTest().
+ */
return TC_PASS;
}
@@ -1014,38 +1016,38 @@ int RegressionTask(void)
TC_PRINT("Testing task_pipe_put() ...\n");
tcRC = pipePutTest();
if (tcRC != TC_PASS) {
- return TC_FAIL;
- }
+ return TC_FAIL;
+ }
TC_PRINT("Testing task_pipe_put_wait() ...\n");
tcRC = pipePutWaitTest();
if (tcRC != TC_PASS) {
- return TC_FAIL;
- }
+ return TC_FAIL;
+ }
TC_PRINT("Testing task_pipe_put_wait_timeout() ...\n");
tcRC = pipePutTimeoutTest();
if (tcRC != TC_PASS) {
- return TC_FAIL;
- }
+ return TC_FAIL;
+ }
TC_PRINT("Testing task_pipe_get() ...\n");
tcRC = pipeGetTest();
if (tcRC != TC_PASS) {
- return TC_FAIL;
- }
+ return TC_FAIL;
+ }
TC_PRINT("Testing task_pipe_get_wait() ...\n");
tcRC = pipeGetWaitTest();
if (tcRC != TC_PASS) {
- return TC_FAIL;
- }
+ return TC_FAIL;
+ }
TC_PRINT("Testing task_pipe_get_wait_timeout() ...\n");
tcRC = pipeGetTimeoutTest();
if (tcRC != TC_PASS) {
- return TC_FAIL;
- }
+ return TC_FAIL;
+ }
return TC_PASS;
}
diff --git a/samples/microkernel/test/test_pool/src/pool.c b/samples/microkernel/test/test_pool/src/pool.c
index bf64de768..2a00c704b 100644
--- a/samples/microkernel/test/test_pool/src/pool.c
+++ b/samples/microkernel/test/test_pool/src/pool.c
@@ -59,7 +59,7 @@ This modules tests the following memory pool routines:
typedef struct {
struct k_block *block; /* pointer to block data */
- kmemory_pool_t poolId; /* pool ID */
+ kmemory_pool_t poolId; /* pool ID */
int size; /* request size in bytes */
int32_t timeout; /* # of ticks to wait */
int rcode; /* expected return code */
diff --git a/samples/microkernel/test/test_secure_string_api/src/secure.c b/samples/microkernel/test/test_secure_string_api/src/secure.c
index f1eef4ded..57e552267 100644
--- a/samples/microkernel/test/test_secure_string_api/src/secure.c
+++ b/samples/microkernel/test/test_secure_string_api/src/secure.c
@@ -58,43 +58,46 @@ This modules tests the following secure routines:
*/
void MainTask(void)
- {
+{
int result;
- /* wait for the first task to start */
+ /* wait for the first task to start */
result = task_sem_take_wait_timeout(SEMA1, WAIT_TOUT);
if (result != RC_OK) {
- TC_ERROR("Test task 1 did not start properly\n");
- goto fail;
+ TC_ERROR("Test task 1 did not start properly\n");
+ goto fail;
}
- /* now we check the first task to perform the test and die */
+
+ /* 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) {
- TC_PRINT("As expected, test task 1 did not continue operating \n");
- TC_PRINT("after calling memcpy_s with incorrect parameters\n");
+ TC_PRINT("As expected, test task 1 did not continue operating \n");
+ TC_PRINT("after calling memcpy_s with incorrect parameters\n");
}
else {
- TC_ERROR("Test task 1 unexpectedly continued\n"
- "after calling memcpy_s with incorrect parameters\n");
- goto fail;
+ TC_ERROR("Test task 1 unexpectedly continued\n"
+ "after calling memcpy_s with incorrect parameters\n");
+ goto fail;
}
- /* wait for the second task to start */
+ /* wait for the second task to start */
result = task_sem_take_wait_timeout(SEMA2, WAIT_TOUT);
if (result != RC_OK) {
- TC_ERROR("Test task 2 did not start properly\n");
- goto fail;
+ TC_ERROR("Test task 2 did not start properly\n");
+ goto fail;
}
- /* now we check the second task to perform the test and die */
+
+ /* 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) {
- TC_PRINT("As expected, test task 2 did not continue operating \n");
- TC_PRINT("after calling strcpy_s with incorrect parameters\n");
+ TC_PRINT("As expected, test task 2 did not continue operating \n");
+ TC_PRINT("after calling strcpy_s with incorrect parameters\n");
}
else {
- TC_ERROR("Test task 2 unexpectedly continued\n"
- "after calling memcpy_s with incorrect parameters\n");
- goto fail;
+ TC_ERROR("Test task 2 unexpectedly continued\n"
+ "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,18 +116,19 @@ fail:
* RETURNS: N/A
*/
void MemcpyTask(void)
- {
+{
uint8_t buf1[BUFSIZE];
uint8_t buf2[BUFSIZE + 1];
- /* do correct memory copy */
+ /* do correct memory copy */
k_memcpy_s(buf2, sizeof(buf2), buf1, sizeof(buf1));
task_sem_give(SEMA1);
task_yield();
- /* do incorrect memory copy */
+
+ /* do incorrect memory copy */
k_memcpy_s(buf1, sizeof(buf1), buf2, sizeof(buf2));
task_sem_give(SEMA1);
- }
+}
/*******************************************************************************
*
@@ -135,22 +139,22 @@ 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 */
+ /* do correct string copy */
strcpy_s(buf1, sizeof(buf1), buf2);
task_sem_give(SEMA2);
task_yield();
- /*
- * Make the string not \0 terminated as a result
- * strcpy_s has to make an error
- */
+ /*
+ * Make the string not \0 terminated as a result
+ * strcpy_s has to make an error
+ */
buf2[BUFSIZE - 1] = '0';
- /* do incorrect string copy */
+
+ /* do incorrect string copy */
strcpy_s(buf1, sizeof(buf1), buf2);
task_sem_give(SEMA2);
- }
+}
diff --git a/samples/microkernel/test/test_sema/src/main.c b/samples/microkernel/test/test_sema/src/main.c
index 7b893af9d..49b96aa6f 100644
--- a/samples/microkernel/test/test_sema/src/main.c
+++ b/samples/microkernel/test/test_sema/src/main.c
@@ -249,22 +249,22 @@ void MonitorTaskEntry(void)
PRINT_DATA("Starting semaphore tests\n");
PRINT_LINE;
- /*
- * the various test tasks start executing automatically;
- * wait for all tasks to complete or a failure to occur,
- * then issue the appropriate test case summary message
- */
+ /*
+ * the various test tasks start executing automatically;
+ * wait for all tasks to complete or a failure to occur,
+ * then issue the appropriate test case summary message
+ */
for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) {
- result = task_sem_group_take_wait_timeout(resultSems, SECONDS(60));
- if (result != resultSems[TC_PASS]) {
- if (result != resultSems[TC_FAIL]) {
- TC_ERROR("Monitor task timed out\n");
+ result = task_sem_group_take_wait_timeout(resultSems, SECONDS(60));
+ if (result != resultSems[TC_PASS]) {
+ if (result != resultSems[TC_FAIL]) {
+ TC_ERROR("Monitor task timed out\n");
+ }
+ TC_END_RESULT(TC_FAIL);
+ TC_END_REPORT(TC_FAIL);
+ return;
}
- TC_END_RESULT(TC_FAIL);
- TC_END_REPORT(TC_FAIL);
- return;
- }
}
TC_END_RESULT(TC_PASS);
diff --git a/samples/microkernel/test/test_sema/src/sema.c b/samples/microkernel/test/test_sema/src/sema.c
index a582ae6e0..bc5255048 100644
--- a/samples/microkernel/test/test_sema/src/sema.c
+++ b/samples/microkernel/test/test_sema/src/sema.c
@@ -81,15 +81,15 @@ extern ksem_t semList[];
*/
int simpleSemaTest(void)
- {
+{
int signalCount;
int i;
int status;
- /*
- * Signal the semaphore several times from an ISR. After each signal,
- * check the signal count.
- */
+ /*
+ * Signal the semaphore several times from an ISR. After each signal,
+ * check the signal count.
+ */
for (i = 0; i < 5; i++) {
trigger_isrSemaSignal(simpleSem);
@@ -97,74 +97,74 @@ int simpleSemaTest(void)
task_sleep(10); /* Time for low priority task to run. */
signalCount = task_sem_count_get(simpleSem);
if (signalCount != (i + 1)) {
- TC_ERROR("<signalCount> error. Expected %d, got %d\n",
- i + 1, signalCount);
- return TC_FAIL;
- }
+ TC_ERROR("<signalCount> error. Expected %d, got %d\n",
+ i + 1, signalCount);
+ return TC_FAIL;
}
+ }
- /*
- * Signal the semaphore several times from a task. After each signal,
- * check the signal count.
- */
+ /*
+ * Signal the semaphore several times from a task. After each signal,
+ * check the signal count.
+ */
for (i = 5; i < 10; i++) {
task_sem_give(simpleSem);
signalCount = task_sem_count_get(simpleSem);
if (signalCount != (i + 1)) {
- TC_ERROR("<signalCount> error. Expected %d, got %d\n",
- i + 1, signalCount);
- return TC_FAIL;
- }
+ TC_ERROR("<signalCount> error. Expected %d, got %d\n",
+ i + 1, signalCount);
+ return TC_FAIL;
}
+ }
- /*
- * Test the semaphore without wait. Check the signal count after each
- * attempt (it should be decrementing by 1 each time).
- */
+ /*
+ * Test the semaphore without wait. Check the signal count after each
+ * attempt (it should be decrementing by 1 each time).
+ */
for (i = 9; i >= 4; i--) {
status = task_sem_take(simpleSem);
if (status != RC_OK) {
- TC_ERROR("task_sem_take(SIMPLE_SEM) error. Expected %d, not %d.\n",
- RC_OK, status);
- return TC_FAIL;
- }
+ TC_ERROR("task_sem_take(SIMPLE_SEM) error. Expected %d, not %d.\n",
+ RC_OK, status);
+ return TC_FAIL;
+ }
signalCount = task_sem_count_get(simpleSem);
if (signalCount != i) {
- TC_ERROR("<signalCount> error. Expected %d, not %d\n",
- i, signalCount);
- return TC_FAIL;
- }
+ TC_ERROR("<signalCount> error. Expected %d, not %d\n",
+ i, signalCount);
+ return TC_FAIL;
}
+ }
task_sem_reset(simpleSem);
- /*
- * The semaphore's signal count should now be zero (0). Test the
- * semaphore without wait. It should fail.
- */
+ /*
+ * The semaphore's signal count should now be zero (0). Test the
+ * semaphore without wait. It should fail.
+ */
for (i = 0; i < 10; i++) {
status = task_sem_take(simpleSem);
if (status != RC_FAIL) {
- TC_ERROR("task_sem_take(SIMPLE_SEM) error. Expected %d, got %d.\n",
- RC_FAIL, status);
- return TC_FAIL;
- }
+ TC_ERROR("task_sem_take(SIMPLE_SEM) error. Expected %d, got %d.\n",
+ RC_FAIL, status);
+ return TC_FAIL;
+ }
signalCount = task_sem_count_get(simpleSem);
if (signalCount != 0) {
- TC_ERROR("<signalCount> error. Expected %d, not %d\n",
- 0, signalCount);
- return TC_FAIL;
- }
+ TC_ERROR("<signalCount> error. Expected %d, not %d\n",
+ 0, signalCount);
+ return TC_FAIL;
}
+ }
return TC_PASS;
- }
+}
/*******************************************************************************
*
@@ -174,55 +174,55 @@ int simpleSemaTest(void)
*/
int simpleSemaWaitTest(void)
- {
+{
int status;
int i;
for (i = 0; i < 5; i++) {
- /* Wait one second for SIMPLE_SEM. Timeout is expected. */
+ /* Wait one second for SIMPLE_SEM. Timeout is expected. */
status = task_sem_take_wait_timeout(simpleSem, OBJ_TIMEOUT);
if (status != RC_TIME) {
- TC_ERROR("task_sem_take_wait_timeout() error. Expected %d, got %d\n",
- RC_TIME, status);
- return TC_FAIL;
- }
+ TC_ERROR("task_sem_take_wait_timeout() error. Expected %d, got %d\n",
+ RC_TIME, status);
+ return TC_FAIL;
}
+ }
- /*
- * Signal the semaphore upon which the alternate task is waiting. The
- * alternate task (which is at a lower priority) will cause SIMPLE_SEM
- * to be signalled, thus waking this task.
- */
+ /*
+ * Signal the semaphore upon which the alternate task is waiting. The
+ * alternate task (which is at a lower priority) will cause SIMPLE_SEM
+ * to be signalled, thus waking this task.
+ */
task_sem_give(altSem);
status = task_sem_take_wait_timeout(simpleSem, OBJ_TIMEOUT);
if (status != RC_OK) {
TC_ERROR("task_sem_take_wait_timeout() error. Expected %d, got %d\n",
- RC_OK, status);
+ RC_OK, status);
return TC_FAIL;
- }
+ }
- /*
- * Note that task_sem_take_wait() has been tested when waking up the alternate
- * task. Since previous tests had this task waiting, the alternate task
- * must have had the time to enter the state where it is waiting for the
- * ALTTASK_SEM semaphore to be given. Thus, we do not need to test for
- * it here.
- *
- * Now wait on SIMPLE_SEM again. This time it will be woken up by an
- * ISR signalling the semaphore.
- */
+ /*
+ * Note that task_sem_take_wait() has been tested when waking up the alternate
+ * task. Since previous tests had this task waiting, the alternate task
+ * must have had the time to enter the state where it is waiting for the
+ * ALTTASK_SEM semaphore to be given. Thus, we do not need to test for
+ * it here.
+ *
+ * Now wait on SIMPLE_SEM again. This time it will be woken up by an
+ * ISR signalling the semaphore.
+ */
status = task_sem_take_wait_timeout(simpleSem, OBJ_TIMEOUT);
if (status != RC_OK) {
TC_ERROR("task_sem_take_wait_timeout() error. Expected %d, got %d\n",
- RC_OK, status);
+ RC_OK, status);
return TC_FAIL;
- }
+ }
return TC_PASS;
- }
+}
/*******************************************************************************
*
@@ -232,77 +232,77 @@ int simpleSemaWaitTest(void)
*/
int simpleGroupTest(void)
- {
+{
int i;
int j;
int status;
ksem_t value;
- /* Ensure that the semaphores in the group are reset */
+ /* Ensure that the semaphores in the group are reset */
task_sem_group_reset(semList);
for (i = 0; semList[i] != ENDLIST; i++) {
status = task_sem_count_get(semList[i]);
if (status != 0) {
- TC_ERROR("task_sem_count_get() returned %d not %d\n", status, 0);
- return TC_FAIL;
- }
+ TC_ERROR("task_sem_count_get() returned %d not %d\n", status, 0);
+ return TC_FAIL;
}
+ }
- /* Timeout while waiting for a semaphore from the group */
+ /* Timeout while waiting for a semaphore from the group */
value = task_sem_group_take_wait_timeout(semList, OBJ_TIMEOUT);
if (value != ENDLIST) {
TC_ERROR("task_sem_group_take_wait_timeout() returned %d not %d\n",
- value, ENDGROUP);
+ value, ENDGROUP);
return TC_FAIL;
- }
+ }
- /* Signal the semaphores in the group */
+ /* Signal the semaphores in the group */
for (i = 0; i < 10; i++) {
task_sem_group_give(semList);
for (j = 0; semList[j] != ENDLIST; j++) {
- status = task_sem_count_get(semList[j]);
- if (status != i + 1) {
- TC_ERROR("task_sem_count_get() returned %d not %d\n",
- status, i + 1);
- return TC_FAIL;
- }
- }
+ status = task_sem_count_get(semList[j]);
+ if (status != i + 1) {
+ TC_ERROR("task_sem_count_get() returned %d not %d\n",
+ status, i + 1);
+ return TC_FAIL;
+ }
}
+ }
- /* Get the semaphores */
+ /* Get the semaphores */
for (i = 9; i >= 5; i--) {
value = task_sem_group_take_wait_timeout(semList, 0);
for (j = 0; semList[j] != ENDLIST; j++) {
- status = task_sem_count_get(semList[j]);
- if (status != (value == semList[j] ? i : 10)) {
- TC_ERROR("task_sem_count_get(0x%x) returned %d not %d\n",
- semList[j], status, (value == semList[j]) ? i : 10);
- return TC_FAIL;
- }
- }
+ status = task_sem_count_get(semList[j]);
+ if (status != (value == semList[j] ? i : 10)) {
+ TC_ERROR("task_sem_count_get(0x%x) returned %d not %d\n",
+ semList[j], status, (value == semList[j]) ? i : 10);
+ return TC_FAIL;
+ }
}
+ }
- /* Reset the semaphores in the group */
+ /* Reset the semaphores in the group */
task_sem_group_reset(semList);
for (i = 0; semList[i] != ENDLIST; i++) {
status = task_sem_count_get(semList[i]);
if (status != 0) {
- TC_ERROR("task_sem_count_get() returned %d not %d\n", status, 0);
- return TC_FAIL;
- }
+ TC_ERROR("task_sem_count_get() returned %d not %d\n", status, 0);
+ return TC_FAIL;
}
+ }
return TC_PASS;
- }
+}
/*******************************************************************************
*
@@ -315,57 +315,57 @@ int simpleGroupTest(void)
*/
int simpleGroupWaitTest(void)
- {
+{
int i;
ksem_t sema;
task_sem_give(altSem); /* Wake the alternate task */
- /*
- * Wait for a semaphore to be signalled by the alternate task.
- * Each semaphore in the group will be tested.
- */
+ /*
+ * Wait for a semaphore to be signalled by the alternate task.
+ * Each semaphore in the group will be tested.
+ */
for (i = 0; semList[i] != ENDLIST; i++) {
sema = task_sem_group_take_wait(semList);
if (sema != semList[i]) {
- TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n",
- (int) semList[i], (int) sema);
- return TC_FAIL;
- }
+ TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n",
+ (int) semList[i], (int) sema);
+ return TC_FAIL;
}
+ }
- /*
- * The Alternate Task will signal the semaphore group once. Note that
- * when the semaphore group is signalled, the last semaphore in the
- * group is the value that is returned, not the first.
- */
+ /*
+ * The Alternate Task will signal the semaphore group once. Note that
+ * when the semaphore group is signalled, the last semaphore in the
+ * group is the value that is returned, not the first.
+ */
for (i = 3; i >= 0; i--) {
sema = task_sem_group_take_wait(semList);
if (sema != semList[i]) {
- TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n",
- (int) semList[3], (int) sema);
- return TC_FAIL;
- }
+ TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n",
+ (int) semList[3], (int) sema);
+ return TC_FAIL;
}
+ }
- /*
- * Again wait for a semaphore to be signalled. This time, the alternate
- * task will trigger an interrupt that signals the semaphore.
- */
+ /*
+ * Again wait for a semaphore to be signalled. This time, the alternate
+ * task will trigger an interrupt that signals the semaphore.
+ */
for (i = 0; semList[i] != ENDLIST; i++) {
sema = task_sem_group_take_wait(semList);
if (sema != semList[i]) {
- TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n",
- (int) semList[i], (int) sema);
- return TC_FAIL;
- }
+ TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n",
+ (int) semList[i], (int) sema);
+ return TC_FAIL;
}
+ }
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;
@@ -391,36 +391,36 @@ static int simpleFiberSemTest(void)
task_sem_reset(simpleSem);
task_sem_group_reset(semList);
- /* let the fiber signal the semaphore and wait on it */
+ /* let the fiber signal the semaphore and wait on it */
releaseTestFiber();
status = task_sem_take_wait_timeout(simpleSem, OBJ_TIMEOUT);
if (status != RC_OK) {
- TC_ERROR("task_sem_take_wait_timeout() error. Expected %d, got %d\n",
- RC_OK, status);
- return TC_FAIL;
+ TC_ERROR("task_sem_take_wait_timeout() error. Expected %d, got %d\n",
+ RC_OK, status);
+ return TC_FAIL;
}
- /* release the fiber and let it signal the semaphore N_TESTS times */
+ /* release the fiber and let it signal the semaphore N_TESTS times */
releaseTestFiber();
signalCount = task_sem_count_get(simpleSem);
if (signalCount != N_TESTS) {
- TC_ERROR("<signalCount> error. Expected %d, got %d\n",
- N_TESTS, signalCount);
- return TC_FAIL;
+ TC_ERROR("<signalCount> error. Expected %d, got %d\n",
+ N_TESTS, signalCount);
+ return TC_FAIL;
}
- /* wait on the semaphore group while the fiber signals each semaphore in it */
+ /* wait on the semaphore group while the fiber signals each semaphore in it */
for (i = 0; semList[i] != ENDLIST; i++) {
- releaseTestFiber();
+ releaseTestFiber();
sema = task_sem_group_take_wait_timeout(semList, OBJ_TIMEOUT);
if (sema != semList[i]) {
- TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n",
- (int) semList[i], (int) sema);
- return TC_FAIL;
- }
+ TC_ERROR("task_sem_group_take_wait() error. Expected %d, not %d\n",
+ (int) semList[i], (int) sema);
+ return TC_FAIL;
}
- return TC_PASS;
}
+ return TC_PASS;
+}
/*******************************************************************************
*
@@ -430,31 +430,31 @@ static int simpleFiberSemTest(void)
*/
int HighPriTask(void)
- {
+{
int status;
- /* Wait until task is activated */
+ /* Wait until task is activated */
status = task_sem_take_wait(hpSem);
if (status != RC_OK) {
TC_ERROR("%s priority task failed to wait on %s: %d\n",
- "High", "HIGH_PRI_SEM", status);
+ "High", "HIGH_PRI_SEM", status);
return TC_FAIL;
- }
+ }
- /* Wait on a semaphore along with other tasks */
+ /* Wait on a semaphore along with other tasks */
status = task_sem_take_wait(manyBlockSem);
if (status != RC_OK) {
TC_ERROR("%s priority task failed to wait on %s: %d\n",
- "High", "MANY_BLOCKED_SEM", status);
+ "High", "MANY_BLOCKED_SEM", status);
return TC_FAIL;
- }
+ }
- /* Inform Regression test HP task is no longer blocked on MANY_BLOCKED_SEM*/
+ /* Inform Regression test HP task is no longer blocked on MANY_BLOCKED_SEM*/
task_sem_give(blockHpSem);
return TC_PASS;
- }
+}
/*******************************************************************************
*
@@ -464,22 +464,22 @@ int HighPriTask(void)
*/
int LowPriTask(void)
- {
+{
int status;
- /* Wait on a semaphore along with other tasks */
+ /* Wait on a semaphore along with other tasks */
status = task_sem_take_wait(manyBlockSem);
if (status != RC_OK) {
TC_ERROR("%s priority task failed to wait on %s: %d\n",
- "Low", "MANY_BLOCKED_SEM", status);
+ "Low", "MANY_BLOCKED_SEM", status);
return TC_FAIL;
- }
+ }
- /* Inform Regression test LP task is no longer blocked on MANY_BLOCKED_SEM*/
+ /* Inform Regression test LP task is no longer blocked on MANY_BLOCKED_SEM*/
task_sem_give(blockLpSem);
return TC_PASS;
- }
+}
/*******************************************************************************
*
@@ -491,74 +491,74 @@ int LowPriTask(void)
*/
int AlternateTask(void)
- {
+{
int status;
int i;
- /* Wait until it is time to continue */
+ /* Wait until it is time to continue */
status = task_sem_take_wait(altSem);
if (status != RC_OK) {
TC_ERROR("task_sem_take_wait() error. Expected %d, got %d\n",
- RC_OK, status);
+ RC_OK, status);
return TC_FAIL;
- }
+ }
- /*
- * After signalling the semaphore upon which the main (RegressionTask) task
- * is waiting, control will pass back to the main (RegressionTask) task.
- */
+ /*
+ * After signalling the semaphore upon which the main (RegressionTask) task
+ * is waiting, control will pass back to the main (RegressionTask) task.
+ */
task_sem_give(simpleSem);
- /*
- * Control has returned to the alternate task. Trigger an ISR that will
- * signal the semaphore upon which RegressionTask is waiting.
- */
+ /*
+ * Control has returned to the alternate task. Trigger an ISR that will
+ * signal the semaphore upon which RegressionTask is waiting.
+ */
trigger_isrSemaSignal(simpleSem);
- /* Wait for RegressionTask to wake this task up */
+ /* Wait for RegressionTask to wake this task up */
status = task_sem_take_wait(altSem);
if (status != RC_OK) {
TC_ERROR("task_sem_take_wait() error. Expected %d, got %d",
- RC_OK, status);
+ RC_OK, status);
return TC_FAIL;
- }
+ }
- /* Wait on a semaphore that will have many waiters */
+ /* Wait on a semaphore that will have many waiters */
status = task_sem_take_wait(manyBlockSem);
if (status != RC_OK) {
TC_ERROR("task_sem_take_wait() error. Expected %d, got %d",
- RC_OK, status);
+ RC_OK, status);
return TC_FAIL;
- }
+ }
- /* Inform Regression test MP task is no longer blocked on MANY_BLOCKED_SEM*/
+ /* Inform Regression test MP task is no longer blocked on MANY_BLOCKED_SEM*/
task_sem_give(blockMpSem);
- /* Wait until the alternate task is needed again */
+ /* Wait until the alternate task is needed again */
status = task_sem_take_wait(altSem);
if (status != RC_OK) {
TC_ERROR("task_sem_take_wait() error. Expected %d, got %d",
- RC_OK, status);
+ RC_OK, status);
return TC_FAIL;
- }
+ }
for (i = 0; semList[i] != ENDLIST; i++) {
task_sem_give(semList[i]);
- /* Context switch back to Regression Task */
- }
+ /* Context switch back to Regression Task */
+ }
task_sem_group_give(semList);
- /* Context switch back to Regression Task */
+ /* Context switch back to Regression Task */
for (i = 0; semList[i] != ENDLIST; i++) {
trigger_isrSemaSignal(semList[i]);
- /* Context switch back to Regression Task */
- }
+ /* Context switch back to Regression Task */
+ }
return TC_PASS;
- }
+}
/*******************************************************************************
*
@@ -570,7 +570,7 @@ int AlternateTask(void)
*/
int RegressionTask(void)
- {
+{
int tcRC;
int value;
ksem_t semBlockList[4];
@@ -580,31 +580,31 @@ int RegressionTask(void)
semBlockList[2] = blockLpSem;
semBlockList[3] = ENDLIST;
- /* Signal a semaphore that has no waiting tasks. */
+ /* Signal a semaphore that has no waiting tasks. */
TC_PRINT("Signal and test a semaphore without blocking\n");
tcRC = simpleSemaTest();
if (tcRC != TC_PASS) {
return TC_FAIL;
- }
+ }
- /* Wait on a semaphore. */
+ /* Wait on a semaphore. */
TC_PRINT("Signal and test a semaphore with blocking\n");
tcRC = simpleSemaWaitTest();
if (tcRC != TC_PASS) {
- return TC_FAIL;
- }
+ return TC_FAIL;
+ }
- /*
- * Have many tasks wait on a semaphore (MANY_BLOCKED_SEM). They will
- * block in the following order:
- * LowPriorityTask (low priority)
- * HighPriorityTask (high priority)
- * AlternateTask (medium priority)
- *
- * When the semaphore (MANY_BLOCKED_SEM) is signalled, HighPriorityTask
- * will be woken first.
- *
- */
+ /*
+ * Have many tasks wait on a semaphore (MANY_BLOCKED_SEM). They will
+ * block in the following order:
+ * LowPriorityTask (low priority)
+ * HighPriorityTask (high priority)
+ * AlternateTask (medium priority)
+ *
+ * When the semaphore (MANY_BLOCKED_SEM) is signalled, HighPriorityTask
+ * will be woken first.
+ *
+ */
TC_PRINT("Testing many tasks blocked on the same semaphore\n");
@@ -619,18 +619,18 @@ int RegressionTask(void)
value = task_sem_group_take_wait_timeout(semBlockList, OBJ_TIMEOUT);
if (value != blockHpSem) {
TC_ERROR("%s priority task did not get semaphore: 0x%x\n",
- "High", value);
+ "High", value);
return TC_FAIL;
- }
+ }
task_sem_give(manyBlockSem);
task_sleep(OBJ_TIMEOUT); /* Ensure medium priority task can run */
value = task_sem_group_take_wait_timeout(semBlockList, OBJ_TIMEOUT);
if (value != blockMpSem) {
TC_ERROR("%s priority task did not get semaphore: 0x%x\n",
- "Medium", value);
+ "Medium", value);
return TC_FAIL;
- }
+ }
task_sem_give(manyBlockSem);
@@ -639,35 +639,35 @@ int RegressionTask(void)
value = task_sem_group_take_wait_timeout(semBlockList, OBJ_TIMEOUT);
if (value != blockLpSem) {
TC_ERROR("%s priority task did not get semaphore: 0x%x\n",
- "Low", value);
+ "Low", value);
return TC_FAIL;
- }
+ }
value = task_sem_group_take_wait_timeout(semBlockList, OBJ_TIMEOUT);
if (value != ENDLIST) {
TC_ERROR("Group test Expecting ENDLIST, but got 0x%x\n",
- value);
+ value);
return TC_FAIL;
- }
+ }
TC_PRINT("Testing semaphore groups without blocking\n");
tcRC = simpleGroupTest();
if (tcRC != TC_PASS) {
- return TC_FAIL;
- }
+ return TC_FAIL;
+ }
TC_PRINT("Testing semaphore groups with blocking\n");
tcRC = simpleGroupWaitTest();
if (tcRC != TC_PASS) {
- return TC_FAIL;
- }
+ return TC_FAIL;
+ }
TC_PRINT("Testing semaphore release by fiber\n");
tcRC = simpleFiberSemTest();
if (tcRC != TC_PASS) {
- return TC_FAIL;
- }
+ return TC_FAIL;
+ }
return TC_PASS;
- }
+}
diff --git a/samples/microkernel/test/test_sema/src/test_fiber.c b/samples/microkernel/test/test_sema/src/test_fiber.c
index be7fd1add..24d44f7da 100644
--- a/samples/microkernel/test/test_sema/src/test_fiber.c
+++ b/samples/microkernel/test/test_sema/src/test_fiber.c
@@ -72,24 +72,24 @@ 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 */
+ /* release semaphore test task is waiting for */
nano_fiber_sem_take_wait(&fiberSem);
fiber_sem_give(simpleSem, &CMD_PKT_SET(cmdPktSet));
- /* release the semaphore for N_TESTS times */
+ /* release the semaphore for N_TESTS times */
nano_fiber_sem_take_wait(&fiberSem);
for (i = 0; i < N_TESTS; i++) {
- fiber_sem_give(simpleSem, &CMD_PKT_SET(cmdPktSet));
+ fiber_sem_give(simpleSem, &CMD_PKT_SET(cmdPktSet));
}
- /* signal each semaphore in the group */
+ /* signal each semaphore in the group */
for (i = 0; semList[i] != ENDLIST; i++) {
- nano_fiber_sem_take_wait(&fiberSem);
- fiber_sem_give(semList[i], &CMD_PKT_SET(cmdPktSet));
- }
+ 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);
- }
+}
diff --git a/samples/microkernel/test/test_sprintf/src/test_sprintf.c b/samples/microkernel/test/test_sprintf/src/test_sprintf.c
index 367e3f9a1..02805f303 100644
--- a/samples/microkernel/test/test_sprintf/src/test_sprintf.c
+++ b/samples/microkernel/test/test_sprintf/src/test_sprintf.c
@@ -75,8 +75,8 @@ typedef union {
struct {
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
/*******************************************************************************
@@ -98,7 +98,7 @@ int sprintfDoubleTest(void)
if (strcmp(buffer, "+INF") != 0) {
TC_ERROR("sprintf(+INF) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
var.u1 = 0x00000000;
var.u2 = 0xfff00000; /* Bit pattern for -INF (double) */
@@ -106,7 +106,7 @@ int sprintfDoubleTest(void)
if (strcmp(buffer, "-INF") != 0) {
TC_ERROR("sprintf(-INF) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
var.u1 = 0x00000000;
var.u2 = 0x7ff80000; /* Bit pattern for NaN (double) */
@@ -114,123 +114,122 @@ int sprintfDoubleTest(void)
if (strcmp(buffer, "NaN") != 0) {
TC_ERROR("sprintf(NaN) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
var.d = 1.0;
sprintf(buffer, "%f", var.d);
if (strcmp(buffer, "1.000000") != 0) {
TC_ERROR("sprintf(1.0) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
sprintf(buffer, "%+f", var.d);
if (strcmp(buffer, "+1.000000") != 0) {
TC_ERROR("sprintf(+1.0) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
sprintf(buffer, "%.2f", var.d);
if (strcmp(buffer, "1.00") != 0) {
TC_ERROR("sprintf(1.00) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
sprintf(buffer, "%.*f", 11, var.d);
if (strcmp(buffer, "1.00000000000") != 0) {
TC_ERROR("sprintf(1.00000000000) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
sprintf(buffer, "%12f", var.d);
if (strcmp(buffer, " 1.000000") != 0) {
TC_ERROR("sprintf( 1.000000) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
sprintf(buffer, "%-12f", var.d);
if (strcmp(buffer, "1.000000 ") != 0) {
TC_ERROR("sprintf(1.000000 ) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
sprintf(buffer, "%012f", var.d);
if (strcmp(buffer, "00001.000000") != 0) {
TC_ERROR("sprintf(00001.000000) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
var.d = -1.0;
sprintf(buffer, "%f", var.d);
if (strcmp(buffer, "-1.000000") != 0) {
TC_ERROR("sprintf(-1.0) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
var.d = 1234.56789;
sprintf(buffer, "%f", var.d);
if (strcmp(buffer, "1234.567890") != 0) {
TC_ERROR("sprintf(-1.0) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
var.d = 1234.0;
sprintf(buffer, "%e", var.d);
if (strcmp(buffer, "1.234000e+003") != 0) {
TC_ERROR("sprintf(1.234000e+003) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
sprintf(buffer, "%E", var.d);
if (strcmp(buffer, "1.234000E+003") != 0) {
TC_ERROR("sprintf(1.234000E+003) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
var.d = 0.1234;
sprintf(buffer, "%e", var.d);
if (strcmp(buffer, "1.234000e-001") != 0) {
TC_ERROR("sprintf(1.234000e-001) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
sprintf(buffer, "%E", var.d);
if (strcmp(buffer, "1.234000E-001") != 0) {
TC_ERROR("sprintf(1.234000E-001) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
var.d = 1234000000.0;
sprintf(buffer, "%g", var.d);
if (strcmp(buffer, "1.234e+009") != 0) {
TC_ERROR("sprintf(1.234e+009) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
sprintf(buffer, "%G", var.d);
if (strcmp(buffer, "1.234E+009") != 0) {
TC_ERROR("sprintf(1.234E+009) - incorrect output '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
- /*
- * VxMicro does not support size modifiers such as L. As such, attempts to
- * print a long double will NOT result in intuitively expected output.
- * Until such time as they are supported (if ever) the output will remain
- * counter-intuitive. If they ever are supported then this test will have
- * to be updated.
- */
+ /*
+ * VxMicro does not support size modifiers such as L. As such, attempts to
+ * print a long double will NOT result in intuitively expected output.
+ * Until such time as they are supported (if ever) the output will remain
+ * counter-intuitive. If they ever are supported then this test will have
+ * to be updated.
+ */
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;
- }
+ }
return status;
}
@@ -271,55 +270,55 @@ int vsnprintfTest(void)
int status = TC_PASS;
char buffer[100];
- /*
- * VxMicro may be handling the string size in a non-standard manner.
- * If a negative value is supplied for the string size, VxMicro converts
- * it to 0x7fffffff--maximum integer size. Since there is insufficient
- * memory to test a string of that length, we just check that the string
- * was fully written so that we can exercise the code path.
- */
+ /*
+ * VxMicro may be handling the string size in a non-standard manner.
+ * If a negative value is supplied for the string size, VxMicro converts
+ * it to 0x7fffffff--maximum integer size. Since there is insufficient
+ * memory to test a string of that length, we just check that the string
+ * was fully written so that we can exercise the code path.
+ */
buffer[0] = '\0';
len = tvsnprintf(buffer, (size_t)(-4), "%x", DEADBEEF);
if (len != strlen(DEADBEEF_LHEX_STR)) {
TC_ERROR("vsnprintf(%%x). Expected return value %d, not %d\n",
- strlen(DEADBEEF_LHEX_STR), len);
+ strlen(DEADBEEF_LHEX_STR), len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, DEADBEEF_LHEX_STR) != 0) {
TC_ERROR("vsnprintf(%%x). Expected '%s', got '%s'\n",
- DEADBEEF_LHEX_STR, buffer);
+ DEADBEEF_LHEX_STR, buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
buffer[0] = '\0';
len = tvsnprintf(buffer, 0, "%x", DEADBEEF);
if (len != strlen(DEADBEEF_LHEX_STR)) {
TC_ERROR("vsnprintf(%%x). Expected return value %d, not %d\n",
- strlen(DEADBEEF_LHEX_STR), len);
+ strlen(DEADBEEF_LHEX_STR), len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, "") != 0) {
TC_ERROR("vsnprintf(%%x). Expected '%s', got '%s'\n",
- "", buffer);
+ "", buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
len = tvsnprintf(buffer, 4, "%x", DEADBEEF);
if (len != strlen(DEADBEEF_LHEX_STR)) {
TC_ERROR("vsnprintf(%%x). Expected return value %d, not %d\n",
- strlen(DEADBEEF_LHEX_STR), len);
+ strlen(DEADBEEF_LHEX_STR), len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, "dea") != 0) {
TC_ERROR("vsnprintf(%%x). Expected '%s', got '%s'\n",
- "dea", buffer);
+ "dea", buffer);
status = TC_FAIL;
- }
+ }
return status;
}
@@ -358,19 +357,19 @@ int vsprintfTest(void)
int status = TC_PASS;
char buffer[100];
- /*******************/
+ /*******************/
len = tvsprintf(buffer, "%x", DEADBEEF);
if (len != strlen(DEADBEEF_LHEX_STR)) {
TC_ERROR("sprintf(%%x). Expected %d bytes written, not %d\n",
- strlen(DEADBEEF_LHEX_STR), len);
+ strlen(DEADBEEF_LHEX_STR), len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, DEADBEEF_LHEX_STR) != 0) {
TC_ERROR("sprintf(%%x). Expected '%s', got '%s'\n",
- DEADBEEF_LHEX_STR, buffer);
+ DEADBEEF_LHEX_STR, buffer);
status = TC_FAIL;
- }
+ }
return status;
}
@@ -392,55 +391,55 @@ int snprintfTest(void)
int status = TC_PASS;
char buffer[100];
- /*
- * VxMicro may be handling the string size in a non-standard manner.
- * If a negative value is supplied for the string size, VxMicro converts
- * it to 0x7fffffff--maximum integer size. Since there is insufficient
- * memory to test a string of that length, we just check that the string
- * was fully written so that we can exercise the code path.
- */
+ /*
+ * VxMicro may be handling the string size in a non-standard manner.
+ * If a negative value is supplied for the string size, VxMicro converts
+ * it to 0x7fffffff--maximum integer size. Since there is insufficient
+ * memory to test a string of that length, we just check that the string
+ * was fully written so that we can exercise the code path.
+ */
buffer[0] = '\0';
len = snprintf(buffer, (size_t)(-4), "%x", DEADBEEF);
if (len != strlen(DEADBEEF_LHEX_STR)) {
TC_ERROR("snprintf(%%x). Expected return value %d, not %d\n",
- strlen(DEADBEEF_LHEX_STR), len);
+ strlen(DEADBEEF_LHEX_STR), len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, DEADBEEF_LHEX_STR) != 0) {
TC_ERROR("snprintf(%%x). Expected '%s', got '%s'\n",
- DEADBEEF_LHEX_STR, buffer);
+ DEADBEEF_LHEX_STR, buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
buffer[0] = '\0';
len = snprintf(buffer, 0, "%x", DEADBEEF);
if (len != strlen(DEADBEEF_LHEX_STR)) {
TC_ERROR("snprintf(%%x). Expected return value %d, not %d\n",
- strlen(DEADBEEF_LHEX_STR), len);
+ strlen(DEADBEEF_LHEX_STR), len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, "") != 0) {
TC_ERROR("snprintf(%%x). Expected '%s', got '%s'\n",
- "", buffer);
+ "", buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
len = snprintf(buffer, 4, "%x", DEADBEEF);
if (len != strlen(DEADBEEF_LHEX_STR)) {
TC_ERROR("snprintf(%%x). Expected return value %d, not %d\n",
- strlen(DEADBEEF_LHEX_STR), len);
+ strlen(DEADBEEF_LHEX_STR), len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, "dea") != 0) {
TC_ERROR("snprintf(%%x). Expected '%s', got '%s'\n",
- "dea", buffer);
+ "dea", buffer);
status = TC_FAIL;
- }
+ }
return status;
}
@@ -458,65 +457,65 @@ int sprintfMiscTest(void)
int count;
char buffer[100];
- /*******************/
+ /*******************/
sprintf(buffer, "%p", (void *) DEADBEEF);
if (strcmp(buffer, DEADBEEF_PTR_STR) != 0) {
TC_ERROR("sprintf(%%p). Expected '%s', got '%s'\n",
- DEADBEEF_PTR_STR, buffer);
+ DEADBEEF_PTR_STR, buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
sprintf(buffer, "test data %n test data", &count);
if (count != 10) {
TC_ERROR("sprintf(%%n). Expected count to be %d, not %d\n",
- 10, count);
+ 10, count);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, "test data test data") != 0) {
TC_ERROR("sprintf(%%p). Expected '%s', got '%s'\n",
- "test data test data", buffer);
+ "test data test data", buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
sprintf(buffer, "%*d", 10, 1234);
if (strcmp(buffer, " 1234") != 0) {
TC_ERROR("sprintf(%%p). Expected '%s', got '%s'\n",
- " 1234", buffer);
+ " 1234", buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
sprintf(buffer, "%*d", -10, 1234);
if (strcmp(buffer, "1234 ") != 0) {
TC_ERROR("sprintf(%%p). Expected '%s', got '%s'\n",
- "1234 ", buffer);
+ "1234 ", buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
sprintf(buffer, "% d", 1234);
if (strcmp(buffer, " 1234") != 0) {
TC_ERROR("sprintf(%% d). Expected '%s', got '%s'\n",
- " 1234", buffer);
+ " 1234", buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
sprintf(buffer, "%hx", 1234);
if (strcmp("4d2", buffer) != 0) {
TC_ERROR("sprintf(%%hx). Expected '4d2', got '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
sprintf(buffer, "%lx", 1234ul);
if (strcmp("4d2", buffer) != 0) {
TC_ERROR("sprintf(%%lx). Expected '4d2', got '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
return status;
}
@@ -534,142 +533,142 @@ int sprintfIntegerTest(void)
int len;
char buffer[100];
- /*******************/
+ /*******************/
- /* Note: VxMicro prints hex numbers in 8 characters */
+ /* Note: VxMicro prints hex numbers in 8 characters */
len = sprintf(buffer, "%x", 0x11);
if (len != 2) {
TC_ERROR("sprintf(%%x). Expected 2 bytes written, not %d\n", len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, "11") != 0) {
TC_ERROR("sprintf(%%x). Expected '%s', got '%s'\n", "11", buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
len = sprintf(buffer, "%x", DEADBEEF);
if (len != strlen(DEADBEEF_LHEX_STR)) {
TC_ERROR("sprintf(%%x). Expected %d bytes written, not %d\n",
- strlen(DEADBEEF_LHEX_STR), len);
+ strlen(DEADBEEF_LHEX_STR), len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, DEADBEEF_LHEX_STR) != 0) {
TC_ERROR("sprintf(%%x). Expected '%s', got '%s'\n",
- DEADBEEF_LHEX_STR, buffer);
+ DEADBEEF_LHEX_STR, buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
len = sprintf(buffer, "%X", DEADBEEF);
if (len != strlen(DEADBEEF_UHEX_STR)) {
TC_ERROR("sprintf(%%X). Expected %d bytes written, not %d\n",
- strlen(DEADBEEF_UHEX_STR), len);
+ strlen(DEADBEEF_UHEX_STR), len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, DEADBEEF_UHEX_STR) != 0) {
TC_ERROR("sprintf(%%X). Expected '%s', got '%s'\n",
- DEADBEEF_UHEX_STR, buffer);
+ DEADBEEF_UHEX_STR, buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
len = sprintf(buffer, "%u", DEADBEEF);
if (len != strlen(DEADBEEF_UNSIGNED_STR)) {
TC_ERROR("sprintf(%%u). Expected %d bytes written, not %d\n",
- strlen(DEADBEEF_UNSIGNED_STR), len);
+ strlen(DEADBEEF_UNSIGNED_STR), len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, DEADBEEF_UNSIGNED_STR) != 0) {
TC_ERROR("sprintf(%%u). Expected '%s', got '%s'\n",
- DEADBEEF_UNSIGNED_STR, buffer);
+ DEADBEEF_UNSIGNED_STR, buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
len = sprintf(buffer, "%d", (int) DEADBEEF);
if (len != strlen(DEADBEEF_SIGNED_STR)) {
TC_ERROR("sprintf(%%d). Expected %d bytes written, not %d\n",
- strlen(DEADBEEF_SIGNED_STR), len);
+ strlen(DEADBEEF_SIGNED_STR), len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, DEADBEEF_SIGNED_STR) != 0) {
TC_ERROR("sprintf(%%d). Expected '%s', got '%s'\n",
- DEADBEEF_SIGNED_STR, buffer);
+ DEADBEEF_SIGNED_STR, buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
len = sprintf(buffer, "%o", DEADBEEF);
if (len != strlen(DEADBEEF_OCTAL_STR)) {
TC_ERROR("sprintf(%%o). Expected %d bytes written, not %d\n",
- strlen(DEADBEEF_OCTAL_STR), len);
+ strlen(DEADBEEF_OCTAL_STR), len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, DEADBEEF_OCTAL_STR) != 0) {
TC_ERROR("sprintf(%%o). Expected '%s', got '%s'\n",
- DEADBEEF_OCTAL_STR, buffer);
+ DEADBEEF_OCTAL_STR, buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
len = sprintf(buffer, "%#o", DEADBEEF);
if (len != strlen(DEADBEEF_OCTAL_ALT_STR)) {
TC_ERROR("sprintf(%%#o). Expected %d bytes written, not %d\n",
- strlen(DEADBEEF_OCTAL_ALT_STR), len);
+ strlen(DEADBEEF_OCTAL_ALT_STR), len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, DEADBEEF_OCTAL_ALT_STR) != 0) {
TC_ERROR("sprintf(%%#o). Expected '%s', got '%s'\n",
- DEADBEEF_OCTAL_ALT_STR, buffer);
+ DEADBEEF_OCTAL_ALT_STR, buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
len = sprintf(buffer, "%#x", DEADBEEF);
if (len != strlen(DEADBEEF_LHEX_ALT_STR)) {
TC_ERROR("sprintf(%%#x). Expected %d bytes written, not %d\n",
- strlen(DEADBEEF_LHEX_ALT_STR), len);
+ strlen(DEADBEEF_LHEX_ALT_STR), len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, DEADBEEF_LHEX_ALT_STR) != 0) {
TC_ERROR("sprintf(%%#x). Expected '%s', got '%s'\n",
- DEADBEEF_LHEX_ALT_STR, buffer);
+ DEADBEEF_LHEX_ALT_STR, buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
len = sprintf(buffer, "%#X", DEADBEEF);
if (len != strlen(DEADBEEF_UHEX_ALT_STR)) {
TC_ERROR("sprintf(%%#X). Expected %d bytes written, not %d\n",
- strlen(DEADBEEF_UHEX_ALT_STR), len);
+ strlen(DEADBEEF_UHEX_ALT_STR), len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, DEADBEEF_UHEX_ALT_STR) != 0) {
TC_ERROR("sprintf(%%#X). Expected '%s', got '%s'\n",
- DEADBEEF_UHEX_ALT_STR, buffer);
+ DEADBEEF_UHEX_ALT_STR, buffer);
status = TC_FAIL;
- }
+ }
- /*******************/
+ /*******************/
len = sprintf(buffer, "%+d", 1);
if (len != 2) {
TC_ERROR("sprintf(%%+d). Expected %d bytes written, not %d\n",
- 2, len);
+ 2, len);
status = TC_FAIL;
- }
+ }
if (strcmp(buffer, "+1") != 0) {
TC_ERROR("sprintf(%%+d). Expected '+1', got '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
return status;
}
@@ -691,31 +690,31 @@ int sprintfStringTest(void)
if (strcmp(buffer, "%") != 0) {
TC_ERROR("sprintf(%%). Expected '%%', got '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
sprintf(buffer, "%c", 't');
if (strcmp(buffer, "t") != 0) {
TC_ERROR("sprintf(%%c). Expected 't', got '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
sprintf(buffer, "%s", "short string");
if (strcmp(buffer, "short string") != 0) {
TC_ERROR("sprintf(%%s). Expected 'short string', got '%s'\n", buffer);
status = TC_FAIL;
- }
+ }
len = sprintf(buffer, "%s", REALLY_LONG_STRING);
if (len != PRINTF_MAX_STRING_LENGTH) {
TC_ERROR("Internals changed. Max string length no longer %d\n",
- PRINTF_MAX_STRING_LENGTH);
+ PRINTF_MAX_STRING_LENGTH);
status = TC_FAIL;
- }
+ }
if (strncmp(buffer, REALLY_LONG_STRING, PRINTF_MAX_STRING_LENGTH) != 0) {
TC_ERROR("First %d characters of REALLY_LONG_STRING not printed!\n",
- PRINTF_MAX_STRING_LENGTH);
+ PRINTF_MAX_STRING_LENGTH);
status = TC_FAIL;
- }
+ }
return status;
}
@@ -738,38 +737,38 @@ void RegressionTask(void)
TC_PRINT("Testing sprintf() with integers ....\n");
if (sprintfIntegerTest() != TC_PASS) {
status = TC_FAIL;
- }
+ }
TC_PRINT("Testing snprintf() ....\n");
if (snprintfTest() != TC_PASS) {
status = TC_FAIL;
- }
+ }
TC_PRINT("Testing vsprintf() ....\n");
if (vsprintfTest() != TC_PASS) {
status = TC_FAIL;
- }
+ }
TC_PRINT("Testing vsnprintf() ....\n");
if (vsnprintfTest() != TC_PASS) {
status = TC_FAIL;
- }
+ }
TC_PRINT("Testing sprintf() with strings ....\n");
if (sprintfStringTest() != TC_PASS) {
status = TC_FAIL;
- }
+ }
TC_PRINT("Testing sprintf() with misc options ....\n");
if (sprintfMiscTest() != TC_PASS) {
status = TC_FAIL;
- }
+ }
#ifdef CONFIG_FLOAT
TC_PRINT("Testing sprintf() with doubles ....\n");
if (sprintfDoubleTest() != TC_PASS) {
status = TC_FAIL;
- }
+ }
#endif /* CONFIG_FLOAT */
TC_END_RESULT(status);
diff --git a/samples/microkernel/test/test_stackprot/src/stackprot.c b/samples/microkernel/test/test_stackprot/src/stackprot.c
index 379ba76aa..7dee7568f 100644
--- a/samples/microkernel/test/test_stackprot/src/stackprot.c
+++ b/samples/microkernel/test/test_stackprot/src/stackprot.c
@@ -85,10 +85,10 @@ void check_input(const char *name, const char *input);
void printLoop(const char *name)
{
while (count < 6) {
- /* A short input string to check_input. It will pass. */
+ /* A short input string to check_input. It will pass. */
check_input(name, "Stack ok");
count++;
- }
+ }
}
/*******************************************************************************
@@ -109,7 +109,7 @@ void printLoop(const char *name)
void check_input(const char *name, const char *input)
{
- /* Stack will overflow when input is more than 16 characters */
+ /* Stack will overflow when input is more than 16 characters */
char buf[16];
strcpy(buf, input);
@@ -135,12 +135,11 @@ void fiber1(void)
#endif /* ! CONFIG_MICROKERNEL */
{
TC_PRINT("Starts %s\n", __func__);
- 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.
- */
+ 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.
+ */
printLoop(__func__);
tcRC = TC_FAIL;
@@ -168,17 +167,17 @@ void main(void)
TC_PRINT("Starts %s\n", __func__);
#ifdef CONFIG_MICROKERNEL
- /* Start task */
+ /* Start task */
task_start(ALTERNATETASK); /* refer to prj.vpf file */
#else
- /* Start fiber */
+ /* Start fiber */
task_fiber_start(&fiberStack[0], STACKSIZE,
- (nano_fiber_entry_t) fiber1, 0, 0, 7, 0);
+ (nano_fiber_entry_t) fiber1, 0, 0, 7, 0);
#endif /* ! CONFIG_MICROKERNEL */
if (tcRC == TC_FAIL) {
goto errorExit;
- }
+ }
printLoop(__func__);
diff --git a/samples/microkernel/test/test_static_idt/src/static_idt.c b/samples/microkernel/test/test_static_idt/src/static_idt.c
index c93591b0d..c5ed03763 100644
--- a/samples/microkernel/test/test_static_idt/src/static_idt.c
+++ b/samples/microkernel/test/test_static_idt/src/static_idt.c
@@ -137,44 +137,44 @@ int nanoIdtStubTest(void)
IDT_ENTRY *pIdtEntry;
uint16_t offset;
- /* Check for the interrupt stub */
+ /* Check for the interrupt stub */
pIdtEntry = (IDT_ENTRY *) (_idt_base_address + (TEST_SOFT_INT << 3));
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);
- return TC_FAIL;
+ 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);
- return TC_FAIL;
+ TC_ERROR("Failed to find high offset of nanoIntStub "
+ "(0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT);
+ return TC_FAIL;
}
- /* Check for the exception stub */
+ /* Check for the exception stub */
pIdtEntry = (IDT_ENTRY *) (_idt_base_address + (IV_DIVIDE_ERROR << 3));
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);
- return TC_FAIL;
+ 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);
- return TC_FAIL;
+ 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;
}
- /*
- * If the other fields are wrong, the system will crash when the exception
- * and software interrupt are triggered so we don't check them.
- */
+ /*
+ * If the other fields are wrong, the system will crash when the exception
+ * and software interrupt are triggered so we don't check them.
+ */
return TC_PASS;
}
@@ -200,7 +200,7 @@ static void idtSpurFiber(int a1, int a2)
_trigger_spurHandler();
- /* Shouldn't get here */
+ /* Shouldn't get here */
spurHandlerAbortedContext = 0;
}
@@ -230,59 +230,59 @@ void main(void)
rv = nanoIdtStubTest();
if (rv != TC_PASS) {
goto doneTests;
- }
+ }
TC_PRINT("Testing to see interrupt handler executes properly\n");
_trigger_isrHandler();
if (intHandlerExecuted == 0) {
- TC_ERROR("Interrupt handler did not execute\n");
- rv = TC_FAIL;
- goto doneTests;
+ TC_ERROR("Interrupt handler did not execute\n");
+ rv = TC_FAIL;
+ goto doneTests;
} else if (intHandlerExecuted != 1) {
- TC_ERROR("Interrupt handler executed more than once! (%d)\n",
- intHandlerExecuted);
- rv = TC_FAIL;
- goto doneTests;
+ TC_ERROR("Interrupt handler executed more than once! (%d)\n",
+ intHandlerExecuted);
+ rv = TC_FAIL;
+ goto doneTests;
}
TC_PRINT("Testing to see exception handler executes properly\n");
- /*
- * Use excHandlerExecuted instead of 0 to prevent the compiler issuing a
- * 'divide by zero' warning.
- */
+ /*
+ * Use excHandlerExecuted instead of 0 to prevent the compiler issuing a
+ * 'divide by zero' warning.
+ */
error = error / excHandlerExecuted;
if (excHandlerExecuted == 0) {
- TC_ERROR("Exception handler did not execute\n");
- rv = TC_FAIL;
- goto doneTests;
+ TC_ERROR("Exception handler did not execute\n");
+ rv = TC_FAIL;
+ goto doneTests;
}
else if (excHandlerExecuted != 1) {
- TC_ERROR("Exception handler executed more than once! (%d)\n",
- excHandlerExecuted);
- rv = TC_FAIL;
- goto doneTests;
+ TC_ERROR("Exception handler executed more than once! (%d)\n",
+ excHandlerExecuted);
+ rv = TC_FAIL;
+ goto doneTests;
}
- /*
- * Start fiber/task to trigger the spurious interrupt handler
- */
+ /*
+ * Start fiber/task to trigger the spurious interrupt handler
+ */
TC_PRINT("Testing to see spurious handler executes properly\n");
#ifdef CONFIG_MICROKERNEL
task_start(tSpurTask);
#else
task_fiber_start(fiberStack, sizeof(fiberStack), idtSpurFiber, 0, 0, 5, 0);
#endif
- /*
- * The fiber/task should not run past where the spurious interrupt is
- * generated. Therefore spurHandlerAbortedContext should remain at 1.
- */
+ /*
+ * The fiber/task should not run past where the spurious interrupt is
+ * generated. Therefore spurHandlerAbortedContext should remain at 1.
+ */
if (spurHandlerAbortedContext == 0) {
- TC_ERROR("Spurious handler did not execute as expected\n");
- rv = TC_FAIL;
- goto doneTests;
+ TC_ERROR("Spurious handler did not execute as expected\n");
+ rv = TC_FAIL;
+ goto doneTests;
}
doneTests:
diff --git a/samples/microkernel/test/test_task/src/task.c b/samples/microkernel/test/test_task/src/task.c
index b8bf2eabd..e79291697 100644
--- a/samples/microkernel/test/test_task/src/task.c
+++ b/samples/microkernel/test/test_task/src/task.c
@@ -65,7 +65,7 @@ This module tests the following task APIs:
typedef struct {
int cmd;
int data;
- } ISR_INFO;
+} ISR_INFO;
/* locals */
@@ -91,14 +91,14 @@ void isr_task_command_handler(void *data)
int value = -1;
switch (pInfo->cmd) {
- case CMD_TASKID:
- value = isr_task_id_get();
- break;
+ case CMD_TASKID:
+ value = isr_task_id_get();
+ break;
- case CMD_PRIORITY:
- value = isr_task_priority_get();
- break;
- }
+ case CMD_PRIORITY:
+ value = isr_task_priority_get();
+ break;
+ }
pInfo->data = value;
}
@@ -116,17 +116,17 @@ int isrAPIsTest(int taskId, int taskPrio)
_trigger_isrTaskCommand();
if (isrInfo.data != taskId) {
TC_ERROR("isr_task_id_get() returned %d, not %d\n",
- isrInfo.data, taskId);
+ isrInfo.data, taskId);
return TC_FAIL;
- }
+ }
isrInfo.cmd = CMD_PRIORITY;
_trigger_isrTaskCommand();
if (isrInfo.data != taskPrio) {
TC_ERROR("isr_task_priority_get() returned %d, not %d\n",
- isrInfo.data, taskPrio);
+ isrInfo.data, taskPrio);
return TC_FAIL;
- }
+ }
return TC_PASS;
}
@@ -145,16 +145,16 @@ int taskMacrosTest(int taskId, int taskPrio)
value = task_id_get();
if (value != taskId) {
TC_ERROR("task_id_get() returned 0x%x, not 0x%x\n",
- value, taskId);
+ value, taskId);
return TC_FAIL;
- }
+ }
value = task_priority_get();
if (value != taskPrio) {
TC_ERROR("task_priority_get() returned %d, not %d\n",
- value, taskPrio);
+ value, taskPrio);
return TC_FAIL;
- }
+ }
return TC_PASS;
}
@@ -211,65 +211,65 @@ int taskSetPrioTest(void)
{
int rv;
- /* Lower the priority of the current task (RegressionTask) */
+ /* Lower the priority of the current task (RegressionTask) */
task_priority_set(RT_TASKID, RT_PRIO + 5);
rv = task_priority_get();
if (rv != RT_PRIO + 5) {
TC_ERROR("Expected priority to be changed to %d, not %d\n",
- RT_PRIO + 5, rv);
+ RT_PRIO + 5, rv);
return TC_FAIL;
- }
+ }
- /* Raise the priority of the current task (RegressionTask) */
+ /* Raise the priority of the current task (RegressionTask) */
task_priority_set(RT_TASKID, RT_PRIO - 5);
rv = task_priority_get();
if (rv != RT_PRIO - 5) {
TC_ERROR("Expected priority to be changed to %d, not %d\n",
- RT_PRIO - 5, rv);
+ RT_PRIO - 5, rv);
return TC_FAIL;
- }
+ }
- /* Restore the priority of the current task (RegressionTask) */
+ /* Restore the priority of the current task (RegressionTask) */
task_priority_set(RT_TASKID, RT_PRIO);
rv = task_priority_get();
if (rv != RT_PRIO) {
TC_ERROR("Expected priority to be changed to %d, not %d\n",
- RT_PRIO, rv);
+ RT_PRIO, rv);
return TC_FAIL;
- }
+ }
- /* Lower the priority of the helper task (HelperTask) */
+ /* Lower the priority of the helper task (HelperTask) */
task_priority_set(HT_TASKID, HT_PRIO + 5);
task_sem_give(HT_SEM);
task_sem_take_wait(RT_SEM);
if (helperData != HT_PRIO + 5) {
TC_ERROR("Expected priority to be changed to %d, not %d\n",
- HT_PRIO + 5, helperData);
+ HT_PRIO + 5, helperData);
return TC_FAIL;
- }
+ }
- /* Raise the priority of the helper task (HelperTask) */
+ /* Raise the priority of the helper task (HelperTask) */
task_priority_set(HT_TASKID, HT_PRIO - 5);
task_sem_give(HT_SEM);
task_sem_take_wait(RT_SEM);
if (helperData != HT_PRIO - 5) {
TC_ERROR("Expected priority to be changed to %d, not %d\n",
- HT_PRIO - 5, helperData);
+ HT_PRIO - 5, helperData);
return TC_FAIL;
- }
+ }
- /* Restore the priority of the helper task (HelperTask) */
+ /* Restore the priority of the helper task (HelperTask) */
task_priority_set(HT_TASKID, HT_PRIO);
task_sem_give(HT_SEM);
task_sem_take_wait(RT_SEM);
if (helperData != HT_PRIO) {
TC_ERROR("Expected priority to be changed to %d, not %d\n",
- HT_PRIO, helperData);
+ HT_PRIO, helperData);
return TC_FAIL;
- }
+ }
return TC_PASS;
}
@@ -289,7 +289,7 @@ void helperTaskSleepTest(void)
firstTick = task_tick_get_32();
while (mainTaskNotReady) {
- }
+ }
helperData = task_tick_get_32() - firstTick;
task_sem_give(RT_SEM);
@@ -308,7 +308,7 @@ int taskSleepTest(void)
tick = task_tick_get_32(); /* Busy wait to align */
while (tick == task_tick_get_32()) { /* to tick boundary */
- }
+ }
task_sem_give(HT_SEM);
@@ -319,9 +319,9 @@ int taskSleepTest(void)
if (helperData != SLEEP_TIME) {
TC_ERROR("task_sleep() slept for %d ticks, not %d\n",
- helperData, SLEEP_TIME);
+ helperData, SLEEP_TIME);
return TC_FAIL;
- }
+ }
return TC_PASS;
}
@@ -341,7 +341,7 @@ void helperTaskYieldTest(void)
for (i = 0; i < 5; i++) {
helperData++;
task_yield();
- }
+ }
task_sem_give(RT_SEM);
}
@@ -360,7 +360,7 @@ int taskYieldTest(void)
helperData = 0;
- /* 1st raise the priority of the helper task */
+ /* 1st raise the priority of the helper task */
task_priority_set(HT_TASKID, RT_PRIO);
task_sem_give(HT_SEM);
@@ -369,16 +369,16 @@ int taskYieldTest(void)
task_yield();
if (helperData == prevHelperData) {
- TC_ERROR("Iter %d. helperData did not change (%d) \n",
- i + 1, helperData);
- return TC_FAIL;
- }
+ TC_ERROR("Iter %d. helperData did not change (%d) \n",
+ i + 1, helperData);
+ return TC_FAIL;
}
+ }
- /* Restore helper task priority */
+ /* Restore helper task priority */
task_priority_set(HT_TASKID, HT_PRIO);
- /* Ensure that the helper task finishes */
+ /* Ensure that the helper task finishes */
task_sem_take_wait(RT_SEM);
return TC_PASS;
@@ -424,7 +424,7 @@ int taskSuspendTest(void)
if (prevHelperData != helperData) {
TC_ERROR("Helper task did not suspend!\n");
return TC_FAIL;
- }
+ }
task_resume(HT_TASKID);
task_sleep(SLEEP_TIME);
@@ -432,7 +432,7 @@ int taskSuspendTest(void)
if (prevHelperData == helperData) {
TC_ERROR("Helper task did not resume!\n");
return TC_FAIL;
- }
+ }
task_sem_give(HT_SEM);
return TC_PASS;
@@ -454,7 +454,7 @@ void HelperTask(void)
if (rv != TC_PASS) {
tcRC = TC_FAIL;
return;
- }
+ }
task_sem_give(RT_SEM);
task_sem_take_wait(HT_SEM);
@@ -462,7 +462,7 @@ void HelperTask(void)
if (rv != TC_PASS) {
tcRC = TC_FAIL;
return;
- }
+ }
task_sem_give(RT_SEM);
helperTaskSetPrioTest();
@@ -496,7 +496,7 @@ void RegressionTask(void)
if (rv != TC_PASS) {
tcRC = TC_FAIL;
goto errorReturn;
- }
+ }
task_sem_give(HT_SEM);
task_sem_take_wait(RT_SEM);
@@ -506,7 +506,7 @@ void RegressionTask(void)
if (rv != TC_PASS) {
tcRC = TC_FAIL;
goto errorReturn;
- }
+ }
task_sem_give(HT_SEM);
task_sem_take_wait(RT_SEM);
@@ -515,25 +515,25 @@ void RegressionTask(void)
if (taskSetPrioTest() != TC_PASS) {
tcRC = TC_FAIL;
goto errorReturn;
- }
+ }
TC_PRINT("Testing task_sleep()\n");
if (taskSleepTest() != TC_PASS) {
tcRC = TC_FAIL;
goto errorReturn;
- }
+ }
TC_PRINT("Testing task_yield()\n");
if (taskYieldTest() != TC_PASS) {
tcRC = TC_FAIL;
goto errorReturn;
- }
+ }
TC_PRINT("Testing task_suspend() and task_resume()\n");
if (taskSuspendTest() != TC_PASS) {
tcRC = TC_FAIL;
goto errorReturn;
- }
+ }
errorReturn:
TC_END_RESULT(tcRC);
diff --git a/samples/microkernel/test/test_task_irq/src/main.c b/samples/microkernel/test/test_task_irq/src/main.c
index 9325754ed..88a5e5d5c 100644
--- a/samples/microkernel/test/test_task_irq/src/main.c
+++ b/samples/microkernel/test/test_task_irq/src/main.c
@@ -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,29 +96,30 @@ void taskBMain(void)
* RETURNS: N/A
*/
void registerWait(void)
- {
+{
extern void raiseInt(uint8_t id);
int tasksDone;
int irq_obj;
- /* Wait for the 2 tasks to finish registering their IRQ objects*/
+ /* Wait for the 2 tasks to finish registering their IRQ objects*/
for (tasksDone = 0; tasksDone < NUM_TEST_TASKS - 1; tasksDone++) {
if (task_sem_take_wait_timeout(SEM_RDY, TIMEOUT) != RC_OK) {
- TC_ERROR("Monitor task timed out\n");
- task_sem_give(resultSems[TC_FAIL]);
- return;
- }
+ TC_ERROR("Monitor task timed out\n");
+ task_sem_give(resultSems[TC_FAIL]);
+ return;
}
+ }
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)
- raiseInt((uint8_t)task_irq_object[irq_obj].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;
@@ -139,24 +140,24 @@ void MonitorTaskEntry(void)
PRINT_DATA("Starting task level interrupt handling tests\n");
PRINT_LINE;
- /*
- * the various test tasks start executing automatically;
- * wait for all tasks to complete or a failure to occur,
- * then issue the appropriate test case summary message
- */
+ /*
+ * the various test tasks start executing automatically;
+ * wait for all tasks to complete or a failure to occur,
+ * then issue the appropriate test case summary message
+ */
for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) {
result = task_sem_group_take_wait_timeout(resultSems, TIMEOUT);
if (result != resultSems[TC_PASS]) {
- if (result != resultSems[TC_FAIL]) {
- TC_ERROR("Monitor task timed out\n");
- }
- TC_END_RESULT(TC_FAIL);
- TC_END_REPORT(TC_FAIL);
- return;
- }
+ if (result != resultSems[TC_FAIL]) {
+ TC_ERROR("Monitor task timed out\n");
+ }
+ TC_END_RESULT(TC_FAIL);
+ TC_END_REPORT(TC_FAIL);
+ return;
}
+ }
TC_END_RESULT(TC_PASS);
TC_END_REPORT(TC_PASS);
- }
+}
diff --git a/samples/microkernel/test/test_task_irq/src/raise_int.c b/samples/microkernel/test/test_task_irq/src/raise_int.c
index eab832631..89afb9c3f 100644
--- a/samples/microkernel/test/test_task_irq/src/raise_int.c
+++ b/samples/microkernel/test/test_task_irq/src/raise_int.c
@@ -43,1350 +43,1350 @@
#if defined(VXMICRO_ARCH_x86)
static void genInt0(void)
- {
+{
__asm__ volatile("int $0");
- }
+}
static void genInt1(void)
- {
+{
__asm__ volatile("int $1");
- }
+}
static void genInt2(void)
- {
+{
__asm__ volatile("int $2");
- }
+}
static void genInt3(void)
- {
+{
__asm__ volatile("int $3");
- }
+}
static void genInt4(void)
- {
+{
__asm__ volatile("int $4");
- }
+}
static void genInt5(void)
- {
+{
__asm__ volatile("int $5");
- }
+}
static void genInt6(void)
- {
+{
__asm__ volatile("int $6");
- }
+}
static void genInt7(void)
- {
+{
__asm__ volatile("int $7");
- }
+}
static void genInt8(void)
- {
+{
__asm__ volatile("int $8");
- }
+}
static void genInt9(void)
- {
+{
__asm__ volatile("int $9");
- }
+}
static void genInt10(void)
- {
+{
__asm__ volatile("int $10");
- }
+}
static void genInt11(void)
- {
+{
__asm__ volatile("int $11");
- }
+}
static void genInt12(void)
- {
+{
__asm__ volatile("int $12");
- }
+}
static void genInt13(void)
- {
+{
__asm__ volatile("int $13");
- }
+}
static void genInt14(void)
- {
+{
__asm__ volatile("int $14");
- }
+}
static void genInt15(void)
- {
+{
__asm__ volatile("int $15");
- }
+}
static void genInt16(void)
- {
+{
__asm__ volatile("int $16");
- }
+}
static void genInt17(void)
- {
+{
__asm__ volatile("int $17");
- }
+}
static void genInt18(void)
- {
+{
__asm__ volatile("int $18");
- }
+}
static void genInt19(void)
- {
+{
__asm__ volatile("int $19");
- }
+}
static void genInt20(void)
- {
+{
__asm__ volatile("int $20");
- }
+}
static void genInt21(void)
- {
+{
__asm__ volatile("int $21");
- }
+}
static void genInt22(void)
- {
+{
__asm__ volatile("int $22");
- }
+}
static void genInt23(void)
- {
+{
__asm__ volatile("int $23");
- }
+}
static void genInt24(void)
- {
+{
__asm__ volatile("int $24");
- }
+}
static void genInt25(void)
- {
+{
__asm__ volatile("int $25");
- }
+}
static void genInt26(void)
- {
+{
__asm__ volatile("int $26");
- }
+}
static void genInt27(void)
- {
+{
__asm__ volatile("int $27");
- }
+}
static void genInt28(void)
- {
+{
__asm__ volatile("int $28");
- }
+}
static void genInt29(void)
- {
+{
__asm__ volatile("int $29");
- }
+}
static void genInt30(void)
- {
+{
__asm__ volatile("int $30");
- }
+}
static void genInt31(void)
- {
+{
__asm__ volatile("int $31");
- }
+}
static void genInt32(void)
- {
+{
__asm__ volatile("int $32");
- }
+}
static void genInt33(void)
- {
+{
__asm__ volatile("int $33");
- }
+}
static void genInt34(void)
- {
+{
__asm__ volatile("int $34");
- }
+}
static void genInt35(void)
- {
+{
__asm__ volatile("int $35");
- }
+}
static void genInt36(void)
- {
+{
__asm__ volatile("int $36");
- }
+}
static void genInt37(void)
- {
+{
__asm__ volatile("int $37");
- }
+}
static void genInt38(void)
- {
+{
__asm__ volatile("int $38");
- }
+}
static void genInt39(void)
- {
+{
__asm__ volatile("int $39");
- }
+}
static void genInt40(void)
- {
+{
__asm__ volatile("int $40");
- }
+}
static void genInt41(void)
- {
+{
__asm__ volatile("int $41");
- }
+}
static void genInt42(void)
- {
+{
__asm__ volatile("int $42");
- }
+}
static void genInt43(void)
- {
+{
__asm__ volatile("int $43");
- }
+}
static void genInt44(void)
- {
+{
__asm__ volatile("int $44");
- }
+}
static void genInt45(void)
- {
+{
__asm__ volatile("int $45");
- }
+}
static void genInt46(void)
- {
+{
__asm__ volatile("int $46");
- }
+}
static void genInt47(void)
- {
+{
__asm__ volatile("int $47");
- }
+}
static void genInt48(void)
- {
+{
__asm__ volatile("int $48");
- }
+}
static void genInt49(void)
- {
+{
__asm__ volatile("int $49");
- }
+}
static void genInt50(void)
- {
+{
__asm__ volatile("int $50");
- }
+}
static void genInt51(void)
- {
+{
__asm__ volatile("int $51");
- }
+}
static void genInt52(void)
- {
+{
__asm__ volatile("int $52");
- }
+}
static void genInt53(void)
- {
+{
__asm__ volatile("int $53");
- }
+}
static void genInt54(void)
- {
+{
__asm__ volatile("int $54");
- }
+}
static void genInt55(void)
- {
+{
__asm__ volatile("int $55");
- }
+}
static void genInt56(void)
- {
+{
__asm__ volatile("int $56");
- }
+}
static void genInt57(void)
- {
+{
__asm__ volatile("int $57");
- }
+}
static void genInt58(void)
- {
+{
__asm__ volatile("int $58");
- }
+}
static void genInt59(void)
- {
+{
__asm__ volatile("int $59");
- }
+}
static void genInt60(void)
- {
+{
__asm__ volatile("int $60");
- }
+}
static void genInt61(void)
- {
+{
__asm__ volatile("int $61");
- }
+}
static void genInt62(void)
- {
+{
__asm__ volatile("int $62");
- }
+}
static void genInt63(void)
- {
+{
__asm__ volatile("int $63");
- }
+}
static void genInt64(void)
- {
+{
__asm__ volatile("int $64");
- }
+}
static void genInt65(void)
- {
+{
__asm__ volatile("int $65");
- }
+}
static void genInt66(void)
- {
+{
__asm__ volatile("int $66");
- }
+}
static void genInt67(void)
- {
+{
__asm__ volatile("int $67");
- }
+}
static void genInt68(void)
- {
+{
__asm__ volatile("int $68");
- }
+}
static void genInt69(void)
- {
+{
__asm__ volatile("int $69");
- }
+}
static void genInt70(void)
- {
+{
__asm__ volatile("int $70");
- }
+}
static void genInt71(void)
- {
+{
__asm__ volatile("int $71");
- }
+}
static void genInt72(void)
- {
+{
__asm__ volatile("int $72");
- }
+}
static void genInt73(void)
- {
+{
__asm__ volatile("int $73");
- }
+}
static void genInt74(void)
- {
+{
__asm__ volatile("int $74");
- }
+}
static void genInt75(void)
- {
+{
__asm__ volatile("int $75");
- }
+}
static void genInt76(void)
- {
+{
__asm__ volatile("int $76");
- }
+}
static void genInt77(void)
- {
+{
__asm__ volatile("int $77");
- }
+}
static void genInt78(void)
- {
+{
__asm__ volatile("int $78");
- }
+}
static void genInt79(void)
- {
+{
__asm__ volatile("int $79");
- }
+}
static void genInt80(void)
- {
+{
__asm__ volatile("int $80");
- }
+}
static void genInt81(void)
- {
+{
__asm__ volatile("int $81");
- }
+}
static void genInt82(void)
- {
+{
__asm__ volatile("int $82");
- }
+}
static void genInt83(void)
- {
+{
__asm__ volatile("int $83");
- }
+}
static void genInt84(void)
- {
+{
__asm__ volatile("int $84");
- }
+}
static void genInt85(void)
- {
+{
__asm__ volatile("int $85");
- }
+}
static void genInt86(void)
- {
+{
__asm__ volatile("int $86");
- }
+}
static void genInt87(void)
- {
+{
__asm__ volatile("int $87");
- }
+}
static void genInt88(void)
- {
+{
__asm__ volatile("int $88");
- }
+}
static void genInt89(void)
- {
+{
__asm__ volatile("int $89");
- }
+}
static void genInt90(void)
- {
+{
__asm__ volatile("int $90");
- }
+}
static void genInt91(void)
- {
+{
__asm__ volatile("int $91");
- }
+}
static void genInt92(void)
- {
+{
__asm__ volatile("int $92");
- }
+}
static void genInt93(void)
- {
+{
__asm__ volatile("int $93");
- }
+}
static void genInt94(void)
- {
+{
__asm__ volatile("int $94");
- }
+}
static void genInt95(void)
- {
+{
__asm__ volatile("int $95");
- }
+}
static void genInt96(void)
- {
+{
__asm__ volatile("int $96");
- }
+}
static void genInt97(void)
- {
+{
__asm__ volatile("int $97");
- }
+}
static void genInt98(void)
- {
+{
__asm__ volatile("int $98");
- }
+}
static void genInt99(void)
- {
+{
__asm__ volatile("int $99");
- }
+}
static void genInt100(void)
- {
+{
__asm__ volatile("int $100");
- }
+}
static void genInt101(void)
- {
+{
__asm__ volatile("int $101");
- }
+}
static void genInt102(void)
- {
+{
__asm__ volatile("int $102");
- }
+}
static void genInt103(void)
- {
+{
__asm__ volatile("int $103");
- }
+}
static void genInt104(void)
- {
+{
__asm__ volatile("int $104");
- }
+}
static void genInt105(void)
- {
+{
__asm__ volatile("int $105");
- }
+}
static void genInt106(void)
- {
+{
__asm__ volatile("int $106");
- }
+}
static void genInt107(void)
- {
+{
__asm__ volatile("int $107");
- }
+}
static void genInt108(void)
- {
+{
__asm__ volatile("int $108");
- }
+}
static void genInt109(void)
- {
+{
__asm__ volatile("int $109");
- }
+}
static void genInt110(void)
- {
+{
__asm__ volatile("int $110");
- }
+}
static void genInt111(void)
- {
+{
__asm__ volatile("int $111");
- }
+}
static void genInt112(void)
- {
+{
__asm__ volatile("int $112");
- }
+}
static void genInt113(void)
- {
+{
__asm__ volatile("int $113");
- }
+}
static void genInt114(void)
- {
+{
__asm__ volatile("int $114");
- }
+}
static void genInt115(void)
- {
+{
__asm__ volatile("int $115");
- }
+}
static void genInt116(void)
- {
+{
__asm__ volatile("int $116");
- }
+}
static void genInt117(void)
- {
+{
__asm__ volatile("int $117");
- }
+}
static void genInt118(void)
- {
+{
__asm__ volatile("int $118");
- }
+}
static void genInt119(void)
- {
+{
__asm__ volatile("int $119");
- }
+}
static void genInt120(void)
- {
+{
__asm__ volatile("int $120");
- }
+}
static void genInt121(void)
- {
+{
__asm__ volatile("int $121");
- }
+}
static void genInt122(void)
- {
+{
__asm__ volatile("int $122");
- }
+}
static void genInt123(void)
- {
+{
__asm__ volatile("int $123");
- }
+}
static void genInt124(void)
- {
+{
__asm__ volatile("int $124");
- }
+}
static void genInt125(void)
- {
+{
__asm__ volatile("int $125");
- }
+}
static void genInt126(void)
- {
+{
__asm__ volatile("int $126");
- }
+}
static void genInt127(void)
- {
+{
__asm__ volatile("int $127");
- }
+}
static void genInt128(void)
- {
+{
__asm__ volatile("int $128");
- }
+}
static void genInt129(void)
- {
+{
__asm__ volatile("int $129");
- }
+}
static void genInt130(void)
- {
+{
__asm__ volatile("int $130");
- }
+}
static void genInt131(void)
- {
+{
__asm__ volatile("int $131");
- }
+}
static void genInt132(void)
- {
+{
__asm__ volatile("int $132");
- }
+}
static void genInt133(void)
- {
+{
__asm__ volatile("int $133");
- }
+}
static void genInt134(void)
- {
+{
__asm__ volatile("int $134");
- }
+}
static void genInt135(void)
- {
+{
__asm__ volatile("int $135");
- }
+}
static void genInt136(void)
- {
+{
__asm__ volatile("int $136");
- }
+}
static void genInt137(void)
- {
+{
__asm__ volatile("int $137");
- }
+}
static void genInt138(void)
- {
+{
__asm__ volatile("int $138");
- }
+}
static void genInt139(void)
- {
+{
__asm__ volatile("int $139");
- }
+}
static void genInt140(void)
- {
+{
__asm__ volatile("int $140");
- }
+}
static void genInt141(void)
- {
+{
__asm__ volatile("int $141");
- }
+}
static void genInt142(void)
- {
+{
__asm__ volatile("int $142");
- }
+}
static void genInt143(void)
- {
+{
__asm__ volatile("int $143");
- }
+}
static void genInt144(void)
- {
+{
__asm__ volatile("int $144");
- }
+}
static void genInt145(void)
- {
+{
__asm__ volatile("int $145");
- }
+}
static void genInt146(void)
- {
+{
__asm__ volatile("int $146");
- }
+}
static void genInt147(void)
- {
+{
__asm__ volatile("int $147");
- }
+}
static void genInt148(void)
- {
+{
__asm__ volatile("int $148");
- }
+}
static void genInt149(void)
- {
+{
__asm__ volatile("int $149");
- }
+}
static void genInt150(void)
- {
+{
__asm__ volatile("int $150");
- }
+}
static void genInt151(void)
- {
+{
__asm__ volatile("int $151");
- }
+}
static void genInt152(void)
- {
+{
__asm__ volatile("int $152");
- }
+}
static void genInt153(void)
- {
+{
__asm__ volatile("int $153");
- }
+}
static void genInt154(void)
- {
+{
__asm__ volatile("int $154");
- }
+}
static void genInt155(void)
- {
+{
__asm__ volatile("int $155");
- }
+}
static void genInt156(void)
- {
+{
__asm__ volatile("int $156");
- }
+}
static void genInt157(void)
- {
+{
__asm__ volatile("int $157");
- }
+}
static void genInt158(void)
- {
+{
__asm__ volatile("int $158");
- }
+}
static void genInt159(void)
- {
+{
__asm__ volatile("int $159");
- }
+}
static void genInt160(void)
- {
+{
__asm__ volatile("int $160");
- }
+}
static void genInt161(void)
- {
+{
__asm__ volatile("int $161");
- }
+}
static void genInt162(void)
- {
+{
__asm__ volatile("int $162");
- }
+}
static void genInt163(void)
- {
+{
__asm__ volatile("int $163");
- }
+}
static void genInt164(void)
- {
+{
__asm__ volatile("int $164");
- }
+}
static void genInt165(void)
- {
+{
__asm__ volatile("int $165");
- }
+}
static void genInt166(void)
- {
+{
__asm__ volatile("int $166");
- }
+}
static void genInt167(void)
- {
+{
__asm__ volatile("int $167");
- }
+}
static void genInt168(void)
- {
+{
__asm__ volatile("int $168");
- }
+}
static void genInt169(void)
- {
+{
__asm__ volatile("int $169");
- }
+}
static void genInt170(void)
- {
+{
__asm__ volatile("int $170");
- }
+}
static void genInt171(void)
- {
+{
__asm__ volatile("int $171");
- }
+}
static void genInt172(void)
- {
+{
__asm__ volatile("int $172");
- }
+}
static void genInt173(void)
- {
+{
__asm__ volatile("int $173");
- }
+}
static void genInt174(void)
- {
+{
__asm__ volatile("int $174");
- }
+}
static void genInt175(void)
- {
+{
__asm__ volatile("int $175");
- }
+}
static void genInt176(void)
- {
+{
__asm__ volatile("int $176");
- }
+}
static void genInt177(void)
- {
+{
__asm__ volatile("int $177");
- }
+}
static void genInt178(void)
- {
+{
__asm__ volatile("int $178");
- }
+}
static void genInt179(void)
- {
+{
__asm__ volatile("int $179");
- }
+}
static void genInt180(void)
- {
+{
__asm__ volatile("int $180");
- }
+}
static void genInt181(void)
- {
+{
__asm__ volatile("int $181");
- }
+}
static void genInt182(void)
- {
+{
__asm__ volatile("int $182");
- }
+}
static void genInt183(void)
- {
+{
__asm__ volatile("int $183");
- }
+}
static void genInt184(void)
- {
+{
__asm__ volatile("int $184");
- }
+}
static void genInt185(void)
- {
+{
__asm__ volatile("int $185");
- }
+}
static void genInt186(void)
- {
+{
__asm__ volatile("int $186");
- }
+}
static void genInt187(void)
- {
+{
__asm__ volatile("int $187");
- }
+}
static void genInt188(void)
- {
+{
__asm__ volatile("int $188");
- }
+}
static void genInt189(void)
- {
+{
__asm__ volatile("int $189");
- }
+}
static void genInt190(void)
- {
+{
__asm__ volatile("int $190");
- }
+}
static void genInt191(void)
- {
+{
__asm__ volatile("int $191");
- }
+}
static void genInt192(void)
- {
+{
__asm__ volatile("int $192");
- }
+}
static void genInt193(void)
- {
+{
__asm__ volatile("int $193");
- }
+}
static void genInt194(void)
- {
+{
__asm__ volatile("int $194");
- }
+}
static void genInt195(void)
- {
+{
__asm__ volatile("int $195");
- }
+}
static void genInt196(void)
- {
+{
__asm__ volatile("int $196");
- }
+}
static void genInt197(void)
- {
+{
__asm__ volatile("int $197");
- }
+}
static void genInt198(void)
- {
+{
__asm__ volatile("int $198");
- }
+}
static void genInt199(void)
- {
+{
__asm__ volatile("int $199");
- }
+}
static void genInt200(void)
- {
+{
__asm__ volatile("int $200");
- }
+}
static void genInt201(void)
- {
+{
__asm__ volatile("int $201");
- }
+}
static void genInt202(void)
- {
+{
__asm__ volatile("int $202");
- }
+}
static void genInt203(void)
- {
+{
__asm__ volatile("int $203");
- }
+}
static void genInt204(void)
- {
+{
__asm__ volatile("int $204");
- }
+}
static void genInt205(void)
- {
+{
__asm__ volatile("int $205");
- }
+}
static void genInt206(void)
- {
+{
__asm__ volatile("int $206");
- }
+}
static void genInt207(void)
- {
+{
__asm__ volatile("int $207");
- }
+}
static void genInt208(void)
- {
+{
__asm__ volatile("int $208");
- }
+}
static void genInt209(void)
- {
+{
__asm__ volatile("int $209");
- }
+}
static void genInt210(void)
- {
+{
__asm__ volatile("int $210");
- }
+}
static void genInt211(void)
- {
+{
__asm__ volatile("int $211");
- }
+}
static void genInt212(void)
- {
+{
__asm__ volatile("int $212");
- }
+}
static void genInt213(void)
- {
+{
__asm__ volatile("int $213");
- }
+}
static void genInt214(void)
- {
+{
__asm__ volatile("int $214");
- }
+}
static void genInt215(void)
- {
+{
__asm__ volatile("int $215");
- }
+}
static void genInt216(void)
- {
+{
__asm__ volatile("int $216");
- }
+}
static void genInt217(void)
- {
+{
__asm__ volatile("int $217");
- }
+}
static void genInt218(void)
- {
+{
__asm__ volatile("int $218");
- }
+}
static void genInt219(void)
- {
+{
__asm__ volatile("int $219");
- }
+}
static void genInt220(void)
- {
+{
__asm__ volatile("int $220");
- }
+}
static void genInt221(void)
- {
+{
__asm__ volatile("int $221");
- }
+}
static void genInt222(void)
- {
+{
__asm__ volatile("int $222");
- }
+}
static void genInt223(void)
- {
+{
__asm__ volatile("int $223");
- }
+}
static void genInt224(void)
- {
+{
__asm__ volatile("int $224");
- }
+}
static void genInt225(void)
- {
+{
__asm__ volatile("int $225");
- }
+}
static void genInt226(void)
- {
+{
__asm__ volatile("int $226");
- }
+}
static void genInt227(void)
- {
+{
__asm__ volatile("int $227");
- }
+}
static void genInt228(void)
- {
+{
__asm__ volatile("int $228");
- }
+}
static void genInt229(void)
- {
+{
__asm__ volatile("int $229");
- }
+}
static void genInt230(void)
- {
+{
__asm__ volatile("int $230");
- }
+}
static void genInt231(void)
- {
+{
__asm__ volatile("int $231");
- }
+}
static void genInt232(void)
- {
+{
__asm__ volatile("int $232");
- }
+}
static void genInt233(void)
- {
+{
__asm__ volatile("int $233");
- }
+}
static void genInt234(void)
- {
+{
__asm__ volatile("int $234");
- }
+}
static void genInt235(void)
- {
+{
__asm__ volatile("int $235");
- }
+}
static void genInt236(void)
- {
+{
__asm__ volatile("int $236");
- }
+}
static void genInt237(void)
- {
+{
__asm__ volatile("int $237");
- }
+}
static void genInt238(void)
- {
+{
__asm__ volatile("int $238");
- }
+}
static void genInt239(void)
- {
+{
__asm__ volatile("int $239");
- }
+}
static void genInt240(void)
- {
+{
__asm__ volatile("int $240");
- }
+}
static void genInt241(void)
- {
+{
__asm__ volatile("int $241");
- }
+}
static void genInt242(void)
- {
+{
__asm__ volatile("int $242");
- }
+}
static void genInt243(void)
- {
+{
__asm__ volatile("int $243");
- }
+}
static void genInt244(void)
- {
+{
__asm__ volatile("int $244");
- }
+}
static void genInt245(void)
- {
+{
__asm__ volatile("int $245");
- }
+}
static void genInt246(void)
- {
+{
__asm__ volatile("int $246");
- }
+}
static void genInt247(void)
- {
+{
__asm__ volatile("int $247");
- }
+}
static void genInt248(void)
- {
+{
__asm__ volatile("int $248");
- }
+}
static void genInt249(void)
- {
+{
__asm__ volatile("int $249");
- }
+}
static void genInt250(void)
- {
+{
__asm__ volatile("int $250");
- }
+}
static void genInt251(void)
- {
+{
__asm__ volatile("int $251");
- }
+}
static void genInt252(void)
- {
+{
__asm__ volatile("int $252");
- }
+}
static void genInt253(void)
- {
+{
__asm__ volatile("int $253");
- }
+}
static void genInt254(void)
- {
+{
__asm__ volatile("int $254");
- }
+}
static void genInt255(void)
- {
+{
__asm__ volatile("int $255");
- }
+}
static void (*intFPtr[256])(void) = {
- genInt0, genInt1, genInt2,genInt3,
- genInt4, genInt5, genInt6,genInt7,
- genInt8, genInt9, genInt10,genInt11,
- genInt12, genInt13, genInt14,genInt15,
- genInt16, genInt17, genInt18,genInt19,
- genInt20, genInt21, genInt22,genInt23,
- genInt24, genInt25, genInt26,genInt27,
- genInt28, genInt29, genInt30,genInt31,
- genInt32, genInt33, genInt34,genInt35,
- genInt36, genInt37, genInt38,genInt39,
- genInt40, genInt41, genInt42,genInt43,
- genInt44, genInt45, genInt46,genInt47,
- genInt48, genInt49, genInt50,genInt51,
- genInt52, genInt53, genInt54,genInt55,
- genInt56, genInt57, genInt58,genInt59,
- genInt60, genInt61, genInt62,genInt63,
- genInt64, genInt65, genInt66,genInt67,
- genInt68, genInt69, genInt70,genInt71,
- genInt72, genInt73, genInt74,genInt75,
- genInt76, genInt77, genInt78,genInt79,
- genInt80, genInt81, genInt82,genInt83,
- genInt84, genInt85, genInt86,genInt87,
- genInt88, genInt89, genInt90,genInt91,
- genInt92, genInt93, genInt94,genInt95,
- genInt96, genInt97, genInt98,genInt99,
- genInt100, genInt101, genInt102,genInt103,
- genInt104, genInt105, genInt106,genInt107,
- genInt108, genInt109, genInt110,genInt111,
- genInt112, genInt113, genInt114,genInt115,
- genInt116, genInt117, genInt118,genInt119,
- genInt120, genInt121, genInt122,genInt123,
- genInt124, genInt125, genInt126,genInt127,
- genInt128, genInt129, genInt130,genInt131,
- genInt132, genInt133, genInt134,genInt135,
- genInt136, genInt137, genInt138,genInt139,
- genInt140, genInt141, genInt142,genInt143,
- genInt144, genInt145, genInt146,genInt147,
- genInt148, genInt149, genInt150,genInt151,
- genInt152, genInt153, genInt154,genInt155,
- genInt156, genInt157, genInt158,genInt159,
- genInt160, genInt161, genInt162,genInt163,
- genInt164, genInt165, genInt166,genInt167,
- genInt168, genInt169, genInt170,genInt171,
- genInt172, genInt173, genInt174,genInt175,
- genInt176, genInt177, genInt178,genInt179,
- genInt180, genInt181, genInt182,genInt183,
- genInt184, genInt185, genInt186,genInt187,
- genInt188, genInt189, genInt190,genInt191,
- genInt192, genInt193, genInt194,genInt195,
- genInt196, genInt197, genInt198,genInt199,
- genInt200, genInt201, genInt202,genInt203,
- genInt204, genInt205, genInt206,genInt207,
- genInt208, genInt209, genInt210,genInt211,
- genInt212, genInt213, genInt214,genInt215,
- genInt216, genInt217, genInt218,genInt219,
- genInt220, genInt221, genInt222,genInt223,
- genInt224, genInt225, genInt226,genInt227,
- genInt228, genInt229, genInt230,genInt231,
- genInt232, genInt233, genInt234,genInt235,
- genInt236, genInt237, genInt238,genInt239,
- genInt240, genInt241, genInt242,genInt243,
- genInt244, genInt245, genInt246,genInt247,
- genInt248, genInt249, genInt250,genInt251,
- genInt252, genInt253, genInt254,genInt255};
+ genInt0, genInt1, genInt2,genInt3,
+ genInt4, genInt5, genInt6,genInt7,
+ genInt8, genInt9, genInt10,genInt11,
+ genInt12, genInt13, genInt14,genInt15,
+ genInt16, genInt17, genInt18,genInt19,
+ genInt20, genInt21, genInt22,genInt23,
+ genInt24, genInt25, genInt26,genInt27,
+ genInt28, genInt29, genInt30,genInt31,
+ genInt32, genInt33, genInt34,genInt35,
+ genInt36, genInt37, genInt38,genInt39,
+ genInt40, genInt41, genInt42,genInt43,
+ genInt44, genInt45, genInt46,genInt47,
+ genInt48, genInt49, genInt50,genInt51,
+ genInt52, genInt53, genInt54,genInt55,
+ genInt56, genInt57, genInt58,genInt59,
+ genInt60, genInt61, genInt62,genInt63,
+ genInt64, genInt65, genInt66,genInt67,
+ genInt68, genInt69, genInt70,genInt71,
+ genInt72, genInt73, genInt74,genInt75,
+ genInt76, genInt77, genInt78,genInt79,
+ genInt80, genInt81, genInt82,genInt83,
+ genInt84, genInt85, genInt86,genInt87,
+ genInt88, genInt89, genInt90,genInt91,
+ genInt92, genInt93, genInt94,genInt95,
+ genInt96, genInt97, genInt98,genInt99,
+ genInt100, genInt101, genInt102,genInt103,
+ genInt104, genInt105, genInt106,genInt107,
+ genInt108, genInt109, genInt110,genInt111,
+ genInt112, genInt113, genInt114,genInt115,
+ genInt116, genInt117, genInt118,genInt119,
+ genInt120, genInt121, genInt122,genInt123,
+ genInt124, genInt125, genInt126,genInt127,
+ genInt128, genInt129, genInt130,genInt131,
+ genInt132, genInt133, genInt134,genInt135,
+ genInt136, genInt137, genInt138,genInt139,
+ genInt140, genInt141, genInt142,genInt143,
+ genInt144, genInt145, genInt146,genInt147,
+ genInt148, genInt149, genInt150,genInt151,
+ genInt152, genInt153, genInt154,genInt155,
+ genInt156, genInt157, genInt158,genInt159,
+ genInt160, genInt161, genInt162,genInt163,
+ genInt164, genInt165, genInt166,genInt167,
+ genInt168, genInt169, genInt170,genInt171,
+ genInt172, genInt173, genInt174,genInt175,
+ genInt176, genInt177, genInt178,genInt179,
+ genInt180, genInt181, genInt182,genInt183,
+ genInt184, genInt185, genInt186,genInt187,
+ genInt188, genInt189, genInt190,genInt191,
+ genInt192, genInt193, genInt194,genInt195,
+ genInt196, genInt197, genInt198,genInt199,
+ genInt200, genInt201, genInt202,genInt203,
+ genInt204, genInt205, genInt206,genInt207,
+ genInt208, genInt209, genInt210,genInt211,
+ genInt212, genInt213, genInt214,genInt215,
+ genInt216, genInt217, genInt218,genInt219,
+ genInt220, genInt221, genInt222,genInt223,
+ genInt224, genInt225, genInt226,genInt227,
+ genInt228, genInt229, genInt230,genInt231,
+ genInt232, genInt233, genInt234,genInt235,
+ genInt236, genInt237, genInt238,genInt239,
+ genInt240, genInt241, genInt242,genInt243,
+ genInt244, genInt245, genInt246,genInt247,
+ genInt248, genInt249, genInt250,genInt251,
+ genInt252, genInt253, genInt254,genInt255};
/*******************************************************************************
*
@@ -1400,9 +1400,9 @@ static void (*intFPtr[256])(void) = {
* \NOMANUAL
*/
void raiseInt(uint8_t id)
- {
+{
(*intFPtr[id])();
- }
+}
#endif /* Intel */
#if defined(CONFIG_CPU_CORTEXM3)
@@ -1419,7 +1419,7 @@ void raiseInt(uint8_t id)
*/
void raiseInt(uint8_t id)
- {
+{
_NvicSwInterruptTrigger((unsigned int)id);
- }
+}
#endif
diff --git a/samples/microkernel/test/test_task_irq/src/test_device.c b/samples/microkernel/test/test_task_irq/src/test_device.c
index 88fae4042..c6a562312 100644
--- a/samples/microkernel/test/test_task_irq/src/test_device.c
+++ b/samples/microkernel/test/test_task_irq/src/test_device.c
@@ -77,63 +77,63 @@ 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;
- }
+ TC_ERROR("Not able to allocate IRQ object\n");
+ return TC_FAIL;
+ }
TC_PRINT("IRQ object %d using IRQ%d allocated\n", DEV1_ID, DEV1_IRQ);
if (task_irq_alloc(DEV2_ID, DEV2_IRQ, 2) == INVALID_VECTOR) {
- TC_ERROR("Not able to allocate IRQ object\n");
- return TC_FAIL;
- }
+ TC_ERROR("Not able to allocate IRQ object\n");
+ return TC_FAIL;
+ }
TC_PRINT("IRQ object %d using IRQ%d allocated\n\n", DEV2_ID, DEV2_IRQ);
- /* Send semaphore to let loader know IRQ objects have been allocated */
+ /* Send semaphore to let loader know IRQ objects have been allocated */
task_sem_give(semRdy);
if (task_irq_test_wait(DEV1_ID) != RC_OK) {
- TC_ERROR("Not able to test IRQ object event\n");
- return TC_FAIL;
- }
+ TC_ERROR("Not able to test IRQ object event\n");
+ return TC_FAIL;
+ }
TC_PRINT("Received event for IRQ object %d\n", DEV1_ID);
task_irq_ack(DEV1_ID);
if (task_irq_test_wait(DEV2_ID) != RC_OK) {
- TC_ERROR("Not able to test IRQ object event\n");
- return TC_FAIL;
- }
+ TC_ERROR("Not able to test IRQ object event\n");
+ return TC_FAIL;
+ }
TC_PRINT("Received event for IRQ object %d\n", DEV2_ID);
task_irq_ack(DEV2_ID);
- /* Wait for other task to receive its events */
+ /* Wait for other task to receive its events */
(void)task_sem_take_wait(semRdy);
TC_PRINT("\nAttempt to allocate an IRQ object that\n");
TC_PRINT("is already allocated by another task...\n");
if (task_irq_alloc(DEV4_ID, DEV4_IRQ, 1) != INVALID_VECTOR) {
- TC_ERROR("Error: Was able to allocate\n\n");
+ TC_ERROR("Error: Was able to allocate\n\n");
return TC_FAIL;
- }
+ }
TC_PRINT("Re-allocation of IRQ object %d prevented\n", DEV4_ID);
TC_PRINT("\nAttempt to allocate an IRQ that\n"
"is already allocated by another task...\n");
if (task_irq_alloc(DEV5_ID, DEV4_IRQ, 1) != INVALID_VECTOR) {
- TC_ERROR("Error: Was able to allocate\n\n");
+ TC_ERROR("Error: Was able to allocate\n\n");
return TC_FAIL;
- }
+ }
TC_PRINT("Re-allocation of IRQ%d prevented\n\n", DEV4_IRQ);
- /* Signal other task that we are done processing */
+ /* Signal other task that we are done processing */
task_sem_give(semRdy);
return TC_PASS;
- }
+}
/*******************************************************************************
*
@@ -147,46 +147,46 @@ 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;
- }
+ TC_ERROR("Not able to allocate IRQ object\n");
+ return TC_FAIL;
+ }
TC_PRINT("IRQ object %d using IRQ%d allocated\n", DEV3_ID, DEV3_IRQ);
if (task_irq_alloc(DEV4_ID, DEV4_IRQ, 1) == INVALID_VECTOR) {
- TC_ERROR("Not able to allocate IRQ object\n");
- return TC_FAIL;
- }
+ TC_ERROR("Not able to allocate IRQ object\n");
+ return TC_FAIL;
+ }
TC_PRINT("IRQ object %d using IRQ%d allocated\n\n", DEV4_ID, DEV4_IRQ);
- /* Send semaphore to let loader/main know objects have been allocated */
+ /* Send semaphore to let loader/main know objects have been allocated */
task_sem_give(semRdy);
if (task_irq_test_wait(DEV3_ID) != RC_OK) {
TC_ERROR("Not able to test IRQ object event\n");
return TC_FAIL;
- }
+ }
TC_PRINT("Received event for IRQ object %d\n", DEV3_ID);
task_irq_ack(DEV3_ID);
if (task_irq_test_wait(DEV4_ID) != RC_OK) {
- TC_ERROR("Not able to test IRQ object event\n");
- return TC_FAIL;
- }
+ TC_ERROR("Not able to test IRQ object event\n");
+ return TC_FAIL;
+ }
TC_PRINT("Received event for IRQ object %d\n", DEV4_ID);
task_irq_ack(DEV4_ID);
- /* Signal other task that we are done receiving events */
+ /* Signal other task that we are done receiving events */
task_sem_give(semRdy);
- /*
- * Wait for other task to finish processing. The signal just previously
- * sent will not be seen here as the other task is a higher priority and
- * will thus consume the signal first.
- */
+ /*
+ * Wait for other task to finish processing. The signal just previously
+ * sent will not be seen here as the other task is a higher priority and
+ * will thus consume the signal first.
+ */
(void)task_sem_take_wait(semRdy);
@@ -195,4 +195,4 @@ int taskB(ksem_t semRdy)
TC_PRINT("IRQ object %d freed\n", DEV3_ID);
return TC_PASS;
- }
+}
diff --git a/samples/microkernel/test/test_tickless/src/test_tickless.c b/samples/microkernel/test/test_tickless/src/test_tickless.c
index bf83c31cc..69a2460ef 100644
--- a/samples/microkernel/test/test_tickless/src/test_tickless.c
+++ b/samples/microkernel/test/test_tickless/src/test_tickless.c
@@ -88,7 +88,7 @@ extern void _TimestampClose(void);
#endif
void ticklessTestTask(void)
- {
+{
int32_t start_ticks;
int32_t end_ticks;
int32_t diff_ticks;
@@ -111,25 +111,25 @@ void ticklessTestTask(void)
printk("Calibrating TSC...\n");
#ifdef CONFIG_TICKLESS_IDLE
oldThreshold = _sys_idle_threshold_ticks;
- /* make sure we do not enter tickless idle mode */
+ /* make sure we do not enter tickless idle mode */
_sys_idle_threshold_ticks = 0x7FFFFFFF;
#endif
- /* initialize the timer, if necessary */
+ /* initialize the timer, if necessary */
_TIMESTAMP_OPEN();
for (i = 0; i < CAL_REPS; i++) {
- /*
- * Do a single tick sleep to get us as close to a tick boundary
- * as we can.
- */
- task_sleep(1);
- start_ticks = task_tick_get_32();
- start_tsc = _TIMESTAMP_READ();
- task_sleep(SLEEP_TICKS);
- end_tsc = _TIMESTAMP_READ();
- end_ticks = task_tick_get_32();
- cal_tsc += end_tsc - start_tsc;
+ /*
+ * Do a single tick sleep to get us as close to a tick boundary
+ * as we can.
+ */
+ task_sleep(1);
+ start_ticks = task_tick_get_32();
+ start_tsc = _TIMESTAMP_READ();
+ task_sleep(SLEEP_TICKS);
+ end_tsc = _TIMESTAMP_READ();
+ end_ticks = task_tick_get_32();
+ cal_tsc += end_tsc - start_tsc;
}
cal_tsc /= CAL_REPS;
@@ -149,17 +149,17 @@ void ticklessTestTask(void)
printk("Going idle for %d ticks...\n", SLEEP_TICKS);
for (i = 0; i < CAL_REPS; i++) {
- /*
- * Do a single tick sleep to get us as close to a tick boundary
- * as we can.
- */
- task_sleep(1);
- start_ticks = task_tick_get_32();
- start_tsc = _TIMESTAMP_READ();
- task_sleep(SLEEP_TICKS);
- end_tsc = _TIMESTAMP_READ();
- end_ticks = task_tick_get_32();
- diff_tsc += end_tsc - start_tsc;
+ /*
+ * Do a single tick sleep to get us as close to a tick boundary
+ * as we can.
+ */
+ task_sleep(1);
+ start_ticks = task_tick_get_32();
+ start_tsc = _TIMESTAMP_READ();
+ task_sleep(SLEEP_TICKS);
+ end_tsc = _TIMESTAMP_READ();
+ end_ticks = task_tick_get_32();
+ diff_tsc += end_tsc - start_tsc;
}
diff_tsc /= CAL_REPS;
@@ -180,25 +180,27 @@ void ticklessTestTask(void)
printk("Cal time stamp: 0x%x\n", cal_tsc);
#endif
- /* Calculate percentage difference between calibrated TSC diff and measured result */
- if (diff_tsc > cal_tsc)
- diff_per = (100 * (diff_tsc - cal_tsc)) / cal_tsc;
- else
- diff_per = (100 * (cal_tsc - diff_tsc)) / cal_tsc;
+ /* Calculate percentage difference between calibrated TSC diff and measured result */
+ if (diff_tsc > cal_tsc) {
+ diff_per = (100 * (diff_tsc - cal_tsc)) / cal_tsc;
+ }
+ else {
+ diff_per = (100 * (cal_tsc - diff_tsc)) / cal_tsc;
+ }
printk("variance in time stamp diff: %d percent\n", (int32_t)diff_per);
if (diff_ticks != SLEEP_TICKS) {
- printk("* TEST FAILED. TICK COUNT INCORRECT *\n");
- TC_END_REPORT(TC_FAIL);
+ printk("* TEST FAILED. TICK COUNT INCORRECT *\n");
+ TC_END_REPORT(TC_FAIL);
}
else {
- TC_END_REPORT(TC_PASS);
- }
+ TC_END_REPORT(TC_PASS);
+ }
- /* release the timer, if necessary */
+ /* release the timer, if necessary */
_TIMESTAMP_CLOSE();
while(1);
- }
+}
diff --git a/samples/microkernel/test/test_tickless/src/timestamps.c b/samples/microkernel/test/test_tickless/src/timestamps.c
index 6dd1ddb4d..f8d62a42b 100644
--- a/samples/microkernel/test/test_tickless/src/timestamps.c
+++ b/samples/microkernel/test/test_tickless/src/timestamps.c
@@ -82,14 +82,14 @@ 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 */
+{
+ /* QEMU does not currently support the 32-bit timer modes of the GPTM */
printk("WARNING! Timestamp is not supported for this target!\n");
- /* enable timer access */
+ /* enable timer access */
_CLKGATECTRL |= _CLKGATECTRL_TIMESTAMP_EN;
- /* minimum 3 clk delay is required before timer register access */
+ /* minimum 3 clk delay is required before timer register access */
task_sleep(3);
_TIMESTAMP_CTRL = 0x0; /* disable/reset timer */
@@ -100,7 +100,7 @@ void _TimestampOpen(void)
_TIMESTAMP_ICLEAR = 0x70F; /* clear all interrupt status */
_TIMESTAMP_CTRL = 0x1; /* enable timer */
- }
+}
/*******************************************************************************
*
@@ -114,30 +114,30 @@ void _TimestampOpen(void)
*/
uint32_t _TimestampRead(void)
- {
+{
static uint32_t lastTimerVal = 0;
static uint32_t cnt = 0;
uint32_t timerVal = _TIMESTAMP_VAL;
- /* handle rollover for every other read (end of sleep) */
+ /* handle rollover for every other read (end of sleep) */
if ((cnt % 2) && (timerVal > lastTimerVal)) {
- lastTimerVal = timerVal;
+ lastTimerVal = timerVal;
- /* convert to extended up-counter value */
- timerVal = _TIMESTAMP_EXT + (_TIMESTAMP_MAX - timerVal);
+ /* convert to extended up-counter value */
+ timerVal = _TIMESTAMP_EXT + (_TIMESTAMP_MAX - timerVal);
}
else {
- lastTimerVal = timerVal;
+ lastTimerVal = timerVal;
- /* convert to up-counter value */
- timerVal = _TIMESTAMP_MAX - timerVal;
+ /* convert to up-counter value */
+ timerVal = _TIMESTAMP_MAX - timerVal;
}
cnt++;
return timerVal;
- }
+}
/*******************************************************************************
*
@@ -151,15 +151,15 @@ uint32_t _TimestampRead(void)
*/
void _TimestampClose(void)
- {
+{
- /* disable/reset timer */
+ /* disable/reset timer */
_TIMESTAMP_CTRL = 0x0;
_TIMESTAMP_CFG = 0x0;
- /* disable timer access */
+ /* disable timer access */
_CLKGATECTRL &= ~_CLKGATECTRL_TIMESTAMP_EN;
- }
+}
#elif defined(CONFIG_BSP_FSL_FRDM_K64F)
/* Freescale FRDM-K64F target - use RTC (prescale value) */
@@ -198,11 +198,11 @@ void _TimestampClose(void)
*/
void _TimestampOpen(void)
- {
- /* enable timer access */
+{
+ /* enable timer access */
_CLKGATECTRL |= _CLKGATECTRL_TIMESTAMP_EN;
- /* set 32 KHz RTC clk */
+ /* set 32 KHz RTC clk */
_SYSOPTCTRL2 |= _SYSOPTCTRL2_32KHZRTCCLK;
_TIMESTAMP_STATUS = 0x0; /* disable counter */
@@ -215,13 +215,13 @@ void _TimestampOpen(void)
_TIMESTAMP_WACCESS = 0xFF; /* allow register write access */
_TIMESTAMP_IMASK = 0x0; /* mask all timer interrupts */
- /* minimum 0.3 sec delay required for oscillator stabilization */
+ /* minimum 0.3 sec delay required for oscillator stabilization */
task_sleep(300000/sys_clock_us_per_tick);
_TIMESTAMP_VAL = 0x0; /* clear invalid time flag in status register */
_TIMESTAMP_STATUS = 0x10; /* enable counter */
- }
+}
/*******************************************************************************
*
@@ -235,30 +235,30 @@ void _TimestampOpen(void)
*/
uint32_t _TimestampRead(void)
- {
+{
static uint32_t lastPrescale = 0;
static uint32_t cnt = 0;
uint32_t prescale1 = _TIMESTAMP_PRESCALE;
uint32_t prescale2 = _TIMESTAMP_PRESCALE;
- /* ensure a valid reading */
+ /* ensure a valid reading */
while (prescale1 != prescale2) {
prescale1 = _TIMESTAMP_PRESCALE;
prescale2 = _TIMESTAMP_PRESCALE;
- }
+ }
- /* handle prescale rollover @ 0x8000 for every other read (end of sleep) */
+ /* handle prescale rollover @ 0x8000 for every other read (end of sleep) */
if ((cnt % 2) && (prescale1 < lastPrescale)) {
prescale1 += 0x8000;
- }
+ }
lastPrescale = prescale2;
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"
diff --git a/samples/microkernel/test/test_timer/src/timer.c b/samples/microkernel/test/test_timer/src/timer.c
index a50525d63..826cbd759 100644
--- a/samples/microkernel/test/test_timer/src/timer.c
+++ b/samples/microkernel/test/test_timer/src/timer.c
@@ -128,7 +128,7 @@ int testLowTimerPeriodicity(void)
}
(void) task_tick_delta_32(&refTime);
- /* Use task_timer_restart() to change the periodicity */
+ /* Use task_timer_restart() to change the periodicity */
task_timer_restart(pTimer[0], 0, 60);
for (i = 0; i < 6; i++) {
status = task_sem_take_wait_timeout(TIMER_SEM, 100);
diff --git a/samples/microkernel/test/test_xip/src/test_xip.c b/samples/microkernel/test/test_xip/src/test_xip.c
index ae98e71ea..f90dd380d 100644
--- a/samples/microkernel/test/test_xip/src/test_xip.c
+++ b/samples/microkernel/test/test_xip/src/test_xip.c
@@ -66,27 +66,27 @@ void main(void)
void RegressionTaskEntry(void)
#endif
- {
+{
int tcRC = TC_PASS;
int i;
PRINT_DATA("Starting XIP tests\n");
PRINT_LINE;
- /* Test globals are correct */
+ /* Test globals are correct */
TC_PRINT("Test globals\n");
- /* Array should be filled with monotomically incrementing values */
+ /* Array should be filled with monotomically incrementing values */
for (i = 0; i < XIP_TEST_ARRAY_SZ; i++) {
- if (xip_array[i] != (i+1)) {
- TC_PRINT("xip_array[%d] != %d\n", i, i+1);
- tcRC = TC_FAIL;
- goto exitRtn;
- }
+ if (xip_array[i] != (i+1)) {
+ TC_PRINT("xip_array[%d] != %d\n", i, i+1);
+ tcRC = TC_FAIL;
+ goto exitRtn;
+ }
}
exitRtn:
TC_END_RESULT(tcRC);
TC_END_REPORT(tcRC);
- }
+}
diff --git a/samples/nanokernel/benchmark/footprint/src/nanokernel_footprint.c b/samples/nanokernel/benchmark/footprint/src/nanokernel_footprint.c
index fbfa1279a..4bdc38bef 100644
--- a/samples/nanokernel/benchmark/footprint/src/nanokernel_footprint.c
+++ b/samples/nanokernel/benchmark/footprint/src/nanokernel_footprint.c
@@ -87,24 +87,24 @@ static char pStack[FIBER_STACK_SIZE];
/* pointer array ensures specified functions are linked into the image */
volatile pfunc func_array[] = {
- /* nano timer functions */
+ /* nano timer functions */
(pfunc)nano_timer_init,
(pfunc)nano_fiber_timer_start,
(pfunc)nano_fiber_timer_wait,
- /* nano semaphore functions */
+ /* nano semaphore functions */
(pfunc)nano_sem_init,
(pfunc)nano_fiber_sem_take_wait,
(pfunc)nano_fiber_sem_give,
#ifdef TEST_max
- /* nano LIFO functions */
+ /* nano LIFO functions */
(pfunc)nano_lifo_init,
(pfunc)nano_fiber_lifo_put,
(pfunc)nano_fiber_lifo_get,
- /* nano stack functions */
+ /* nano stack functions */
(pfunc)nano_stack_init,
(pfunc)nano_fiber_stack_push,
(pfunc)nano_fiber_stack_pop,
- /* nano FIFO functions */
+ /* nano FIFO functions */
(pfunc)nano_fifo_init,
(pfunc)nano_fiber_fifo_put,
(pfunc)nano_fiber_fifo_get,
@@ -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,19 +179,19 @@ static void fiberEntry
*/
void main(void)
- {
+{
#ifdef TEST_max
- /* dynamically link in dummy ISR */
+ /* dynamically link in dummy ISR */
irq_connect(NANO_SOFT_IRQ, IRQ_PRIORITY, dummyIsr,
- (void *) 0, isrDummyHandlerStub);
+ (void *) 0, isrDummyHandlerStub);
#endif /* TEST_max */
#ifndef TEST_min
- /* start a trivial fiber */
+ /* start a trivial fiber */
task_fiber_start(pStack, FIBER_STACK_SIZE, fiberEntry, (int) MESSAGE,
- (int) func_array, 10, 0);
+ (int) func_array, 10, 0);
#endif /* !TEST_min */
while (1) {
- i++;
- }
+ i++;
}
+}
diff --git a/samples/nanokernel/benchmark/footprint/src/test_asm_inline_gcc.h b/samples/nanokernel/benchmark/footprint/src/test_asm_inline_gcc.h
index 427e32051..83570103f 100644
--- a/samples/nanokernel/benchmark/footprint/src/test_asm_inline_gcc.h
+++ b/samples/nanokernel/benchmark/footprint/src/test_asm_inline_gcc.h
@@ -42,7 +42,7 @@ static inline void isr_dummy(void)
extern void _IntEnt(void);
extern void _IntExit(void);
- /* compiler-generated preamble pushes & modifies EBP */
+ /* compiler-generated preamble pushes & modifies EBP */
__asm__ volatile (
"pop %%ebp;\n\t"
"call _IntEnt;\n\t"
diff --git a/samples/nanokernel/benchmark/sys_kernel/src/lifo.c b/samples/nanokernel/benchmark/sys_kernel/src/lifo.c
index 09ca249e4..12af810eb 100644
--- a/samples/nanokernel/benchmark/sys_kernel/src/lifo.c
+++ b/samples/nanokernel/benchmark/sys_kernel/src/lifo.c
@@ -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];
@@ -75,84 +75,89 @@ void lifo_fiber1(
ARG_UNUSED(par1);
for (i = 0; i < par2 / 2; i++) {
- pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo1);
- 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)
- break;
- element_b[1] = 2 * i + 1;
- nano_fiber_lifo_put(&nanoLifo2, element_b);
+ pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo1);
+ 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) {
+ break;
+ }
+ element_b[1] = 2 * i + 1;
+ nano_fiber_lifo_put(&nanoLifo2, element_b);
}
- /* wait till it is safe to end: */
+ /* 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;
int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) {
- element[1] = i;
- nano_fiber_lifo_put(&nanoLifo1, element);
- pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo2);
- if (pelement[1] != i)
- break;
- (*pcounter)++;
+ element[1] = i;
+ nano_fiber_lifo_put(&nanoLifo1, element);
+ pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo2);
+ if (pelement[1] != i) {
+ break;
+ }
+ (*pcounter)++;
}
- /* wait till it is safe to end: */
+ /* 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;
int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) {
- element[1] = i;
- nano_fiber_lifo_put(&nanoLifo1, element);
- while (NULL == (pelement = (int *) nano_fiber_lifo_get(&nanoLifo2)))
- fiber_yield();
- if (pelement[1] != i)
- break;
- (*pcounter)++;
+ element[1] = i;
+ nano_fiber_lifo_put(&nanoLifo1, element);
+ while (NULL == (pelement = (int *) nano_fiber_lifo_get(&nanoLifo2))) {
+ fiber_yield();
+ }
+ if (pelement[1] != i) {
+ break;
+ }
+ (*pcounter)++;
}
- /* wait till it is safe to end: */
+ /* 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;
@@ -173,12 +178,12 @@ int lifo_test(void)
nano_fifo_init(&nanoFifo_sync);
- /* test get wait & put fiber functions */
+ /* test get wait & put fiber functions */
fprintf(output_file, sz_test_case_fmt,
- "LIFO channel - 'nano_fiber_lifo_get_wait'");
+ "LIFO channel - 'nano_fiber_lifo_get_wait'");
fprintf(output_file, sz_description,
- "testing 'nano_lifo_init','nano_fiber_lifo_get_wait',"
- " 'nano_fiber_lifo_put' functions;");
+ "testing 'nano_lifo_init','nano_fiber_lifo_get_wait',"
+ " 'nano_fiber_lifo_put' functions;");
printf(sz_test_start_fmt, "'nano_fiber_lifo_get_wait'");
lifo_test_init();
@@ -186,26 +191,27 @@ int lifo_test(void)
t = BENCH_START();
task_fiber_start(fiber_stack1, STACK_SIZE, lifo_fiber1, 0,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
task_fiber_start(fiber_stack2, STACK_SIZE, lifo_fiber2, (int) &i,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
t = TIME_STAMP_DELTA_GET(t);
return_value += check_result(i, t);
- /* fiber contexts have done their job, they can stop now safely: */
- for (j = 0; j < 2; j++)
- nano_task_fifo_put(&nanoFifo_sync, (void *) element);
+ /* fiber contexts have done their job, they can stop now safely: */
+ for (j = 0; j < 2; j++) {
+ nano_task_fifo_put(&nanoFifo_sync, (void *) element);
+ }
- /* test get/yield & put fiber functions */
+ /* test get/yield & put fiber functions */
fprintf(output_file, sz_test_case_fmt,
- "LIFO channel - 'nano_fiber_lifo_get'");
+ "LIFO channel - 'nano_fiber_lifo_get'");
fprintf(output_file, sz_description,
- "testing 'nano_lifo_init','nano_fiber_lifo_get_wait',"
- " 'nano_fiber_lifo_get',\n");
+ "testing 'nano_lifo_init','nano_fiber_lifo_get_wait',"
+ " 'nano_fiber_lifo_get',\n");
fprintf(output_file,
- "\t'nano_fiber_lifo_put', 'fiber_yield' functions;");
+ "\t'nano_fiber_lifo_put', 'fiber_yield' functions;");
printf(sz_test_start_fmt, "'nano_fiber_lifo_get'");
lifo_test_init();
@@ -214,24 +220,25 @@ int lifo_test(void)
i = 0;
task_fiber_start(fiber_stack1, STACK_SIZE, lifo_fiber1, 0,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
task_fiber_start(fiber_stack2, STACK_SIZE, lifo_fiber3, (int) &i,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
t = TIME_STAMP_DELTA_GET(t);
return_value += check_result(i, t);
- /* fiber contexts have done their job, they can stop now safely: */
- for (j = 0; j < 2; j++)
- nano_task_fifo_put(&nanoFifo_sync, (void *) element);
+ /* fiber contexts have done their job, they can stop now safely: */
+ for (j = 0; j < 2; j++) {
+ nano_task_fifo_put(&nanoFifo_sync, (void *) element);
+ }
- /* test get wait & put fiber/task functions */
+ /* test get wait & put fiber/task functions */
fprintf(output_file, sz_test_case_fmt,
- "LIFO channel - 'nano_task_lifo_get_wait'");
+ "LIFO channel - 'nano_task_lifo_get_wait'");
fprintf(output_file, sz_description,
- "testing 'nano_lifo_init','nano_fiber_lifo_get_wait',"
- " 'nano_fiber_lifo_put',\n");
+ "testing 'nano_lifo_init','nano_fiber_lifo_get_wait',"
+ " 'nano_fiber_lifo_put',\n");
fprintf(output_file, "\t'nano_task_lifo_get_wait', 'nano_task_lifo_put' functions;");
printf(sz_test_start_fmt, "'nano_task_lifo_get_wait'");
@@ -240,30 +247,33 @@ int lifo_test(void)
t = BENCH_START();
task_fiber_start(fiber_stack1, STACK_SIZE, lifo_fiber1, 0,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) {
- int element[2];
- int * pelement;
- element[1] = 2 * i;
- nano_task_lifo_put(&nanoLifo1, element);
- element[1] = 2 * i + 1;
- nano_task_lifo_put(&nanoLifo1, element);
-
- pelement = (int *) nano_task_lifo_get_wait(&nanoLifo2);
- if (pelement[1] != 2 * i + 1)
- break;
- pelement = (int *) nano_task_lifo_get_wait(&nanoLifo2);
- if (pelement[1] != 2 * i)
- break;
+ int element[2];
+ int * pelement;
+ element[1] = 2 * i;
+ nano_task_lifo_put(&nanoLifo1, element);
+ element[1] = 2 * i + 1;
+ nano_task_lifo_put(&nanoLifo1, element);
+
+ pelement = (int *) nano_task_lifo_get_wait(&nanoLifo2);
+ if (pelement[1] != 2 * i + 1) {
+ break;
+ }
+ pelement = (int *) nano_task_lifo_get_wait(&nanoLifo2);
+ 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++)
- nano_task_fifo_put(&nanoFifo_sync, (void *) element);
+ /* fiber contexts have done their job, they can stop now safely: */
+ for (j = 0; j < 2; j++) {
+ nano_task_fifo_put(&nanoFifo_sync, (void *) element);
+ }
return return_value;
- }
+}
diff --git a/samples/nanokernel/benchmark/sys_kernel/src/mwfifo.c b/samples/nanokernel/benchmark/sys_kernel/src/mwfifo.c
index 86738ad48..5122fffb2 100644
--- a/samples/nanokernel/benchmark/sys_kernel/src/mwfifo.c
+++ b/samples/nanokernel/benchmark/sys_kernel/src/mwfifo.c
@@ -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,29 +60,30 @@ 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;
ARG_UNUSED(par1);
for (i = 0; i < par2; i++) {
- pelement = (int *) nano_fiber_fifo_get_wait(&nanoFifo1);
- if (pelement[1] != i)
- break;
- element[1] = i;
- nano_fiber_fifo_put(&nanoFifo2, element);
+ pelement = (int *) nano_fiber_fifo_get_wait(&nanoFifo1);
+ if (pelement[1] != i) {
+ break;
+ }
+ element[1] = i;
+ nano_fiber_fifo_put(&nanoFifo2, element);
}
- /* wait till it is safe to end: */
+ /* wait till it is safe to end: */
nano_fiber_fifo_get_wait(&nanoFifo_sync);
- }
+}
/*******************************************************************************
@@ -91,30 +92,31 @@ 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;
int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) {
- element[1] = i;
- nano_fiber_fifo_put(&nanoFifo1, element);
- pelement = (int *) nano_fiber_fifo_get_wait(&nanoFifo2);
- if (pelement[1] != i)
- break;
- (*pcounter)++;
+ element[1] = i;
+ nano_fiber_fifo_put(&nanoFifo1, element);
+ pelement = (int *) nano_fiber_fifo_get_wait(&nanoFifo2);
+ if (pelement[1] != i) {
+ break;
+ }
+ (*pcounter)++;
}
- /* wait till it is safe to end: */
+ /* wait till it is safe to end: */
nano_fiber_fifo_get_wait(&nanoFifo_sync);
- }
+}
/*******************************************************************************
@@ -123,31 +125,33 @@ 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;
int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) {
- element[1] = i;
- nano_fiber_fifo_put(&nanoFifo1, element);
- while (NULL == (pelement = (int *) nano_fiber_fifo_get(&nanoFifo2)))
- fiber_yield();
- if (pelement[1] != i)
- break;
- (*pcounter)++;
+ element[1] = i;
+ nano_fiber_fifo_put(&nanoFifo1, element);
+ while (NULL == (pelement = (int *) nano_fiber_fifo_get(&nanoFifo2))) {
+ fiber_yield();
+ }
+ if (pelement[1] != i) {
+ break;
+ }
+ (*pcounter)++;
}
- /* wait till it is safe to end: */
+ /* 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;
@@ -169,12 +173,12 @@ int fifo_test(void)
nano_fifo_init(&nanoFifo_sync);
- /* test get wait & put fiber functions */
+ /* test get wait & put fiber functions */
fprintf(output_file, sz_test_case_fmt,
- "FIFO channel - 'nano_fiber_fifo_get_wait'");
+ "FIFO channel - 'nano_fiber_fifo_get_wait'");
fprintf(output_file, sz_description,
- "testing 'nano_fifo_init','nano_fiber_fifo_get_wait',"
- " 'nano_fiber_fifo_put' functions;");
+ "testing 'nano_fifo_init','nano_fiber_fifo_get_wait',"
+ " 'nano_fiber_fifo_put' functions;");
printf(sz_test_start_fmt, "'nano_fiber_fifo_get_wait'");
fifo_test_init();
@@ -182,26 +186,27 @@ int fifo_test(void)
t = BENCH_START();
task_fiber_start(fiber_stack1, STACK_SIZE, fifo_fiber1, 0,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
task_fiber_start(fiber_stack2, STACK_SIZE, fifo_fiber2, (int) &i,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
t = TIME_STAMP_DELTA_GET(t);
return_value += check_result(i, t);
- /* fiber contexts have done their job, they can stop now safely: */
- for (j = 0; j < 2; j++)
- nano_task_fifo_put(&nanoFifo_sync, (void *) element);
+ /* fiber contexts have done their job, they can stop now safely: */
+ for (j = 0; j < 2; j++) {
+ nano_task_fifo_put(&nanoFifo_sync, (void *) element);
+ }
- /* test get/yield & put fiber functions */
+ /* test get/yield & put fiber functions */
fprintf(output_file, sz_test_case_fmt,
- "FIFO channel - 'nano_fiber_fifo_get'");
+ "FIFO channel - 'nano_fiber_fifo_get'");
fprintf(output_file, sz_description,
- "testing 'nano_fifo_init','nano_fiber_fifo_get_wait',"
- " 'nano_fiber_fifo_get',\n");
+ "testing 'nano_fifo_init','nano_fiber_fifo_get_wait',"
+ " 'nano_fiber_fifo_get',\n");
fprintf(output_file,
- "\t'nano_fiber_fifo_put', 'fiber_yield' functions;");
+ "\t'nano_fiber_fifo_put', 'fiber_yield' functions;");
printf(sz_test_start_fmt, "'nano_fiber_fifo_get'");
fifo_test_init();
@@ -210,26 +215,27 @@ int fifo_test(void)
i = 0;
task_fiber_start(fiber_stack1, STACK_SIZE, fifo_fiber1, 0,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
task_fiber_start(fiber_stack2, STACK_SIZE, fifo_fiber3, (int) &i,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
t = TIME_STAMP_DELTA_GET(t);
return_value += check_result(i, t);
- /* fiber contexts have done their job, they can stop now safely: */
- for (j = 0; j < 2; j++)
- nano_task_fifo_put(&nanoFifo_sync, (void *) element);
+ /* fiber contexts have done their job, they can stop now safely: */
+ for (j = 0; j < 2; j++) {
+ nano_task_fifo_put(&nanoFifo_sync, (void *) element);
+ }
- /* test get wait & put fiber/task functions */
+ /* test get wait & put fiber/task functions */
fprintf(output_file, sz_test_case_fmt,
- "FIFO channel - 'nano_task_fifo_get_wait'");
+ "FIFO channel - 'nano_task_fifo_get_wait'");
fprintf(output_file, sz_description,
- "testing 'nano_fifo_init','nano_fiber_fifo_get_wait',"
- " 'nano_fiber_fifo_put',\n");
+ "testing 'nano_fifo_init','nano_fiber_fifo_get_wait',"
+ " 'nano_fiber_fifo_put',\n");
fprintf(output_file,
- "\t'nano_task_fifo_get_wait', 'nano_task_fifo_put' functions;");
+ "\t'nano_task_fifo_get_wait', 'nano_task_fifo_put' functions;");
printf(sz_test_start_fmt, "'nano_task_fifo_get_wait'");
fifo_test_init();
@@ -237,31 +243,34 @@ int fifo_test(void)
t = BENCH_START();
task_fiber_start(fiber_stack1, STACK_SIZE, fifo_fiber1, 0,
- NUMBER_OF_LOOPS / 2, 3, 0);
+ NUMBER_OF_LOOPS / 2, 3, 0);
task_fiber_start(fiber_stack2, STACK_SIZE, fifo_fiber1, 0,
- NUMBER_OF_LOOPS / 2, 3, 0);
+ NUMBER_OF_LOOPS / 2, 3, 0);
for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) {
- int element[2];
- int * pelement;
- element[1] = i;
- nano_task_fifo_put(&nanoFifo1, element);
- element[1] = i;
- nano_task_fifo_put(&nanoFifo1, element);
-
- pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2);
- if (pelement[1] != i)
- break;
- pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2);
- if (pelement[1] != i)
- break;
+ int element[2];
+ int * pelement;
+ element[1] = i;
+ nano_task_fifo_put(&nanoFifo1, element);
+ element[1] = i;
+ nano_task_fifo_put(&nanoFifo1, element);
+
+ pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2);
+ if (pelement[1] != i) {
+ break;
+ }
+ pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2);
+ 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++)
- nano_task_fifo_put(&nanoFifo_sync, (void *) element);
+ /* fiber contexts have done their job, they can stop now safely: */
+ for (j = 0; j < 2; j++) {
+ nano_task_fifo_put(&nanoFifo_sync, (void *) element);
+ }
return return_value;
- }
+}
diff --git a/samples/nanokernel/benchmark/sys_kernel/src/sema.c b/samples/nanokernel/benchmark/sys_kernel/src/sema.c
index 9d8093365..6047073e7 100644
--- a/samples/nanokernel/benchmark/sys_kernel/src/sema.c
+++ b/samples/nanokernel/benchmark/sys_kernel/src/sema.c
@@ -45,85 +45,86 @@ 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);
for (i = 0; i < par2; i++) {
- nano_fiber_sem_take_wait(&nanoSem1);
- nano_fiber_sem_give(&nanoSem2);
- }
+ 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;
for (i = 0; i < par2; i++) {
- nano_fiber_sem_give(&nanoSem1);
- nano_fiber_sem_take_wait(&nanoSem2);
- (*pcounter)++;
- }
+ nano_fiber_sem_give(&nanoSem1);
+ 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))
- fiber_yield();
- (*pcounter)++;
- }
+ nano_fiber_sem_give(&nanoSem1);
+ while (!nano_fiber_sem_take(&nanoSem2)) {
+ fiber_yield();
+ }
+ (*pcounter)++;
}
+}
/*******************************************************************************
@@ -136,16 +137,16 @@ void sema_fiber3(
*/
int sema_test(void)
- {
+{
uint32_t t;
int i = 0;
int return_value = 0;
fprintf(output_file, sz_test_case_fmt,
- "Semaphore channel - 'nano_fiber_sem_take_wait'");
+ "Semaphore channel - 'nano_fiber_sem_take_wait'");
fprintf(output_file, sz_description,
- "testing 'nano_sem_init','nano_fiber_sem_take_wait',"
- " 'nano_fiber_sem_give' functions;");
+ "testing 'nano_sem_init','nano_fiber_sem_take_wait',"
+ " 'nano_fiber_sem_give' functions;");
printf(sz_test_start_fmt, "'nano_fiber_sem_take_wait'");
sema_test_init();
@@ -153,18 +154,18 @@ int sema_test(void)
t = BENCH_START();
task_fiber_start(fiber_stack1, STACK_SIZE, sema_fiber1, 0,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
task_fiber_start(fiber_stack2, STACK_SIZE, sema_fiber2, (int) &i,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
t = TIME_STAMP_DELTA_GET(t);
return_value += check_result(i, t);
fprintf(output_file, sz_test_case_fmt,
- "Semaphore channel - 'nano_fiber_sem_take'");
+ "Semaphore channel - 'nano_fiber_sem_take'");
fprintf(output_file, sz_description,
- "testing 'nano_sem_init','nano_fiber_sem_take', 'fiber_yield',\n");
+ "testing 'nano_sem_init','nano_fiber_sem_take', 'fiber_yield',\n");
fprintf(output_file, "\t'nano_fiber_sem_give' functions;");
printf(sz_test_start_fmt, "'nano_fiber_sem_take'");
@@ -174,21 +175,21 @@ int sema_test(void)
t = BENCH_START();
task_fiber_start(fiber_stack1, STACK_SIZE, sema_fiber1, 0,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
task_fiber_start(fiber_stack2, STACK_SIZE, sema_fiber3, (int) &i,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
t = TIME_STAMP_DELTA_GET(t);
return_value += check_result(i, t);
fprintf(output_file, sz_test_case_fmt,
- "Semaphore channel - 'nano_task_sem_take_wait'");
+ "Semaphore channel - 'nano_task_sem_take_wait'");
fprintf(output_file, sz_description,
- "testing 'nano_sem_init','nano_fiber_sem_take_wait',"
- " 'nano_fiber_sem_give',\n");
+ "testing 'nano_sem_init','nano_fiber_sem_take_wait',"
+ " 'nano_fiber_sem_give',\n");
fprintf(output_file,
- "\t'nano_task_sem_give', 'nano_task_sem_take_wait' functions;");
+ "\t'nano_task_sem_give', 'nano_task_sem_take_wait' functions;");
printf(sz_test_start_fmt, "'nano_task_sem_take_wait'");
sema_test_init();
@@ -196,10 +197,10 @@ int sema_test(void)
t = BENCH_START();
task_fiber_start(fiber_stack1, STACK_SIZE, sema_fiber1, 0,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
for (i = 0; i < NUMBER_OF_LOOPS; i++) {
- nano_task_sem_give(&nanoSem1);
- nano_task_sem_take_wait(&nanoSem2);
+ nano_task_sem_give(&nanoSem1);
+ nano_task_sem_take_wait(&nanoSem2);
}
t = TIME_STAMP_DELTA_GET(t);
@@ -207,4 +208,4 @@ int sema_test(void)
return_value += check_result(i, t);
return return_value;
- }
+}
diff --git a/samples/nanokernel/benchmark/sys_kernel/src/stack.c b/samples/nanokernel/benchmark/sys_kernel/src/stack.c
index 4fa89d5db..ea13e2440 100644
--- a/samples/nanokernel/benchmark/sys_kernel/src/stack.c
+++ b/samples/nanokernel/benchmark/sys_kernel/src/stack.c
@@ -48,104 +48,109 @@ 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;
ARG_UNUSED(par1);
for (i = 0; i < par2 / 2; i++) {
- data = nano_fiber_stack_pop_wait(&nanoChannel1);
- 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)
- break;
- data = 2 * i + 1;
- nano_fiber_stack_push(&nanoChannel2, data);
- }
+ data = nano_fiber_stack_pop_wait(&nanoChannel1);
+ 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) {
+ 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;
for (i = 0; i < par2; i++) {
- data = i;
- nano_fiber_stack_push(&nanoChannel1, data);
- data = nano_fiber_stack_pop_wait(&nanoChannel2);
- if (data != i)
- break;
- (*pcounter)++;
- }
+ data = i;
+ nano_fiber_stack_push(&nanoChannel1, data);
+ data = nano_fiber_stack_pop_wait(&nanoChannel2);
+ 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;
for (i = 0; i < par2; i++) {
- data = i;
- nano_fiber_stack_push(&nanoChannel1, data);
- data = 0xffffffff;
- while (!nano_fiber_stack_pop(&nanoChannel2, &data))
- fiber_yield();
- if (data != i)
- break;
- (*pcounter)++;
- }
+ data = i;
+ nano_fiber_stack_push(&nanoChannel1, data);
+ data = 0xffffffff;
+ while (!nano_fiber_stack_pop(&nanoChannel2, &data)) {
+ fiber_yield();
+ }
+ if (data != i) {
+ break;
+ }
+ (*pcounter)++;
}
+}
/*******************************************************************************
@@ -158,17 +163,17 @@ void stack_fiber3(
*/
int stack_test(void)
- {
+{
uint32_t t;
int i = 0;
int return_value = 0;
- /* test get wait & put fiber functions */
+ /* test get wait & put fiber functions */
fprintf(output_file, sz_test_case_fmt,
- "Stack channel - 'nano_fiber_stack_pop_wait'");
+ "Stack channel - 'nano_fiber_stack_pop_wait'");
fprintf(output_file, sz_description,
- "testing 'nano_stack_init','nano_fiber_stack_pop_wait',"
- " 'nano_fiber_stack_push' functions;");
+ "testing 'nano_stack_init','nano_fiber_stack_pop_wait',"
+ " 'nano_fiber_stack_push' functions;");
printf(sz_test_start_fmt, "'nano_fiber_stack_pop_wait'");
stack_test_init();
@@ -176,22 +181,22 @@ int stack_test(void)
t = BENCH_START();
task_fiber_start(fiber_stack1, STACK_SIZE, stack_fiber1, 0,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
task_fiber_start(fiber_stack2, STACK_SIZE, stack_fiber2, (int) &i,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
t = TIME_STAMP_DELTA_GET(t);
return_value += check_result(i, t);
- /* test get/yield & put fiber functions */
+ /* test get/yield & put fiber functions */
fprintf(output_file, sz_test_case_fmt,
- "Stack channel - 'nano_fiber_stack_pop'");
+ "Stack channel - 'nano_fiber_stack_pop'");
fprintf(output_file, sz_description,
- "testing 'nano_stack_init','nano_fiber_stack_pop_wait',"
- " 'nano_fiber_stack_pop',\n");
+ "testing 'nano_stack_init','nano_fiber_stack_pop_wait',"
+ " 'nano_fiber_stack_pop',\n");
fprintf(output_file,
- "\t'nano_fiber_stack_push', 'fiber_yield' functions;");
+ "\t'nano_fiber_stack_push', 'fiber_yield' functions;");
printf(sz_test_start_fmt, "'nano_fiber_stack_pop'");
stack_test_init();
@@ -200,22 +205,22 @@ int stack_test(void)
i = 0;
task_fiber_start(fiber_stack1, STACK_SIZE, stack_fiber1, 0,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
task_fiber_start(fiber_stack2, STACK_SIZE, stack_fiber3, (int) &i,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
t = TIME_STAMP_DELTA_GET(t);
return_value += check_result(i, t);
- /* test get wait & put fiber/task functions */
+ /* test get wait & put fiber/task functions */
fprintf(output_file, sz_test_case_fmt,
- "Stack channel - 'nano_task_stack_pop_wait'");
+ "Stack channel - 'nano_task_stack_pop_wait'");
fprintf(output_file, sz_description,
- "testing 'nano_stack_init','nano_fiber_stack_pop_wait',"
- " 'nano_fiber_stack_push',\n");
+ "testing 'nano_stack_init','nano_fiber_stack_pop_wait',"
+ " 'nano_fiber_stack_push',\n");
fprintf(output_file,
- "\t'nano_task_stack_pop_wait', 'nano_task_stack_push' functions;");
+ "\t'nano_task_stack_pop_wait', 'nano_task_stack_push' functions;");
printf(sz_test_start_fmt, "'nano_task_stack_pop_wait'");
stack_test_init();
@@ -223,20 +228,22 @@ int stack_test(void)
t = BENCH_START();
task_fiber_start(fiber_stack1, STACK_SIZE, stack_fiber1, 0,
- NUMBER_OF_LOOPS, 3, 0);
+ NUMBER_OF_LOOPS, 3, 0);
for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) {
- uint32_t data;
- data = 2 * i;
- nano_task_stack_push(&nanoChannel1, data);
- data = 2 * i + 1;
- nano_task_stack_push(&nanoChannel1, data);
-
- data = nano_task_stack_pop_wait(&nanoChannel2);
- if (data != 2 * i + 1)
- break;
- data = nano_task_stack_pop_wait(&nanoChannel2);
- if (data != 2 * i)
- break;
+ uint32_t data;
+ data = 2 * i;
+ nano_task_stack_push(&nanoChannel1, data);
+ data = 2 * i + 1;
+ nano_task_stack_push(&nanoChannel1, data);
+
+ data = nano_task_stack_pop_wait(&nanoChannel2);
+ if (data != 2 * i + 1) {
+ break;
+ }
+ data = nano_task_stack_pop_wait(&nanoChannel2);
+ if (data != 2 * i) {
+ break;
+ }
}
t = TIME_STAMP_DELTA_GET(t);
@@ -244,4 +251,4 @@ int stack_test(void)
return_value += check_result(i * 2, t);
return return_value;
- }
+}
diff --git a/samples/nanokernel/benchmark/sys_kernel/src/syskernel.c b/samples/nanokernel/benchmark/sys_kernel/src/syskernel.c
index aff016126..ffd7beea8 100644
--- a/samples/nanokernel/benchmark/sys_kernel/src/syskernel.c
+++ b/samples/nanokernel/benchmark/sys_kernel/src/syskernel.c
@@ -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,41 +101,41 @@ 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 */
- )
- {
- /*
- bench_test_end checks tCheck static variable.
- bench_test_start modifies it
- */
+int check_result(int i, uint32_t t)
+{
+ /*
+ * 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);
- fprintf(output_file, sz_case_details_fmt,
- "timer tick happened. Results are inaccurate");
- fprintf(output_file, sz_case_end_fmt);
- return 0;
+ fprintf(output_file, sz_case_result_fmt, sz_fail);
+ fprintf(output_file, sz_case_details_fmt,
+ "timer tick happened. Results are inaccurate");
+ fprintf(output_file, sz_case_end_fmt);
+ return 0;
}
if (i != NUMBER_OF_LOOPS) {
- fprintf(output_file, sz_case_result_fmt, sz_fail);
- fprintf(output_file, sz_case_details_fmt, "loop counter = ");
- fprintf(output_file, "%i !!!", i);
- fprintf(output_file, sz_case_end_fmt);
- return 0;
+ fprintf(output_file, sz_case_result_fmt, sz_fail);
+ fprintf(output_file, sz_case_details_fmt, "loop counter = ");
+ fprintf(output_file, "%i !!!", i);
+ fprintf(output_file, sz_case_end_fmt);
+ return 0;
}
fprintf(output_file, sz_case_result_fmt, sz_success);
fprintf(output_file, sz_case_details_fmt,
- "Average time for 1 iteration: ");
+ "Average time for 1 iteration: ");
fprintf(output_file, sz_case_timing_fmt,
- SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, NUMBER_OF_LOOPS));
+ SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, NUMBER_OF_LOOPS));
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
- */
+ /*
+ * 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;
@@ -210,31 +210,33 @@ void main(void)
bench_test_init();
do {
- fprintf(output_file, sz_module_title_fmt, "Nanokernel API test");
- fprintf(output_file, sz_kernel_ver_fmt, kernel_version_get());
- fprintf(output_file,
- "\n\nEach test below are repeated %d times and the average\n"
- "time for one iteration is displayed.", NUMBER_OF_LOOPS);
-
- test_result = 0;
-
- test_result += sema_test();
- test_result += lifo_test();
- test_result += fifo_test();
- test_result += stack_test();
-
- if (test_result) {
- /* sema, lifo, fifo, stack account for twelve tests in total */
- if (test_result == 12)
- fprintf(output_file, sz_module_result_fmt, sz_success);
- else
- fprintf(output_file, sz_module_result_fmt, sz_partial);
- }
- else
- fprintf(output_file, sz_module_result_fmt, sz_fail);
-
- }
- while (continuously && !kbhit());
+ fprintf(output_file, sz_module_title_fmt, "Nanokernel API test");
+ fprintf(output_file, sz_kernel_ver_fmt, kernel_version_get());
+ fprintf(output_file,
+ "\n\nEach test below are repeated %d times and the average\n"
+ "time for one iteration is displayed.", NUMBER_OF_LOOPS);
+
+ test_result = 0;
+
+ test_result += sema_test();
+ test_result += lifo_test();
+ test_result += fifo_test();
+ test_result += stack_test();
+
+ if (test_result) {
+ /* sema, lifo, fifo, stack account for twelve tests in total */
+ if (test_result == 12) {
+ fprintf(output_file, sz_module_result_fmt, sz_success);
+ }
+ else {
+ fprintf(output_file, sz_module_result_fmt, sz_partial);
+ }
+ }
+ else {
+ fprintf(output_file, sz_module_result_fmt, sz_fail);
+ }
+
+ } while (continuously && !kbhit());
output_close();
- }
+}
diff --git a/samples/nanokernel/benchmark/sys_kernel/src/syskernel.h b/samples/nanokernel/benchmark/sys_kernel/src/syskernel.h
index 77431f162..051e53860 100644
--- a/samples/nanokernel/benchmark/sys_kernel/src/syskernel.h
+++ b/samples/nanokernel/benchmark/sys_kernel/src/syskernel.h
@@ -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 */
diff --git a/samples/nanokernel/test/test_arm_m3_irq_vector_table/src/main.c b/samples/nanokernel/test/test_arm_m3_irq_vector_table/src/main.c
index 5ba4ed6d5..7744fbf66 100644
--- a/samples/nanokernel/test/test_arm_m3_irq_vector_table/src/main.c
+++ b/samples/nanokernel/test/test_arm_m3_irq_vector_table/src/main.c
@@ -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,13 +101,13 @@ void isr2(void)
*/
void main(void)
- {
+{
TC_START("Test Cortex-M3 IRQ installed directly in vector table");
for (int ii = 0; ii < 3; ii++) {
- irq_enable(ii);
- irq_priority_set(ii, _EXC_IRQ_DEFAULT_PRIO);
- nano_sem_init(&sem[ii]);
+ irq_enable(ii);
+ irq_priority_set(ii, _EXC_IRQ_DEFAULT_PRIO);
+ nano_sem_init(&sem[ii]);
}
int rv;
@@ -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] = {
diff --git a/samples/nanokernel/test/test_context/src/context.c b/samples/nanokernel/test/test_context/src/context.c
index d472703b7..b6f8fee4c 100644
--- a/samples/nanokernel/test/test_context/src/context.c
+++ b/samples/nanokernel/test/test_context/src/context.c
@@ -96,9 +96,8 @@ typedef struct {
union {
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);
@@ -139,18 +138,18 @@ void isr_handler(void *data)
ARG_UNUSED(data);
switch (isrInfo.command) {
- case CTX_SELF_CMD:
- isrInfo.data = (void *) context_self_get();
- break;
+ case CTX_SELF_CMD:
+ isrInfo.data = (void *) context_self_get();
+ break;
- case CTX_TYPE_CMD:
- isrInfo.value = context_type_get();
- break;
+ case CTX_TYPE_CMD:
+ isrInfo.value = context_type_get();
+ break;
- default:
- isrInfo.error = UNKNOWN_COMMAND;
- break;
- }
+ default:
+ isrInfo.error = UNKNOWN_COMMAND;
+ break;
+ }
}
/* Cortex-M3 does not implement connecting non-IRQ exception handlers */
@@ -220,19 +219,19 @@ int nano_cpu_idleTest(void)
int tick; /* current tick count */
int i; /* loop variable */
- /* Align to a "tick boundary". */
+ /* Align to a "tick boundary". */
tick = nano_tick_get_32();
while (tick == nano_tick_get_32()) {
- }
+ }
tick = nano_tick_get_32();
for (i = 0; i < 5; i++) { /* Repeat the test five times */
nano_cpu_idle();
tick++;
if (nano_tick_get_32() != tick) {
- return TC_FAIL;
- }
+ return TC_FAIL;
}
+ }
return TC_PASS;
}
@@ -334,22 +333,22 @@ int nanoCpuDisableInterruptsTest(disable_interrupt_func disableRtn,
int tick2;
int imask;
- /* Align to a "tick boundary" */
+ /* Align to a "tick boundary" */
tick = nano_tick_get_32();
while (nano_tick_get_32() == tick) {
- }
+ }
tick++;
while (nano_tick_get_32() == tick) {
count++;
- }
+ }
- /*
- * Inflate <count> so that when we loop later, many ticks should have
- * elapsed during the loop. This later loop will not exactly match the
- * previous loop, but it should be close enough in structure that when
- * combined with the inflated count, many ticks will have passed.
- */
+ /*
+ * Inflate <count> so that when we loop later, many ticks should have
+ * elapsed during the loop. This later loop will not exactly match the
+ * previous loop, but it should be close enough in structure that when
+ * combined with the inflated count, many ticks will have passed.
+ */
count <<= 4;
@@ -357,25 +356,25 @@ int nanoCpuDisableInterruptsTest(disable_interrupt_func disableRtn,
tick = nano_tick_get_32();
for (i = 0; i < count; i++) {
nano_tick_get_32();
- }
+ }
tick2 = nano_tick_get_32();
- /*
- * Re-enable interrupts before returning (for both success and failure
- * cases).
- */
+ /*
+ * Re-enable interrupts before returning (for both success and failure
+ * cases).
+ */
enableRtn(imask);
if (tick2 != tick) {
return TC_FAIL;
- }
+ }
- /* Now repeat with interrupts unlocked. */
+ /* Now repeat with interrupts unlocked. */
for (i = 0; i < count; i++) {
nano_tick_get_32();
- }
+ }
return (tick == nano_tick_get_32()) ? TC_FAIL : TC_PASS;
}
@@ -401,12 +400,12 @@ int nanoCtxTaskTest(void)
isrInfo.error = 0;
_trigger_isrHandler();
if ((isrInfo.error != 0) || (isrInfo.data != (void *) ctxId)) {
- /*
- * Either the ISR detected an error, or the ISR context ID does not
- * match the interrupted task's context ID.
- */
+ /*
+ * Either the ISR detected an error, or the ISR context ID does not
+ * match the interrupted task's context ID.
+ */
return TC_FAIL;
- }
+ }
TC_PRINT("Testing context_type_get() from an ISR\n");
isrInfo.command = CTX_TYPE_CMD;
@@ -414,12 +413,12 @@ int nanoCtxTaskTest(void)
_trigger_isrHandler();
if ((isrInfo.error != 0) || (isrInfo.value != NANO_CTX_ISR)) {
return TC_FAIL;
- }
+ }
TC_PRINT("Testing context_type_get() from a task\n");
if (context_type_get() != NANO_CTX_TASK) {
return TC_FAIL;
- }
+ }
return TC_PASS;
}
@@ -449,19 +448,19 @@ int nanoCtxFiberTest(nano_context_id_t taskCtxId)
if (ctxId == taskCtxId) {
fiberDetectedError = 1;
return TC_FAIL;
- }
+ }
isrInfo.command = CTX_SELF_CMD;
isrInfo.error = 0;
_trigger_isrHandler();
if ((isrInfo.error != 0) || (isrInfo.data != (void *) ctxId)) {
- /*
- * Either the ISR detected an error, or the ISR context ID does not
- * match the interrupted fiber's context ID.
- */
+ /*
+ * Either the ISR detected an error, or the ISR context ID does not
+ * match the interrupted fiber's context ID.
+ */
fiberDetectedError = 2;
return TC_FAIL;
- }
+ }
isrInfo.command = CTX_TYPE_CMD;
isrInfo.error = 0;
@@ -469,12 +468,12 @@ int nanoCtxFiberTest(nano_context_id_t taskCtxId)
if ((isrInfo.error != 0) || (isrInfo.value != NANO_CTX_ISR)) {
fiberDetectedError = 3;
return TC_FAIL;
- }
+ }
if (context_type_get() != NANO_CTX_FIBER) {
fiberDetectedError = 4;
return TC_FAIL;
- }
+ }
return TC_PASS;
}
@@ -499,20 +498,20 @@ static void fiberHelper(int arg1, int arg2)
ARG_UNUSED(arg1);
ARG_UNUSED(arg2);
- /*
- * This fiber starts off at a higher priority than fiberEntry(). Thus, it
- * should execute immediately.
- */
+ /*
+ * This fiber starts off at a higher priority than fiberEntry(). Thus, it
+ * should execute immediately.
+ */
fiberEvidence++;
- /* Test that helper will yield to a fiber of equal priority */
+ /* Test that helper will yield to a fiber of equal priority */
ctxId = context_self_get();
ctxId->prio++; /* Lower priority to that of fiberEntry() */
fiber_yield(); /* Yield to fiber of equal priority */
fiberEvidence++;
- /* <fiberEvidence> should now be 2 */
+ /* <fiberEvidence> should now be 2 */
}
@@ -538,27 +537,27 @@ int fiber_yieldTest(void)
{
nano_context_id_t ctxId;
- /*
- * Start a fiber of higher priority. Note that since the new fiber is
- * being started from a fiber, it will not automatically switch to the
- * fiber as it would if done from a task.
- */
+ /*
+ * Start a fiber of higher priority. Note that since the new fiber is
+ * being started from a fiber, it will not automatically switch to the
+ * fiber as it would if done from a task.
+ */
ctxId = context_self_get();
fiberEvidence = 0;
fiber_fiber_start(fiberStack2, FIBER_STACKSIZE, fiberHelper,
- 0, 0, FIBER_PRIORITY - 1, 0);
+ 0, 0, FIBER_PRIORITY - 1, 0);
if (fiberEvidence != 0) {
/* ERROR! Helper spawned at higher */
fiberDetectedError = 10; /* priority ran prematurely. */
return TC_FAIL;
- }
+ }
- /*
- * Test that the fiber will yield to the higher priority helper.
- * <fiberEvidence> is still 0.
- */
+ /*
+ * Test that the fiber will yield to the higher priority helper.
+ * <fiberEvidence> is still 0.
+ */
fiber_yield();
@@ -566,18 +565,18 @@ int fiber_yieldTest(void)
/* ERROR! Did not yield to higher */
fiberDetectedError = 11; /* priority fiber. */
return TC_FAIL;
- }
+ }
if (fiberEvidence > 1) {
/* ERROR! Helper did not yield to */
fiberDetectedError = 12; /* equal priority fiber. */
return TC_FAIL;
- }
+ }
- /*
- * Raise the priority of fiberEntry(). Calling fiber_yield() should
- * not result in switching to the helper.
- */
+ /*
+ * Raise the priority of fiberEntry(). Calling fiber_yield() should
+ * not result in switching to the helper.
+ */
ctxId->prio--;
fiber_yield();
@@ -586,12 +585,12 @@ int fiber_yieldTest(void)
/* ERROR! Context switched to a lower */
fiberDetectedError = 13; /* priority fiber! */
return TC_FAIL;
- }
+ }
- /*
- * Block on <wakeFiber>. This will allow the helper fiber to complete.
- * The main task will wake this fiber.
- */
+ /*
+ * Block on <wakeFiber>. This will allow the helper fiber to complete.
+ * The main task will wake this fiber.
+ */
nano_fiber_sem_take_wait(&wakeFiber);
@@ -622,15 +621,15 @@ static void fiberEntry(int taskCtxId, int arg1)
rv = nanoCtxFiberTest((nano_context_id_t) taskCtxId);
if (rv != TC_PASS) {
return;
- }
+ }
- /* Allow the task to print any messages before the next test runs */
+ /* Allow the task to print any messages before the next test runs */
nano_fiber_sem_take_wait(&wakeFiber);
rv = fiber_yieldTest();
if (rv != TC_PASS) {
return;
- }
+ }
}
/*******************************************************************************
@@ -652,101 +651,101 @@ void main(void)
rv = initNanoObjects();
if (rv != TC_PASS) {
goto doneTests;
- }
+ }
TC_PRINT("Testing nano_cpu_idle()\n");
rv = nano_cpu_idleTest();
if (rv != TC_PASS) {
goto doneTests;
- }
+ }
TC_PRINT("Testing interrupt locking and unlocking\n");
rv = nanoCpuDisableInterruptsTest(irq_lockWrapper,
- irq_unlockWrapper, -1);
+ irq_unlockWrapper, -1);
if (rv != TC_PASS) {
goto doneTests;
- }
+ }
TC_PRINT("Testing inline interrupt locking and unlocking\n");
rv = nanoCpuDisableInterruptsTest(irq_lock_inlineWrapper,
- irq_unlock_inlineWrapper, -1);
+ irq_unlock_inlineWrapper, -1);
if (rv != TC_PASS) {
goto doneTests;
- }
+ }
/*
* The Cortex-M3/M4 use the SYSTICK exception for the system timer, which is
* not considered an IRQ by the irq_enable/Disable APIs.
*/
#if !defined(CONFIG_CPU_CORTEXM3)
- /*
- * !!! TAKE NOTE !!!
- * Disable interrupts coming from the timer. In the pcPentium case, this
- * is IRQ0 (see board.h for definition of PIT_INT_LVL). Other BSPs may
- * not be using the i8253 timer on IRQ0 and so a different IRQ value may
- * be necessary when porting to another BSP.
- */
+ /*
+ * !!! TAKE NOTE !!!
+ * Disable interrupts coming from the timer. In the pcPentium case, this
+ * is IRQ0 (see board.h for definition of PIT_INT_LVL). Other BSPs may
+ * not be using the i8253 timer on IRQ0 and so a different IRQ value may
+ * be necessary when porting to another BSP.
+ */
TC_PRINT("Testing irq_disable() and irq_enable()\n");
rv = nanoCpuDisableInterruptsTest(irq_disableWrapper,
- irq_enableWrapper, TICK_IRQ);
+ irq_enableWrapper, TICK_IRQ);
if (rv != TC_PASS) {
goto doneTests;
- }
+ }
#endif
rv = nanoCtxTaskTest();
if (rv != TC_PASS) {
goto doneTests;
- }
+ }
TC_PRINT("Spawning a fiber from a task\n");
fiberEvidence = 0;
task_fiber_start(fiberStack1, FIBER_STACKSIZE, fiberEntry,
- (int) context_self_get(), 0, FIBER_PRIORITY, 0);
+ (int) context_self_get(), 0, FIBER_PRIORITY, 0);
if (fiberEvidence != 1) {
- rv = TC_FAIL;
+ rv = TC_FAIL;
TC_ERROR(" - fiber did not execute as expected!\n");
goto doneTests;
- }
+ }
- /* The fiber ran, now wake it so it can test context_self_get and context_type_get */
+ /* The fiber ran, now wake it so it can test context_self_get and context_type_get */
TC_PRINT("Fiber to test context_self_get() and context_type_get\n");
nano_task_sem_give(&wakeFiber);
if (fiberDetectedError != 0) {
- rv = TC_FAIL;
+ rv = TC_FAIL;
TC_ERROR(" - failure detected in fiber; fiberDetectedError = %d\n",
- fiberDetectedError);
+ fiberDetectedError);
goto doneTests;
- }
+ }
TC_PRINT("Fiber to test fiber_yield()\n");
nano_task_sem_give(&wakeFiber);
if (fiberDetectedError != 0) {
- rv = TC_FAIL;
+ rv = TC_FAIL;
TC_ERROR(" - failure detected in fiber; fiberDetectedError = %d\n",
- fiberDetectedError);
+ fiberDetectedError);
goto doneTests;
- }
+ }
nano_task_sem_give(&wakeFiber);
/* Cortex-M3 does not implement connecting non-IRQ exception handlers */
#if !defined(CONFIG_CPU_CORTEXM3)
- /*
- * Test divide by zero exception handler.
- *
- * WARNING: This code has been very carefully crafted so that it does
- * what it is supposed to. Both "error" and "excHandlerExecuted" must be
- * volatile to prevent the compiler from issuing a "divide by zero"
- * warning (since otherwise in knows "excHandlerExecuted" is zero),
- * and to ensure the compiler issues the two byte "idiv" instruction
- * that the exception handler is designed to deal with.
- */
+ /*
+ * Test divide by zero exception handler.
+ *
+ * WARNING: This code has been very carefully crafted so that it does
+ * what it is supposed to. Both "error" and "excHandlerExecuted" must be
+ * volatile to prevent the compiler from issuing a "divide by zero"
+ * warning (since otherwise in knows "excHandlerExecuted" is zero),
+ * and to ensure the compiler issues the two byte "idiv" instruction
+ * that the exception handler is designed to deal with.
+ */
volatile int error; /* used to create a divide by zero error */
TC_PRINT("Verifying exception handler installed\n");
diff --git a/samples/nanokernel/test/test_fifo/src/fifo.c b/samples/nanokernel/test/test_fifo/src/fifo.c
index a7da0cc5d..a53a7daa0 100644
--- a/samples/nanokernel/test/test_fifo/src/fifo.c
+++ b/samples/nanokernel/test/test_fifo/src/fifo.c
@@ -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 */
@@ -199,58 +199,58 @@ void fiber1(void)
void *pData; /* pointer to FIFO object get from the queue */
int count = 0; /* counter */
- /* Wait for fiber1 to be activated. */
+ /* Wait for fiber1 to be activated. */
nano_fiber_sem_take_wait(&nanoSemObj1);
- /* Wait for data to be added to <nanoFifoObj> by task */
+ /* Wait for data to be added to <nanoFifoObj> by task */
pData = nano_fiber_fifo_get_wait(&nanoFifoObj);
if (pData != pPutList1[0]) {
TC_ERROR("fiber1 (1) - expected 0x%x, got 0x%x\n",
- pPutList1[0], pData);
+ pPutList1[0], pData);
retCode = TC_FAIL;
return;
- }
+ }
- /* Wait for data to be added to <nanoFifoObj2> by fiber3 */
+ /* Wait for data to be added to <nanoFifoObj2> by fiber3 */
pData = nano_fiber_fifo_get_wait(&nanoFifoObj2);
if (pData != pPutList2[0]) {
TC_ERROR("fiber1 (2) - expected 0x%x, got 0x%x\n",
- pPutList2[0], pData);
+ pPutList2[0], pData);
retCode = TC_FAIL;
return;
- }
+ }
nano_fiber_sem_take_wait(&nanoSemObj1); /* Wait for fiber1 to be reactivated */
TC_PRINT("Test Fiber FIFO Get\n\n");
- /* Get all FIFOs */
+ /* 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])) {
- TCERR1(count);
- retCode = TC_FAIL;
- return;
- }
- count++;
+ if ((count >= NUM_FIFO_ELEMENT) || (pData != pPutList1[count])) {
+ TCERR1(count);
+ retCode = TC_FAIL;
+ return;
}
+ count++;
+ }
TC_END_RESULT(retCode);
PRINT_LINE;
- /*
- * Entries in the FIFO queue have to be unique.
- * Put data.
- */
+ /*
+ * Entries in the FIFO queue have to be unique.
+ * Put data.
+ */
TC_PRINT("Test Fiber FIFO Put\n");
TC_PRINT("\nFIBER FIFO Put Order: ");
for (int i=0; i<NUM_FIFO_ELEMENT; i++) {
nano_fiber_fifo_put(&nanoFifoObj, pPutList2[i]);
TC_PRINT(" %p,", pPutList2[i]);
- }
+ }
TC_PRINT("\n");
PRINT_LINE;
- /* Give semaphore to allow the main task to run */
+ /* Give semaphore to allow the main task to run */
nano_fiber_sem_give(&nanoSemObjTask);
} /* fiber1 */
@@ -274,12 +274,12 @@ void testFiberFifoGetW(void)
TC_PRINT("Test Fiber FIFO Get Wait Interfaces\n\n");
pGetData = nano_fiber_fifo_get_wait(&nanoFifoObj2);
TC_PRINT("FIBER FIFO Get from queue2: %p\n", pGetData);
- /* Verify results */
+ /* Verify results */
if (pGetData != pMyFifoData1) {
retCode = TC_FAIL;
TCERR2;
return;
- }
+ }
pPutData = pMyFifoData2;
TC_PRINT("FIBER FIFO Put to queue1: %p\n", pPutData);
@@ -287,12 +287,12 @@ void testFiberFifoGetW(void)
pGetData = nano_fiber_fifo_get_wait(&nanoFifoObj2);
TC_PRINT("FIBER FIFO Get from queue2: %p\n", pGetData);
- /* Verify results */
+ /* Verify results */
if (pGetData != pMyFifoData3) {
retCode = TC_FAIL;
TCERR2;
return;
- }
+ }
pPutData = pMyFifoData4;
TC_PRINT("FIBER FIFO Put to queue1: %p\n", pPutData);
@@ -317,42 +317,42 @@ void testFiberFifoGetW(void)
void testIsrFifoFromFiber(void)
{
- void *pGetData; /* pointer to FIFO object get from the queue */
+ void *pGetData; /* pointer to FIFO object get from the queue */
- TC_PRINT("Test ISR FIFO (invoked from Fiber)\n\n");
+ TC_PRINT("Test ISR FIFO (invoked from Fiber)\n\n");
- /* This is data pushed by function testFiberFifoGetW */
- _trigger_nano_isr_fifo_get();
- pGetData = isrFifoInfo.data;
+ /* This is data pushed by function testFiberFifoGetW */
+ _trigger_nano_isr_fifo_get();
+ pGetData = isrFifoInfo.data;
- TC_PRINT("ISR FIFO Get from queue1: %p\n", pGetData);
- if (isrFifoInfo.data != pMyFifoData4) {
- retCode = TC_FAIL;
- TCERR2;
- return;
- }
+ TC_PRINT("ISR FIFO Get from queue1: %p\n", pGetData);
+ if (isrFifoInfo.data != pMyFifoData4) {
+ retCode = TC_FAIL;
+ TCERR2;
+ return;
+ }
- /* Verify that the queue is empty */
- _trigger_nano_isr_fifo_get();
- pGetData = isrFifoInfo.data;
+ /* Verify that the queue is empty */
+ _trigger_nano_isr_fifo_get();
+ pGetData = isrFifoInfo.data;
- if (pGetData != NULL) {
- TC_PRINT("Get from queue1: %p\n", pGetData);
- retCode = TC_FAIL;
- TCERR3;
- return;
- }
+ if (pGetData != NULL) {
+ TC_PRINT("Get from queue1: %p\n", pGetData);
+ retCode = TC_FAIL;
+ TCERR3;
+ return;
+ }
- /* Put more item into queue */
- TC_PRINT("\nISR FIFO (running in fiber context) Put Order: \n");
- for (int i=0; i<NUM_FIFO_ELEMENT; i++) {
- isrFifoInfo.data = pPutList1[i];
- TC_PRINT(" %p,", pPutList1[i]);
- _trigger_nano_isr_fifo_put();
- }
- TC_PRINT("\n");
+ /* Put more item into queue */
+ TC_PRINT("\nISR FIFO (running in fiber context) Put Order: \n");
+ for (int i=0; i<NUM_FIFO_ELEMENT; i++) {
+ isrFifoInfo.data = pPutList1[i];
+ TC_PRINT(" %p,", pPutList1[i]);
+ _trigger_nano_isr_fifo_put();
+ }
+ TC_PRINT("\n");
- TC_END_RESULT(retCode);
+ TC_END_RESULT(retCode);
} /* testIsrFifoFromFiber */
@@ -371,54 +371,54 @@ void testIsrFifoFromFiber(void)
void testIsrFifoFromTask(void)
{
- void *pGetData; /* pointer to FIFO object get from the queue */
- void *pPutData; /* pointer to FIFO object put to queue */
- int count = 0; /* counter */
-
- TC_PRINT("Test ISR FIFO (invoked from Task)\n\n");
+ void *pGetData; /* pointer to FIFO object get from the queue */
+ void *pPutData; /* pointer to FIFO object put to queue */
+ int count = 0; /* counter */
+
+ TC_PRINT("Test ISR FIFO (invoked from Task)\n\n");
+
+ /* This is data pushed by function testIsrFifoFromFiber
+ * Get all FIFOs
+ */
+ _trigger_nano_isr_fifo_get();
+ pGetData = isrFifoInfo.data;
+
+ while (pGetData != NULL) {
+ TC_PRINT("Get from queue1: count = %d, ptr is %p\n", count, pGetData);
+ if ((count >= NUM_FIFO_ELEMENT) || (pGetData != pPutList1[count])) {
+ TCERR1(count);
+ retCode = TC_FAIL;
+ return;
+ }
- /* This is data pushed by function testIsrFifoFromFiber
- * Get all FIFOs
- */
+ /* Get the next element */
_trigger_nano_isr_fifo_get();
pGetData = isrFifoInfo.data;
-
- while (pGetData != NULL) {
- TC_PRINT("Get from queue1: count = %d, ptr is %p\n", count, pGetData);
- if ((count >= NUM_FIFO_ELEMENT) || (pGetData != pPutList1[count])) {
- TCERR1(count);
- retCode = TC_FAIL;
- return;
- }
-
- /* Get the next element */
- _trigger_nano_isr_fifo_get();
- pGetData = isrFifoInfo.data;
- count++;
- } /* while */
+ count++;
+ } /* while */
- /* Put data into queue and get it again */
- pPutData = pPutList2[3];
+ /* Put data into queue and get it again */
+ pPutData = pPutList2[3];
- isrFifoInfo.data = pPutData;
- _trigger_nano_isr_fifo_put();
- isrFifoInfo.data = NULL; /* force data to a new value */
- /* Get data from queue */
- _trigger_nano_isr_fifo_get();
- pGetData = isrFifoInfo.data;
- /* Verify data */
- if (pGetData != pPutData) {
- retCode = TC_FAIL;
- TCERR2;
- return;
- }
- else {
+ isrFifoInfo.data = pPutData;
+ _trigger_nano_isr_fifo_put();
+ isrFifoInfo.data = NULL; /* force data to a new value */
+ /* Get data from queue */
+ _trigger_nano_isr_fifo_get();
+ pGetData = isrFifoInfo.data;
+ /* Verify data */
+ if (pGetData != pPutData) {
+ retCode = TC_FAIL;
+ TCERR2;
+ return;
+ }
+ else {
TC_PRINT("\nTest ISR FIFO (invoked from Task) - put %p and get back %p\n",
- pPutData, pGetData);
- }
+ pPutData, pGetData);
+ }
- TC_END_RESULT(retCode);
+ TC_END_RESULT(retCode);
} /* testIsrFifoFromTask */
/*******************************************************************************
@@ -432,40 +432,40 @@ void fiber2(void)
{
void *pData; /* pointer to FIFO object from the queue */
- /* Wait for fiber2 to be activated */
+ /* Wait for fiber2 to be activated */
nano_fiber_sem_take_wait(&nanoSemObj2);
- /* Wait for data to be added to <nanoFifoObj> */
+ /* Wait for data to be added to <nanoFifoObj> */
pData = nano_fiber_fifo_get_wait(&nanoFifoObj);
if (pData != pPutList1[1]) {
TC_ERROR("fiber2 (1) - expected 0x%x, got 0x%x\n",
- pPutList1[1], pData);
+ pPutList1[1], pData);
retCode = TC_FAIL;
return;
- }
+ }
- /* Wait for data to be added to <nanoFifoObj2> by fiber3 */
+ /* Wait for data to be added to <nanoFifoObj2> by fiber3 */
pData = nano_fiber_fifo_get_wait(&nanoFifoObj2);
if (pData != pPutList2[1]) {
TC_ERROR("fiber2 (2) - expected 0x%x, got 0x%x\n",
- pPutList2[1], pData);
+ pPutList2[1], pData);
retCode = TC_FAIL;
return;
- }
+ }
nano_fiber_sem_take_wait(&nanoSemObj2); /* Wait for fiber2 to be reactivated */
- /* Fiber #2 has been reactivated by main task */
+ /* Fiber #2 has been reactivated by main task */
for (int i = 0; i < 4; i++) {
pData = nano_fiber_fifo_get_wait(&nanoFifoObj);
if (pData != pPutList1[i]) {
- TC_ERROR("fiber2 (3) - iteration %d expected 0x%x, got 0x%x\n",
- i, pPutList1[i], pData);
- retCode = TC_FAIL;
- return;
- }
+ TC_ERROR("fiber2 (3) - iteration %d expected 0x%x, got 0x%x\n",
+ i, pPutList1[i], pData);
+ retCode = TC_FAIL;
+ return;
}
+ }
nano_fiber_sem_give(&nanoSemObjTask); /* Wake main task */
nano_fiber_sem_take_wait(&nanoSemObj2); /* Wait for fiber2 to be reactivated */
@@ -488,37 +488,37 @@ void fiber3(void)
{
void *pData;
- /* Wait for fiber3 to be activated */
+ /* Wait for fiber3 to be activated */
nano_fiber_sem_take_wait(&nanoSemObj3);
- /* Put two items onto <nanoFifoObj2> to unblock fibers #1 and #2. */
+ /* Put two items onto <nanoFifoObj2> to unblock fibers #1 and #2. */
nano_fiber_fifo_put(&nanoFifoObj2, pPutList2[0]); /* Wake fiber1 */
nano_fiber_fifo_put(&nanoFifoObj2, pPutList2[1]); /* Wake fiber2 */
- /* Wait for fiber3 to be re-activated */
+ /* Wait for fiber3 to be re-activated */
nano_fiber_sem_take_wait(&nanoSemObj3);
- /* Immediately get the data from <nanoFifoObj2>. */
+ /* Immediately get the data from <nanoFifoObj2>. */
pData = nano_fiber_fifo_get_wait(&nanoFifoObj2);
if (pData != pPutList2[0]) {
retCode = TC_FAIL;
TC_ERROR("fiber3 (1) - got 0x%x from <nanoFifoObj2>, expected 0x%x\n",
- pData, pPutList2[0]);
- }
+ pData, pPutList2[0]);
+ }
- /* Put three items onto the FIFO for the task to get */
+ /* Put three items onto the FIFO for the task to get */
nano_fiber_fifo_put(&nanoFifoObj2, pPutList2[0]);
nano_fiber_fifo_put(&nanoFifoObj2, pPutList2[1]);
nano_fiber_fifo_put(&nanoFifoObj2, pPutList2[2]);
- /* Sleep for 2 seconds */
+ /* Sleep for 2 seconds */
nano_fiber_timer_start(&timer, SECONDS(2));
nano_fiber_timer_wait(&timer);
- /* Put final item onto the FIFO for the task to get */
+ /* Put final item onto the FIFO for the task to get */
nano_fiber_fifo_put(&nanoFifoObj2, pPutList2[3]);
- /* Wait for fiber3 to be re-activated (not expected to occur) */
+ /* Wait for fiber3 to be re-activated (not expected to occur) */
nano_fiber_sem_take_wait(&nanoSemObj3);
}
@@ -544,17 +544,17 @@ void testTaskFifoGetW(void)
TC_PRINT("TASK FIFO Put to queue2: %p\n", pPutData);
nano_task_fifo_put(&nanoFifoObj2, pPutData);
- /* Activate fiber2 */
+ /* Activate fiber2 */
nano_task_sem_give(&nanoSemObj2);
pGetData = nano_task_fifo_get_wait(&nanoFifoObj);
TC_PRINT("TASK FIFO Get from queue1: %p\n", pGetData);
- /* Verify results */
+ /* Verify results */
if (pGetData != pMyFifoData2) {
retCode = TC_FAIL;
TCERR2;
return;
- }
+ }
pPutData = pMyFifoData3;
TC_PRINT("TASK FIFO Put to queue2: %p\n", pPutData);
@@ -608,41 +608,41 @@ void main(void)
TC_START("Test Nanokernel FIFO");
- /* Initialize the FIFO queues and semaphore */
+ /* Initialize the FIFO queues and semaphore */
initNanoObjects();
- /* Create and start the three (3) fibers. */
+ /* Create and start the three (3) fibers. */
task_fiber_start(&fiberStack1[0], STACKSIZE, (nano_fiber_entry_t) fiber1,
- 0, 0, 7, 0);
+ 0, 0, 7, 0);
task_fiber_start(&fiberStack2[0], STACKSIZE, (nano_fiber_entry_t) fiber2,
- 0, 0, 7, 0);
+ 0, 0, 7, 0);
task_fiber_start(&fiberStack3[0], STACKSIZE, (nano_fiber_entry_t) fiber3,
- 0, 0, 7, 0);
+ 0, 0, 7, 0);
- /*
- * The three fibers have each blocked on a different semaphore. Giving
- * the semaphore nanoSemObjX will unblock fiberX (where X = {1, 2, 3}).
- *
- * Activate fibers #1 and #2. They will each block on nanoFifoObj.
- */
+ /*
+ * The three fibers have each blocked on a different semaphore. Giving
+ * the semaphore nanoSemObjX will unblock fiberX (where X = {1, 2, 3}).
+ *
+ * Activate fibers #1 and #2. They will each block on nanoFifoObj.
+ */
nano_task_sem_give(&nanoSemObj1);
nano_task_sem_give(&nanoSemObj2);
- /* Put two items into <nanoFifoObj> to unblock fibers #1 and #2. */
+ /* Put two items into <nanoFifoObj> to unblock fibers #1 and #2. */
nano_task_fifo_put(&nanoFifoObj, pPutList1[0]); /* Wake fiber1 */
nano_task_fifo_put(&nanoFifoObj, pPutList1[1]); /* Wake fiber2 */
- /* Activate fiber #3 */
+ /* Activate fiber #3 */
nano_task_sem_give(&nanoSemObj3);
- /*
- * All three fibers should be blocked on their semaphores. Put data into
- * <nanoFifoObj2>. Fiber #3 will read it after it is reactivated.
- */
+ /*
+ * All three fibers should be blocked on their semaphores. Put data into
+ * <nanoFifoObj2>. Fiber #3 will read it after it is reactivated.
+ */
nano_task_fifo_put(&nanoFifoObj2, pPutList2[0]);
nano_task_sem_give(&nanoSemObj3); /* Reactivate fiber #3 */
@@ -650,37 +650,37 @@ void main(void)
for (int i = 0; i < 4; i++) {
pData = nano_task_fifo_get_wait(&nanoFifoObj2);
if (pData != pPutList2[i]) {
- TC_ERROR("nano_task_fifo_get_wait() expected 0x%x, got 0x%x\n",
- pPutList2[i], pData);
- goto exit;
- }
+ TC_ERROR("nano_task_fifo_get_wait() expected 0x%x, got 0x%x\n",
+ pPutList2[i], pData);
+ goto exit;
}
+ }
- /* Add items to <nanoFifoObj> for fiber #2 */
+ /* Add items to <nanoFifoObj> for fiber #2 */
for (int i = 0; i < 4; i++) {
nano_task_fifo_put(&nanoFifoObj, pPutList1[i]);
- }
+ }
nano_task_sem_give(&nanoSemObj2); /* Activate fiber #2 */
- /* Wait for fibers to finish */
+ /* Wait for fibers to finish */
nano_task_sem_take_wait(&nanoSemObjTask);
if (retCode == TC_FAIL) {
goto exit;
- }
+ }
- /*
- * Entries in the FIFO queue have to be unique.
- * Put data to queue.
- */
+ /*
+ * Entries in the FIFO queue have to be unique.
+ * Put data to queue.
+ */
TC_PRINT("Test Task FIFO Put\n");
TC_PRINT("\nTASK FIFO Put Order: ");
for (int i=0; i<NUM_FIFO_ELEMENT; i++) {
nano_task_fifo_put(&nanoFifoObj, pPutList1[i]);
TC_PRINT(" %p,", pPutList1[i]);
- }
+ }
TC_PRINT("\n");
PRINT_LINE;
@@ -689,28 +689,28 @@ void main(void)
if (retCode == TC_FAIL) {
goto exit;
- }
+ }
- /*
- * Wait for fiber1 to complete execution. (Using a semaphore gives
- * the fiber the freedom to do blocking-type operations if it wants to.)
- */
+ /*
+ * Wait for fiber1 to complete execution. (Using a semaphore gives
+ * the fiber the freedom to do blocking-type operations if it wants to.)
+ */
nano_task_sem_take_wait(&nanoSemObjTask);
TC_PRINT("Test Task FIFO Get\n");
- /* Get all FIFOs */
+ /* Get all FIFOs */
while ((pData = nano_task_fifo_get(&nanoFifoObj)) != NULL) {
TC_PRINT("TASK FIFO Get: count = %d, ptr is %p\n", count, pData);
if ((count >= NUM_FIFO_ELEMENT) || (pData != pPutList2[count])) {
- TCERR1(count);
- retCode = TC_FAIL;
- goto exit;
- }
- count++;
+ TCERR1(count);
+ retCode = TC_FAIL;
+ goto exit;
}
+ count++;
+ }
- /* Test FIFO Get Wait interfaces*/
+ /* Test FIFO Get Wait interfaces*/
testTaskFifoGetW();
PRINT_LINE;
diff --git a/samples/nanokernel/test/test_lifo/src/lifo.c b/samples/nanokernel/test/test_lifo/src/lifo.c
index 1a4919538..92bc49458 100644
--- a/samples/nanokernel/test/test_lifo/src/lifo.c
+++ b/samples/nanokernel/test/test_lifo/src/lifo.c
@@ -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 */
@@ -160,10 +160,10 @@ int fiberLifoWaitTest(void)
{
void *data; /* ptr to data retrieved from LIFO */
- /*
- * The LIFO is empty; wait for an item to be added to the LIFO
- * from the task.
- */
+ /*
+ * The LIFO is empty; wait for an item to be added to the LIFO
+ * from the task.
+ */
TC_PRINT("Fiber waiting on an empty LIFO\n");
nano_fiber_sem_give(&taskWaitSem);
@@ -171,35 +171,35 @@ int fiberLifoWaitTest(void)
if (data != &lifoItem[0]) {
fiberDetectedFailure = 1;
return -1;
- }
+ }
nano_fiber_sem_take_wait(&fiberWaitSem);
data = nano_fiber_lifo_get_wait(&lifoChannel);
if (data != &lifoItem[2]) {
fiberDetectedFailure = 1;
return -1;
- }
+ }
- /*
- * Give the task some time to check the results. Ideally, this would
- * be waiting for a semaphore instead of a using a delay, but if the
- * main task wakes the fiber before it blocks on the LIFO, the fiber
- * will add the item to the LIFO too soon. Obviously, a semaphore could
- * not be given if the task is blocked on the LIFO; hence the delay.
- */
+ /*
+ * Give the task some time to check the results. Ideally, this would
+ * be waiting for a semaphore instead of a using a delay, but if the
+ * main task wakes the fiber before it blocks on the LIFO, the fiber
+ * will add the item to the LIFO too soon. Obviously, a semaphore could
+ * not be given if the task is blocked on the LIFO; hence the delay.
+ */
nano_fiber_timer_start(&timer, SECONDS(2));
nano_fiber_timer_wait(&timer);
- /* The task is waiting on an empty LIFO. Wake it up. */
+ /* The task is waiting on an empty LIFO. Wake it up. */
nano_fiber_lifo_put(&lifoChannel, &lifoItem[3]);
nano_fiber_lifo_put(&lifoChannel, &lifoItem[1]);
- /*
- * Wait for the task to check the results. If the results pass, then the
- * the task will wake the fiber. If the results do not pass, then the
- * fiber will wait forever.
- */
+ /*
+ * Wait for the task to check the results. If the results pass, then the
+ * the task will wake the fiber. If the results do not pass, then the
+ * fiber will wait forever.
+ */
nano_fiber_sem_take_wait(&fiberWaitSem);
@@ -220,62 +220,62 @@ int fiberLifoNonWaitTest(void)
{
void *data; /* pointer to data retrieved from LIFO */
- /* The LIFO has two items in it; retrieve them both */
+ /* The LIFO has two items in it; retrieve them both */
data = nano_fiber_lifo_get(&lifoChannel);
if (data != (void *) &lifoItem[3]) {
goto errorReturn;
- }
+ }
data = nano_fiber_lifo_get(&lifoChannel);
if (data != (void *) &lifoItem[2]) {
goto errorReturn;
- }
+ }
- /* LIFO should be empty--verify. */
+ /* LIFO should be empty--verify. */
data = nano_fiber_lifo_get(&lifoChannel);
if (data != NULL) {
goto errorReturn;
- }
+ }
- /*
- * The LIFO is now empty. Add two items to the LIFO and then wait
- * for the semaphore so that the task can retrieve them.
- */
+ /*
+ * The LIFO is now empty. Add two items to the LIFO and then wait
+ * for the semaphore so that the task can retrieve them.
+ */
TC_PRINT("Task to get LIFO items without waiting\n");
nano_fiber_lifo_put(&lifoChannel, &lifoItem[0]);
nano_fiber_lifo_put(&lifoChannel, &lifoItem[1]);
nano_fiber_sem_give(&taskWaitSem); /* Wake the task (if blocked) */
- /*
- * Wait for the task to get the items and then trigger an ISR to populate
- * the LIFO.
- */
+ /*
+ * Wait for the task to get the items and then trigger an ISR to populate
+ * the LIFO.
+ */
nano_fiber_sem_take_wait(&fiberWaitSem);
- /*
- * The task retrieved the two items from the LIFO and then triggered
- * two interrupts to add two other items to the LIFO. The fiber will
- * now trigger two interrupts to read the two items.
- */
+ /*
+ * The task retrieved the two items from the LIFO and then triggered
+ * two interrupts to add two other items to the LIFO. The fiber will
+ * now trigger two interrupts to read the two items.
+ */
_trigger_nano_isr_lifo_get();
if (isrLifoInfo.data != &lifoItem[1]) {
goto errorReturn;
- }
+ }
_trigger_nano_isr_lifo_get();
if (isrLifoInfo.data != &lifoItem[3]) {
goto errorReturn;
- }
+ }
- /* The LIFO should now be empty--verify */
+ /* The LIFO should now be empty--verify */
_trigger_nano_isr_lifo_get();
if (isrLifoInfo.data != NULL) {
goto errorReturn;
- }
+ }
return 0;
@@ -308,7 +308,7 @@ static void fiberEntry(int arg1, int arg2)
if (rv == 0) {
fiberLifoNonWaitTest();
- }
+ }
}
@@ -327,45 +327,45 @@ int taskLifoWaitTest(void)
{
void *data; /* ptr to data retrieved from LIFO */
- /* Wait on <taskWaitSem> in case fiber's print message blocked */
+ /* Wait on <taskWaitSem> in case fiber's print message blocked */
nano_fiber_sem_take_wait(&taskWaitSem);
- /* The fiber is waiting on the LIFO. Wake it. */
+ /* The fiber is waiting on the LIFO. Wake it. */
nano_task_lifo_put(&lifoChannel, &lifoItem[0]);
- /*
- * The fiber ran, but is now blocked on the semaphore. Add an item to the
- * LIFO before giving the semaphore that wakes the fiber so that we can
- * cover the path of nano_fiber_lifo_get_wait() not waiting on the LIFO.
- */
+ /*
+ * The fiber ran, but is now blocked on the semaphore. Add an item to the
+ * LIFO before giving the semaphore that wakes the fiber so that we can
+ * cover the path of nano_fiber_lifo_get_wait() not waiting on the LIFO.
+ */
nano_task_lifo_put(&lifoChannel, &lifoItem[2]);
nano_task_sem_give(&fiberWaitSem);
- /* Check that the fiber got the correct item (lifoItem[0]) */
+ /* Check that the fiber got the correct item (lifoItem[0]) */
if (fiberDetectedFailure) {
TC_ERROR(" *** nano_task_lifo_put()/nano_fiber_lifo_get_wait() failure\n");
return TC_FAIL;
- }
+ }
- /* The LIFO is empty. This time the task will wait for the item. */
+ /* The LIFO is empty. This time the task will wait for the item. */
TC_PRINT("Task waiting on an empty LIFO\n");
data = nano_task_lifo_get_wait(&lifoChannel);
if (data != (void *) &lifoItem[1]) {
TC_ERROR(" *** nano_task_lifo_get_wait()/nano_fiber_lifo_put() failure\n");
return TC_FAIL;
- }
+ }
data = nano_task_lifo_get_wait(&lifoChannel);
if (data != (void *) &lifoItem[3]) {
TC_ERROR(" *** nano_task_lifo_get_wait()/nano_fiber_lifo_put() failure\n");
return TC_FAIL;
- }
+ }
- /* Waiting on an empty LIFO passed for both fiber and task. */
+ /* Waiting on an empty LIFO passed for both fiber and task. */
return TC_PASS;
}
@@ -384,51 +384,51 @@ int taskLifoNonWaitTest(void)
{
void *data; /* ptr to data retrieved from LIFO */
- /*
- * The fiber is presently waiting for <fiberWaitSem>. Populate the LIFO
- * before waking the fiber.
- */
+ /*
+ * The fiber is presently waiting for <fiberWaitSem>. Populate the LIFO
+ * before waking the fiber.
+ */
TC_PRINT("Fiber to get LIFO items without waiting\n");
nano_task_lifo_put(&lifoChannel, &lifoItem[2]);
nano_task_lifo_put(&lifoChannel, &lifoItem[3]);
nano_task_sem_give(&fiberWaitSem); /* Wake the fiber */
- /* Check that fiber received the items correctly */
+ /* Check that fiber received the items correctly */
if (fiberDetectedFailure) {
TC_ERROR(" *** nano_task_lifo_put()/nano_fiber_lifo_get() failure\n");
return TC_FAIL;
- }
+ }
- /* Wait for the fiber to be ready */
+ /* Wait for the fiber to be ready */
nano_task_sem_take_wait(&taskWaitSem);
data = nano_task_lifo_get(&lifoChannel);
if (data != (void *) &lifoItem[1]) {
TC_ERROR(" *** nano_task_lifo_get()/nano_fiber_lifo_put() failure\n");
return TC_FAIL;
- }
+ }
data = nano_task_lifo_get(&lifoChannel);
if (data != (void *) &lifoItem[0]) {
TC_ERROR(" *** nano_task_lifo_get()/nano_fiber_lifo_put() failure\n");
return TC_FAIL;
- }
+ }
data = nano_task_lifo_get(&lifoChannel);
if (data != NULL) {
TC_ERROR(" *** nano_task_lifo_get()/nano_fiber_lifo_put() failure\n");
return TC_FAIL;
- }
+ }
- /*
- * Software interrupts have been configured so that when invoked,
- * the ISR will add an item to the LIFO. The fiber (when unblocked)
- * trigger software interrupts to get the items from the LIFO from
- * within an ISR.
- *
- * Populate the LIFO.
- */
+ /*
+ * Software interrupts have been configured so that when invoked,
+ * the ISR will add an item to the LIFO. The fiber (when unblocked)
+ * trigger software interrupts to get the items from the LIFO from
+ * within an ISR.
+ *
+ * Populate the LIFO.
+ */
TC_PRINT("ISR to get LIFO items without waiting\n");
isrLifoInfo.data = &lifoItem[3];
@@ -443,7 +443,7 @@ int taskLifoNonWaitTest(void)
if (fiberDetectedFailure) {
TC_ERROR(" *** nano_isr_lifo_put()/nano_isr_lifo_get() failure\n");
return TC_FAIL;
- }
+ }
return TC_PASS;
}
@@ -510,13 +510,13 @@ static void fiber_multi_waiters(int arg1, int arg2)
if (item != &multi_waiters_items[arg1]) {
TC_ERROR(" *** fiber %d did not receive correct item\n", arg1);
TC_ERROR(" *** received %p instead of %p.\n",
- item, &multi_waiters_items[arg1]);
+ item, &multi_waiters_items[arg1]);
/* do NOT give the semaphore, signifying an error */
return;
}
TC_PRINT("multiple-waiter fiber %d got correct item, giving semaphore\n",
- arg1);
+ arg1);
nano_fiber_sem_give(&reply_multi_waiters);
}
@@ -534,7 +534,7 @@ static int do_test_multiple_waiters(void)
/* pend all fibers one the same lifo */
for (ii = 0; ii < NUM_WAITERS; ii++) {
task_fiber_start(fiber_multi_waiters_stacks[ii], FIBER_STACKSIZE,
- fiber_multi_waiters, ii, 0, FIBER_PRIORITY, 0);
+ fiber_multi_waiters, ii, 0, FIBER_PRIORITY, 0);
}
/* wake up all the fibers: the task is preempted each time */
@@ -551,7 +551,7 @@ static int do_test_multiple_waiters(void)
}
TC_PRINT("Task took multi-waiter reply semaphore %d times, as expected.\n",
- NUM_WAITERS);
+ NUM_WAITERS);
if (nano_task_lifo_get(&multi_waiters)) {
TC_ERROR(" *** multi_waiters should have been empty.\n");
@@ -607,23 +607,23 @@ void main(void)
initNanoObjects();
- /*
- * Start the fiber. The fiber will be given a higher priority than the
- * main task.
- */
+ /*
+ * Start the fiber. The fiber will be given a higher priority than the
+ * main task.
+ */
task_fiber_start(fiberStack, FIBER_STACKSIZE, fiberEntry,
- 0, 0, FIBER_PRIORITY, 0);
+ 0, 0, FIBER_PRIORITY, 0);
rv = taskLifoWaitTest();
if (rv == TC_PASS) {
rv = taskLifoNonWaitTest();
- }
+ }
if (rv == TC_PASS) {
rv = test_multiple_waiters();
- }
+ }
TC_END_RESULT(rv);
TC_END_REPORT(rv);
diff --git a/samples/nanokernel/test/test_sema/src/sema.c b/samples/nanokernel/test/test_sema/src/sema.c
index 42f2bd6a5..d597f0fc8 100644
--- a/samples/nanokernel/test/test_sema/src/sema.c
+++ b/samples/nanokernel/test/test_sema/src/sema.c
@@ -70,15 +70,15 @@ Scenario #3:
typedef struct {
struct nano_sem *sem; /* ptr to semaphore */
- int data; /* data */
- } ISR_SEM_INFO;
+ int data; /* data */
+} 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 */
@@ -153,26 +153,26 @@ int testSemFiberNoWait(void)
TC_PRINT("Giving and taking a semaphore in a fiber (non-blocking)\n");
- /*
- * Give the semaphore many times and then make sure that it can only be
- * taken that many times.
- */
+ /*
+ * Give the semaphore many times and then make sure that it can only be
+ * taken that many times.
+ */
for (i = 0; i < 32; i++) {
nano_fiber_sem_give(&testSem);
- }
+ }
for (i = 0; i < 32; i++) {
if (nano_fiber_sem_take(&testSem) != 1) {
- TC_ERROR(" *** Expected nano_fiber_sem_take() to succeed, not fail\n");
- goto errorReturn;
- }
+ TC_ERROR(" *** Expected nano_fiber_sem_take() to succeed, not fail\n");
+ goto errorReturn;
}
+ }
if (nano_fiber_sem_take(&testSem) != 0) {
TC_ERROR(" *** Expected nano_fiber_sem_take() to fail, not succeed\n");
goto errorReturn;
- }
+ }
return TC_PASS;
@@ -204,56 +204,57 @@ static void fiberEntry(int arg1, int arg2)
rv = testSemFiberNoWait();
if (rv != TC_PASS) {
return;
- }
+ }
- /*
- * At this point <testSem> is not available. Wait for <testSem> to become
- * available (the main task will give it).
- */
+ /*
+ * At this point <testSem> is not available. Wait for <testSem> to become
+ * available (the main task will give it).
+ */
nano_fiber_sem_take_wait(&testSem);
semTestState = STS_TASK_WOKE_FIBER;
- /*
- * Delay for two seconds. This gives the main task time to print
- * any messages (very important if I/O link is slow!), and wait
- * on <testSem>. Once the delay is done, this fiber will give <testSem>
- * thus waking the main task.
- */
+ /*
+ * Delay for two seconds. This gives the main task time to print
+ * any messages (very important if I/O link is slow!), and wait
+ * on <testSem>. Once the delay is done, this fiber will give <testSem>
+ * thus waking the main task.
+ */
nano_fiber_timer_start(&timer, SECONDS(2));
nano_fiber_timer_wait(&timer);
- /*
- * The main task is now waiting on <testSem>. Give the semaphore <testSem>
- * to wake it.
- */
+ /*
+ * The main task is now waiting on <testSem>. Give the semaphore <testSem>
+ * to wake it.
+ */
nano_fiber_sem_give(&testSem);
- /*
- * Some small delay must be done so that the main task can process the
- * semaphore signal.
- */
+ /*
+ * Some small delay must be done so that the main task can process the
+ * semaphore signal.
+ */
semTestState = STS_FIBER_WOKE_TASK;
nano_fiber_timer_start(&timer, SECONDS(2));
nano_fiber_timer_wait(&timer);
- /*
- * The main task should be waiting on <testSem> again. This time, instead
- * of giving the semaphore from the semaphore, give it from an ISR to wake
- * the main task.
- */
+ /*
+ * The main task should be waiting on <testSem> again. This time, instead
+ * of giving the semaphore from the semaphore, give it from an ISR to wake
+ * the main task.
+ */
isrSemInfo.data = 0;
isrSemInfo.sem = &testSem;
_trigger_nano_isr_sem_give();
- if (isrSemInfo.data == 1)
+ if (isrSemInfo.data == 1) {
semTestState = STS_ISR_WOKE_TASK;
+ }
}
/*******************************************************************************
@@ -298,30 +299,30 @@ int testSemIsrNoWait(void)
TC_PRINT("Giving and taking a semaphore in an ISR (non-blocking)\n");
- /*
- * Give the semaphore many times and then make sure that it can only be
- * taken that many times.
- */
+ /*
+ * Give the semaphore many times and then make sure that it can only be
+ * taken that many times.
+ */
isrSemInfo.sem = &testSem;
for (i = 0; i < 32; i++) {
_trigger_nano_isr_sem_give();
- }
+ }
for (i = 0; i < 32; i++) {
isrSemInfo.data = 0;
_trigger_nano_isr_sem_take();
if (isrSemInfo.data != 1) {
- TC_ERROR(" *** Expected nano_isr_sem_take() to succeed, not fail\n");
- goto errorReturn;
- }
+ TC_ERROR(" *** Expected nano_isr_sem_take() to succeed, not fail\n");
+ goto errorReturn;
}
+ }
_trigger_nano_isr_sem_take();
if (isrSemInfo.data != 0) {
TC_ERROR(" *** Expected nano_isr_sem_take() to fail, not succeed!\n");
goto errorReturn;
- }
+ }
return TC_PASS;
@@ -345,26 +346,26 @@ int testSemTaskNoWait(void)
TC_PRINT("Giving and taking a semaphore in a task (non-blocking)\n");
- /*
- * Give the semaphore many times and then make sure that it can only be
- * taken that many times.
- */
+ /*
+ * Give the semaphore many times and then make sure that it can only be
+ * taken that many times.
+ */
for (i = 0; i < 32; i++) {
nano_task_sem_give(&testSem);
- }
+ }
for (i = 0; i < 32; i++) {
if (nano_task_sem_take(&testSem) != 1) {
- TC_ERROR(" *** Expected nano_task_sem_take() to succeed, not fail\n");
- goto errorReturn;
- }
+ TC_ERROR(" *** Expected nano_task_sem_take() to succeed, not fail\n");
+ goto errorReturn;
}
+ }
if (nano_task_sem_take(&testSem) != 0) {
TC_ERROR(" *** Expected nano_task_sem_take() to fail, not succeed!\n");
goto errorReturn;
- }
+ }
return TC_PASS;
@@ -387,14 +388,14 @@ int testSemWait(void)
if (fiberDetectedFailure != 0) {
TC_ERROR(" *** Failure detected in the fiber.");
return TC_FAIL;
- }
+ }
nano_task_sem_give(&testSem); /* Wake the fiber. */
if (semTestState != STS_TASK_WOKE_FIBER) {
TC_ERROR(" *** Expected task to wake fiber. It did not.\n");
return TC_FAIL;
- }
+ }
TC_PRINT("Semaphore from the task woke the fiber\n");
@@ -403,7 +404,7 @@ int testSemWait(void)
if (semTestState != STS_FIBER_WOKE_TASK) {
TC_ERROR(" *** Expected fiber to wake task. It did not.\n");
return TC_FAIL;
- }
+ }
TC_PRINT("Semaphore from the fiber woke the task\n");
@@ -412,7 +413,7 @@ int testSemWait(void)
if (semTestState != STS_ISR_WOKE_TASK) {
TC_ERROR(" *** Expected ISR to wake task. It did not.\n");
return TC_FAIL;
- }
+ }
TC_PRINT("Semaphore from the ISR woke the task.\n");
return TC_PASS;
@@ -541,32 +542,32 @@ void main(void)
rv = testSemTaskNoWait();
if (rv != TC_PASS) {
goto doneTests;
- }
+ }
rv = testSemIsrNoWait();
if (rv != TC_PASS) {
goto doneTests;
- }
+ }
semTestState = STS_INIT;
- /*
- * Start the fiber. The fiber will be given a higher priority than the
- * main task.
- */
+ /*
+ * Start the fiber. The fiber will be given a higher priority than the
+ * main task.
+ */
task_fiber_start(fiberStack, FIBER_STACKSIZE, fiberEntry,
- 0, 0, FIBER_PRIORITY, 0);
+ 0, 0, FIBER_PRIORITY, 0);
rv = testSemWait();
if (rv != TC_PASS) {
goto doneTests;
- }
+ }
rv = test_multiple_waiters();
if (rv != TC_PASS) {
goto doneTests;
- }
+ }
doneTests:
TC_END_RESULT(rv);
diff --git a/samples/nanokernel/test/test_stack/src/stack.c b/samples/nanokernel/test/test_stack/src/stack.c
index 930668434..852b716f9 100644
--- a/samples/nanokernel/test/test_stack/src/stack.c
+++ b/samples/nanokernel/test/test_stack/src/stack.c
@@ -87,8 +87,8 @@ these are run in ISR context.
typedef struct {
struct nano_stack *channel; /* STACK channel */
- uint32_t data; /* data to add */
- } ISR_STACK_INFO;
+ uint32_t data; /* data to add */
+} ISR_STACK_INFO;
/* globals */
@@ -100,9 +100,9 @@ char fiberStack3[STACKSIZE];
struct nano_timer timer;
struct nano_stack nanoStackObj;
struct nano_stack nanoStackObj2;
-struct nano_sem nanoSemObj; /* Used for transferring control between
- * main and fiber1
- */
+struct nano_sem nanoSemObj; /* Used for transferring control between
+ * main and fiber1
+ */
uint32_t myData[NUM_STACK_ELEMENT];
uint32_t myIsrData[NUM_STACK_ELEMENT]; /* Data used for testing
@@ -151,7 +151,7 @@ void initData(void)
for (int i=0; i< NUM_STACK_ELEMENT; i++) {
myData[i] = (STARTNUM + i) * MULTIPLIER;
myIsrData[i] = myData[i] + MYNUMBER;
- }
+ }
} /* initData */
/*******************************************************************************
@@ -192,9 +192,9 @@ void isr_stack_pop(void *parameter)
ISR_STACK_INFO *pInfo = (ISR_STACK_INFO *) parameter;
if (nano_isr_stack_pop(pInfo->channel, &(pInfo->data)) == 0) {
- /* the stack is empty, set data to INVALID_DATA */
+ /* the stack is empty, set data to INVALID_DATA */
pInfo->data = INVALID_DATA;
- }
+ }
} /* isr_stack_pop */
@@ -216,31 +216,31 @@ void fiber1(void)
int count = 0; /* counter */
TC_PRINT("Test Fiber STACK Pop\n\n");
- /* Get all data */
+ /* Get all data */
while (nano_fiber_stack_pop(&nanoStackObj, &data) != 0) {
TC_PRINT("FIBER STACK Pop: count = %d, data is %d\n", count, data);
if((count >= NUM_STACK_ELEMENT) || (data != myData[NUM_STACK_ELEMENT - 1 - count])) {
- TCERR1(count);
- retCode = TC_FAIL;
- return;
- }
- count++;
+ TCERR1(count);
+ retCode = TC_FAIL;
+ return;
}
+ count++;
+ }
TC_END_RESULT(retCode);
PRINT_LINE;
- /* Put data */
+ /* Put data */
TC_PRINT("Test Fiber STACK Push\n");
TC_PRINT("\nFIBER STACK Put Order: ");
for (int i=NUM_STACK_ELEMENT; i>0; i--) {
nano_fiber_stack_push(&nanoStackObj, myData[i-1]);
TC_PRINT(" %d,", myData[i-1]);
- }
+ }
TC_PRINT("\n");
PRINT_LINE;
- /* Give semaphore to allow the main task to run */
+ /* Give semaphore to allow the main task to run */
nano_fiber_sem_give(&nanoSemObj);
} /* fiber1 */
@@ -264,12 +264,12 @@ void testFiberStackPopW(void)
TC_PRINT("Test Fiber STACK Pop Wait Interfaces\n\n");
data = nano_fiber_stack_pop_wait(&nanoStackObj2);
TC_PRINT("FIBER STACK Pop from queue2: %d\n", data);
- /* Verify results */
+ /* Verify results */
if (data != myData[0]) {
retCode = TC_FAIL;
TCERR2;
return;
- }
+ }
data = myData[1];
TC_PRINT("FIBER STACK Push to queue1: %d\n", data);
@@ -277,12 +277,12 @@ void testFiberStackPopW(void)
data = nano_fiber_stack_pop_wait(&nanoStackObj2);
TC_PRINT("FIBER STACK Pop from queue2: %d\n", data);
- /* Verify results */
+ /* Verify results */
if (data != myData[2]) {
retCode = TC_FAIL;
TCERR2;
return;
- }
+ }
data = myData[3];
TC_PRINT("FIBER STACK Push to queue1: %d\n", data);
@@ -310,19 +310,19 @@ void testIsrStackFromFiber(void)
TC_PRINT("Test ISR STACK (invoked from Fiber)\n\n");
- /* This is data pushed by function testFiberStackPopW */
+ /* This is data pushed by function testFiberStackPopW */
_trigger_nano_isr_stack_pop();
result = isrStackInfo.data;
if (result != INVALID_DATA) {
TC_PRINT("ISR STACK (running in fiber context) Pop from queue1: %d\n", result);
if (result != myData[3]) {
- retCode = TC_FAIL;
- TCERR2;
- return;
- }
+ retCode = TC_FAIL;
+ TCERR2;
+ return;
}
+ }
- /* Verify that the STACK is empty */
+ /* Verify that the STACK is empty */
_trigger_nano_isr_stack_pop();
result = isrStackInfo.data;
if (result != INVALID_DATA) {
@@ -330,19 +330,19 @@ void testIsrStackFromFiber(void)
retCode = TC_FAIL;
TCERR3;
return;
- }
+ }
- /* Put more data into STACK */
+ /* Put more data into STACK */
TC_PRINT("ISR STACK (running in fiber context) Push to queue1: \n");
for (int i=0; i<NUM_STACK_ELEMENT; i++) {
isrStackInfo.data = myIsrData[i];
TC_PRINT(" %d, ", myIsrData[i]);
_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);
@@ -367,41 +367,41 @@ void testIsrStackFromTask(void)
TC_PRINT("Test ISR STACK (invoked from Task)\n\n");
- /* Get all data */
+ /* Get all data */
_trigger_nano_isr_stack_pop();
result = isrStackInfo.data;
while (result != INVALID_DATA) {
- TC_PRINT(" Pop from queue1: count = %d, data is %d\n", count, result);
- if ((count >= NUM_STACK_ELEMENT) || (result != myIsrData[NUM_STACK_ELEMENT - count - 1])) {
- TCERR1(count);
- retCode = TC_FAIL;
- return;
- } /* if */
-
- /* Get the next element */
- _trigger_nano_isr_stack_pop();
- result = isrStackInfo.data;
- count++;
+ TC_PRINT(" Pop from queue1: count = %d, data is %d\n", count, result);
+ if ((count >= NUM_STACK_ELEMENT) || (result != myIsrData[NUM_STACK_ELEMENT - count - 1])) {
+ TCERR1(count);
+ retCode = TC_FAIL;
+ return;
+ } /* if */
+
+ /* Get the next element */
+ _trigger_nano_isr_stack_pop();
+ result = isrStackInfo.data;
+ count++;
} /* while */
- /* Put data into stack and get it again */
+ /* Put data into stack and get it again */
isrStackInfo.data = myIsrData[3];
_trigger_nano_isr_stack_push();
isrStackInfo.data = INVALID_DATA; /* force variable to a new value */
- /* Get data from stack */
+ /* Get data from stack */
_trigger_nano_isr_stack_pop();
result = isrStackInfo.data;
- /* Verify data */
+ /* Verify data */
if (result != myIsrData[3]) {
- TCERR2;
- retCode = TC_FAIL;
- return;
+ TCERR2;
+ retCode = TC_FAIL;
+ return;
}
else {
- TC_PRINT("\nTest ISR STACK (invoked from Task) - push %d and pop back %d\n",
- myIsrData[3], result);
+ TC_PRINT("\nTest ISR STACK (invoked from Task) - push %d and pop back %d\n",
+ myIsrData[3], result);
}
TC_END_RESULT(retCode);
@@ -446,18 +446,18 @@ void testTaskStackPopW(void)
TC_PRINT("TASK STACK Push to queue2: %d\n", data);
nano_task_stack_push(&nanoStackObj2, data);
- /* Start fiber */
+ /* Start fiber */
task_fiber_start(&fiberStack2[0], STACKSIZE,
- (nano_fiber_entry_t) fiber2, 0, 0, 7, 0);
+ (nano_fiber_entry_t) fiber2, 0, 0, 7, 0);
data = nano_task_stack_pop_wait(&nanoStackObj);
TC_PRINT("TASK STACK Pop from queue1: %d\n", data);
- /* Verify results */
+ /* Verify results */
if (data != myData[1]) {
retCode = TC_FAIL;
TCERR2;
return;
- }
+ }
data = myData[2];
TC_PRINT("TASK STACK Push to queue2: %d\n", data);
@@ -523,77 +523,77 @@ void main(void)
TC_START("Test Nanokernel STACK");
- /* Initialize data */
+ /* Initialize data */
initData();
- /* Initialize the queues and semaphore */
+ /* Initialize the queues and semaphore */
initNanoObjects();
- /* Start fiber3 */
+ /* Start fiber3 */
task_fiber_start(&fiberStack3[0], STACKSIZE, (nano_fiber_entry_t) fiber3,
- 0, 0, 7, 0);
- /*
- * While fiber3 blocks (for one second), wait for an item to be pushed
- * onto the stack so that it can be popped. This will put the nanokernel
- * into an idle state.
- */
+ 0, 0, 7, 0);
+ /*
+ * While fiber3 blocks (for one second), wait for an item to be pushed
+ * onto the stack so that it can be popped. This will put the nanokernel
+ * into an idle state.
+ */
data = nano_task_stack_pop_wait(&nanoStackObj);
if (data != myData[0]) {
TC_ERROR("nano_task_stack_pop_wait() expected 0x%x, but got 0x%x\n",
- myData[0], data);
+ myData[0], data);
retCode = TC_FAIL;
goto exit;
}
- /* Put data */
+ /* Put data */
TC_PRINT("Test Task STACK Push\n");
TC_PRINT("\nTASK STACK Put Order: ");
for (int i=0; i<NUM_STACK_ELEMENT; i++) {
nano_task_stack_push(&nanoStackObj, myData[i]);
TC_PRINT(" %d,", myData[i]);
- }
+ }
TC_PRINT("\n");
PRINT_LINE;
- /* Start fiber */
+ /* Start fiber */
task_fiber_start(&fiberStack1[0], STACKSIZE,
- (nano_fiber_entry_t) fiber1, 0, 0, 7, 0);
+ (nano_fiber_entry_t) fiber1, 0, 0, 7, 0);
if (retCode == TC_FAIL) {
goto exit;
- }
+ }
- /*
- * Wait for fiber1 to complete execution. (Using a semaphore gives
- * the fiber the freedom to do blocking-type operations if it wants to.)
- *
- */
+ /*
+ * Wait for fiber1 to complete execution. (Using a semaphore gives
+ * the fiber the freedom to do blocking-type operations if it wants to.)
+ *
+ */
nano_task_sem_take_wait(&nanoSemObj);
TC_PRINT("Test Task STACK Pop\n");
- /* Get all data */
+ /* Get all data */
while (nano_task_stack_pop(&nanoStackObj, &data) != 0) {
TC_PRINT("TASK STACK Pop: count = %d, data is %d\n", count, data);
if ((count >= NUM_STACK_ELEMENT) || (data != myData[count])) {
- TCERR1(count);
- retCode = TC_FAIL;
- goto exit;
- }
- count++;
+ TCERR1(count);
+ retCode = TC_FAIL;
+ goto exit;
}
+ count++;
+ }
- /* Test Task Stack Pop Wait interfaces*/
+ /* Test Task Stack Pop Wait interfaces*/
testTaskStackPopW();
if (retCode == TC_FAIL) {
goto exit;
- }
+ }
PRINT_LINE;
- /* Test ISR interfaces */
+ /* Test ISR interfaces */
testIsrStackFromTask();
PRINT_LINE;
diff --git a/samples/nanokernel/test/test_timer/src/timer.c b/samples/nanokernel/test/test_timer/src/timer.c
index 8f50ae4b9..978e96c80 100644
--- a/samples/nanokernel/test/test_timer/src/timer.c
+++ b/samples/nanokernel/test/test_timer/src/timer.c
@@ -144,8 +144,8 @@ int basicTimerWait(timer_start_func startRtn, timer_getw_func waitRtn,
tick = nano_tick_get_32();
while (nano_tick_get_32() == tick) {
- /* Align to a tick boundary */
- }
+ /* Align to a tick boundary */
+ }
tick++;
(void) nano_tick_delta(&reftime);
@@ -155,36 +155,36 @@ int basicTimerWait(timer_start_func startRtn, timer_getw_func waitRtn,
elapsed_32 = nano_tick_delta_32(&reftime);
duration = nano_tick_get_32() - tick;
- /*
- * The difference between <duration> and <elapsed> is expected to be zero
- * however, the test is allowing for tolerance of an extra tick in case of
- * timing variations.
- */
+ /*
+ * The difference between <duration> and <elapsed> is expected to be zero
+ * however, the test is allowing for tolerance of an extra tick in case of
+ * timing variations.
+ */
if ((result != pTimerData) ||
(duration - elapsed_32 > 1) || ((duration - ticks) > 1)) {
return TC_FAIL;
- }
+ }
- /* Check that the non-wait-timer-get routine works properly. */
+ /* Check that the non-wait-timer-get routine works properly. */
tick = nano_tick_get_32();
while (nano_tick_get_32() == tick) {
- /* Align to a tick boundary */
- }
+ /* Align to a tick boundary */
+ }
tick++;
(void) nano_tick_delta(&reftime);
startRtn(pTimer, ticks); /* Start the timer */
while ((result = getRtn(pTimer)) == NULL) {
busywaited = 1;
- }
+ }
elapsed = nano_tick_delta(&reftime);
duration = nano_tick_get_32() - tick;
if ((busywaited != 1) || (result != pTimerData) ||
(duration - elapsed > 1) || ((duration - ticks) > 1)) {
return TC_FAIL;
- }
+ }
return TC_PASS;
}
@@ -212,8 +212,8 @@ void startTimers(timer_start_func startRtn)
tick = nano_tick_get_32();
while (nano_tick_get_32() == tick) {
- /* Wait for the end of the tick */
- }
+ /* Wait for the end of the tick */
+ }
startRtn(&timer, TWO_SECONDS);
startRtn(&longTimer, LONG_TIMEOUT);
@@ -247,44 +247,44 @@ int busyWaitTimers(timer_get_func getRtn)
while ((numExpired != 4) && (nano_tick_get_32() < ticks)) {
result = getRtn(&timer);
if (result != NULL) {
- numExpired++;
- if ((result != timerData) || (numExpired != 2)) {
- TC_ERROR("Expected <timer> to expire 2nd, not 0x%x\n",
- result);
- return TC_FAIL;
- }
- }
+ numExpired++;
+ if ((result != timerData) || (numExpired != 2)) {
+ TC_ERROR("Expected <timer> to expire 2nd, not 0x%x\n",
+ result);
+ return TC_FAIL;
+ }
+ }
result = getRtn(&shortTimer);
if (result != NULL) {
- numExpired++;
- if ((result != shortTimerData) || (numExpired != 1)) {
- TC_ERROR("Expected <shortTimer> to expire 1st, not 0x%x\n",
- result);
- return TC_FAIL;
- }
- }
+ numExpired++;
+ if ((result != shortTimerData) || (numExpired != 1)) {
+ TC_ERROR("Expected <shortTimer> to expire 1st, not 0x%x\n",
+ result);
+ return TC_FAIL;
+ }
+ }
result = getRtn(&midTimer);
if (result != NULL) {
- numExpired++;
- if ((result != midTimerData) || (numExpired != 3)) {
- TC_ERROR("Expected <midTimer> to expire 3rd, not 0x%x\n",
- result);
- return TC_FAIL;
- }
- }
+ numExpired++;
+ if ((result != midTimerData) || (numExpired != 3)) {
+ TC_ERROR("Expected <midTimer> to expire 3rd, not 0x%x\n",
+ result);
+ return TC_FAIL;
+ }
+ }
result = getRtn(&longTimer);
if (result != NULL) {
- numExpired++;
- if ((result != longTimerData) || (numExpired != 4)) {
- TC_ERROR("Expected <longTimer> to expire 4th, not 0x%x\n",
- result);
- return TC_FAIL;
- }
- }
+ numExpired++;
+ if ((result != longTimerData) || (numExpired != 4)) {
+ TC_ERROR("Expected <longTimer> to expire 4th, not 0x%x\n",
+ result);
+ return TC_FAIL;
+ }
}
+ }
return (nano_tick_get_32() < ticks) ? TC_PASS : TC_FAIL;
}
@@ -319,16 +319,16 @@ int stopTimers(timer_stop_func stopRtn, timer_get_func getRtn)
startTick = nano_tick_get_32();
while (nano_tick_get_32() == startTick) {
- }
+ }
startTick++;
endTick = startTick + SIX_SECONDS;
while (nano_tick_get_32() < endTick) {
if ((getRtn(&timer) != NULL) || (getRtn(&shortTimer) != NULL) ||
- (getRtn(&midTimer) != NULL) || (getRtn(&longTimer) != NULL)) {
- return TC_FAIL;
- }
+ (getRtn(&midTimer) != NULL) || (getRtn(&longTimer) != NULL)) {
+ return TC_FAIL;
}
+ }
return TC_PASS;
}
@@ -378,16 +378,16 @@ static void fiberEntry(int arg1, int arg2)
TC_PRINT("Fiber testing basic timer functionality\n");
rv = basicTimerWait(nano_fiber_timer_start, nano_fiber_timer_wait,
- nano_fiber_timer_test, &timer, timerData, TWO_SECONDS);
+ nano_fiber_timer_test, &timer, timerData, TWO_SECONDS);
nano_fiber_sem_give(&wakeTask);
if (rv != TC_PASS) {
fiberDetectedError = 1;
return;
- }
+ }
nano_fiber_sem_take_wait(&wakeFiber); /* Wait forever - let task run */
- /* Check that timers expire in the correct order */
+ /* Check that timers expire in the correct order */
TC_PRINT("Fiber testing timers expire in the correct order\n");
startTimers(nano_fiber_timer_start);
rv = busyWaitTimers(nano_fiber_timer_test);
@@ -395,10 +395,10 @@ static void fiberEntry(int arg1, int arg2)
if (rv != TC_PASS) {
fiberDetectedError = 2;
return;
- }
+ }
nano_fiber_sem_take_wait(&wakeFiber); /* Wait forever - let task run */
- /* Check that timers can be stopped */
+ /* Check that timers can be stopped */
TC_PRINT("Task testing the stopping of timers\n");
startTimers(nano_fiber_timer_start);
rv = stopTimers(nano_fiber_timer_stop, nano_fiber_timer_test);
@@ -406,23 +406,23 @@ static void fiberEntry(int arg1, int arg2)
if (rv != TC_PASS) {
fiberDetectedError = 3;
return;
- }
+ }
nano_fiber_sem_take_wait(&wakeFiber); /* Wait forever - let task run */
- /* Fiber to wait on a timer that will be stopped by another fiber */
+ /* Fiber to wait on a timer that will be stopped by another fiber */
TC_PRINT("Fiber to stop a timer that has a waiting fiber\n");
fiber_fiber_start(fiber2Stack, FIBER2_STACKSIZE, fiber2Entry,
- 0, 0, FIBER2_PRIORITY, 0);
+ 0, 0, FIBER2_PRIORITY, 0);
nano_fiber_timer_start(&timer, TWO_SECONDS); /* Start timer */
result = nano_fiber_timer_wait(&timer); /* Wait on timer */
- /* Control switches to newly created fiber #2 before coming back. */
+ /* Control switches to newly created fiber #2 before coming back. */
if (result != NULL) {
fiberDetectedError = 4;
nano_fiber_sem_give(&wakeTask);
return;
- }
+ }
- /* Fiber to wait on timer that will be stopped by the task */
+ /* Fiber to wait on timer that will be stopped by the task */
TC_PRINT("Task to stop a timer that has a waiting fiber\n");
nano_fiber_sem_give(&wakeTask);
nano_fiber_timer_start(&timer, TWO_SECONDS);
@@ -430,7 +430,7 @@ static void fiberEntry(int arg1, int arg2)
if (result != NULL) {
fiberDetectedError = 5;
return;
- }
+ }
nano_fiber_sem_give(&wakeTask);
}
@@ -454,10 +454,10 @@ int nano_cycle_get_32Test(void)
timeStamp2 = nano_cycle_get_32();
if (timeStamp2 < timeStamp1) {
- TC_ERROR("Timestamp value not increasing with successive calls\n");
- return TC_FAIL;
- }
+ TC_ERROR("Timestamp value not increasing with successive calls\n");
+ return TC_FAIL;
}
+ }
return TC_PASS;
}
@@ -481,37 +481,37 @@ void main(void)
TC_PRINT("Task testing basic timer functionality\n");
rv = basicTimerWait(nano_task_timer_start, nano_task_timer_wait,
- nano_task_timer_test, &timer, timerData, TWO_SECONDS);
+ nano_task_timer_test, &timer, timerData, TWO_SECONDS);
if (rv != TC_PASS) {
TC_ERROR("Task-level of waiting for timers failed\n");
goto doneTests;
- }
+ }
- /* Check that timers expire in the correct order */
+ /* Check that timers expire in the correct order */
TC_PRINT("Task testing timers expire in the correct order\n");
startTimers(nano_task_timer_start);
rv = busyWaitTimers(nano_task_timer_test);
if (rv != TC_PASS) {
TC_ERROR("Task-level timer expiration order failed\n");
goto doneTests;
- }
+ }
- /* Check that timers can be stopped */
+ /* Check that timers can be stopped */
TC_PRINT("Task testing the stopping of timers\n");
startTimers(nano_task_timer_start);
rv = stopTimers(nano_task_timer_stop, nano_task_timer_test);
if (rv != TC_PASS) {
TC_ERROR("Task-level stopping of timers test failed\n");
goto doneTests;
- }
+ }
- /*
- * Start the fiber. The fiber will be given a higher priority than the
- * main task.
- */
+ /*
+ * Start the fiber. The fiber will be given a higher priority than the
+ * main task.
+ */
task_fiber_start(fiberStack, FIBER_STACKSIZE, fiberEntry,
- 0, 0, FIBER_PRIORITY, 0);
+ 0, 0, FIBER_PRIORITY, 0);
nano_task_sem_take_wait(&wakeTask);
@@ -519,7 +519,7 @@ void main(void)
TC_ERROR("Fiber-level of waiting for timers failed\n");
rv = TC_FAIL;
goto doneTests;
- }
+ }
nano_task_sem_give(&wakeFiber);
nano_task_sem_take_wait(&wakeTask);
@@ -528,7 +528,7 @@ void main(void)
TC_ERROR("Fiber-level timer expiration order failed\n");
rv = TC_FAIL;
goto doneTests;
- }
+ }
nano_task_sem_give(&wakeFiber);
nano_task_sem_take_wait(&wakeTask);
@@ -537,7 +537,7 @@ void main(void)
TC_ERROR("Fiber-level stopping of timers test failed\n");
rv = TC_FAIL;
goto doneTests;
- }
+ }
nano_task_sem_give(&wakeFiber);
nano_task_sem_take_wait(&wakeTask);
@@ -545,27 +545,27 @@ void main(void)
TC_ERROR("Fiber stopping a timer waited upon by a fiber failed\n");
rv = TC_FAIL;
goto doneTests;
- }
+ }
nano_task_timer_stop(&timer);
if (fiberDetectedError == 5) {
TC_ERROR("Task stopping a timer waited upon by a fiber failed\n");
rv = TC_FAIL;
goto doneTests;
- }
+ }
nano_task_sem_take_wait(&wakeTask);
#if 0
- /*
- * Due to recent changes in the i8253 file that correct an issue on real
- * hardware, this test will fail when run under QEMU. On QEMU, the i8253
- * timer can at appear to run backwards. This can generate a false
- * failure detection when this test is run under QEMU as part of the
- * standard sanity/regression checks. This suggests that the test is not
- * of high enough quality to be included during the standard sanity/
- * regression checks.
- */
+ /*
+ * Due to recent changes in the i8253 file that correct an issue on real
+ * hardware, this test will fail when run under QEMU. On QEMU, the i8253
+ * timer can at appear to run backwards. This can generate a false
+ * failure detection when this test is run under QEMU as part of the
+ * standard sanity/regression checks. This suggests that the test is not
+ * of high enough quality to be included during the standard sanity/
+ * regression checks.
+ */
TC_PRINT("Task testing of nano_cycle_get_32()\n");
rv = nano_cycle_get_32Test();