1/* $NetBSD: prom_disp.s,v 1.7 1997/04/08 00:19:03 cgd Exp $ */ 2 3/* 4 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. 5 * All rights reserved. 6 * 7 * Author: Chris G. Demetriou 8 * 9 * Permission to use, copy, modify and distribute this software and 10 * its documentation is hereby granted, provided that both the copyright 11 * notice and this permission notice appear in all copies of the 12 * software, derivative works or modified versions, and any portions 13 * thereof, and that both notices appear in supporting documentation. 14 * 15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 18 * 19 * Carnegie Mellon requests users of this software to return to 20 * 21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 22 * School of Computer Science 23 * Carnegie Mellon University 24 * Pittsburgh PA 15213-3890 25 * 26 * any improvements or extensions that they make and grant Carnegie the 27 * rights to redistribute these changes. 28 */ 29 30#ifndef _LOCORE 31#include <machine/asm.h> 32#else 33__KERNEL_RCSID(2, "$NetBSD: prom_disp.s,v 1.7 1997/04/08 00:19:03 cgd Exp $"); 34#endif 35 36 .globl prom_dispatch_v 37 .comm prom_dispatch_v,16 38 39 .text 40 .align 4 41 42inc3: .stabs __FILE__,132,0,0,inc3; .loc 1 __LINE__ 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 60 ldgp gp, 0(pv) 61 62 lda sp, -DISPATCH_FRAME_SIZE(sp) 63 stq ra, D_RA(sp) 64 stq s0, D_S0(sp) 65 stq s1, D_S1(sp) 66 stq s2, D_S2(sp) 67 stq s3, D_S3(sp) 68 stq s4, D_S4(sp) 69 stq s5, D_S5(sp) 70 stq s6, D_S6(sp) 71 72 /* Lord have mercy because.. I would not. */ 73#define STUPID_PROM_IS_32_BITS 74#ifdef STUPID_PROM_IS_32_BITS 75 ldah s0, 0x2000(zero) /* hack for hack */ 76 lda s0, (0x2000-8)(s0) 77 78 stq sp, 0(s0) 79 or s0, zero, sp 80#endif /* STUPID_PROM_IS_32_BITS */ 81 82 lda pv, prom_dispatch_v 83 ldq v0, 0(pv) /* routine */ 84 ldq pv, 8(pv) /* routine_arg */ 85 86 jsr ra, (v0) 87 88#ifdef STUPID_PROM_IS_32_BITS 89 ldah s0, 0x2000(zero) /* hack for hack */ 90 lda s0, (0x2000-8)(s0) 91 92 ldq sp, 0(s0) 93#endif /* STUPID_PROM_IS_32_BITS */ 94 95 ldq ra, D_RA(sp) 96 ldq s0, D_S0(sp) 97 ldq s1, D_S1(sp) 98 ldq s2, D_S2(sp) 99 ldq s3, D_S3(sp) 100 ldq s4, D_S4(sp) 101 ldq s5, D_S5(sp) 102 ldq s6, D_S6(sp) 103 lda sp, DISPATCH_FRAME_SIZE(sp) 104 RET 105END(prom_dispatch) 106 107#undef D_RA 108#undef D_S0 109#undef D_S1 110#undef D_S2 111#undef D_S3 112#undef D_S4 113#undef D_S5 114#undef D_S6 115#undef DISPATCH_FRAME_SIZE 116#undef DISPATCH_REGS 117