xref: /netbsd-src/sys/arch/hppa/stand/common/exec_hppa.c (revision 6d3ceb1d619615401b17c9aa3e4bc674a1cb048b)
1*6d3ceb1dSskrll /*	$NetBSD: exec_hppa.c,v 1.1 2014/02/24 07:23:43 skrll Exp $	*/
2*6d3ceb1dSskrll 
3*6d3ceb1dSskrll /*	$OpenBSD: exec_hppa.c,v 1.7 1999/05/06 02:13:15 mickey Exp $	*/
4*6d3ceb1dSskrll 
5*6d3ceb1dSskrll /*
6*6d3ceb1dSskrll  * Copyright (c) 1998-2004 Michael Shalayeff
7*6d3ceb1dSskrll  * All rights reserved.
8*6d3ceb1dSskrll  *
9*6d3ceb1dSskrll  * Redistribution and use in source and binary forms, with or without
10*6d3ceb1dSskrll  * modification, are permitted provided that the following conditions
11*6d3ceb1dSskrll  * are met:
12*6d3ceb1dSskrll  * 1. Redistributions of source code must retain the above copyright
13*6d3ceb1dSskrll  *    notice, this list of conditions and the following disclaimer.
14*6d3ceb1dSskrll  * 2. Redistributions in binary form must reproduce the above copyright
15*6d3ceb1dSskrll  *    notice, this list of conditions and the following disclaimer in the
16*6d3ceb1dSskrll  *    documentation and/or other materials provided with the distribution.
17*6d3ceb1dSskrll  *
18*6d3ceb1dSskrll  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19*6d3ceb1dSskrll  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20*6d3ceb1dSskrll  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21*6d3ceb1dSskrll  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
22*6d3ceb1dSskrll  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23*6d3ceb1dSskrll  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24*6d3ceb1dSskrll  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25*6d3ceb1dSskrll  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26*6d3ceb1dSskrll  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27*6d3ceb1dSskrll  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28*6d3ceb1dSskrll  * THE POSSIBILITY OF SUCH DAMAGE.
29*6d3ceb1dSskrll  *
30*6d3ceb1dSskrll  */
31*6d3ceb1dSskrll 
32*6d3ceb1dSskrll #include <sys/param.h>
33*6d3ceb1dSskrll #include <sys/exec.h>
34*6d3ceb1dSskrll #include <sys/reboot.h>
35*6d3ceb1dSskrll #include <dev/cons.h>
36*6d3ceb1dSskrll #include <stand/boot/bootarg.h>
37*6d3ceb1dSskrll #include <sys/disklabel.h>
38*6d3ceb1dSskrll #include "libsa.h"
39*6d3ceb1dSskrll #include <lib/libsa/exec.h>
40*6d3ceb1dSskrll 
41*6d3ceb1dSskrll #include <machine/pdc.h>
42*6d3ceb1dSskrll #include "dev_hppa.h"
43*6d3ceb1dSskrll 
44*6d3ceb1dSskrll typedef void (*startfuncp)(int, int, int, int, int, int, void *)
45*6d3ceb1dSskrll     __attribute__ ((noreturn));
46*6d3ceb1dSskrll 
47*6d3ceb1dSskrll void
machdep_exec(struct x_param * xp,int howto,void * loadaddr)48*6d3ceb1dSskrll machdep_exec(struct x_param *xp, int howto, void *loadaddr)
49*6d3ceb1dSskrll {
50*6d3ceb1dSskrll #ifdef EXEC_DEBUG
51*6d3ceb1dSskrll 	extern int debug;
52*6d3ceb1dSskrll 	int i;
53*6d3ceb1dSskrll #endif
54*6d3ceb1dSskrll 	size_t ac = BOOTARG_LEN;
55*6d3ceb1dSskrll 	void *av = (void *)BOOTARG_OFF;
56*6d3ceb1dSskrll #ifdef notyet
57*6d3ceb1dSskrll 	makebootargs(av, &ac);
58*6d3ceb1dSskrll #endif
59*6d3ceb1dSskrll 
60*6d3ceb1dSskrll #ifdef EXEC_DEBUG
61*6d3ceb1dSskrll 	if (debug) {
62*6d3ceb1dSskrll 		printf("ep=0x%x [", xp->xp_entry);
63*6d3ceb1dSskrll 		for (i = 0; i < 10240; i++) {
64*6d3ceb1dSskrll 			if (!(i % 8)) {
65*6d3ceb1dSskrll 				printf("\b\n%p:", &((u_int *)xp->xp_entry)[i]);
66*6d3ceb1dSskrll 				if (getchar() != ' ')
67*6d3ceb1dSskrll 					break;
68*6d3ceb1dSskrll 			}
69*6d3ceb1dSskrll 			printf("%x,", ((int *)xp->xp_entry)[i]);
70*6d3ceb1dSskrll 		}
71*6d3ceb1dSskrll 		printf("\b\b ]\n");
72*6d3ceb1dSskrll 	}
73*6d3ceb1dSskrll #endif
74*6d3ceb1dSskrll 
75*6d3ceb1dSskrll 	fcacheall();
76*6d3ceb1dSskrll 
77*6d3ceb1dSskrll 	__asm("mtctl %r0, %cr17");
78*6d3ceb1dSskrll 	__asm("mtctl %r0, %cr17");
79*6d3ceb1dSskrll 	/* stack and the gung is ok at this point, so, no need for asm setup */
80*6d3ceb1dSskrll 	(*(startfuncp)(xp->xp_entry)) ((int)pdc, howto, bootdev, xp->xp_end,
81*6d3ceb1dSskrll 				       BOOTARG_APIVER, ac, av);
82*6d3ceb1dSskrll 	/* not reached */
83*6d3ceb1dSskrll }
84