]> git.proxmox.com Git - qemu.git/blobdiff - m68k-semi.c
iothread: replace fair_mutex with a condition variable
[qemu.git] / m68k-semi.c
index ef2729f4a8c64f5a11ae9dc37ad5e108be66fd3c..7fde10e8f36254685058e153c93a39c4d4a28a94 100644 (file)
 #define SEMIHOSTING_HEAP_SIZE (128 * 1024 * 1024)
 #else
 #include "qemu-common.h"
-#include "sysemu.h"
 #include "gdbstub.h"
 #include "softmmu-semi.h"
 #endif
+#include "sysemu.h"
 
 #define HOSTED_EXIT  0
 #define HOSTED_INIT_SIM 1
 #define HOSTED_ISATTY 12
 #define HOSTED_SYSTEM 13
 
-typedef uint32_t a_gdb_mode;
-typedef uint32_t a_gdb_time;
+typedef uint32_t gdb_mode_t;
+typedef uint32_t gdb_time_t;
 
 struct m68k_gdb_stat {
   uint32_t    gdb_st_dev;     /* device */
   uint32_t    gdb_st_ino;     /* inode */
-  a_gdb_mode  gdb_st_mode;    /* protection */
+  gdb_mode_t  gdb_st_mode;    /* protection */
   uint32_t    gdb_st_nlink;   /* number of hard links */
   uint32_t    gdb_st_uid;     /* user ID of owner */
   uint32_t    gdb_st_gid;     /* group ID of owner */
@@ -67,13 +67,13 @@ struct m68k_gdb_stat {
   uint64_t    gdb_st_size;    /* total size, in bytes */
   uint64_t    gdb_st_blksize; /* blocksize for filesystem I/O */
   uint64_t    gdb_st_blocks;  /* number of blocks allocated */
-  a_gdb_time  gdb_st_atime;   /* time of last access */
-  a_gdb_time  gdb_st_mtime;   /* time of last modification */
-  a_gdb_time  gdb_st_ctime;   /* time of last change */
+  gdb_time_t  gdb_st_atime;   /* time of last access */
+  gdb_time_t  gdb_st_mtime;   /* time of last modification */
+  gdb_time_t  gdb_st_ctime;   /* time of last change */
 } __attribute__((packed));
 
 struct gdb_timeval {
-  a_gdb_time tv_sec;  /* second */
+  gdb_time_t tv_sec;  /* second */
   uint64_t tv_usec;   /* microsecond */
 } __attribute__((packed));
 
@@ -172,6 +172,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
     args = env->dregs[1];
     switch (nr) {
     case HOSTED_EXIT:
+        gdb_exit(env, env->dregs[0]);
         exit(env->dregs[0]);
     case HOSTED_OPEN:
         if (use_gdb_syscalls()) {
@@ -369,7 +370,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
         TaskState *ts = env->opaque;
         /* Allocate the heap using sbrk.  */
         if (!ts->heap_limit) {
-            long ret;
+            abi_ulong ret;
             uint32_t size;
             uint32_t base;
 
@@ -378,8 +379,9 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
             /* Try a big heap, and reduce the size if that fails.  */
             for (;;) {
                 ret = do_brk(base + size);
-                if (ret != -1)
+                if (ret >= (base + size)) {
                     break;
+                }
                 size >>= 1;
             }
             ts->heap_limit = base + size;