summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-11-10 20:50:20 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-11-10 20:50:20 +0000
commit2536fb059e1b51728527428eebd79bbcbec6cf90 (patch)
treeb50f30b88d8f458bd2057f96246230072665b45c
parentbeb40a51df987c04649b6243d4db2daf32b7ef86 (diff)
New ntp demo test from Eric Norum <eric@cls.usask.ca>.
-rw-r--r--ntp/Makefile63
-rw-r--r--ntp/init.c80
2 files changed, 143 insertions, 0 deletions
diff --git a/ntp/Makefile b/ntp/Makefile
new file mode 100644
index 0000000..573dbbe
--- /dev/null
+++ b/ntp/Makefile
@@ -0,0 +1,63 @@
+#
+# $Id$
+#
+
+SAMPLE=ntpdemo
+PGM=${ARCH}/$(SAMPLE).exe
+
+MANAGERS=io event semaphore
+
+# C source names, if any, go here -- minus the .c
+C_PIECES= init
+C_FILES=$(C_PIECES:%=%.c)
+C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
+
+H_FILES=
+
+DOCTYPES=
+DOCS=$(DOCTYPES:%=$(SAMPLE).%)
+
+SRCS=$(DOCS) $(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES)
+OBJS=$(C_O_FILES) $(CC_O_FILES) $(S_O_FILES)
+
+PRINT_SRCS=$(DOCS)
+
+PGM=${ARCH}/$(SAMPLE).exe
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+DEFINES +=
+CPPFLAGS +=
+CFLAGS +=
+CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0xC0000
+CFLAGS_OPTIMIZE_V +=
+CFLAGS_DEBUG_V += -v -qrtems_debug
+
+LD_PATHS +=
+LD_LIBS +=
+
+#
+# Add your list of files to delete here. The config files
+# already know how to delete some stuff, so you may want
+# to just run 'make clean' first to see what gets missed.
+# 'make clobber' already includes 'make clean'
+#
+
+CLEAN_ADDITIONS +=
+CLOBBER_ADDITIONS +=
+
+all: ${ARCH} $(SRCS) $(PGM)
+
+${PGM}: $(OBJS) $(LINK_FILES)
+ $(make-exe)
+
+# Install the program(s), appending _g or _p as appropriate.
+# for include files, just use $(INSTALL)
+install: all
+ $(INSTALL_VARIANT) -m 555 ${PGM} ${PROJECT_RELEASE}/tests
diff --git a/ntp/init.c b/ntp/init.c
new file mode 100644
index 0000000..2f4f900
--- /dev/null
+++ b/ntp/init.c
@@ -0,0 +1,80 @@
+/*
+ * RTEMS configuration/initialization
+ *
+ * This program may be distributed and used for any purpose.
+ * I ask only that you:
+ * 1. Leave this author information intact.
+ * 2. Document any changes you make.
+ *
+ * W. Eric Norum
+ * Saskatchewan Accelerator Laboratory
+ * University of Saskatchewan
+ * Saskatoon, Saskatchewan, CANADA
+ * eric@skatter.usask.ca
+ *
+ * $Id$
+ */
+
+#include <bsp.h>
+
+#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_EXECUTIVE_RAM_SIZE (512*1024)
+#define CONFIGURE_MAXIMUM_SEMAPHORES 20
+#define CONFIGURE_MAXIMUM_TASKS 20
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 10486
+
+#define CONFIGURE_INIT_TASK_STACK_SIZE (10*1024)
+#define CONFIGURE_INIT_TASK_PRIORITY 120
+#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
+ RTEMS_NO_TIMESLICE | \
+ RTEMS_NO_ASR | \
+ RTEMS_INTERRUPT_LEVEL(0))
+
+#define CONFIGURE_INIT
+rtems_task Init (rtems_task_argument argument);
+
+#include <confdefs.h>
+
+#include <stdio.h>
+#include <rtems/rtems_bsdnet.h>
+#include <rtems/error.h>
+#include "../networkconfig.h"
+
+/*
+ * RTEMS Startup Task
+ */
+rtems_task
+Init (rtems_task_argument ignored)
+{
+ rtems_status_code sc;
+ rtems_time_of_day now;
+ rtems_interval ticksPerSecond;
+ int rtems_bsdnet_synchronize_ntp (int interval, rtems_task_priority priority);
+
+ printf ("****************** NTP TEST ***************\n");
+ rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
+ sc = rtems_clock_get (RTEMS_CLOCK_GET_TOD, &now);
+ if (sc == RTEMS_SUCCESSFUL)
+ printf ("Got time of day -- should have failed!\n");
+ else if (sc != RTEMS_NOT_DEFINED)
+ printf ("Failed to get time of day: %s\n", rtems_status_text (sc));
+ rtems_bsdnet_initialize_network ();
+ rtems_bsdnet_synchronize_ntp (0, 0);
+ sc = rtems_clock_get (RTEMS_CLOCK_GET_TOD, &now);
+ if (sc != RTEMS_SUCCESSFUL)
+ printf ("Failed to get time of day: %s\n", rtems_status_text (sc));
+ printf ("The time is **** %.4d-%.2d-%.2d %.2d:%.2d:%.2d.%.3d (%d) ****\n",
+ now.year,
+ now.month,
+ now.day,
+ now.hour,
+ now.minute,
+ now.second,
+ (now.ticks * 1000) / ticksPerSecond,
+ now.ticks);
+ exit (0);
+}