Index: c/src/exec/libcsupport/include/rtems/libio.h
===================================================================
--- c/src/exec/libcsupport/include/rtems/libio.h	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ c/src/exec/libcsupport/include/rtems/libio.h	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -158,5 +158,5 @@
 rtems_status_code rtems_termios_ioctl (void *arg);
 int rtems_termios_enqueue_raw_characters (void *ttyp, char *buf, int len);
-void rtems_termios_dequeue_characters (void *ttyp, int len);
+int rtems_termios_dequeue_characters (void *ttyp, int len);
 void rtems_termios_reserve_resources(
   rtems_configuration_table *configuration,
Index: c/src/exec/libcsupport/src/termios.c
===================================================================
--- c/src/exec/libcsupport/src/termios.c	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ c/src/exec/libcsupport/src/termios.c	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -895,7 +895,8 @@
  * The second argument is the number of characters transmitted so far.
  * This value will always be 1 for devices which generate an interrupt
- * for each transmitted character.
- */
-void
+ * for each transmitted character. 
+ * It returns number of characters left to transmit
+ */
+int
 rtems_termios_dequeue_characters (void *ttyp, int len)
 {
@@ -907,5 +908,5 @@
 		rtems_semaphore_release (tty->rawOutBufSemaphore);
 	if ( tty->rawOutBufHead == tty->rawOutBufTail )
-		return;
+		return 0;
 	newTail = (tty->rawOutBufTail + len) % RAW_OUTPUT_BUFFER_SIZE;
 	if (newTail == tty->rawOutBufHead) {
@@ -914,4 +915,5 @@
 		 */
 		tty->rawOutBufState = rob_idle;
+		nToSend = 0;
 	}
 	else {
@@ -927,3 +929,7 @@
 	}
 	tty->rawOutBufTail = newTail;
-}
+
+	return nToSend;
+}
+
+
Index: c/src/lib/include/rtems/libio.h
===================================================================
--- c/src/lib/include/rtems/libio.h	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ c/src/lib/include/rtems/libio.h	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -158,5 +158,5 @@
 rtems_status_code rtems_termios_ioctl (void *arg);
 int rtems_termios_enqueue_raw_characters (void *ttyp, char *buf, int len);
-void rtems_termios_dequeue_characters (void *ttyp, int len);
+int rtems_termios_dequeue_characters (void *ttyp, int len);
 void rtems_termios_reserve_resources(
   rtems_configuration_table *configuration,
Index: c/src/lib/libbsp/i386/pc386/console/console.c
===================================================================
--- c/src/lib/libbsp/i386/pc386/console/console.c	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ c/src/lib/libbsp/i386/pc386/console/console.c	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -59,5 +59,4 @@
 int PC386ConsolePort = PC386_CONSOLE_PORT_CONSOLE;
 
-static int conSetAttr(int minor, const struct termios *);
 extern BSP_polling_getchar_function_type BSP_poll_char;
 
@@ -65,19 +64,38 @@
 | External Prototypes
 +--------------------------------------------------------------------------*/
-extern void 	_IBMPC_keyboard_isr(void);
-extern void 	_IBMPC_keyboard_isr_on(const rtems_irq_connect_data*);
-extern void 	_IBMPC_keyboard_isr_off(const rtems_irq_connect_data*);
-extern int 	_IBMPC_keyboard_isr_is_on(const rtems_irq_connect_data*);
-
-static rtems_irq_connect_data console_isr_data = {PC_386_KEYBOARD,
-						   _IBMPC_keyboard_isr,
-						   _IBMPC_keyboard_isr_on,
-						   _IBMPC_keyboard_isr_off,
-						   _IBMPC_keyboard_isr_is_on};
-						   
-
+extern void _IBMPC_keyboard_isr(void);
 extern rtems_boolean _IBMPC_scankey(char *);  /* defined in 'inch.c' */
 extern char BSP_wait_polled_input(void);
 extern void _IBMPC_initVideo(void);
+
+static int  conSetAttr(int minor, const struct termios *);
+static void isr_on(const rtems_irq_connect_data *);
+static void isr_off(const rtems_irq_connect_data *);
+static int  isr_is_on(const rtems_irq_connect_data *);
+
+
+static rtems_irq_connect_data console_isr_data = {PC_386_KEYBOARD,
+						   _IBMPC_keyboard_isr,
+						   isr_on,
+						   isr_off,
+						   isr_is_on};
+
+static void
+isr_on(const rtems_irq_connect_data *unused)
+{
+  return;
+}
+						   
+static void
+isr_off(const rtems_irq_connect_data *unused)
+{
+  return;
+}
+
+static int
+isr_is_on(const rtems_irq_connect_data *irq)
+{
+  return pc386_irq_enabled_at_i8259s(irq->name);
+}
 
 void console_reserve_resources(rtems_configuration_table *conf)
@@ -204,5 +222,5 @@
 	  printk("Initialized console on port COM2 9600-8-N-1\n\n");
 	}
-#define  PRINTK_ON_SERIAL     
+#define  PRINTK_ON_SERIAL
 #ifdef PRINTK_ON_SERIAL
       /*
@@ -222,7 +240,9 @@
 static int console_open_count = 0;
 
-static void console_last_close()
+static int console_last_close(int major, int minor, void *arg)
 {
   pc386_remove_rtems_irq_handler (&console_isr_data);
+
+  return 0;
 }
 
@@ -295,5 +315,5 @@
   else {
     if (--console_open_count == 0) { 
-      console_last_close();
+      console_last_close(major, minor, arg);
     }
   }
@@ -475,8 +495,3 @@
 BSP_polling_getchar_function_type BSP_poll_char = BSP_wait_polled_input;
 
-void BSP_emergency_output_init()
-{
-  _IBMPC_initVideo();
-}
-
-
+
Index: c/src/lib/libbsp/i386/pc386/console/inch.c
===================================================================
--- c/src/lib/libbsp/i386/pc386/console/inch.c	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ c/src/lib/libbsp/i386/pc386/console/inch.c	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -211,16 +211,4 @@
 } /* _IBMPC_scankey */
 
-void _IBMPC_keyboard_isr_on(const rtems_irq_connect_data* unused)
-{}
-void _IBMPC_keyboard_isr_off(const rtems_irq_connect_data* unused)
-{}
-
-int _IBMPC_keyboard_isr_is_on(const rtems_irq_connect_data* irq)
-{
-  return pc386_irq_enabled_at_i8259s (irq->name);
-}
-
-
-
 /*-------------------------------------------------------------------------+
 |         Function: _IBMPC_keyboard_isr
Index: c/src/lib/libbsp/i386/pc386/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/i386/pc386/startup/bspstart.c	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ c/src/lib/libbsp/i386/pc386/startup/bspstart.c	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -37,5 +37,4 @@
 #include <rtems/libio.h>
 #include <libcpu/cpuModel.h>
-#include <pc386uart.h>
 
 /*-------------------------------------------------------------------------+
@@ -65,15 +64,10 @@
 char            *rtems_progname;               /* Program name - from main(). */
 
-extern void debugPollingGetChar();
-
 /*-------------------------------------------------------------------------+
 | External Prototypes
 +--------------------------------------------------------------------------*/
-extern void _exit(int);  /* define in exit.c */
-extern void _IBMPC_initVideo(void); 
-extern void rtems_irq_mngt_init();
+extern void rtems_irq_mngt_init(void);
 void bsp_libc_init( void *, unsigned32, int );
 void bsp_postdriver_hook(void);
-extern void _IBMPC_initVideo(void);
 
 /*-------------------------------------------------------------------------+
@@ -109,6 +103,4 @@
 	}
 
-      printk("\n");
-
       for(i=2; i<=2048; i++)
 	{
@@ -146,12 +138,10 @@
 +--------------------------------------------------------------------------*/
 void bsp_start( void )
-  /* Initialize printk channel */
-  _IBMPC_initVideo();
 {
-
   /*
    * Calibrate variable for 1ms-loop (see timer.c)
    */
   Calibrate_loop_1ms();
+
   /*
    * Initialize printk channel
Index: c/src/lib/libbsp/i386/pc386/startup/exit.c
===================================================================
--- c/src/lib/libbsp/i386/pc386/startup/exit.c	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ c/src/lib/libbsp/i386/pc386/startup/exit.c	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -38,5 +38,5 @@
 #include <pc386uart.h>
 
-void bsp_cleanup()
+void bsp_cleanup(void)
 {
   unsigned char ch;
@@ -57,2 +57,5 @@
 
 
+
+
+
Index: c/src/lib/libbsp/i386/shared/irq/idt.c
===================================================================
--- c/src/lib/libbsp/i386/shared/irq/idt.c	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ c/src/lib/libbsp/i386/shared/irq/idt.c	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -46,11 +46,4 @@
 
     i386_get_info_from_IDTR (&idt_entry_tbl, &limit);
-	
-    /* Convert limit into number of entries */
-    limit = (limit + 1) >> 3;
-
-    if(index >= limit) {
-        return 0;
-    }
 	
     /* Convert limit into number of entries */
@@ -280,5 +273,5 @@
 
     /*
-    return 1;
+     * Now, reload all segment registers so the limit takes effect.
      */
 
Index: c/src/lib/libbsp/i386/shared/irq/irq_init.c
===================================================================
--- c/src/lib/libbsp/i386/shared/irq/irq_init.c	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ c/src/lib/libbsp/i386/shared/irq/irq_init.c	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -117,10 +117,17 @@
     int 			i;
     interrupt_gate_descriptor* 	idt_entry_tbl;
-    unsigned			limit;
+    unsigned int                limit;
     unsigned int 		level;
 
-    i386_get_info_from_IDTR (&idt_entry_tbl, &limit);
-    /* Convert limit into number of entries */
-    limit = (limit + 1) / sizeof(interrupt_gate_descriptor);    
+    i386_get_info_from_IDTR(&idt_entry_tbl, &limit);
+
+    /* Convert into number of entries */
+    limit = (limit + 1)/sizeof(interrupt_gate_descriptor);
+
+    if(limit != IDT_SIZE) {
+       printk("IDT table size mismatch !!! System locked\n");
+       while(1);
+    }
+    
 
     _CPU_ISR_Disable(level);
@@ -129,8 +136,9 @@
      * Init the complete IDT vector table with defaultRawIrq value
      */
-    for (i = 0; i < limit; i++) {
+    for (i = 0; i < IDT_SIZE ; i++) {
       idtHdl[i] 	 = defaultRawIrq;
       idtHdl[i].idtIndex = i;
     }
+
     raw_initial_config.idtSize = IDT_SIZE;
     raw_initial_config.defaultRawEntry = defaultRawIrq;
Index: c/src/lib/libc/libio.h
===================================================================
--- c/src/lib/libc/libio.h	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ c/src/lib/libc/libio.h	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -158,5 +158,5 @@
 rtems_status_code rtems_termios_ioctl (void *arg);
 int rtems_termios_enqueue_raw_characters (void *ttyp, char *buf, int len);
-void rtems_termios_dequeue_characters (void *ttyp, int len);
+int rtems_termios_dequeue_characters (void *ttyp, int len);
 void rtems_termios_reserve_resources(
   rtems_configuration_table *configuration,
Index: c/src/lib/libc/termios.c
===================================================================
--- c/src/lib/libc/termios.c	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ c/src/lib/libc/termios.c	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -895,7 +895,8 @@
  * The second argument is the number of characters transmitted so far.
  * This value will always be 1 for devices which generate an interrupt
- * for each transmitted character.
- */
-void
+ * for each transmitted character. 
+ * It returns number of characters left to transmit
+ */
+int
 rtems_termios_dequeue_characters (void *ttyp, int len)
 {
@@ -907,5 +908,5 @@
 		rtems_semaphore_release (tty->rawOutBufSemaphore);
 	if ( tty->rawOutBufHead == tty->rawOutBufTail )
-		return;
+		return 0;
 	newTail = (tty->rawOutBufTail + len) % RAW_OUTPUT_BUFFER_SIZE;
 	if (newTail == tty->rawOutBufHead) {
@@ -914,4 +915,5 @@
 		 */
 		tty->rawOutBufState = rob_idle;
+		nToSend = 0;
 	}
 	else {
@@ -927,3 +929,7 @@
 	}
 	tty->rawOutBufTail = newTail;
-}
+
+	return nToSend;
+}
+
+
Index: c/src/lib/libcpu/i386/cpu.c
===================================================================
--- c/src/lib/libcpu/i386/cpu.c	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ c/src/lib/libcpu/i386/cpu.c	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -46,11 +46,4 @@
 
     i386_get_info_from_IDTR (&idt_entry_tbl, &limit);
-	
-    /* Convert limit into number of entries */
-    limit = (limit + 1) >> 3;
-
-    if(index >= limit) {
-        return 0;
-    }
 	
     /* Convert limit into number of entries */
@@ -280,5 +273,5 @@
 
     /*
-    return 1;
+     * Now, reload all segment registers so the limit takes effect.
      */
 
Index: c/src/lib/libcpu/i386/idt.c
===================================================================
--- c/src/lib/libcpu/i386/idt.c	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ c/src/lib/libcpu/i386/idt.c	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -46,11 +46,4 @@
 
     i386_get_info_from_IDTR (&idt_entry_tbl, &limit);
-	
-    /* Convert limit into number of entries */
-    limit = (limit + 1) >> 3;
-
-    if(index >= limit) {
-        return 0;
-    }
 	
     /* Convert limit into number of entries */
@@ -280,5 +273,5 @@
 
     /*
-    return 1;
+     * Now, reload all segment registers so the limit takes effect.
      */
 
Index: cpukit/libcsupport/include/rtems/libio.h
===================================================================
--- cpukit/libcsupport/include/rtems/libio.h	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ cpukit/libcsupport/include/rtems/libio.h	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -158,5 +158,5 @@
 rtems_status_code rtems_termios_ioctl (void *arg);
 int rtems_termios_enqueue_raw_characters (void *ttyp, char *buf, int len);
-void rtems_termios_dequeue_characters (void *ttyp, int len);
+int rtems_termios_dequeue_characters (void *ttyp, int len);
 void rtems_termios_reserve_resources(
   rtems_configuration_table *configuration,
Index: cpukit/libcsupport/src/termios.c
===================================================================
--- cpukit/libcsupport/src/termios.c	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ cpukit/libcsupport/src/termios.c	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -895,7 +895,8 @@
  * The second argument is the number of characters transmitted so far.
  * This value will always be 1 for devices which generate an interrupt
- * for each transmitted character.
- */
-void
+ * for each transmitted character. 
+ * It returns number of characters left to transmit
+ */
+int
 rtems_termios_dequeue_characters (void *ttyp, int len)
 {
@@ -907,5 +908,5 @@
 		rtems_semaphore_release (tty->rawOutBufSemaphore);
 	if ( tty->rawOutBufHead == tty->rawOutBufTail )
-		return;
+		return 0;
 	newTail = (tty->rawOutBufTail + len) % RAW_OUTPUT_BUFFER_SIZE;
 	if (newTail == tty->rawOutBufHead) {
@@ -914,4 +915,5 @@
 		 */
 		tty->rawOutBufState = rob_idle;
+		nToSend = 0;
 	}
 	else {
@@ -927,3 +929,7 @@
 	}
 	tty->rawOutBufTail = newTail;
-}
+
+	return nToSend;
+}
+
+
Index: make/target.cfg.in
===================================================================
--- make/target.cfg.in	(revision 362b88ebb5f44e91bc9fc9cc4601364f2b3f6297)
+++ make/target.cfg.in	(revision 8a496e462e37f78fbbd20009f036623f062ccea1)
@@ -40,4 +40,5 @@
 RTEMS_USE_OWN_PDIR = @RTEMS_USE_OWN_PDIR@
 RTEMS_HAS_POSIX_API = @RTEMS_HAS_POSIX_API@
+RTEMS_HAS_POSIX_1H_API = @RTEMS_HAS_POSIX_1H_API@
 RTEMS_HAS_NETWORKING = @RTEMS_HAS_NETWORKING@
 RTEMS_HAS_CPLUSPLUS = @RTEMS_HAS_CPLUSPLUS@
