summaryrefslogtreecommitdiff
path: root/n/avr/modules
diff options
context:
space:
mode:
Diffstat (limited to 'n/avr/modules')
-rw-r--r--n/avr/modules/host/host.h7
-rw-r--r--n/avr/modules/host/host.host.c13
-rw-r--r--n/avr/modules/host/test/test_host.c5
-rw-r--r--n/avr/modules/math/fixed/test/test_fixed.c3
-rw-r--r--n/avr/modules/proto/test/test_proto.c3
-rw-r--r--n/avr/modules/uart/test/test_uart.c3
-rw-r--r--n/avr/modules/uart/uart.host.c5
-rw-r--r--n/avr/modules/utils/test/test_utils.c3
-rw-r--r--n/avr/modules/utils/utils.host.c2
-rw-r--r--n/avr/modules/utils/utils.host.h5
10 files changed, 35 insertions, 14 deletions
diff --git a/n/avr/modules/host/host.h b/n/avr/modules/host/host.h
index d1a00af..73cd4a5 100644
--- a/n/avr/modules/host/host.h
+++ b/n/avr/modules/host/host.h
@@ -30,10 +30,15 @@
# error Use this header only for HOST only files !
#endif
-/** Initialise host modules. */
+/** Initialise host module. */
void
host_init (int argc, char **argv);
+/** Retrieve saved program arguments. Program name and used parameters are
+ * stripped. */
+void
+host_get_program_arguments (int *argc, char ***argv);
+
/** Host variables are usefull on reset. They are passed in the environment.
* This is not optimised for performance. */
diff --git a/n/avr/modules/host/host.host.c b/n/avr/modules/host/host.host.c
index bcfd7d2..7967e9c 100644
--- a/n/avr/modules/host/host.host.c
+++ b/n/avr/modules/host/host.host.c
@@ -36,7 +36,7 @@
static int host_saved_argc;
static char **host_saved_argv;
-/** Initialise host modules. */
+/** Initialise host module. */
void
host_init (int argc, char **argv)
{
@@ -44,6 +44,16 @@ host_init (int argc, char **argv)
host_saved_argv = argv;
}
+/** Retrieve saved program arguments. Program name and used parameters are
+ * stripped. */
+void
+host_get_program_arguments (int *argc, char ***argv)
+{
+ assert (host_saved_argc);
+ *argc = host_saved_argc - 1;
+ *argv = host_saved_argv + 1;
+}
+
/** Register a host integer. */
void
host_register_integer (const char *name, int val)
@@ -84,6 +94,7 @@ host_fetch_string (const char *name)
void
host_reset (void)
{
+ assert (host_saved_argv);
execv (program_invocation_name, host_saved_argv);
assert_perror (errno);
abort ();
diff --git a/n/avr/modules/host/test/test_host.c b/n/avr/modules/host/test/test_host.c
index db8161f..8c98a94 100644
--- a/n/avr/modules/host/test/test_host.c
+++ b/n/avr/modules/host/test/test_host.c
@@ -33,6 +33,8 @@ main (int argc, char **argv)
{
int i;
const char *s;
+ int ac;
+ char **av;
printf ("reset\n");
host_init (argc, argv);
i = host_fetch_integer ("avr_integer");
@@ -40,7 +42,8 @@ main (int argc, char **argv)
if (i != -1)
{
printf ("get\n");
- assert_print (argc == 2 && strcmp (argv[1], "ni") == 0,
+ host_get_program_arguments (&ac, &av);
+ assert_print (ac == 1 && strcmp (av[0], "ni") == 0,
"argument passing not working");
assert (i == 42);
assert (strcmp (s, "Ni!") == 0);
diff --git a/n/avr/modules/math/fixed/test/test_fixed.c b/n/avr/modules/math/fixed/test/test_fixed.c
index ff826d4..875aad4 100644
--- a/n/avr/modules/math/fixed/test/test_fixed.c
+++ b/n/avr/modules/math/fixed/test/test_fixed.c
@@ -233,8 +233,9 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
}
int
-main (void)
+main (int argc, char **argv)
{
+ avr_init (argc, argv);
sei ();
uart0_init ();
proto_send0 ('z');
diff --git a/n/avr/modules/proto/test/test_proto.c b/n/avr/modules/proto/test/test_proto.c
index 0503b6c..0b0883f 100644
--- a/n/avr/modules/proto/test/test_proto.c
+++ b/n/avr/modules/proto/test/test_proto.c
@@ -67,8 +67,9 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
}
int
-main (void)
+main (int argc, char **argv)
{
+ avr_init (argc, argv);
sei ();
uart0_init ();
/* This command should be generaly sent on reset. */
diff --git a/n/avr/modules/uart/test/test_uart.c b/n/avr/modules/uart/test/test_uart.c
index 76716e7..86b2058 100644
--- a/n/avr/modules/uart/test/test_uart.c
+++ b/n/avr/modules/uart/test/test_uart.c
@@ -28,8 +28,9 @@
#include "io.h"
int
-main (void)
+main (int argc, char **argv)
{
+ avr_init (argc, argv);
sei ();
uart0_init ();
uart0_putc ('N');
diff --git a/n/avr/modules/uart/uart.host.c b/n/avr/modules/uart/uart.host.c
index d6aa848..9a335b2 100644
--- a/n/avr/modules/uart/uart.host.c
+++ b/n/avr/modules/uart/uart.host.c
@@ -31,7 +31,6 @@
#if AC_UART (PORT) != -1
-#include <assert.h>
#include <stdlib.h>
#include <sys/types.h>
#include <errno.h>
@@ -83,10 +82,12 @@ void
uart_init (void)
{
#ifdef DRIVER_STDIO
+ int r;
# define uart_pt_fd_in 0
# define uart_pt_fd_out 1
/* Always use line buffering. */
- assert (setvbuf (stdout, 0, _IOLBF, BUFSIZ) == 0);
+ r = setvbuf (stdout, 0, _IOLBF, BUFSIZ);
+ assert (r == 0);
#else
# define uart_pt_fd_in uart_pt_fd
# define uart_pt_fd_out uart_pt_fd
diff --git a/n/avr/modules/utils/test/test_utils.c b/n/avr/modules/utils/test/test_utils.c
index 4c85c45..d4df7b9 100644
--- a/n/avr/modules/utils/test/test_utils.c
+++ b/n/avr/modules/utils/test/test_utils.c
@@ -27,8 +27,9 @@
#include "io.h"
int
-main (void)
+main (int argc, char **argv)
{
+ avr_init (argc, argv);
#ifndef HOST
/* Test regv, the first one should generate a warning. */
TCCR0 = regv (FOC0, WGM00, COM01, COM0, WGM01, CS02, CS00, CS01,
diff --git a/n/avr/modules/utils/utils.host.c b/n/avr/modules/utils/utils.host.c
index 8d2be82..54dda95 100644
--- a/n/avr/modules/utils/utils.host.c
+++ b/n/avr/modules/utils/utils.host.c
@@ -22,12 +22,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* }}} */
+#include "common.h"
#include "utils.h"
#include "modules/host/host.h"
#include <time.h>
#include <errno.h>
-#include <assert.h>
/** Delay in seconds. */
void
diff --git a/n/avr/modules/utils/utils.host.h b/n/avr/modules/utils/utils.host.h
index e4c5183..2e73dc4 100644
--- a/n/avr/modules/utils/utils.host.h
+++ b/n/avr/modules/utils/utils.host.h
@@ -29,11 +29,8 @@
void
utils_delay (double s);
-void
-utils_reset (void) __attribute__ ((noreturn));
-
/** Reset. */
void
-utils_reset (void);
+utils_reset (void) __attribute__ ((noreturn));
#endif /* utils_host_h */