1 ##=============================================================================
2 #####ECOSGPLCOPYRIGHTBEGIN####
3 ## -------------------------------------------
4 ## This file is part of eCos, the Embedded Configurable Operating System.
5 ## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
7 ## eCos is free software; you can redistribute it and/or modify it under
8 ## the terms of the GNU General Public License as published by the Free
9 ## Software Foundation; either version 2 or (at your option) any later version.
11 ## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
12 ## WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 ## You should have received a copy of the GNU General Public License along
17 ## with eCos; if not, write to the Free Software Foundation, Inc.,
18 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20 ## As a special exception, if other files instantiate templates or use macros
21 ## or inline functions from this file, or you compile this file and link it
22 ## with other works to produce a work based on this file, this file does not
23 ## by itself cause the resulting work to be covered by the GNU General Public
24 ## License. However the source code for this file must still be made available
25 ## in accordance with section (3) of the GNU General Public License.
27 ## This exception does not invalidate any other reasons why a work based on
28 ## this file might be covered by the GNU General Public License.
30 ## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
31 ## at http://sources.redhat.com/ecos/ecos-license/
32 ## -------------------------------------------
33 #####ECOSGPLCOPYRIGHTEND####
34 ##=============================================================================
35 /*****************************************************************************
36 hal_arch.S -- m68k architecture code
37 *****************************************************************************/
39 #include <pkgconf/hal.h>
41 /*****************************************************************************
42 FUNC_START -- Function declaration macro
43 *****************************************************************************/
44 #define FUNC_START(name) \
50 /*****************************************************************************
51 The following routines assume the hal_jmp_buf structure is defined as
69 typedef cyg_uint32 hal_jmp_buf[sizeof(hal_jmp_buf_t) / sizeof(cyg_uint32)];
70 *****************************************************************************/
72 /*****************************************************************************
73 hal_m68k_setjmp -- Generic setjmp for the m68k architecture
75 externC int hal_m68k_setjmp(hal_jmp_buf env);
79 0(%sp): return address
81 4(%sp): env - address of a hal_jmp_buf structure
85 d0, d1, a0, a1 are ours to abuse.
89 This routine always returns zero in d0.l.
91 *****************************************************************************/
92 FUNC_START(hal_m68k_setjmp)
94 lea.l 4(%sp),%a1 /* Get a pointer to the position */
95 /* of the stack pointer before this */
96 /* call was made. IMPORTANT: The */
97 /* longjmp routine and the */
98 /* exception handler assume that */
99 /* saved stack pointers point to */
100 /* the location of the stack before */
101 /* the routine/exception occurred. */
103 move.l (%a1),%a0 /* Get a pointer to the buffer to */
104 /* save our state into. */
106 movem.l %d2-%d7/%a2-%a6,(%a0) /* Write all of the preserved */
107 lea (11*4)(%a0),%a0 /* registers, the stack pointer, */
108 move.l %a1,(%a0)+ /* and the return address into the */
109 move.l (%sp),(%a0) /* structure. */
111 moveq.l #0,%d0 /* Load a zero return value and */
114 /*****************************************************************************
115 hal_m68k_longjmp -- Generic longjmp for the m68k architecture
117 externC void hal_m68k_longjmp(hal_jmp_buf env, int val);
121 0(%sp): return address
123 4(%sp): env - address of a hal_jmp_buf structure
125 8(%sp): val - the non-zero value to return
129 d0, d1, a0, a1 are ours to abuse.
133 This routine always returns the value from the val parameter in d0.l
134 and to the location of the PC in the env structure.
136 *****************************************************************************/
137 FUNC_START(hal_m68k_longjmp)
139 move.l 8(%sp),%d0 /* Load the return value */
142 move.l 4(%sp),%a0 /* Get a pointer to the buffer to */
143 /* read our state from. */
145 movem.l (%a0),%d2-%d7/%a2-%a6 /* Load our preserved registers, */
146 lea (11*4)(%a0),%a0 /* stack pointer and return address */
147 move.l (%a0)+,%d1 /* from the structure. */
150 move.l %d1,%sp /* Set the stack pointer from the */
151 jmp (%a1) /* structure as out current stack */
152 /* pointer and jump to the return */
153 /* address from the structure. */