# HG changeset patch # User Mychaela Falconia # Date 1600227651 0 # Node ID 7d1df6d831e42cfcf3573c4cb5853e6a16f27215 # Parent 5b8287c655cfc327bf2516ea9c2b1d57c4e212fe libpwon: added -Pdtr and -Prts support for DUART28C diff -r 5b8287c655cf -r 7d1df6d831e4 libpwon/Makefile --- a/libpwon/Makefile Tue Sep 15 04:29:43 2020 +0000 +++ b/libpwon/Makefile Wed Sep 16 03:40:51 2020 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -OBJS= forkoff.o readconf.o +OBJS= duart28c.o forkoff.o readconf.o LIB= libpwon.a all: ${LIB} diff -r 5b8287c655cf -r 7d1df6d831e4 libpwon/duart28c.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpwon/duart28c.c Wed Sep 16 03:40:51 2020 +0000 @@ -0,0 +1,46 @@ +#include +#include +#include +#include +#include +#include +#include + +extern int target_fd; + +int bootctrl_duart28c_mode; +static int mctl_arg; + +bootctrl_check_duart28c(bc_name) + char *bc_name; +{ + if (!strcmp(bc_name, "dtr")) { + bootctrl_duart28c_mode = 1; + mctl_arg = TIOCM_DTR; + return 1; + } + if (!strcmp(bc_name, "rts")) { + bootctrl_duart28c_mode = 1; + mctl_arg = TIOCM_RTS; + return 1; + } + return 0; +} + +void +fork_duart28c_pulse() +{ + int i; + + i = fork(); + if (i < 0) { + perror("fork"); + exit(1); + } + if (i) + return; + ioctl(target_fd, TIOCMBIS, &mctl_arg); + usleep(50000); + ioctl(target_fd, TIOCMBIC, &mctl_arg); + exit(0); +} diff -r 5b8287c655cf -r 7d1df6d831e4 libpwon/forkoff.c --- a/libpwon/forkoff.c Tue Sep 15 04:29:43 2020 +0000 +++ b/libpwon/forkoff.c Wed Sep 16 03:40:51 2020 +0000 @@ -5,6 +5,7 @@ #include extern char bootctrl_pwon_cmd[]; +extern int bootctrl_duart28c_mode; static char shell_pathname[] = "/bin/sh"; @@ -27,9 +28,15 @@ pwon_if_needed() { - if (!bootctrl_pwon_cmd[0]) - return(0); - signal(SIGCHLD, SIG_IGN); - fork_exec_pwon_cmd(); - return(1); + if (bootctrl_duart28c_mode) { + signal(SIGCHLD, SIG_IGN); + fork_duart28c_pulse(); + return(1); + } + if (bootctrl_pwon_cmd[0]) { + signal(SIGCHLD, SIG_IGN); + fork_exec_pwon_cmd(); + return(1); + } + return(0); } diff -r 5b8287c655cf -r 7d1df6d831e4 libpwon/readconf.c --- a/libpwon/readconf.c Tue Sep 15 04:29:43 2020 +0000 +++ b/libpwon/readconf.c Wed Sep 16 03:40:51 2020 +0000 @@ -18,6 +18,8 @@ int lineno; char *cp, *np; + if (bootctrl_check_duart28c(soughtname)) + return(0); inf = fopen(conf_file_pathname, "r"); if (!inf) { perror(conf_file_pathname);