This is the mail archive of the ecos-patches@sourceware.org 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]
Other format: [Raw text]

[PATCH] add option to override redboot abort script check


This patch factors out the test for ^C that is used to bypass the start-up script.
By creating the function redboot_abort_script and declaring weak, it's possible
to easily replace it for custom needs.


In my case, there's no easily accessible serial port so get to the redboot prompt
telnet is used. However, if there's a boot script, there needs to be a way for the
user to abort it in an easy manner. So, in my platform specific code, the
redboot_abort_script is replaced by code to check for to see button if a button
is pressed.


-jose

diff -r 690e1f51d092 packages/redboot/current/src/main.c
--- a/packages/redboot/current/src/main.c    Sun May 04 17:02:34 2008 -0400
+++ b/packages/redboot/current/src/main.c    Mon Aug 25 21:44:30 2008 -0400
@@ -234,6 +234,29 @@
}
#endif

+// Check for ^C on console
+bool redboot_abort_script(int script_timeout_ms) CYBLD_ATTRIB_WEAK;
+
+bool
+redboot_abort_script(int script_timeout_ms)
+{
+ int res = _GETS_CTRLC; // Treat 0 timeout as ^C
+ char line[CYGPKG_REDBOOT_MAX_CMD_LINE];
+ diag_printf("== Executing boot script in %d.%03d seconds - enter ^C to abort\n",
+ script_timeout_ms/1000, script_timeout_ms%1000);
+
+ while (script_timeout_ms >= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT) {
+ res = _rb_gets(line, sizeof(line), CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT);
+ if (res >= _GETS_OK) {
+ diag_printf("== Executing boot script in %d.%03d seconds - enter ^C to abort\n",
+ script_timeout_ms/1000, script_timeout_ms%1000);
+ continue; // Ignore anything but ^C
+ }
+ if (res != _GETS_TIMEOUT) break;
+ script_timeout_ms -= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT;
+ }
+ return res == _GETS_CTRLC;
+}


//
// This is the main entry point for RedBoot
@@ -337,26 +360,10 @@
# endif
if (script) {
// Give the guy a chance to abort any boot script
- unsigned char *hold_script = script;
int script_timeout_ms = script_timeout * CYGNUM_REDBOOT_BOOT_SCRIPT_TIMEOUT_RESOLUTION;
- diag_printf("== Executing boot script in %d.%03d seconds - enter ^C to abort\n",
- script_timeout_ms/1000, script_timeout_ms%1000);
- script = (unsigned char *)0;
- res = _GETS_CTRLC; // Treat 0 timeout as ^C
- while (script_timeout_ms >= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT) {
- res = _rb_gets(line, sizeof(line), CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT);
- if (res >= _GETS_OK) {
- diag_printf("== Executing boot script in %d.%03d seconds - enter ^C to abort\n",
- script_timeout_ms/1000, script_timeout_ms%1000);
- continue; // Ignore anything but ^C
- }
- if (res != _GETS_TIMEOUT) break;
- script_timeout_ms -= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT;
- }
- if (res == _GETS_CTRLC) {
+ res = redboot_abort_script(script_timeout_ms);
+ if (res) {
script = (unsigned char *)0; // Disable script
- } else {
- script = hold_script; // Re-enable script
}
}
#endif



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