| OLD | NEW |
| 1 /* Simulation code for the CR16 processor. | 1 /* Simulation code for the CR16 processor. |
| 2 Copyright (C) 2008-2012 Free Software Foundation, Inc. | 2 Copyright (C) 2008-2012 Free Software Foundation, Inc. |
| 3 Contributed by M Ranga Swami Reddy <MR.Swami.Reddy@nsc.com> | 3 Contributed by M Ranga Swami Reddy <MR.Swami.Reddy@nsc.com> |
| 4 | 4 |
| 5 This file is part of GDB, the GNU debugger. | 5 This file is part of GDB, the GNU debugger. |
| 6 | 6 |
| 7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
| 8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
| 9 the Free Software Foundation; either version 3, or (at your option) | 9 the Free Software Foundation; either version 3, or (at your option) |
| 10 any later version. | 10 any later version. |
| (...skipping 5113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5124 #define RETVAL32(X) do { result = (X); SET_GPR32 (0, result);} while (0) | 5124 #define RETVAL32(X) do { result = (X); SET_GPR32 (0, result);} while (0) |
| 5125 #define RETERR(X) SET_GPR (4, (X)) /* return error code. */ | 5125 #define RETERR(X) SET_GPR (4, (X)) /* return error code. */ |
| 5126 | 5126 |
| 5127 /* Turn a pointer in a register into a pointer into real memory. */ | 5127 /* Turn a pointer in a register into a pointer into real memory. */ |
| 5128 | 5128 |
| 5129 #define MEMPTR(x) ((char *)(dmem_addr(x))) | 5129 #define MEMPTR(x) ((char *)(dmem_addr(x))) |
| 5130 | 5130 |
| 5131 switch (FUNC) | 5131 switch (FUNC) |
| 5132 { | 5132 { |
| 5133 #if !defined(__GO32__) && !defined(_WIN32) | 5133 #if !defined(__GO32__) && !defined(_WIN32) |
| 5134 #ifdef TARGET_SYS_fork |
| 5134 case TARGET_SYS_fork: | 5135 case TARGET_SYS_fork: |
| 5135 trace_input ("<fork>", OP_VOID, OP_VOID, OP_VOID); | 5136 trace_input ("<fork>", OP_VOID, OP_VOID, OP_VOID); |
| 5136 RETVAL (fork ()); | 5137 RETVAL (fork ()); |
| 5137 trace_output_16 (result); | 5138 trace_output_16 (result); |
| 5138 break; | 5139 break; |
| 5140 #endif |
| 5139 | 5141 |
| 5140 #define getpid() 47 | 5142 #define getpid() 47 |
| 5141 case TARGET_SYS_getpid: | 5143 case TARGET_SYS_getpid: |
| 5142 trace_input ("<getpid>", OP_VOID, OP_VOID, OP_VOID); | 5144 trace_input ("<getpid>", OP_VOID, OP_VOID, OP_VOID); |
| 5143 RETVAL (getpid ()); | 5145 RETVAL (getpid ()); |
| 5144 trace_output_16 (result); | 5146 trace_output_16 (result); |
| 5145 break; | 5147 break; |
| 5146 | 5148 |
| 5147 case TARGET_SYS_kill: | 5149 case TARGET_SYS_kill: |
| 5148 trace_input ("<kill>", OP_REG, OP_REG, OP_VOID); | 5150 trace_input ("<kill>", OP_REG, OP_REG, OP_VOID); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5265 State.exception = SIGILL; | 5267 State.exception = SIGILL; |
| 5266 } | 5268 } |
| 5267 else | 5269 else |
| 5268 { | 5270 { |
| 5269 RETVAL (kill (PARM1, PARM2)); | 5271 RETVAL (kill (PARM1, PARM2)); |
| 5270 trace_output_16 (result); | 5272 trace_output_16 (result); |
| 5271 } | 5273 } |
| 5272 } | 5274 } |
| 5273 break; | 5275 break; |
| 5274 | 5276 |
| 5277 #ifdef TARGET_SYS_execve |
| 5275 case TARGET_SYS_execve: | 5278 case TARGET_SYS_execve: |
| 5276 trace_input ("<execve>", OP_VOID, OP_VOID, OP_VOID); | 5279 trace_input ("<execve>", OP_VOID, OP_VOID, OP_VOID); |
| 5277 RETVAL (execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2<<16|PARM3), | 5280 RETVAL (execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2<<16|PARM3), |
| 5278 (char **)MEMPTR (PARM4))); | 5281 (char **)MEMPTR (PARM4))); |
| 5279 trace_output_16 (result); | 5282 trace_output_16 (result); |
| 5280 break; | 5283 break; |
| 5284 #endif |
| 5281 | 5285 |
| 5282 #ifdef TARGET_SYS_execv | 5286 #ifdef TARGET_SYS_execv |
| 5283 case TARGET_SYS_execv: | 5287 case TARGET_SYS_execv: |
| 5284 trace_input ("<execv>", OP_VOID, OP_VOID, OP_VOID); | 5288 trace_input ("<execv>", OP_VOID, OP_VOID, OP_VOID); |
| 5285 RETVAL (execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2), NULL)); | 5289 RETVAL (execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2), NULL)); |
| 5286 trace_output_16 (result); | 5290 trace_output_16 (result); |
| 5287 break; | 5291 break; |
| 5288 #endif | 5292 #endif |
| 5289 | 5293 |
| 5294 #ifdef TARGET_SYS_pipe |
| 5290 case TARGET_SYS_pipe: | 5295 case TARGET_SYS_pipe: |
| 5291 { | 5296 { |
| 5292 reg_t buf; | 5297 reg_t buf; |
| 5293 int host_fd[2]; | 5298 int host_fd[2]; |
| 5294 | 5299 |
| 5295 trace_input ("<pipe>", OP_VOID, OP_VOID, OP_VOID); | 5300 trace_input ("<pipe>", OP_VOID, OP_VOID, OP_VOID); |
| 5296 buf = PARM1; | 5301 buf = PARM1; |
| 5297 RETVAL (pipe (host_fd)); | 5302 RETVAL (pipe (host_fd)); |
| 5298 SW (buf, host_fd[0]); | 5303 SW (buf, host_fd[0]); |
| 5299 buf += sizeof(uint16); | 5304 buf += sizeof(uint16); |
| 5300 SW (buf, host_fd[1]); | 5305 SW (buf, host_fd[1]); |
| 5301 trace_output_16 (result); | 5306 trace_output_16 (result); |
| 5302 } | 5307 } |
| 5303 break; | 5308 break; |
| 5309 #endif |
| 5304 | 5310 |
| 5305 #ifdef TARGET_SYS_wait | 5311 #ifdef TARGET_SYS_wait |
| 5306 case TARGET_SYS_wait: | 5312 case TARGET_SYS_wait: |
| 5307 { | 5313 { |
| 5308 int status; | 5314 int status; |
| 5309 trace_input ("<wait>", OP_REG, OP_VOID, OP_VOID); | 5315 trace_input ("<wait>", OP_REG, OP_VOID, OP_VOID); |
| 5310 RETVAL (wait (&status)); | 5316 RETVAL (wait (&status)); |
| 5311 if (PARM1) | 5317 if (PARM1) |
| 5312 SW (PARM1, status); | 5318 SW (PARM1, status); |
| 5313 trace_output_16 (result); | 5319 trace_output_16 (result); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5358 break; | 5364 break; |
| 5359 | 5365 |
| 5360 case TARGET_SYS_open: | 5366 case TARGET_SYS_open: |
| 5361 trace_input ("<open>", OP_MEMREF, OP_REG, OP_VOID); | 5367 trace_input ("<open>", OP_MEMREF, OP_REG, OP_VOID); |
| 5362 RETVAL32 (cr16_callback->open (cr16_callback, | 5368 RETVAL32 (cr16_callback->open (cr16_callback, |
| 5363 MEMPTR ((((unsigned long)PARM2)<<16)|PARM1), | 5369 MEMPTR ((((unsigned long)PARM2)<<16)|PARM1), |
| 5364 PARM3)); | 5370 PARM3)); |
| 5365 trace_output_32 (result); | 5371 trace_output_32 (result); |
| 5366 break; | 5372 break; |
| 5367 | 5373 |
| 5374 #ifdef TARGET_SYS_rename |
| 5368 case TARGET_SYS_rename: | 5375 case TARGET_SYS_rename: |
| 5369 trace_input ("<rename>", OP_MEMREF, OP_MEMREF, OP_VOID); | 5376 trace_input ("<rename>", OP_MEMREF, OP_MEMREF, OP_VOID); |
| 5370 RETVAL (cr16_callback->rename (cr16_callback, | 5377 RETVAL (cr16_callback->rename (cr16_callback, |
| 5371 MEMPTR ((((unsigned long)PARM2)<<16) |PARM1), | 5378 MEMPTR ((((unsigned long)PARM2)<<16) |PARM1), |
| 5372 MEMPTR ((((unsigned long)PARM4)<<16) |PARM3))
); | 5379 MEMPTR ((((unsigned long)PARM4)<<16) |PARM3))
); |
| 5373 trace_output_16 (result); | 5380 trace_output_16 (result); |
| 5374 break; | 5381 break; |
| 5382 #endif |
| 5375 | 5383 |
| 5376 case 0x408: /* REVISIT: Added a dummy getenv call. */ | 5384 case 0x408: /* REVISIT: Added a dummy getenv call. */ |
| 5377 trace_input ("<getenv>", OP_MEMREF, OP_MEMREF, OP_VOID); | 5385 trace_input ("<getenv>", OP_MEMREF, OP_MEMREF, OP_VOID); |
| 5378 RETVAL32(NULL); | 5386 RETVAL32(NULL); |
| 5379 trace_output_32 (result); | 5387 trace_output_32 (result); |
| 5380 break; | 5388 break; |
| 5381 | 5389 |
| 5382 case TARGET_SYS_exit: | 5390 case TARGET_SYS_exit: |
| 5383 trace_input ("<exit>", OP_VOID, OP_VOID, OP_VOID); | 5391 trace_input ("<exit>", OP_VOID, OP_VOID, OP_VOID); |
| 5384 State.exception = SIG_CR16_EXIT; | 5392 State.exception = SIG_CR16_EXIT; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5417 SW (buf+12, host_stat.st_rdev); | 5425 SW (buf+12, host_stat.st_rdev); |
| 5418 SLW (buf+16, host_stat.st_size); | 5426 SLW (buf+16, host_stat.st_size); |
| 5419 SLW (buf+20, host_stat.st_atime); | 5427 SLW (buf+20, host_stat.st_atime); |
| 5420 SLW (buf+28, host_stat.st_mtime); | 5428 SLW (buf+28, host_stat.st_mtime); |
| 5421 SLW (buf+36, host_stat.st_ctime); | 5429 SLW (buf+36, host_stat.st_ctime); |
| 5422 } | 5430 } |
| 5423 trace_output_16 (result); | 5431 trace_output_16 (result); |
| 5424 break; | 5432 break; |
| 5425 #endif | 5433 #endif |
| 5426 | 5434 |
| 5435 #ifdef TARGET_SYS_chown |
| 5427 case TARGET_SYS_chown: | 5436 case TARGET_SYS_chown: |
| 5428 trace_input ("<chown>", OP_VOID, OP_VOID, OP_VOID); | 5437 trace_input ("<chown>", OP_VOID, OP_VOID, OP_VOID); |
| 5429 RETVAL (chown (MEMPTR (PARM1), PARM2, PARM3)); | 5438 RETVAL (chown (MEMPTR (PARM1), PARM2, PARM3)); |
| 5430 trace_output_16 (result); | 5439 trace_output_16 (result); |
| 5431 break; | 5440 break; |
| 5441 #endif |
| 5432 | 5442 |
| 5433 case TARGET_SYS_chmod: | 5443 case TARGET_SYS_chmod: |
| 5434 trace_input ("<chmod>", OP_VOID, OP_VOID, OP_VOID); | 5444 trace_input ("<chmod>", OP_VOID, OP_VOID, OP_VOID); |
| 5435 RETVAL (chmod (MEMPTR (PARM1), PARM2)); | 5445 RETVAL (chmod (MEMPTR (PARM1), PARM2)); |
| 5436 trace_output_16 (result); | 5446 trace_output_16 (result); |
| 5437 break; | 5447 break; |
| 5438 | 5448 |
| 5439 #ifdef TARGET_SYS_utime | 5449 #ifdef TARGET_SYS_utime |
| 5440 case TARGET_SYS_utime: | 5450 case TARGET_SYS_utime: |
| 5441 trace_input ("<utime>", OP_REG, OP_REG, OP_REG); | 5451 trace_input ("<utime>", OP_REG, OP_REG, OP_REG); |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5966 trace_output_32 (a); | 5976 trace_output_32 (a); |
| 5967 } | 5977 } |
| 5968 | 5978 |
| 5969 /* null. */ | 5979 /* null. */ |
| 5970 void | 5980 void |
| 5971 OP_0_20 () | 5981 OP_0_20 () |
| 5972 { | 5982 { |
| 5973 trace_input ("null", OP_VOID, OP_VOID, OP_VOID); | 5983 trace_input ("null", OP_VOID, OP_VOID, OP_VOID); |
| 5974 State.exception = SIG_CR16_STOP; | 5984 State.exception = SIG_CR16_STOP; |
| 5975 } | 5985 } |
| OLD | NEW |