X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=sim%2Farm%2Farmos.c;h=76c449b73d0f7dd4b69fe32de97056fb354c0efd;hb=87f83f20023bf366c14ec4e0fd307948d96caaee;hp=77390521009889ffe65dbcec4a78c35d72796528;hpb=4b1d9c58548086d46f2883b5ed780c0156e08964;p=deliverable%2Fbinutils-gdb.git
diff --git a/sim/arm/armos.c b/sim/arm/armos.c
index 7739052100..76c449b73d 100644
--- a/sim/arm/armos.c
+++ b/sim/arm/armos.c
@@ -1,19 +1,18 @@
/* armos.c -- ARMulator OS interface: ARM6 Instruction Emulator.
Copyright (C) 1994 Advanced RISC Machines Ltd.
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
+ along with this program; if not, see . */
/* This file contains a model of Demon, ARM Ltd's Debug Monitor,
including all the SWI's required to support the C library. The code in
@@ -24,6 +23,7 @@
#include "config.h"
#include "ansidecl.h"
+#include "libiberty.h"
#include
#include
@@ -39,23 +39,6 @@
#include /* For SEEK_SET etc. */
#endif
-#ifdef __riscos
-extern int _fisatty (FILE *);
-#define isatty_(f) _fisatty(f)
-#else
-#ifdef __ZTC__
-#include
-#define isatty_(f) isatty((f)->_file)
-#else
-#ifdef macintosh
-#include
-#define isatty_(f) (~ioctl ((f)->_file, FIOINTERACTIVE, NULL))
-#else
-#define isatty_(f) isatty (fileno (f))
-#endif
-#endif
-#endif
-
#include "armdefs.h"
#include "armos.h"
#include "armemu.h"
@@ -75,17 +58,11 @@ extern int _fisatty (FILE *);
extern host_callback *sim_callback;
extern unsigned ARMul_OSInit (ARMul_State *);
-extern void ARMul_OSExit (ARMul_State *);
extern unsigned ARMul_OSHandleSWI (ARMul_State *, ARMword);
-extern unsigned ARMul_OSException (ARMul_State *, ARMword, ARMword);
-extern ARMword ARMul_OSLastErrorP (ARMul_State *);
-extern ARMword ARMul_Debug (ARMul_State *, ARMword, ARMword);
-#define BUFFERSIZE 4096
#ifndef FOPEN_MAX
#define FOPEN_MAX 64
#endif
-#define UNIQUETEMPS 256
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
@@ -94,28 +71,9 @@ extern ARMword ARMul_Debug (ARMul_State *, ARMword, ARMword);
struct OSblock
{
- ARMword Time0;
- ARMword ErrorP;
ARMword ErrorNo;
- FILE *FileTable[FOPEN_MAX];
- char FileFlags[FOPEN_MAX];
- char *tempnames[UNIQUETEMPS];
};
-#define NOOP 0
-#define BINARY 1
-#define READOP 2
-#define WRITEOP 4
-
-#ifdef macintosh
-#define FIXCRLF(t,c) ((t & BINARY) ? \
- c : \
- ((c == '\n' || c == '\r' ) ? (c ^ 7) : c) \
- )
-#else
-#define FIXCRLF(t,c) c
-#endif
-
/* Bit mask of enabled SWI implementations. */
unsigned int swi_mask = -1;
@@ -158,20 +116,19 @@ ARMul_OSInit (ARMul_State * state)
exit (15);
}
}
-
+
OSptr = (struct OSblock *) state->OSptr;
- OSptr->ErrorP = 0;
state->Reg[13] = ADDRSUPERSTACK; /* Set up a stack for the current mode... */
ARMul_SetReg (state, SVC32MODE, 13, ADDRSUPERSTACK);/* ...and for supervisor mode... */
ARMul_SetReg (state, ABORT32MODE, 13, ADDRSUPERSTACK);/* ...and for abort 32 mode... */
ARMul_SetReg (state, UNDEF32MODE, 13, ADDRSUPERSTACK);/* ...and for undef 32 mode... */
ARMul_SetReg (state, SYSTEMMODE, 13, ADDRSUPERSTACK);/* ...and for system mode. */
instr = 0xe59ff000 | (ADDRSOFTVECTORS - 8); /* Load pc from soft vector */
-
+
for (i = ARMul_ResetV; i <= ARMFIQV; i += 4)
/* Write hardware vectors. */
ARMul_WriteWord (state, i, instr);
-
+
SWI_vector_installed = 0;
for (i = ARMul_ResetV; i <= ARMFIQV + 4; i += 4)
@@ -184,12 +141,6 @@ ARMul_OSInit (ARMul_State * state)
for (i = 0; i < sizeof (softvectorcode); i += 4)
ARMul_WriteWord (state, SOFTVECTORCODE + i, softvectorcode[i / 4]);
- for (i = 0; i < FOPEN_MAX; i++)
- OSptr->FileTable[i] = NULL;
-
- for (i = 0; i < UNIQUETEMPS; i++)
- OSptr->tempnames[i] = NULL;
-
ARMul_ConsolePrint (state, ", Demon 1.01");
/* #ifndef ASIM */
@@ -235,20 +186,6 @@ ARMul_OSInit (ARMul_State * state)
return TRUE;
}
-void
-ARMul_OSExit (ARMul_State * state)
-{
- free ((char *) state->OSptr);
-}
-
-
-/* Return the last Operating System Error. */
-
-ARMword ARMul_OSLastErrorP (ARMul_State * state)
-{
- return ((struct OSblock *) state->OSptr)->ErrorP;
-}
-
static int translate_open_mode[] =
{
TARGET_O_RDONLY, /* "r" */
@@ -324,7 +261,10 @@ SWIopen (ARMul_State * state, ARMword name, ARMword SWIflags)
return;
/* Now we need to decode the Demon open mode. */
- flags = translate_open_mode[SWIflags];
+ if (SWIflags >= ARRAY_SIZE (translate_open_mode))
+ flags = 0;
+ else
+ flags = translate_open_mode[SWIflags];
/* Filename ":tt" is special: it denotes stdin/out. */
if (strcmp (buf, ":tt") == 0)
@@ -401,7 +341,7 @@ SWIflen (ARMul_State * state, ARMword fh)
struct OSblock *OSptr = (struct OSblock *) state->OSptr;
ARMword addr;
- if (fh == 0 || fh > FOPEN_MAX)
+ if (fh > FOPEN_MAX)
{
OSptr->ErrorNo = EBADF;
state->Reg[0] = -1L;
@@ -627,7 +567,7 @@ ARMul_OSHandleSWI (ARMul_State * state, ARMword number)
returning -1 in r0 to the caller. If GDB is then used to
resume the system call the reason code will now be -1. */
return TRUE;
-
+
/* Unimplemented reason codes. */
case AngelSWI_Reason_ReadC:
case AngelSWI_Reason_TmpNam:
@@ -778,7 +718,7 @@ ARMul_OSHandleSWI (ARMul_State * state, ARMword number)
state->EndCondition = RDIError_SoftwareInterrupt;
state->Emulate = FALSE;
return FALSE;
- }
+ }
case 0x90: /* Reset. */
case 0x92: /* SWI. */
@@ -800,7 +740,7 @@ ARMul_OSHandleSWI (ARMul_State * state, ARMword number)
returning -1 in r0 to the caller. If GDB is then used to
resume the system call the reason code will now be -1. */
return TRUE;
-
+
case 0x180001: /* RedBoot's Syscall SWI in ARM mode. */
if (swi_mask & SWI_MASK_REDBOOT)
{
@@ -841,8 +781,7 @@ ARMul_OSHandleSWI (ARMul_State * state, ARMword number)
break;
case 17: /* Utime. */
- state->Reg[0] = (ARMword) sim_callback->time (sim_callback,
- (long *) state->Reg[1]);
+ state->Reg[0] = state->Reg[1] = (ARMword) sim_callback->time (sim_callback, NULL);
OSptr->ErrorNo = sim_callback->get_errno (sim_callback);
break;
@@ -889,11 +828,11 @@ ARMul_OSHandleSWI (ARMul_State * state, ARMword number)
}
break;
}
-
+
default:
unhandled = TRUE;
}
-
+
if (unhandled)
{
if (SWI_vector_installed)
@@ -927,22 +866,3 @@ ARMul_OSHandleSWI (ARMul_State * state, ARMword number)
return TRUE;
}
-
-#ifndef NOOS
-#ifndef ASIM
-
-/* The emulator calls this routine when an Exception occurs. The second
- parameter is the address of the relevant exception vector. Returning
- FALSE from this routine causes the trap to be taken, TRUE causes it to
- be ignored (so set state->Emulate to FALSE!). */
-
-unsigned
-ARMul_OSException (ARMul_State * state ATTRIBUTE_UNUSED,
- ARMword vector ATTRIBUTE_UNUSED,
- ARMword pc ATTRIBUTE_UNUSED)
-{
- return FALSE;
-}
-
-#endif
-#endif /* NOOS */