Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / boot / alpha / libalpha / prom_disp.S
1 /* 
2  * $FreeBSD: src/sys/boot/alpha/libalpha/prom_disp.S,v 1.2 1999/08/28 00:39:28 peter Exp $ 
3  * From: $NetBSD: prom_disp.S,v 1.2 1997/04/06 08:41:00 cgd Exp $ 
4  */
5
6 /*
7  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
8  * All rights reserved.
9  *
10  * Author: Chris G. Demetriou
11  * 
12  * Permission to use, copy, modify and distribute this software and
13  * its documentation is hereby granted, provided that both the copyright
14  * notice and this permission notice appear in all copies of the
15  * software, derivative works or modified versions, and any portions
16  * thereof, and that both notices appear in supporting documentation.
17  * 
18  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 
19  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 
20  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
21  * 
22  * Carnegie Mellon requests users of this software to return to
23  *
24  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
25  *  School of Computer Science
26  *  Carnegie Mellon University
27  *  Pittsburgh PA 15213-3890
28  *
29  * any improvements or extensions that they make and grant Carnegie the
30  * rights to redistribute these changes.
31  */
32
33 #ifndef _LOCORE
34 #define ASSEMBLER
35 #include <machine/asm.h>
36 #include <machine/prom.h>
37 #include <machine/rpb.h>
38 #endif
39
40         .globl  prom_dispatch_v
41         .comm   prom_dispatch_v,16
42
43         .text
44         .align  4
45
46 /*
47  * Dispatcher routine.  Implements prom's calling machinery, saves our
48  * callee-saved registers as required by C.
49  */
50 #define D_RA                     (7*8)
51 #define D_S0                     (8*8)
52 #define D_S1                     (9*8)
53 #define D_S2                    (10*8)
54 #define D_S3                    (11*8)
55 #define D_S4                    (12*8)
56 #define D_S5                    (13*8)
57 #define D_S6                    (14*8)
58 #define DISPATCH_FRAME_SIZE     (15*8)
59 #define DISPATCH_REGS           IM_RA|IM_S0|IM_S1|IM_S2|IM_S3|IM_S4|IM_S5|IM_S6
60
61 NESTED(prom_dispatch, 5, DISPATCH_FRAME_SIZE, ra, DISPATCH_REGS, 0)
62         LDGP(pv)
63
64         lda     sp, -DISPATCH_FRAME_SIZE(sp)
65         stq     ra, D_RA(sp)
66         stq     s0, D_S0(sp)
67         stq     s1, D_S1(sp)
68         stq     s2, D_S2(sp)
69         stq     s3, D_S3(sp)
70         stq     s4, D_S4(sp)
71         stq     s5, D_S5(sp)
72         stq     s6, D_S6(sp)
73
74         /* Lord have mercy because.. I would not. */
75 /* #define      STUPID_PROM_IS_32_BITS */
76 #ifdef  STUPID_PROM_IS_32_BITS
77         ldah    s0, 0x2000(zero)        /* hack for hack */
78         lda     s0, (0x2000-8)(s0)
79
80         stq     sp, 0(s0)
81         or      s0, zero, sp
82 #endif  /* STUPID_PROM_IS_32_BITS */
83
84         lda     pv, prom_dispatch_v
85         ldq     v0, 0(pv)               /* routine */
86         ldq     pv, 8(pv)               /* routine_arg */
87         
88         jsr     ra, (v0)
89
90 #ifdef  STUPID_PROM_IS_32_BITS
91         ldah    s0, 0x2000(zero)        /* hack for hack */
92         lda     s0, (0x2000-8)(s0)
93
94         ldq     sp, 0(s0)
95 #endif  /* STUPID_PROM_IS_32_BITS */
96
97         ldq     ra, D_RA(sp)
98         ldq     s0, D_S0(sp)
99         ldq     s1, D_S1(sp)
100         ldq     s2, D_S2(sp)
101         ldq     s3, D_S3(sp)
102         ldq     s4, D_S4(sp)
103         ldq     s5, D_S5(sp)
104         ldq     s6, D_S6(sp)
105         lda     sp, DISPATCH_FRAME_SIZE(sp)
106         RET
107 END(prom_dispatch)
108
109 #undef  D_RA                    
110 #undef  D_S0                    
111 #undef  D_S1                    
112 #undef  D_S2                    
113 #undef  D_S3                    
114 #undef  D_S4                    
115 #undef  D_S5                    
116 #undef  D_S6                    
117 #undef  DISPATCH_FRAME_SIZE
118 #undef  DISPATCH_REGS