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