1 /* armos.c -- ARMulator OS interface: ARM6 Instruction Emulator.
2 Copyright (C) 1994 Advanced RISC Machines Ltd.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 /* This file contains a model of Demon, ARM Ltd's Debug Monitor,
18 including all the SWI's required to support the C library. The code in
19 it is not really for the faint-hearted (especially the abort handling
20 code), but it is a complete example. Defining NOOS will disable all the
21 fun, and definign VAILDATE will define SWI 1 to enter SVC mode, and SWI
22 0x11 to halt the emulator. */
31 #include "targ-vals.h"
33 #ifndef TARGET_O_BINARY
34 #define TARGET_O_BINARY 0
38 #include <unistd.h> /* For SEEK_SET etc. */
53 /* For RDIError_BreakpointReached. */
56 #include "gdb/callback.h"
57 extern host_callback
*sim_callback
;
59 extern unsigned ARMul_OSInit (ARMul_State
*);
60 extern unsigned ARMul_OSHandleSWI (ARMul_State
*, ARMword
);
69 /* OS private Information. */
76 /* Bit mask of enabled SWI implementations. */
77 unsigned int swi_mask
= -1;
80 static ARMword softvectorcode
[] =
82 /* Installed instructions:
83 swi tidyexception + event;
86 swi generateexception + event. */
87 0xef000090, 0xe1a0e00f, 0xe89b8800, 0xef000080, /* Reset */
88 0xef000091, 0xe1a0e00f, 0xe89b8800, 0xef000081, /* Undef */
89 0xef000092, 0xe1a0e00f, 0xe89b8800, 0xef000082, /* SWI */
90 0xef000093, 0xe1a0e00f, 0xe89b8800, 0xef000083, /* Prefetch abort */
91 0xef000094, 0xe1a0e00f, 0xe89b8800, 0xef000084, /* Data abort */
92 0xef000095, 0xe1a0e00f, 0xe89b8800, 0xef000085, /* Address exception */
93 0xef000096, 0xe1a0e00f, 0xe89b8800, 0xef000086, /* IRQ */
94 0xef000097, 0xe1a0e00f, 0xe89b8800, 0xef000087, /* FIQ */
95 0xef000098, 0xe1a0e00f, 0xe89b8800, 0xef000088, /* Error */
96 0xe1a0f00e /* Default handler */
99 /* Time for the Operating System to initialise itself. */
102 ARMul_OSInit (ARMul_State
* state
)
107 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
109 if (state
->OSptr
== NULL
)
111 state
->OSptr
= (unsigned char *) malloc (sizeof (struct OSblock
));
112 if (state
->OSptr
== NULL
)
114 perror ("OS Memory");
119 OSptr
= (struct OSblock
*) state
->OSptr
;
120 state
->Reg
[13] = ADDRSUPERSTACK
; /* Set up a stack for the current mode... */
121 ARMul_SetReg (state
, SVC32MODE
, 13, ADDRSUPERSTACK
);/* ...and for supervisor mode... */
122 ARMul_SetReg (state
, ABORT32MODE
, 13, ADDRSUPERSTACK
);/* ...and for abort 32 mode... */
123 ARMul_SetReg (state
, UNDEF32MODE
, 13, ADDRSUPERSTACK
);/* ...and for undef 32 mode... */
124 ARMul_SetReg (state
, SYSTEMMODE
, 13, ADDRSUPERSTACK
);/* ...and for system mode. */
125 instr
= 0xe59ff000 | (ADDRSOFTVECTORS
- 8); /* Load pc from soft vector */
127 for (i
= ARMul_ResetV
; i
<= ARMFIQV
; i
+= 4)
128 /* Write hardware vectors. */
129 ARMul_WriteWord (state
, i
, instr
);
131 SWI_vector_installed
= 0;
133 for (i
= ARMul_ResetV
; i
<= ARMFIQV
+ 4; i
+= 4)
135 ARMul_WriteWord (state
, ADDRSOFTVECTORS
+ i
, SOFTVECTORCODE
+ i
* 4);
136 ARMul_WriteWord (state
, ADDRSOFHANDLERS
+ 2 * i
+ 4L,
137 SOFTVECTORCODE
+ sizeof (softvectorcode
) - 4L);
140 for (i
= 0; i
< sizeof (softvectorcode
); i
+= 4)
141 ARMul_WriteWord (state
, SOFTVECTORCODE
+ i
, softvectorcode
[i
/ 4]);
143 ARMul_ConsolePrint (state
, ", Demon 1.01");
148 for (i
= 0; i
< fpesize
; i
+= 4)
150 ARMul_WriteWord (state
, FPESTART
+ i
, fpecode
[i
>> 2]);
152 /* Scan backwards from the end of the code. */
153 for (i
= FPESTART
+ fpesize
;; i
-= 4)
155 /* When we reach the marker value, break out of
156 the loop, leaving i pointing at the maker. */
157 if ((j
= ARMul_ReadWord (state
, i
)) == 0xffffffff)
160 /* If necessary, reverse the error strings. */
161 if (state
->bigendSig
&& j
< 0x80000000)
163 /* It's part of the string so swap it. */
164 j
= ((j
>> 0x18) & 0x000000ff) |
165 ((j
>> 0x08) & 0x0000ff00) |
166 ((j
<< 0x08) & 0x00ff0000) | ((j
<< 0x18) & 0xff000000);
167 ARMul_WriteWord (state
, i
, j
);
171 /* Copy old illegal instr vector. */
172 ARMul_WriteWord (state
, FPEOLDVECT
, ARMul_ReadWord (state
, ARMUndefinedInstrV
));
173 /* Install new vector. */
174 ARMul_WriteWord (state
, ARMUndefinedInstrV
, FPENEWVECT (ARMul_ReadWord (state
, i
- 4)));
175 ARMul_ConsolePrint (state
, ", FPE");
178 #endif /* VALIDATE */
181 /* Intel do not want DEMON SWI support. */
182 if (state
->is_XScale
)
183 swi_mask
= SWI_MASK_ANGEL
;
188 static int translate_open_mode
[] =
190 TARGET_O_RDONLY
, /* "r" */
191 TARGET_O_RDONLY
+ TARGET_O_BINARY
, /* "rb" */
192 TARGET_O_RDWR
, /* "r+" */
193 TARGET_O_RDWR
+ TARGET_O_BINARY
, /* "r+b" */
194 TARGET_O_WRONLY
+ TARGET_O_CREAT
+ TARGET_O_TRUNC
, /* "w" */
195 TARGET_O_WRONLY
+ TARGET_O_BINARY
+ TARGET_O_CREAT
+ TARGET_O_TRUNC
, /* "wb" */
196 TARGET_O_RDWR
+ TARGET_O_CREAT
+ TARGET_O_TRUNC
, /* "w+" */
197 TARGET_O_RDWR
+ TARGET_O_BINARY
+ TARGET_O_CREAT
+ TARGET_O_TRUNC
, /* "w+b" */
198 TARGET_O_WRONLY
+ TARGET_O_APPEND
+ TARGET_O_CREAT
, /* "a" */
199 TARGET_O_WRONLY
+ TARGET_O_BINARY
+ TARGET_O_APPEND
+ TARGET_O_CREAT
, /* "ab" */
200 TARGET_O_RDWR
+ TARGET_O_APPEND
+ TARGET_O_CREAT
, /* "a+" */
201 TARGET_O_RDWR
+ TARGET_O_BINARY
+ TARGET_O_APPEND
+ TARGET_O_CREAT
/* "a+b" */
205 SWIWrite0 (ARMul_State
* state
, ARMword addr
)
208 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
210 while ((temp
= ARMul_SafeReadByte (state
, addr
++)) != 0)
213 /* Note - we cannot just cast 'temp' to a (char *) here,
214 since on a big-endian host the byte value will end
215 up in the wrong place and a nul character will be printed. */
216 (void) sim_callback
->write_stdout (sim_callback
, & buffer
, 1);
219 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
223 WriteCommandLineTo (ARMul_State
* state
, ARMword addr
)
226 char *cptr
= state
->CommandLine
;
232 temp
= (ARMword
) * cptr
++;
233 ARMul_SafeWriteByte (state
, addr
++, temp
);
239 ReadFileName (ARMul_State
* state
, char *buf
, ARMword src
, size_t n
)
241 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
245 if ((*p
++ = ARMul_SafeReadByte (state
, src
++)) == '\0')
247 OSptr
->ErrorNo
= cb_host_to_target_errno (sim_callback
, ENAMETOOLONG
);
253 SWIopen (ARMul_State
* state
, ARMword name
, ARMword SWIflags
)
255 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
259 if (ReadFileName (state
, buf
, name
, sizeof buf
) == -1)
262 /* Now we need to decode the Demon open mode. */
263 if (SWIflags
>= sizeof (translate_open_mode
) / sizeof (translate_open_mode
[0]))
266 flags
= translate_open_mode
[SWIflags
];
268 /* Filename ":tt" is special: it denotes stdin/out. */
269 if (strcmp (buf
, ":tt") == 0)
271 if (flags
== TARGET_O_RDONLY
) /* opening tty "r" */
272 state
->Reg
[0] = 0; /* stdin */
274 state
->Reg
[0] = 1; /* stdout */
278 state
->Reg
[0] = sim_callback
->open (sim_callback
, buf
, flags
);
279 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
284 SWIread (ARMul_State
* state
, ARMword f
, ARMword ptr
, ARMword len
)
286 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
289 char *local
= malloc (len
);
293 sim_callback
->printf_filtered
295 "sim: Unable to read 0x%ulx bytes - out of memory\n",
300 res
= sim_callback
->read (sim_callback
, f
, local
, len
);
302 for (i
= 0; i
< res
; i
++)
303 ARMul_SafeWriteByte (state
, ptr
+ i
, local
[i
]);
306 state
->Reg
[0] = res
== -1 ? -1 : len
- res
;
307 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
311 SWIwrite (ARMul_State
* state
, ARMword f
, ARMword ptr
, ARMword len
)
313 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
316 char *local
= malloc (len
);
320 sim_callback
->printf_filtered
322 "sim: Unable to write 0x%lx bytes - out of memory\n",
327 for (i
= 0; i
< len
; i
++)
328 local
[i
] = ARMul_SafeReadByte (state
, ptr
+ i
);
330 res
= sim_callback
->write (sim_callback
, f
, local
, len
);
331 state
->Reg
[0] = res
== -1 ? -1 : len
- res
;
334 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
338 SWIflen (ARMul_State
* state
, ARMword fh
)
340 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
345 OSptr
->ErrorNo
= EBADF
;
350 addr
= sim_callback
->lseek (sim_callback
, fh
, 0, SEEK_CUR
);
352 state
->Reg
[0] = sim_callback
->lseek (sim_callback
, fh
, 0L, SEEK_END
);
353 (void) sim_callback
->lseek (sim_callback
, fh
, addr
, SEEK_SET
);
355 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
359 SWIremove (ARMul_State
* state
, ARMword path
)
363 if (ReadFileName (state
, buf
, path
, sizeof buf
) != -1)
365 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
366 state
->Reg
[0] = sim_callback
->unlink (sim_callback
, buf
);
367 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
372 SWIrename (ARMul_State
* state
, ARMword old
, ARMword
new)
374 char oldbuf
[PATH_MAX
], newbuf
[PATH_MAX
];
376 if (ReadFileName (state
, oldbuf
, old
, sizeof oldbuf
) != -1
377 && ReadFileName (state
, newbuf
, new, sizeof newbuf
) != -1)
379 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
380 state
->Reg
[0] = sim_callback
->rename (sim_callback
, oldbuf
, newbuf
);
381 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
385 /* The emulator calls this routine when a SWI instruction is encuntered.
386 The parameter passed is the SWI number (lower 24 bits of the instruction). */
389 ARMul_OSHandleSWI (ARMul_State
* state
, ARMword number
)
391 struct OSblock
* OSptr
= (struct OSblock
*) state
->OSptr
;
392 int unhandled
= FALSE
;
397 if (swi_mask
& SWI_MASK_DEMON
)
398 SWIread (state
, state
->Reg
[0], state
->Reg
[1], state
->Reg
[2]);
404 if (swi_mask
& SWI_MASK_DEMON
)
405 SWIwrite (state
, state
->Reg
[0], state
->Reg
[1], state
->Reg
[2]);
411 if (swi_mask
& SWI_MASK_DEMON
)
412 SWIopen (state
, state
->Reg
[0], state
->Reg
[1]);
418 if (swi_mask
& SWI_MASK_DEMON
)
420 /* Return number of centi-seconds. */
422 #ifdef CLOCKS_PER_SEC
423 (CLOCKS_PER_SEC
>= 100)
424 ? (ARMword
) (clock () / (CLOCKS_PER_SEC
/ 100))
425 : (ARMword
) ((clock () * 100) / CLOCKS_PER_SEC
);
427 /* Presume unix... clock() returns microseconds. */
428 (ARMword
) (clock () / 10000);
430 OSptr
->ErrorNo
= errno
;
437 if (swi_mask
& SWI_MASK_DEMON
)
439 state
->Reg
[0] = (ARMword
) sim_callback
->time (sim_callback
, NULL
);
440 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
447 if (swi_mask
& SWI_MASK_DEMON
)
449 state
->Reg
[0] = sim_callback
->close (sim_callback
, state
->Reg
[0]);
450 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
457 if (swi_mask
& SWI_MASK_DEMON
)
458 SWIflen (state
, state
->Reg
[0]);
464 if (swi_mask
& SWI_MASK_DEMON
)
465 state
->Emulate
= FALSE
;
471 if (swi_mask
& SWI_MASK_DEMON
)
473 /* We must return non-zero for failure. */
474 state
->Reg
[0] = -1 >= sim_callback
->lseek (sim_callback
, state
->Reg
[0], state
->Reg
[1], SEEK_SET
);
475 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
482 if (swi_mask
& SWI_MASK_DEMON
)
484 char tmp
= state
->Reg
[0];
485 (void) sim_callback
->write_stdout (sim_callback
, &tmp
, 1);
486 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
493 if (swi_mask
& SWI_MASK_DEMON
)
494 SWIWrite0 (state
, state
->Reg
[0]);
500 if (swi_mask
& SWI_MASK_DEMON
)
501 state
->Reg
[0] = OSptr
->ErrorNo
;
507 if (swi_mask
& SWI_MASK_DEMON
)
509 state
->Reg
[0] = ADDRCMDLINE
;
511 state
->Reg
[1] = state
->MemSize
;
513 state
->Reg
[1] = ADDRUSERSTACK
;
515 WriteCommandLineTo (state
, state
->Reg
[0]);
522 state
->EndCondition
= RDIError_BreakpointReached
;
523 state
->Emulate
= FALSE
;
527 if (swi_mask
& SWI_MASK_DEMON
)
528 SWIremove (state
, state
->Reg
[0]);
534 if (swi_mask
& SWI_MASK_DEMON
)
535 SWIrename (state
, state
->Reg
[0], state
->Reg
[1]);
541 if (swi_mask
& SWI_MASK_DEMON
)
543 state
->Reg
[0] = sim_callback
->isatty (sim_callback
, state
->Reg
[0]);
544 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
550 /* Handle Angel SWIs as well as Demon ones. */
553 if (swi_mask
& SWI_MASK_ANGEL
)
558 /* R1 is almost always a parameter block. */
559 addr
= state
->Reg
[1];
560 /* R0 is a reason code. */
561 switch (state
->Reg
[0])
564 /* This can happen when a SWI is interrupted (eg receiving a
565 ctrl-C whilst processing SWIRead()). The SWI will complete
566 returning -1 in r0 to the caller. If GDB is then used to
567 resume the system call the reason code will now be -1. */
570 /* Unimplemented reason codes. */
571 case AngelSWI_Reason_ReadC
:
572 case AngelSWI_Reason_TmpNam
:
573 case AngelSWI_Reason_System
:
574 case AngelSWI_Reason_EnterSVC
:
576 state
->Emulate
= FALSE
;
579 case AngelSWI_Reason_Clock
:
580 /* Return number of centi-seconds. */
582 #ifdef CLOCKS_PER_SEC
583 (CLOCKS_PER_SEC
>= 100)
584 ? (ARMword
) (clock () / (CLOCKS_PER_SEC
/ 100))
585 : (ARMword
) ((clock () * 100) / CLOCKS_PER_SEC
);
587 /* Presume unix... clock() returns microseconds. */
588 (ARMword
) (clock () / 10000);
590 OSptr
->ErrorNo
= errno
;
593 case AngelSWI_Reason_Time
:
594 state
->Reg
[0] = (ARMword
) sim_callback
->time (sim_callback
, NULL
);
595 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
598 case AngelSWI_Reason_WriteC
:
600 char tmp
= ARMul_SafeReadByte (state
, addr
);
601 (void) sim_callback
->write_stdout (sim_callback
, &tmp
, 1);
602 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
606 case AngelSWI_Reason_Write0
:
607 SWIWrite0 (state
, addr
);
610 case AngelSWI_Reason_Close
:
611 state
->Reg
[0] = sim_callback
->close (sim_callback
, ARMul_ReadWord (state
, addr
));
612 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
615 case AngelSWI_Reason_Seek
:
616 state
->Reg
[0] = -1 >= sim_callback
->lseek (sim_callback
, ARMul_ReadWord (state
, addr
),
617 ARMul_ReadWord (state
, addr
+ 4),
619 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
622 case AngelSWI_Reason_FLen
:
623 SWIflen (state
, ARMul_ReadWord (state
, addr
));
626 case AngelSWI_Reason_GetCmdLine
:
627 WriteCommandLineTo (state
, ARMul_ReadWord (state
, addr
));
630 case AngelSWI_Reason_HeapInfo
:
631 /* R1 is a pointer to a pointer. */
632 addr
= ARMul_ReadWord (state
, addr
);
634 /* Pick up the right memory limit. */
636 temp
= state
->MemSize
;
638 temp
= ADDRUSERSTACK
;
640 ARMul_WriteWord (state
, addr
, 0); /* Heap base. */
641 ARMul_WriteWord (state
, addr
+ 4, temp
); /* Heap limit. */
642 ARMul_WriteWord (state
, addr
+ 8, temp
); /* Stack base. */
643 ARMul_WriteWord (state
, addr
+ 12, temp
); /* Stack limit. */
646 case AngelSWI_Reason_ReportException
:
647 if (state
->Reg
[1] == ADP_Stopped_ApplicationExit
)
651 state
->Emulate
= FALSE
;
654 case ADP_Stopped_ApplicationExit
:
656 state
->Emulate
= FALSE
;
659 case ADP_Stopped_RunTimeError
:
661 state
->Emulate
= FALSE
;
664 case AngelSWI_Reason_Errno
:
665 state
->Reg
[0] = OSptr
->ErrorNo
;
668 case AngelSWI_Reason_Open
:
670 ARMul_ReadWord (state
, addr
),
671 ARMul_ReadWord (state
, addr
+ 4));
674 case AngelSWI_Reason_Read
:
676 ARMul_ReadWord (state
, addr
),
677 ARMul_ReadWord (state
, addr
+ 4),
678 ARMul_ReadWord (state
, addr
+ 8));
681 case AngelSWI_Reason_Write
:
683 ARMul_ReadWord (state
, addr
),
684 ARMul_ReadWord (state
, addr
+ 4),
685 ARMul_ReadWord (state
, addr
+ 8));
688 case AngelSWI_Reason_IsTTY
:
689 state
->Reg
[0] = sim_callback
->isatty (sim_callback
,
690 ARMul_ReadWord (state
, addr
));
691 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
694 case AngelSWI_Reason_Remove
:
696 ARMul_ReadWord (state
, addr
));
698 case AngelSWI_Reason_Rename
:
700 ARMul_ReadWord (state
, addr
),
701 ARMul_ReadWord (state
, addr
+ 4));
708 /* The following SWIs are generated by the softvectorcode[]
709 installed by default by the simulator. */
710 case 0x91: /* Undefined Instruction. */
712 ARMword addr
= state
->RegBank
[UNDEFBANK
][14] - 4;
714 sim_callback
->printf_filtered
715 (sim_callback
, "sim: exception: Unhandled Instruction '0x%08x' at 0x%08x. Stopping.\n",
716 ARMul_ReadWord (state
, addr
), addr
);
717 state
->EndCondition
= RDIError_SoftwareInterrupt
;
718 state
->Emulate
= FALSE
;
722 case 0x90: /* Reset. */
723 case 0x92: /* SWI. */
724 /* These two can be safely ignored. */
727 case 0x93: /* Prefetch Abort. */
728 case 0x94: /* Data Abort. */
729 case 0x95: /* Address Exception. */
730 case 0x96: /* IRQ. */
731 case 0x97: /* FIQ. */
732 case 0x98: /* Error. */
737 /* This can happen when a SWI is interrupted (eg receiving a
738 ctrl-C whilst processing SWIRead()). The SWI will complete
739 returning -1 in r0 to the caller. If GDB is then used to
740 resume the system call the reason code will now be -1. */
743 case 0x180001: /* RedBoot's Syscall SWI in ARM mode. */
744 if (swi_mask
& SWI_MASK_REDBOOT
)
746 switch (state
->Reg
[0])
748 /* These numbers are defined in libgloss/syscall.h
749 but the simulator should not be dependend upon
750 libgloss being installed. */
752 state
->Emulate
= FALSE
;
753 /* Copy exit code into r0. */
754 state
->Reg
[0] = state
->Reg
[1];
758 SWIopen (state
, state
->Reg
[1], state
->Reg
[2]);
762 state
->Reg
[0] = sim_callback
->close (sim_callback
, state
->Reg
[1]);
763 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
767 SWIread (state
, state
->Reg
[1], state
->Reg
[2], state
->Reg
[3]);
771 SWIwrite (state
, state
->Reg
[1], state
->Reg
[2], state
->Reg
[3]);
775 state
->Reg
[0] = sim_callback
->lseek (sim_callback
,
779 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
782 case 17: /* Utime. */
783 state
->Reg
[0] = state
->Reg
[1] = (ARMword
) sim_callback
->time (sim_callback
, NULL
);
784 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
787 case 7: /* Unlink. */
788 case 8: /* Getpid. */
790 case 10: /* Fstat. */
792 case 12: /* Argvlen. */
794 case 14: /* ChDir. */
796 case 16: /* Chmod. */
798 sim_callback
->printf_filtered
800 "sim: unhandled RedBoot syscall `%d' encountered - "
801 "returning ENOSYS\n",
804 OSptr
->ErrorNo
= cb_host_to_target_errno
805 (sim_callback
, ENOSYS
);
807 case 1001: /* Meminfo. */
809 ARMword totmem
= state
->Reg
[1],
810 topmem
= state
->Reg
[2];
811 ARMword stack
= state
->MemSize
> 0
812 ? state
->MemSize
: ADDRUSERSTACK
;
814 ARMul_WriteWord (state
, totmem
, stack
);
816 ARMul_WriteWord (state
, topmem
, stack
);
822 sim_callback
->printf_filtered
824 "sim: unknown RedBoot syscall '%d' encountered - ignoring\n",
837 if (SWI_vector_installed
)
842 cpsr
= ARMul_GetCPSR (state
);
845 ARMul_SetSPSR (state
, SVC32MODE
, cpsr
);
848 cpsr
|= SVC32MODE
| 0x80;
849 ARMul_SetCPSR (state
, cpsr
);
851 state
->RegBank
[SVCBANK
][14] = state
->Reg
[14] = state
->Reg
[15] - i_size
;
852 state
->NextInstr
= RESUME
;
853 state
->Reg
[15] = state
->pc
= ARMSWIV
;
858 sim_callback
->printf_filtered
860 "sim: unknown SWI encountered - %x - ignoring\n",