2 * $FreeBSD: src/sys/boot/alpha/libalpha/prom_swpal.S,v 1.2 1999/08/28 00:39:29 peter Exp $
3 * From: $NetBSD: prom_swpal.S,v 1.2 1997/04/06 08:41:01 cgd Exp $
7 * Copyright (c) 1994, 1995 Carnegie-Mellon University.
10 * Author: Keith Bostic
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.
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.
22 * Carnegie Mellon requests users of this software to return to
24 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
25 * School of Computer Science
26 * Carnegie Mellon University
27 * Pittsburgh PA 15213-3890
29 * any improvements or extensions that they make and grant Carnegie the
30 * rights to redistribute these changes.
34 #include <machine/asm.h>
35 #include <machine/prom.h>
36 #include <machine/rpb.h>
38 /* Offsets from base of HWRPB. */
39 #define RPB_SELFREF 0x00
40 #define RPB_SLOTSIZE 0x98
41 #define RPB_PERCPU_OFF 0xA0
43 /* Offsets in a boot PCB. */
50 #define PAL_RESERVED 0 /* Reserved to Digital. */
51 #define PAL_VMS 1 /* VMS */
52 #define PAL_OSF 2 /* OSF */
55 * PAL code switch routine.
64 #define PALSW_FRAME_SIZE (14*8)
65 #define PALSW_REGS IM_RA|IM_S0|IM_S1|IM_S2|IM_S3|IM_S4|IM_S5
72 NESTED(switch_palcode, 0, PALSW_FRAME_SIZE, ra, PALSW_REGS, 0)
76 lda sp, -PALSW_FRAME_SIZE(sp)
88 ldiq s0, HWRPB_ADDR /* s0 HWRPB_ADDR */
89 ldq s1, RPB_SLOTSIZE(s0)
90 call_pal PAL_VMS_mfpr_whami
91 mulq s1, v0, s1 /* s1 per_cpu offset from base */
92 ldq s2, RPB_PERCPU_OFF(s0)
94 addq s2, s1, s2 /* s2 PCB (virtual) */
96 call_pal PAL_VMS_mfpr_ptbr
98 stq v0, ptbr_save /* save PTBR for the kernel */
100 stq zero, PCB_FEN(s2)
103 ldq t0, RPB_SELFREF(s0) /* HWRBP base (physical) */
104 ldq t1, RPB_PERCPU_OFF(s0)
106 addq t0, s1, t0 /* PCB base (phys) */
109 call_pal PAL_VMS_mfpr_vptb
115 call_pal PAL_swppal /* a0, a1, a2, a3 */
117 contin: ldq pv, 0(sp)
127 lda sp, PALSW_FRAME_SIZE(sp)
138 #undef PALSW_FRAME_SIZE