1b725ae77Skettenis /*
2b725ae77Skettenis  * Copyright (C) 1995 Advanced RISC Machines Limited. All rights reserved.
3b725ae77Skettenis  *
4b725ae77Skettenis  * This software may be freely used, copied, modified, and distributed
5b725ae77Skettenis  * provided that the above copyright notice is preserved in all copies of the
6b725ae77Skettenis  * software.
7b725ae77Skettenis  */
8b725ae77Skettenis 
9b725ae77Skettenis /*> angel.h <*/
10b725ae77Skettenis /*---------------------------------------------------------------------------*/
11b725ae77Skettenis /* This header file is the main holder for the declarations and
12b725ae77Skettenis  * prototypes for the core Angel system. Some Angel concepts are
13b725ae77Skettenis  * described at the start of this file to ensure that a complete view
14b725ae77Skettenis  * of the Angel world can be derived purely from the source.
15b725ae77Skettenis  *
16*63addd46Skettenis  * $Revision: 1.3 $
17*63addd46Skettenis  *     $Date: 2004/12/27 14:00:53 $
18b725ae77Skettenis  *
19b725ae77Skettenis  *
20b725ae77Skettenis  * NOTE: Currently the Angel source is designed to be simple,
21b725ae77Skettenis  * understandable and easy to port to new hardware platforms. However,
22b725ae77Skettenis  * this does not always yield the highest performing system. The
23b725ae77Skettenis  * current layered approach introduces an overhead to the performance
24b725ae77Skettenis  * of the system. In a true commercial target, this code should be
25b725ae77Skettenis  * re-designed to build a system where the Angel logical message
26b725ae77Skettenis  * system, device driver and hardware accesses are merged to provide
27b725ae77Skettenis  * the best performance.
28b725ae77Skettenis  */
29b725ae77Skettenis /*---------------------------------------------------------------------------*/
30b725ae77Skettenis /* Angel overview:
31b725ae77Skettenis 
32b725ae77Skettenis ... some comments describing Angel ...
33b725ae77Skettenis 
34b725ae77Skettenis  * Angel is designed as a kit-of-parts that can be used to provide
35b725ae77Skettenis  * run-time support for the development of ARM applications. The main
36b725ae77Skettenis  * core of Angel is in providing support for the "debug" message
37b725ae77Skettenis  * communication with a host system. These messages do not just cover
38b725ae77Skettenis  * debugging ARM processes, but also the process of downloading ARM
39b725ae77Skettenis  * programs or attaching to executing processes on the target.
40b725ae77Skettenis  *
41b725ae77Skettenis  * A stand-alone ROM based Angel world is the basic starting point for
42b725ae77Skettenis  * a system, since it will allow programs to be downloaded to the
43b725ae77Skettenis  * target. The ROM version of Angel will provide the generic debug
44b725ae77Skettenis  * support, but no system specific routines. The preferred method of
45b725ae77Skettenis  * using Angel is as a link library. This ensures that applications
46b725ae77Skettenis  * carry with them the Angel routines necessary to support debugging
47b725ae77Skettenis  * (and also ensure that the Angel version is up-to-date, independant
48b725ae77Skettenis  * of the version in the target ROM). Eventually, once a program has
49b725ae77Skettenis  * been fully debugged, a ROMmed version of the program can be
50b725ae77Skettenis  * generated with the Angel code being provided in the application.
51b725ae77Skettenis 
52b725ae77Skettenis .. more comments ..
53b725ae77Skettenis 
54b725ae77Skettenis  * The standard Angel routines do *NOT* perform any dynamic memory
55b725ae77Skettenis  * allocation. To simplify the source, and aid the porting to a non C
56b725ae77Skettenis  * library world, memory is either pre-allocated (as build-time
57b725ae77Skettenis  * globals) or actually given to the particular Angel routine by the
58b725ae77Skettenis  * active run-time. This ensures that the interaction between Angel
59b725ae77Skettenis  * and the target O/S is minimised.
60b725ae77Skettenis  *
61b725ae77Skettenis  * Notes: We sub-include more header files to keep the source
62b725ae77Skettenis  * modular. Since Angel is a kit-of-parts alternative systems may need
63b725ae77Skettenis  * to change the prototypes of particular functions, whilst
64b725ae77Skettenis  * maintaining a fixed external interface. e.g. using the standard
65b725ae77Skettenis  * DEBUG messages, but with a different communications world.
66b725ae77Skettenis  */
67b725ae77Skettenis /*---------------------------------------------------------------------------*/
68b725ae77Skettenis 
69b725ae77Skettenis #ifndef __angel_h
70b725ae77Skettenis #define __angel_h
71b725ae77Skettenis 
72b725ae77Skettenis /*---------------------------------------------------------------------------*/
73b725ae77Skettenis /*-- Global Angel definitions and manifests ---------------------------------*/
74b725ae77Skettenis /*---------------------------------------------------------------------------*/
75b725ae77Skettenis /* When building Angel we may not include the standard library
76b725ae77Skettenis  * headers. However, it is useful coding using standard macro names
77b725ae77Skettenis  * since it makes the code easier to understand.
78b725ae77Skettenis  */
79b725ae77Skettenis 
80b725ae77Skettenis typedef unsigned int  word ;
81b725ae77Skettenis typedef unsigned char byte ;
82b725ae77Skettenis 
83b725ae77Skettenis /* The following typedefs can be used to access I/O registers: */
84b725ae77Skettenis typedef volatile unsigned int  vuword ;
85b725ae77Skettenis typedef volatile unsigned char vubyte ;
86b725ae77Skettenis 
87b725ae77Skettenis /*
88b725ae77Skettenis  * The following typedefs are used when defining objects that may also
89b725ae77Skettenis  * be created on a host system, where the word size is not
90b725ae77Skettenis  * 32bits. This ensures that the same data values are manipulated.
91b725ae77Skettenis  */
92b725ae77Skettenis #ifdef TARGET
93b725ae77Skettenis typedef unsigned int unsigned32;
94b725ae77Skettenis typedef signed int   signed32;
95b725ae77Skettenis typedef        int   int32;
96b725ae77Skettenis 
97b725ae77Skettenis typedef unsigned short int unsigned16;
98b725ae77Skettenis typedef signed   short int signed16;
99b725ae77Skettenis 
100b725ae77Skettenis /*
101b725ae77Skettenis  * yet another solution for the bool/boolean problem, this one is
102b725ae77Skettenis  * copied from Scott's modifications to clx/host.h
103b725ae77Skettenis  */
104b725ae77Skettenis # ifdef IMPLEMENT_BOOL_AS_ENUM
105b725ae77Skettenis    enum _bool { _false, _true };
106b725ae77Skettenis #  define _bool enum _bool
107b725ae77Skettenis # elif defined(IMPLEMENT_BOOL_AS_INT) || !defined(__cplusplus)
108b725ae77Skettenis #  define _bool int
109b725ae77Skettenis #  define _false 0
110b725ae77Skettenis #  define _true 1
111b725ae77Skettenis # endif
112b725ae77Skettenis 
113b725ae77Skettenis # ifdef _bool
114b725ae77Skettenis #  define bool _bool
115b725ae77Skettenis # endif
116b725ae77Skettenis 
117b725ae77Skettenis # ifndef true
118b725ae77Skettenis #  define true _true
119b725ae77Skettenis #  define false _false
120b725ae77Skettenis # endif
121b725ae77Skettenis 
122b725ae77Skettenis # ifndef YES
123b725ae77Skettenis #  define YES   true
124b725ae77Skettenis #  define NO    false
125b725ae77Skettenis # endif
126b725ae77Skettenis 
127b725ae77Skettenis # undef TRUE             /* some OSF headers define as 1 */
128b725ae77Skettenis # define TRUE  true
129b725ae77Skettenis 
130b725ae77Skettenis # undef FALSE            /* some OSF headers define as 1 */
131b725ae77Skettenis # define FALSE false
132b725ae77Skettenis 
133b725ae77Skettenis # ifndef NULL
134b725ae77Skettenis #  define NULL 0
135b725ae77Skettenis # endif
136b725ae77Skettenis 
137b725ae77Skettenis #else
138b725ae77Skettenis 
139b725ae77Skettenis # include "host.h"
140b725ae77Skettenis 
141b725ae77Skettenis #endif
142b725ae77Skettenis 
143b725ae77Skettenis #ifndef IGNORE
144b725ae77Skettenis # define IGNORE(x) ((x)=(x))
145b725ae77Skettenis #endif
146b725ae77Skettenis 
147b725ae77Skettenis /* The following typedef allows us to cast between integral and
148b725ae77Skettenis  * function pointers. This isn't allowed by direct casting when
149b725ae77Skettenis  * conforming to the ANSI spec.
150b725ae77Skettenis  */
151b725ae77Skettenis typedef union ansibodge
152b725ae77Skettenis {
153b725ae77Skettenis  word  w ;
154b725ae77Skettenis  word *wp ;
155b725ae77Skettenis  void *vp ;
156b725ae77Skettenis  byte *bp ;
157b725ae77Skettenis  void (*vfn)(void) ;
158b725ae77Skettenis  word (*wfn)(void) ;
159b725ae77Skettenis  int  (*ifn)(void) ;
160b725ae77Skettenis  byte (*bfn)(void) ;
161b725ae77Skettenis } ansibodge ;
162b725ae77Skettenis 
163b725ae77Skettenis /*---------------------------------------------------------------------------*/
164b725ae77Skettenis 
165b725ae77Skettenis /* The amount setup aside by the run-time system for stack overflow
166b725ae77Skettenis  * handlers to execute in. This must be at least 256bytes, since that
167b725ae77Skettenis  * value is assumed by the current ARM Ltd compiler.
168b725ae77Skettenis  * This space is _only_ kept for the USR stack, not any of the privileged
169b725ae77Skettenis  * mode stacks, as stack overflow on these is always fatal - there is
170b725ae77Skettenis  * no point attemptingto recover.  In addition is is important that
171b725ae77Skettenis  * Angel should keep privileged stack space requirements to a minimum.
172b725ae77Skettenis  */
173b725ae77Skettenis #define APCS_STACKGUARD 256
174b725ae77Skettenis 
175b725ae77Skettenis #endif /* __angel_h */
176b725ae77Skettenis 
177b725ae77Skettenis /* EOF angel.h */
178