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