This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Main loop user callback mechanism patch attached.



Attached is a patch that uses the HAL_TABLE mechanism to allow
the user to register a main-loop callback routine via the macro
RedBoot_loop() much the same why you can register an
initialization routine using RedBoot_init().

NB: This patch also changes the main-loop gets() timeout from
    250ms to 10ms.  I was thinking about making that value
    adjustable via cdl, but haven't done it.

-- 
Grant Edwards
grante@visi.com
Index: include/redboot.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/include/redboot.h,v
retrieving revision 1.8
diff -U5 -r1.8 redboot.h
--- redboot.h	2000/12/08 03:30:08	1.8
+++ redboot.h	2001/01/22 22:54:02
@@ -150,10 +150,21 @@
 } CYG_HAL_TABLE_TYPE;
 #define _RedBoot_init(_f_,_p_)                                          \
 struct init_tab_entry _init_tab_##_p_##_f_ CYG_HAL_TABLE_QUALIFIED_ENTRY(RedBoot_inits,_f_) = { _f_ }; 
 #define RedBoot_init(_f_,_p_) _RedBoot_init(_f_,_p_)
 
+// Main loop call-back functions
+#define RedBoot_LOOP_FIRST 0000
+#define RedBoot_LOOP_PRIO(_n_) 1000+_n_
+#define RedBoot_LOOP_LAST  9999
+struct loop_tab_entry {
+    void_fun_ptr fun;
+} CYG_HAL_TABLE_TYPE;
+#define _RedBoot_loop(_f_,_p_)                                          \
+struct loop_tab_entry _loop_tab_##_p_##_f_ CYG_HAL_TABLE_QUALIFIED_ENTRY(RedBoot_loop,_f_) = { _f_ }; 
+#define RedBoot_loop(_f_,_p_) _RedBoot_loop(_f_,_p_)
+
 
 // Option processing support
 
 struct option_info {
     char flag;
Index: src/main.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/main.c,v
retrieving revision 1.9
diff -U5 -r1.9 main.c
--- main.c	2000/12/08 03:30:08	1.9
+++ main.c	2001/01/22 22:54:03
@@ -95,14 +95,19 @@
 
 // Define table boundaries
 CYG_HAL_TABLE_BEGIN( __RedBoot_INIT_TAB__, RedBoot_inits );
 CYG_HAL_TABLE_END( __RedBoot_INIT_TAB_END__, RedBoot_inits );
 extern struct init_tab_entry __RedBoot_INIT_TAB__[], __RedBoot_INIT_TAB_END__;
+
 CYG_HAL_TABLE_BEGIN( __RedBoot_CMD_TAB__, RedBoot_commands );
 CYG_HAL_TABLE_END( __RedBoot_CMD_TAB_END__, RedBoot_commands );
 extern struct cmd __RedBoot_CMD_TAB__[], __RedBoot_CMD_TAB_END__;
 
+CYG_HAL_TABLE_BEGIN( __RedBoot_LOOP_TAB__, RedBoot_loop );
+CYG_HAL_TABLE_END( __RedBoot_LOOP_TAB_END__, RedBoot_loop );
+extern struct loop_tab_entry __RedBoot_LOOP_TAB__[], __RedBoot_LOOP_TAB_END__;
+
 #ifdef HAL_ARCH_PROGRAM_NEW_STACK
 extern void HAL_ARCH_PROGRAM_NEW_STACK(void *fun);
 #endif
 
 void
@@ -126,10 +131,11 @@
     bool prompt = true;
     static char line[CYGPKG_REDBOOT_MAX_CMD_LINE];
     struct cmd *cmd;
     int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
     struct init_tab_entry *init_entry;
+    struct loop_tab_entry *loop_entry;
 
     CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL);
 #ifdef CYGPKG_REDBOOT_ANY_CONSOLE
     console_selected = false;
 #endif
@@ -184,19 +190,22 @@
     while (true) {
         if (prompt) {
             printf("RedBoot> ");
             prompt = false;
         }
-        res = gets(line, sizeof(line), 250);
+        res = gets(line, sizeof(line), 10);
         if (res == _GETS_TIMEOUT) {
             // No input arrived
 #ifdef CYGPKG_REDBOOT_NETWORKING
             if (have_net) {
                 // Check for incoming TCP debug connection
                 net_io_test();
             }
 #endif
+            for (loop_entry = __RedBoot_LOOP_TAB__; loop_entry != &__RedBoot_LOOP_TAB_END__;  loop_entry++) {
+                (*loop_entry->fun)();
+            }
         } else {
             if (res == _GETS_GDB) {
                 // Special case of '$' - need to start GDB protocol
                 CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
 #ifdef HAL_ARCH_PROGRAM_NEW_STACK

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]