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