From 424eae4cfb7f7e6d6177514f7188f4ede46929b3 Mon Sep 17 00:00:00 2001
From: patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>
Date: Tue, 1 Jan 2008 14:54:10 +0000
Subject: [PATCH] Debug z80sim NSH (still doesn't work)

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@476 42af7a65-404d-4744-a932-0658087f49c3
---
 ChangeLog                         |  2 ++
 Documentation/NuttX.html          |  3 +-
 TODO                              | 18 +++++++++--
 arch/arm/src/common/up_assert.c   | 50 +++++++++++++++----------------
 arch/arm/src/common/up_exit.c     | 42 ++++++++++++++------------
 arch/arm/src/common/up_internal.h | 34 ++++++++++-----------
 configs/z80sim/nshconfig          |  2 +-
 configs/z80sim/src/z80_serial.c   |  2 +-
 sched/sched_setupstreams.c        |  6 ++--
 9 files changed, 89 insertions(+), 70 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3df0a869df..157ef922ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -287,4 +287,6 @@
 
 	* Changes for use with SDCC compiler
 	* Added a simulated z80 target
+	* Fix deadlock errors when using stdio but with no buffering
+
 
diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html
index 4044642d45..2b4fc48e02 100644
--- a/Documentation/NuttX.html
+++ b/Documentation/NuttX.html
@@ -8,7 +8,7 @@
   <tr align="center" bgcolor="#e4e4e4">
     <td>
       <h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
-      <p>Last Updated: December 30, 2007</p>
+      <p>Last Updated: January 1, 2008</p>
     </td>
   </tr>
 </table>
@@ -725,6 +725,7 @@ Other memory:
 
 	* Changes for use with SDCC compiler
 	* Added a simulated z80 target
+	* Fix deadlock errors when using stdio but with no buffering
 </pre></ul>
 
 <table width ="100%">
diff --git a/TODO b/TODO
index 9e19e4272b..a4c63d9f85 100644
--- a/TODO
+++ b/TODO
@@ -18,7 +18,7 @@ NuttX TODO List (Last updated December 13, 2007)
   (1)  ARM/DM320 (arch/arm/src/dm320/)
   (2)  ARM/LPC214x (arch/arm/src/lpc214x/)
   (4)  pjrc-8052 / MCS51 (arch/pjrc-8051/)
-  (0)  z80 (arch/z80/)
+  (2)  z80 (arch/z80/)
 
 o Task/Scheduler (sched/)
   ^^^^^^^^^^^^^^^^^^^^^^^
@@ -315,7 +315,19 @@ o pjrc-8052 / MCS51 (arch/pjrc-8051/)
 o z80 (arch/z80)
  ^^^^^^^^^^^^^^^
 
-  Has the same problems with interger overflow during compilation as described
-  for pjrc-8051
+  Description: The Has the same problems with interger overflow during compilation
+               as described for pjrc-8051.  At typical cause is code like
+               usleep(500*1000) which exceeds the range of a 16-bit integer
+  Status:      See pjrc-8051
+  Priority:    See pjrc-8051
+
+  Description: The simulated serial console (configs/z80sim/src/z80_serial.c +
+               driver/serial.c) does not work.  This is because there are
+               no interrupts in the simulation so there is never any serial
+               traffic.
+  Status:      Open
+  Priority:    Low -- the simulated console is not critical path and the designs
+               to solve the problem are complex.
+
 
 
diff --git a/arch/arm/src/common/up_assert.c b/arch/arm/src/common/up_assert.c
index 3c8c859e07..9ddaf555c4 100644
--- a/arch/arm/src/common/up_assert.c
+++ b/arch/arm/src/common/up_assert.c
@@ -1,7 +1,7 @@
-/************************************************************
+/****************************************************************************
  * common/up_assert.c
  *
- *   Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ *   Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <spudmonkey@racsa.co.cr>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
- * 3. Neither the name Gregory Nutt nor the names of its contributors may be
+ * 3. Neither the name NuttX nor the names of its contributors may be
  *    used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -31,11 +31,11 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- ************************************************************/
+ ****************************************************************************/
 
-/************************************************************
+/****************************************************************************
  * Included Files
- ************************************************************/
+ ****************************************************************************/
 
 #include <nuttx/config.h>
 
@@ -51,9 +51,9 @@
 #include "os_internal.h"
 #include "up_internal.h"
 
-/************************************************************
+/****************************************************************************
  * Definitions
- ************************************************************/
+ ****************************************************************************/
 
 /* Output debug info if stack dump is selected -- even if 
  * debug is not selected.
@@ -64,17 +64,17 @@
 # define lldbg lib_lowprintf
 #endif
 
-/************************************************************
+/****************************************************************************
  * Private Data
- ************************************************************/
+ ****************************************************************************/
 
-/************************************************************
+/****************************************************************************
  * Private Functions
- ************************************************************/
+ ****************************************************************************/
 
-/************************************************************
+/****************************************************************************
  * Name: up_getsp
- ************************************************************/
+ ****************************************************************************/
 
 /* I don't know if the builtin to get SP is enabled */
 
@@ -89,9 +89,9 @@ static inline uint32 up_getsp(void)
   return sp;
 }
 
-/************************************************************
+/****************************************************************************
  * Name: up_stackdump
- ************************************************************/
+ ****************************************************************************/
 
 #ifdef CONFIG_ARCH_STACKDUMP
 static void up_stackdump(void)
@@ -152,9 +152,9 @@ static void up_stackdump(void)
 # define up_stackdump()
 #endif
 
-/************************************************************
+/****************************************************************************
  * Name: _up_assert
- ************************************************************/
+ ****************************************************************************/
 
 static void _up_assert(int errorcode) /* __attribute__ ((noreturn)) */
 {
@@ -179,13 +179,13 @@ static void _up_assert(int errorcode) /* __attribute__ ((noreturn)) */
     }
 }
 
-/************************************************************
- * Public Funtions
- ************************************************************/
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
 
-/************************************************************
+/****************************************************************************
  * Name: up_assert
- ************************************************************/
+ ****************************************************************************/
 
 void up_assert(const ubyte *filename, int lineno)
 {
@@ -205,9 +205,9 @@ void up_assert(const ubyte *filename, int lineno)
   _up_assert(EXIT_FAILURE);
 }
 
-/************************************************************
+/****************************************************************************
  * Name: up_assert_code
- ************************************************************/
+ ****************************************************************************/
 
 void up_assert_code(const ubyte *filename, int lineno, int errorcode)
 {
diff --git a/arch/arm/src/common/up_exit.c b/arch/arm/src/common/up_exit.c
index e1cddbf265..e760b00cf6 100644
--- a/arch/arm/src/common/up_exit.c
+++ b/arch/arm/src/common/up_exit.c
@@ -1,7 +1,7 @@
-/************************************************************
+/****************************************************************************
  * common/up_exit.c
  *
- *   Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ *   Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <spudmonkey@racsa.co.cr>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
- * 3. Neither the name Gregory Nutt nor the names of its contributors may be
+ * 3. Neither the name NuttX nor the names of its contributors may be
  *    used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -31,11 +31,11 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- ************************************************************/
+ ****************************************************************************/
 
-/************************************************************
+/****************************************************************************
  * Included Files
- ************************************************************/
+ ****************************************************************************/
 
 #include <nuttx/config.h>
 #include <sys/types.h>
@@ -49,19 +49,19 @@
 #include <nuttx/fs.h>
 #endif
 
-/************************************************************
+/****************************************************************************
  * Private Definitions
- ************************************************************/
+ ****************************************************************************/
 
-/************************************************************
+/****************************************************************************
  * Private Data
- ************************************************************/
+ ****************************************************************************/
 
-/************************************************************
+/****************************************************************************
  * Private Funtions
- ************************************************************/
+ ****************************************************************************/
 
-/************************************************************
+/****************************************************************************
  * Name: _up_dumponexit
  *
  * Description:
@@ -70,7 +70,7 @@
  *   related reference counting but could be useful again
  *   sometime in the future.
  *
- ************************************************************/
+ ****************************************************************************/
 
 #if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
 static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
@@ -110,9 +110,13 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
           struct file_struct *filep = &tcb->streams->sl_streams[i];
           if (filep->fs_filedes >= 0)
             {
+#if CONFIG_STDIO_BUFFER_SIZE > 0
               dbg("      fd=%d nbytes=%d\n",
                   filep->fs_filedes,
                   filep->fs_bufpos - filep->fs_bufstart);
+#else
+              dbg("      fd=%d\n", filep->fs_filedes);
+#endif
             }
         }
     }
@@ -120,18 +124,18 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
 }
 #endif
 
-/************************************************************
- * Public Funtions
- ************************************************************/
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
 
-/************************************************************
+/****************************************************************************
  * Name: _exit
  *
  * Description:
  *   This function causes the currently executing task to cease
  *   to exist.  This is a special case of task_delete().
  *
- ************************************************************/
+ ****************************************************************************/
 
 void _exit(int status)
 {
diff --git a/arch/arm/src/common/up_internal.h b/arch/arm/src/common/up_internal.h
index a32c5324db..a2be035ff8 100644
--- a/arch/arm/src/common/up_internal.h
+++ b/arch/arm/src/common/up_internal.h
@@ -1,7 +1,7 @@
-/************************************************************
+/****************************************************************************
  * common/up_internal.h
  *
- *   Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ *   Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <spudmonkey@racsa.co.cr>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
- * 3. Neither the name Gregory Nutt nor the names of its contributors may be
+ * 3. Neither the name NuttX nor the names of its contributors may be
  *    used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -31,18 +31,18 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- ************************************************************/
+ ****************************************************************************/
 
 #ifndef __UP_INTERNAL_H
 #define __UP_INTERNAL_H
 
-/************************************************************
+/****************************************************************************
  * Included Files
- ************************************************************/
+ ****************************************************************************/
 
-/************************************************************
+/****************************************************************************
  * Definitions
- ************************************************************/
+ ****************************************************************************/
 
 /* Bring-up debug configurations.  These are here (vs defconfig)
  * because these should only be controlled during low level
@@ -53,19 +53,19 @@
 #undef  CONFIG_SUPPRESS_TIMER_INTS    /* No timer */
 #undef  CONFIG_SUPPRESS_SERIAL_INTS   /* Console will poll */
 #undef  CONFIG_SUPPRESS_UART_CONFIG   /* Do not reconfig UART */
-#define CONFIG_DUMP_ON_EXIT         1 /* Dump task state on exit */
+#undef  CONFIG_DUMP_ON_EXIT           /* Dump task state on exit */
 
-/************************************************************
+/****************************************************************************
  * Public Types
- ************************************************************/
+ ****************************************************************************/
 
 #ifndef __ASSEMBLY__
 typedef void (*up_vector_t)(void);
 #endif
 
-/************************************************************
+/****************************************************************************
  * Public Variables
- ************************************************************/
+ ****************************************************************************/
 
 #ifndef __ASSEMBLY__
 /* This holds a references to the current interrupt level
@@ -84,14 +84,14 @@ extern uint32 *current_regs;
 extern uint32 g_heapbase;
 #endif
 
-/************************************************************
+/****************************************************************************
  * Inline Functions
- ************************************************************/
+ ****************************************************************************/
 
 
-/************************************************************
+/****************************************************************************
  * Public Functions
- ************************************************************/
+ ****************************************************************************/
 
 #ifndef __ASSEMBLY__
 
diff --git a/configs/z80sim/nshconfig b/configs/z80sim/nshconfig
index b14b093622..63326cb6f2 100644
--- a/configs/z80sim/nshconfig
+++ b/configs/z80sim/nshconfig
@@ -130,7 +130,7 @@ CONFIG_DISABLE_POSIX_TIMERS=y
 CONFIG_DISABLE_PTHREAD=y
 CONFIG_DISABLE_SIGNALS=n
 CONFIG_DISABLE_MQUEUE=y
-CONFIG_DISABLE_MOUNTPOINT=n
+CONFIG_DISABLE_MOUNTPOINT=y
 CONFIG_DISABLE_ENVIRON=y
 
 #
diff --git a/configs/z80sim/src/z80_serial.c b/configs/z80sim/src/z80_serial.c
index 9a8fa0f89d..2dcd56c053 100644
--- a/configs/z80sim/src/z80_serial.c
+++ b/configs/z80sim/src/z80_serial.c
@@ -288,7 +288,7 @@ static boolean up_txfifonotfull(struct uart_dev_s *dev)
 
 static boolean up_txfifoempty(struct uart_dev_s *dev)
 {
-  return FALSE;
+  return TRUE;
 }
 
 /****************************************************************************
diff --git a/sched/sched_setupstreams.c b/sched/sched_setupstreams.c
index 6e7216a495..88d0b09c43 100644
--- a/sched/sched_setupstreams.c
+++ b/sched/sched_setupstreams.c
@@ -1,7 +1,7 @@
 /****************************************************************************
  * sched_setupstreams.c
  *
- *   Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ *   Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <spudmonkey@racsa.co.cr>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
- * 3. Neither the name Gregory Nutt nor the names of its contributors may be
+ * 3. Neither the name NuttX nor the names of its contributors may be
  *    used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -78,4 +78,4 @@ int sched_setupstreams(FAR _TCB *tcb)
   return OK;
 }
 
-#endif /* CONFIG_NFILE_STREAMS && CONFIG_NFILE_STREAMS*/
+#endif /* CONFIG_NFILE_STREAMS && CONFIG_NFILE_STREAMS */
-- 
GitLab