2 * $FreeBSD: src/sys/boot/alpha/libalpha/prom_swpal.S,v 1.2 1999/08/28 00:39:29 peter Exp $
3 * $DragonFly: src/sys/boot/alpha/libalpha/Attic/prom_swpal.S,v 1.2 2003/06/17 04:28:16 dillon Exp $
4 * From: $NetBSD: prom_swpal.S,v 1.2 1997/04/06 08:41:01 cgd Exp $
8 * Copyright (c) 1994, 1995 Carnegie-Mellon University.
11 * Author: Keith Bostic
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.
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.
23 * Carnegie Mellon requests users of this software to return to
25 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
26 * School of Computer Science
27 * Carnegie Mellon University
28 * Pittsburgh PA 15213-3890
30 * any improvements or extensions that they make and grant Carnegie the
31 * rights to redistribute these changes.
35 #include <machine/asm.h>
36 #include <machine/prom.h>
37 #include <machine/rpb.h>
39 /* Offsets from base of HWRPB. */
40 #define RPB_SELFREF 0x00
41 #define RPB_SLOTSIZE 0x98
42 #define RPB_PERCPU_OFF 0xA0
44 /* Offsets in a boot PCB. */
51 #define PAL_RESERVED 0 /* Reserved to Digital. */
52 #define PAL_VMS 1 /* VMS */
53 #define PAL_OSF 2 /* OSF */
56 * PAL code switch routine.
65 #define PALSW_FRAME_SIZE (14*8)
66 #define PALSW_REGS IM_RA|IM_S0|IM_S1|IM_S2|IM_S3|IM_S4|IM_S5
73 NESTED(switch_palcode, 0, PALSW_FRAME_SIZE, ra, PALSW_REGS, 0)
77 lda sp, -PALSW_FRAME_SIZE(sp)
89 ldiq s0, HWRPB_ADDR /* s0 HWRPB_ADDR */
90 ldq s1, RPB_SLOTSIZE(s0)
91 call_pal PAL_VMS_mfpr_whami
92 mulq s1, v0, s1 /* s1 per_cpu offset from base */
93 ldq s2, RPB_PERCPU_OFF(s0)
95 addq s2, s1, s2 /* s2 PCB (virtual) */
97 call_pal PAL_VMS_mfpr_ptbr
99 stq v0, ptbr_save /* save PTBR for the kernel */
100 stl zero, PCB_ASN(s2)
101 stq zero, PCB_FEN(s2)
104 ldq t0, RPB_SELFREF(s0) /* HWRBP base (physical) */
105 ldq t1, RPB_PERCPU_OFF(s0)
107 addq t0, s1, t0 /* PCB base (phys) */
110 call_pal PAL_VMS_mfpr_vptb
116 call_pal PAL_swppal /* a0, a1, a2, a3 */
118 contin: ldq pv, 0(sp)
128 lda sp, PALSW_FRAME_SIZE(sp)
139 #undef PALSW_FRAME_SIZE