[OpenBIOS] r72 - in openbios-devel: arch/unix kernel

svn@openbios.org svn at openbios.org
Fri Jul 28 23:44:08 CEST 2006


Author: stepan
Date: 2006-07-28 23:44:07 +0200 (Fri, 28 Jul 2006)
New Revision: 72

Modified:
   openbios-devel/arch/unix/unix.c
   openbios-devel/kernel/forth.c
Log:
blueswirl's latest console patches.


Modified: openbios-devel/arch/unix/unix.c
===================================================================
--- openbios-devel/arch/unix/unix.c	2006-07-23 14:29:29 UTC (rev 71)
+++ openbios-devel/arch/unix/unix.c	2006-07-28 21:44:07 UTC (rev 72)
@@ -225,22 +225,23 @@
  * terminal initialization and cleanup.
  */
 
+static struct termios saved_termios;
+
 static void init_terminal(void)
 {
 	struct termios termios;
 
+	tcgetattr(0, &saved_termios);
 	tcgetattr(0, &termios);
 	termios.c_lflag &= ~(ICANON | ECHO);
+        termios.c_cc[VMIN] = 1;
+        termios.c_cc[VTIME] = 3; // 300 ms
 	tcsetattr(0, 0, &termios);
 }
 
 static void exit_terminal(void)
 {
-	struct termios termios;
-
-	tcgetattr(0, &termios);
-	termios.c_lflag |= (ICANON | ECHO);
-	tcsetattr(0, 0, &termios);
+	tcsetattr(0, 0, &saved_termios);
 }
 
 /*
@@ -286,6 +287,21 @@
 	exit(1);
 }
 
+/*
+ *  Interrupt handler. linux specific?
+ *  Restore terminal state on ctrl-C.
+ */
+
+static void
+int_handler(int signo __attribute__ ((unused)),
+            siginfo_t * si __attribute__ ((unused)),
+            void *context __attribute__ ((unused)))
+{
+    printk("\n");
+    exit_terminal();
+    exit(1);
+}
+
 /* 
  * allocate memory and prepare engine for memory management.
  */
@@ -461,6 +477,18 @@
 
 	/* set terminal to do non blocking reads */
 	init_terminal();
+
+        if (verbose)
+            printk("Installing SIGINT handler...");
+
+        sa.sa_sigaction = int_handler;
+        sigemptyset(&sa.sa_mask);
+        sa.sa_flags = SA_SIGINFO | SA_NODEFER;
+        sigaction(SIGINT, &sa, 0);
+
+        if (verbose)
+            printk("done.\n");
+
 	read_dictionary(argv[optind]);
 
 	PUSH_xt( bind_noname_func(arch_init) );

Modified: openbios-devel/kernel/forth.c
===================================================================
--- openbios-devel/kernel/forth.c	2006-07-23 14:29:29 UTC (rev 71)
+++ openbios-devel/kernel/forth.c	2006-07-28 21:44:07 UTC (rev 72)
@@ -593,7 +593,7 @@
 	const ucell *aaddr = (ucell *)cell2pointer(POP());
 	const ucell x = POP();
 #ifdef CONFIG_DEBUG_INTERNAL
-	printf("!: %lx : %lx -> %lx\n", aaddr, read_ucell(aaddr), x);
+	printk("!: %lx : %lx -> %lx\n", aaddr, read_ucell(aaddr), x);
 #endif
 	write_ucell(aaddr,x);
 }




More information about the OpenBIOS mailing list