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. */
26 #include "libiberty.h"
32 #include "targ-vals.h"
34 #ifndef TARGET_O_BINARY
35 #define TARGET_O_BINARY 0
39 #include <unistd.h> /* For SEEK_SET etc. */
54 /* For RDIError_BreakpointReached. */
57 #include "gdb/callback.h"
58 extern host_callback
*sim_callback
;
60 extern unsigned ARMul_OSInit (ARMul_State
*);
61 extern unsigned ARMul_OSHandleSWI (ARMul_State
*, ARMword
);
70 /* OS private Information. */
77 /* Bit mask of enabled SWI implementations. */
78 unsigned int swi_mask
= -1;
81 static ARMword softvectorcode
[] =
83 /* Installed instructions:
84 swi tidyexception + event;
87 swi generateexception + event. */
88 0xef000090, 0xe1a0e00f, 0xe89b8800, 0xef000080, /* Reset */
89 0xef000091, 0xe1a0e00f, 0xe89b8800, 0xef000081, /* Undef */
90 0xef000092, 0xe1a0e00f, 0xe89b8800, 0xef000082, /* SWI */
91 0xef000093, 0xe1a0e00f, 0xe89b8800, 0xef000083, /* Prefetch abort */
92 0xef000094, 0xe1a0e00f, 0xe89b8800, 0xef000084, /* Data abort */
93 0xef000095, 0xe1a0e00f, 0xe89b8800, 0xef000085, /* Address exception */
94 0xef000096, 0xe1a0e00f, 0xe89b8800, 0xef000086, /* IRQ */
95 0xef000097, 0xe1a0e00f, 0xe89b8800, 0xef000087, /* FIQ */
96 0xef000098, 0xe1a0e00f, 0xe89b8800, 0xef000088, /* Error */
97 0xe1a0f00e /* Default handler */
100 /* Time for the Operating System to initialise itself. */
103 ARMul_OSInit (ARMul_State
* state
)
108 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
110 if (state
->OSptr
== NULL
)
112 state
->OSptr
= (unsigned char *) malloc (sizeof (struct OSblock
));
113 if (state
->OSptr
== NULL
)
115 perror ("OS Memory");
120 OSptr
= (struct OSblock
*) state
->OSptr
;
121 state
->Reg
[13] = ADDRSUPERSTACK
; /* Set up a stack for the current mode... */
122 ARMul_SetReg (state
, SVC32MODE
, 13, ADDRSUPERSTACK
);/* ...and for supervisor mode... */
123 ARMul_SetReg (state
, ABORT32MODE
, 13, ADDRSUPERSTACK
);/* ...and for abort 32 mode... */
124 ARMul_SetReg (state
, UNDEF32MODE
, 13, ADDRSUPERSTACK
);/* ...and for undef 32 mode... */
125 ARMul_SetReg (state
, SYSTEMMODE
, 13, ADDRSUPERSTACK
);/* ...and for system mode. */
126 instr
= 0xe59ff000 | (ADDRSOFTVECTORS
- 8); /* Load pc from soft vector */
128 for (i
= ARMul_ResetV
; i
<= ARMFIQV
; i
+= 4)
129 /* Write hardware vectors. */
130 ARMul_WriteWord (state
, i
, instr
);
132 SWI_vector_installed
= 0;
134 for (i
= ARMul_ResetV
; i
<= ARMFIQV
+ 4; i
+= 4)
136 ARMul_WriteWord (state
, ADDRSOFTVECTORS
+ i
, SOFTVECTORCODE
+ i
* 4);
137 ARMul_WriteWord (state
, ADDRSOFHANDLERS
+ 2 * i
+ 4L,
138 SOFTVECTORCODE
+ sizeof (softvectorcode
) - 4L);
141 for (i
= 0; i
< sizeof (softvectorcode
); i
+= 4)
142 ARMul_WriteWord (state
, SOFTVECTORCODE
+ i
, softvectorcode
[i
/ 4]);
144 ARMul_ConsolePrint (state
, ", Demon 1.01");
149 for (i
= 0; i
< fpesize
; i
+= 4)
151 ARMul_WriteWord (state
, FPESTART
+ i
, fpecode
[i
>> 2]);
153 /* Scan backwards from the end of the code. */
154 for (i
= FPESTART
+ fpesize
;; i
-= 4)
156 /* When we reach the marker value, break out of
157 the loop, leaving i pointing at the maker. */
158 if ((j
= ARMul_ReadWord (state
, i
)) == 0xffffffff)
161 /* If necessary, reverse the error strings. */
162 if (state
->bigendSig
&& j
< 0x80000000)
164 /* It's part of the string so swap it. */
165 j
= ((j
>> 0x18) & 0x000000ff) |
166 ((j
>> 0x08) & 0x0000ff00) |
167 ((j
<< 0x08) & 0x00ff0000) | ((j
<< 0x18) & 0xff000000);
168 ARMul_WriteWord (state
, i
, j
);
172 /* Copy old illegal instr vector. */
173 ARMul_WriteWord (state
, FPEOLDVECT
, ARMul_ReadWord (state
, ARMUndefinedInstrV
));
174 /* Install new vector. */
175 ARMul_WriteWord (state
, ARMUndefinedInstrV
, FPENEWVECT (ARMul_ReadWord (state
, i
- 4)));
176 ARMul_ConsolePrint (state
, ", FPE");
179 #endif /* VALIDATE */
182 /* Intel do not want DEMON SWI support. */
183 if (state
->is_XScale
)
184 swi_mask
= SWI_MASK_ANGEL
;
189 static int translate_open_mode
[] =
191 TARGET_O_RDONLY
, /* "r" */
192 TARGET_O_RDONLY
+ TARGET_O_BINARY
, /* "rb" */
193 TARGET_O_RDWR
, /* "r+" */
194 TARGET_O_RDWR
+ TARGET_O_BINARY
, /* "r+b" */
195 TARGET_O_WRONLY
+ TARGET_O_CREAT
+ TARGET_O_TRUNC
, /* "w" */
196 TARGET_O_WRONLY
+ TARGET_O_BINARY
+ TARGET_O_CREAT
+ TARGET_O_TRUNC
, /* "wb" */
197 TARGET_O_RDWR
+ TARGET_O_CREAT
+ TARGET_O_TRUNC
, /* "w+" */
198 TARGET_O_RDWR
+ TARGET_O_BINARY
+ TARGET_O_CREAT
+ TARGET_O_TRUNC
, /* "w+b" */
199 TARGET_O_WRONLY
+ TARGET_O_APPEND
+ TARGET_O_CREAT
, /* "a" */
200 TARGET_O_WRONLY
+ TARGET_O_BINARY
+ TARGET_O_APPEND
+ TARGET_O_CREAT
, /* "ab" */
201 TARGET_O_RDWR
+ TARGET_O_APPEND
+ TARGET_O_CREAT
, /* "a+" */
202 TARGET_O_RDWR
+ TARGET_O_BINARY
+ TARGET_O_APPEND
+ TARGET_O_CREAT
/* "a+b" */
206 SWIWrite0 (ARMul_State
* state
, ARMword addr
)
209 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
211 while ((temp
= ARMul_SafeReadByte (state
, addr
++)) != 0)
214 /* Note - we cannot just cast 'temp' to a (char *) here,
215 since on a big-endian host the byte value will end
216 up in the wrong place and a nul character will be printed. */
217 (void) sim_callback
->write_stdout (sim_callback
, & buffer
, 1);
220 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
224 WriteCommandLineTo (ARMul_State
* state
, ARMword addr
)
227 char *cptr
= state
->CommandLine
;
233 temp
= (ARMword
) * cptr
++;
234 ARMul_SafeWriteByte (state
, addr
++, temp
);
240 ReadFileName (ARMul_State
* state
, char *buf
, ARMword src
, size_t n
)
242 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
246 if ((*p
++ = ARMul_SafeReadByte (state
, src
++)) == '\0')
248 OSptr
->ErrorNo
= cb_host_to_target_errno (sim_callback
, ENAMETOOLONG
);
254 SWIopen (ARMul_State
* state
, ARMword name
, ARMword SWIflags
)
256 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
260 if (ReadFileName (state
, buf
, name
, sizeof buf
) == -1)
263 /* Now we need to decode the Demon open mode. */
264 if (SWIflags
>= ARRAY_SIZE (translate_open_mode
))
267 flags
= translate_open_mode
[SWIflags
];
269 /* Filename ":tt" is special: it denotes stdin/out. */
270 if (strcmp (buf
, ":tt") == 0)
272 if (flags
== TARGET_O_RDONLY
) /* opening tty "r" */
273 state
->Reg
[0] = 0; /* stdin */
275 state
->Reg
[0] = 1; /* stdout */
279 state
->Reg
[0] = sim_callback
->open (sim_callback
, buf
, flags
);
280 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
285 SWIread (ARMul_State
* state
, ARMword f
, ARMword ptr
, ARMword len
)
287 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
290 char *local
= malloc (len
);
294 sim_callback
->printf_filtered
296 "sim: Unable to read 0x%ulx bytes - out of memory\n",
301 res
= sim_callback
->read (sim_callback
, f
, local
, len
);
303 for (i
= 0; i
< res
; i
++)
304 ARMul_SafeWriteByte (state
, ptr
+ i
, local
[i
]);
307 state
->Reg
[0] = res
== -1 ? -1 : len
- res
;
308 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
312 SWIwrite (ARMul_State
* state
, ARMword f
, ARMword ptr
, ARMword len
)
314 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
317 char *local
= malloc (len
);
321 sim_callback
->printf_filtered
323 "sim: Unable to write 0x%lx bytes - out of memory\n",
328 for (i
= 0; i
< len
; i
++)
329 local
[i
] = ARMul_SafeReadByte (state
, ptr
+ i
);
331 res
= sim_callback
->write (sim_callback
, f
, local
, len
);
332 state
->Reg
[0] = res
== -1 ? -1 : len
- res
;
335 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
339 SWIflen (ARMul_State
* state
, ARMword fh
)
341 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
346 OSptr
->ErrorNo
= EBADF
;
351 addr
= sim_callback
->lseek (sim_callback
, fh
, 0, SEEK_CUR
);
353 state
->Reg
[0] = sim_callback
->lseek (sim_callback
, fh
, 0L, SEEK_END
);
354 (void) sim_callback
->lseek (sim_callback
, fh
, addr
, SEEK_SET
);
356 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
360 SWIremove (ARMul_State
* state
, ARMword path
)
364 if (ReadFileName (state
, buf
, path
, sizeof buf
) != -1)
366 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
367 state
->Reg
[0] = sim_callback
->unlink (sim_callback
, buf
);
368 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
373 SWIrename (ARMul_State
* state
, ARMword old
, ARMword
new)
375 char oldbuf
[PATH_MAX
], newbuf
[PATH_MAX
];
377 if (ReadFileName (state
, oldbuf
, old
, sizeof oldbuf
) != -1
378 && ReadFileName (state
, newbuf
, new, sizeof newbuf
) != -1)
380 struct OSblock
*OSptr
= (struct OSblock
*) state
->OSptr
;
381 state
->Reg
[0] = sim_callback
->rename (sim_callback
, oldbuf
, newbuf
);
382 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
386 /* The emulator calls this routine when a SWI instruction is encuntered.
387 The parameter passed is the SWI number (lower 24 bits of the instruction). */
390 ARMul_OSHandleSWI (ARMul_State
* state
, ARMword number
)
392 struct OSblock
* OSptr
= (struct OSblock
*) state
->OSptr
;
393 int unhandled
= FALSE
;
398 if (swi_mask
& SWI_MASK_DEMON
)
399 SWIread (state
, state
->Reg
[0], state
->Reg
[1], state
->Reg
[2]);
405 if (swi_mask
& SWI_MASK_DEMON
)
406 SWIwrite (state
, state
->Reg
[0], state
->Reg
[1], state
->Reg
[2]);
412 if (swi_mask
& SWI_MASK_DEMON
)
413 SWIopen (state
, state
->Reg
[0], state
->Reg
[1]);
419 if (swi_mask
& SWI_MASK_DEMON
)
421 /* Return number of centi-seconds. */
423 #ifdef CLOCKS_PER_SEC
424 (CLOCKS_PER_SEC
>= 100)
425 ? (ARMword
) (clock () / (CLOCKS_PER_SEC
/ 100))
426 : (ARMword
) ((clock () * 100) / CLOCKS_PER_SEC
);
428 /* Presume unix... clock() returns microseconds. */
429 (ARMword
) (clock () / 10000);
431 OSptr
->ErrorNo
= errno
;
438 if (swi_mask
& SWI_MASK_DEMON
)
440 state
->Reg
[0] = (ARMword
) sim_callback
->time (sim_callback
, NULL
);
441 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
448 if (swi_mask
& SWI_MASK_DEMON
)
450 state
->Reg
[0] = sim_callback
->close (sim_callback
, state
->Reg
[0]);
451 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
458 if (swi_mask
& SWI_MASK_DEMON
)
459 SWIflen (state
, state
->Reg
[0]);
465 if (swi_mask
& SWI_MASK_DEMON
)
466 state
->Emulate
= FALSE
;
472 if (swi_mask
& SWI_MASK_DEMON
)
474 /* We must return non-zero for failure. */
475 state
->Reg
[0] = -1 >= sim_callback
->lseek (sim_callback
, state
->Reg
[0], state
->Reg
[1], SEEK_SET
);
476 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
483 if (swi_mask
& SWI_MASK_DEMON
)
485 char tmp
= state
->Reg
[0];
486 (void) sim_callback
->write_stdout (sim_callback
, &tmp
, 1);
487 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
494 if (swi_mask
& SWI_MASK_DEMON
)
495 SWIWrite0 (state
, state
->Reg
[0]);
501 if (swi_mask
& SWI_MASK_DEMON
)
502 state
->Reg
[0] = OSptr
->ErrorNo
;
508 if (swi_mask
& SWI_MASK_DEMON
)
510 state
->Reg
[0] = ADDRCMDLINE
;
512 state
->Reg
[1] = state
->MemSize
;
514 state
->Reg
[1] = ADDRUSERSTACK
;
516 WriteCommandLineTo (state
, state
->Reg
[0]);
523 state
->EndCondition
= RDIError_BreakpointReached
;
524 state
->Emulate
= FALSE
;
528 if (swi_mask
& SWI_MASK_DEMON
)
529 SWIremove (state
, state
->Reg
[0]);
535 if (swi_mask
& SWI_MASK_DEMON
)
536 SWIrename (state
, state
->Reg
[0], state
->Reg
[1]);
542 if (swi_mask
& SWI_MASK_DEMON
)
544 state
->Reg
[0] = sim_callback
->isatty (sim_callback
, state
->Reg
[0]);
545 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
551 /* Handle Angel SWIs as well as Demon ones. */
554 if (swi_mask
& SWI_MASK_ANGEL
)
559 /* R1 is almost always a parameter block. */
560 addr
= state
->Reg
[1];
561 /* R0 is a reason code. */
562 switch (state
->Reg
[0])
565 /* This can happen when a SWI is interrupted (eg receiving a
566 ctrl-C whilst processing SWIRead()). The SWI will complete
567 returning -1 in r0 to the caller. If GDB is then used to
568 resume the system call the reason code will now be -1. */
571 /* Unimplemented reason codes. */
572 case AngelSWI_Reason_ReadC
:
573 case AngelSWI_Reason_TmpNam
:
574 case AngelSWI_Reason_System
:
575 case AngelSWI_Reason_EnterSVC
:
577 state
->Emulate
= FALSE
;
580 case AngelSWI_Reason_Clock
:
581 /* Return number of centi-seconds. */
583 #ifdef CLOCKS_PER_SEC
584 (CLOCKS_PER_SEC
>= 100)
585 ? (ARMword
) (clock () / (CLOCKS_PER_SEC
/ 100))
586 : (ARMword
) ((clock () * 100) / CLOCKS_PER_SEC
);
588 /* Presume unix... clock() returns microseconds. */
589 (ARMword
) (clock () / 10000);
591 OSptr
->ErrorNo
= errno
;
594 case AngelSWI_Reason_Time
:
595 state
->Reg
[0] = (ARMword
) sim_callback
->time (sim_callback
, NULL
);
596 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
599 case AngelSWI_Reason_WriteC
:
601 char tmp
= ARMul_SafeReadByte (state
, addr
);
602 (void) sim_callback
->write_stdout (sim_callback
, &tmp
, 1);
603 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
607 case AngelSWI_Reason_Write0
:
608 SWIWrite0 (state
, addr
);
611 case AngelSWI_Reason_Close
:
612 state
->Reg
[0] = sim_callback
->close (sim_callback
, ARMul_ReadWord (state
, addr
));
613 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
616 case AngelSWI_Reason_Seek
:
617 state
->Reg
[0] = -1 >= sim_callback
->lseek (sim_callback
, ARMul_ReadWord (state
, addr
),
618 ARMul_ReadWord (state
, addr
+ 4),
620 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
623 case AngelSWI_Reason_FLen
:
624 SWIflen (state
, ARMul_ReadWord (state
, addr
));
627 case AngelSWI_Reason_GetCmdLine
:
628 WriteCommandLineTo (state
, ARMul_ReadWord (state
, addr
));
631 case AngelSWI_Reason_HeapInfo
:
632 /* R1 is a pointer to a pointer. */
633 addr
= ARMul_ReadWord (state
, addr
);
635 /* Pick up the right memory limit. */
637 temp
= state
->MemSize
;
639 temp
= ADDRUSERSTACK
;
641 ARMul_WriteWord (state
, addr
, 0); /* Heap base. */
642 ARMul_WriteWord (state
, addr
+ 4, temp
); /* Heap limit. */
643 ARMul_WriteWord (state
, addr
+ 8, temp
); /* Stack base. */
644 ARMul_WriteWord (state
, addr
+ 12, temp
); /* Stack limit. */
647 case AngelSWI_Reason_ReportException
:
648 if (state
->Reg
[1] == ADP_Stopped_ApplicationExit
)
652 state
->Emulate
= FALSE
;
655 case ADP_Stopped_ApplicationExit
:
657 state
->Emulate
= FALSE
;
660 case ADP_Stopped_RunTimeError
:
662 state
->Emulate
= FALSE
;
665 case AngelSWI_Reason_Errno
:
666 state
->Reg
[0] = OSptr
->ErrorNo
;
669 case AngelSWI_Reason_Open
:
671 ARMul_ReadWord (state
, addr
),
672 ARMul_ReadWord (state
, addr
+ 4));
675 case AngelSWI_Reason_Read
:
677 ARMul_ReadWord (state
, addr
),
678 ARMul_ReadWord (state
, addr
+ 4),
679 ARMul_ReadWord (state
, addr
+ 8));
682 case AngelSWI_Reason_Write
:
684 ARMul_ReadWord (state
, addr
),
685 ARMul_ReadWord (state
, addr
+ 4),
686 ARMul_ReadWord (state
, addr
+ 8));
689 case AngelSWI_Reason_IsTTY
:
690 state
->Reg
[0] = sim_callback
->isatty (sim_callback
,
691 ARMul_ReadWord (state
, addr
));
692 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
695 case AngelSWI_Reason_Remove
:
697 ARMul_ReadWord (state
, addr
));
699 case AngelSWI_Reason_Rename
:
701 ARMul_ReadWord (state
, addr
),
702 ARMul_ReadWord (state
, addr
+ 4));
709 /* The following SWIs are generated by the softvectorcode[]
710 installed by default by the simulator. */
711 case 0x91: /* Undefined Instruction. */
713 ARMword addr
= state
->RegBank
[UNDEFBANK
][14] - 4;
715 sim_callback
->printf_filtered
716 (sim_callback
, "sim: exception: Unhandled Instruction '0x%08x' at 0x%08x. Stopping.\n",
717 ARMul_ReadWord (state
, addr
), addr
);
718 state
->EndCondition
= RDIError_SoftwareInterrupt
;
719 state
->Emulate
= FALSE
;
723 case 0x90: /* Reset. */
724 case 0x92: /* SWI. */
725 /* These two can be safely ignored. */
728 case 0x93: /* Prefetch Abort. */
729 case 0x94: /* Data Abort. */
730 case 0x95: /* Address Exception. */
731 case 0x96: /* IRQ. */
732 case 0x97: /* FIQ. */
733 case 0x98: /* Error. */
738 /* This can happen when a SWI is interrupted (eg receiving a
739 ctrl-C whilst processing SWIRead()). The SWI will complete
740 returning -1 in r0 to the caller. If GDB is then used to
741 resume the system call the reason code will now be -1. */
744 case 0x180001: /* RedBoot's Syscall SWI in ARM mode. */
745 if (swi_mask
& SWI_MASK_REDBOOT
)
747 switch (state
->Reg
[0])
749 /* These numbers are defined in libgloss/syscall.h
750 but the simulator should not be dependend upon
751 libgloss being installed. */
753 state
->Emulate
= FALSE
;
754 /* Copy exit code into r0. */
755 state
->Reg
[0] = state
->Reg
[1];
759 SWIopen (state
, state
->Reg
[1], state
->Reg
[2]);
763 state
->Reg
[0] = sim_callback
->close (sim_callback
, state
->Reg
[1]);
764 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
768 SWIread (state
, state
->Reg
[1], state
->Reg
[2], state
->Reg
[3]);
772 SWIwrite (state
, state
->Reg
[1], state
->Reg
[2], state
->Reg
[3]);
776 state
->Reg
[0] = sim_callback
->lseek (sim_callback
,
780 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
783 case 17: /* Utime. */
784 state
->Reg
[0] = state
->Reg
[1] = (ARMword
) sim_callback
->time (sim_callback
, NULL
);
785 OSptr
->ErrorNo
= sim_callback
->get_errno (sim_callback
);
788 case 7: /* Unlink. */
789 case 8: /* Getpid. */
791 case 10: /* Fstat. */
793 case 12: /* Argvlen. */
795 case 14: /* ChDir. */
797 case 16: /* Chmod. */
799 sim_callback
->printf_filtered
801 "sim: unhandled RedBoot syscall `%d' encountered - "
802 "returning ENOSYS\n",
805 OSptr
->ErrorNo
= cb_host_to_target_errno
806 (sim_callback
, ENOSYS
);
808 case 1001: /* Meminfo. */
810 ARMword totmem
= state
->Reg
[1],
811 topmem
= state
->Reg
[2];
812 ARMword stack
= state
->MemSize
> 0
813 ? state
->MemSize
: ADDRUSERSTACK
;
815 ARMul_WriteWord (state
, totmem
, stack
);
817 ARMul_WriteWord (state
, topmem
, stack
);
823 sim_callback
->printf_filtered
825 "sim: unknown RedBoot syscall '%d' encountered - ignoring\n",
838 if (SWI_vector_installed
)
843 cpsr
= ARMul_GetCPSR (state
);
846 ARMul_SetSPSR (state
, SVC32MODE
, cpsr
);
849 cpsr
|= SVC32MODE
| 0x80;
850 ARMul_SetCPSR (state
, cpsr
);
852 state
->RegBank
[SVCBANK
][14] = state
->Reg
[14] = state
->Reg
[15] - i_size
;
853 state
->NextInstr
= RESUME
;
854 state
->Reg
[15] = state
->pc
= ARMSWIV
;
859 sim_callback
->printf_filtered
861 "sim: unknown SWI encountered - %x - ignoring\n",