Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / boot / alpha / libalpha / OSFpal.c
1 /*
2  * $FreeBSD: src/sys/boot/alpha/libalpha/OSFpal.c,v 1.2.2.1 2000/07/07 00:20:49 obrien Exp $
3  * From $NetBSD: OSFpal.c,v 1.5 1998/06/24 01:33:19 ross Exp $ 
4  */
5
6 /*
7  * Copyright (c) 1994, 1996 Carnegie-Mellon University.
8  * All rights reserved.
9  *
10  * Author: Keith Bostic
11  *
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.
17  *
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.
21  *
22  * Carnegie Mellon requests users of this software to return to
23  *
24  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
25  *  School of Computer Science
26  *  Carnegie Mellon University
27  *  Pittsburgh PA 15213-3890
28  *
29  * any improvements or extensions that they make and grant Carnegie the
30  * rights to redistribute these changes.
31  */
32
33 #include <sys/types.h>
34 #include <stand.h>
35
36 #include <machine/prom.h>
37 #include <machine/rpb.h>
38 #include <machine/alpha_cpu.h>
39
40 vm_offset_t ptbr_save;
41
42 #include "common.h"
43
44 void
45 OSFpal()
46 {
47         struct rpb *r;
48         struct pcs *p;
49
50         r = (struct rpb *)HWRPB_ADDR;
51         /*
52          * Note, cpu_number() is a VMS op, can't necessarily call it.
53          * Real fun: PAL_VMS_mfpr_whami == PAL_OSF1_rti...
54          * We might not be rpb_primary_cpu_id, but it is supposed to go
55          * first so the answer should apply to everyone.
56          */
57         p = LOCATE_PCS(r, r->rpb_primary_cpu_id);
58
59         printf("VMS PAL rev: 0x%lx\n", p->pcs_palrevisions[PALvar_OpenVMS]);
60         printf("OSF PAL rev: 0x%lx\n", p->pcs_palrevisions[PALvar_OSF1]);
61
62         if(p->pcs_pal_type==PAL_TYPE_OSF1) {
63                 printf("OSF PAL code already running.\n");
64                 ptbr_save = ((struct alpha_pcb *)p)->apcb_ptbr;
65                 printf("PTBR is:          0x%lx\n", ptbr_save);
66                 return;
67         }
68         switch_palcode();
69         bcopy(&p->pcs_palrevisions[PALvar_OSF1], &p->pcs_pal_rev,
70               sizeof(p->pcs_pal_rev));
71         printf("Switch to OSF PAL code succeeded.\n");
72 }
73