ia64/linux-2.6.18-xen.hg

diff arch/sparc/prom/misc.c @ 0:831230e53067

Import 2.6.18 from kernel.org tarball.
author Ian Campbell <ian.campbell@xensource.com>
date Wed Apr 11 14:15:44 2007 +0100 (2007-04-11)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/arch/sparc/prom/misc.c	Wed Apr 11 14:15:44 2007 +0100
     1.3 @@ -0,0 +1,138 @@
     1.4 +/* $Id: misc.c,v 1.18 2000/08/26 02:38:03 anton Exp $
     1.5 + * misc.c:  Miscellaneous prom functions that don't belong
     1.6 + *          anywhere else.
     1.7 + *
     1.8 + * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
     1.9 + */
    1.10 +
    1.11 +#include <linux/types.h>
    1.12 +#include <linux/kernel.h>
    1.13 +#include <linux/sched.h>
    1.14 +#include <asm/openprom.h>
    1.15 +#include <asm/oplib.h>
    1.16 +#include <asm/auxio.h>
    1.17 +#include <asm/system.h>
    1.18 +
    1.19 +extern void restore_current(void);
    1.20 +
    1.21 +DEFINE_SPINLOCK(prom_lock);
    1.22 +
    1.23 +/* Reset and reboot the machine with the command 'bcommand'. */
    1.24 +void
    1.25 +prom_reboot(char *bcommand)
    1.26 +{
    1.27 +	unsigned long flags;
    1.28 +	spin_lock_irqsave(&prom_lock, flags);
    1.29 +	(*(romvec->pv_reboot))(bcommand);
    1.30 +	/* Never get here. */
    1.31 +	restore_current();
    1.32 +	spin_unlock_irqrestore(&prom_lock, flags);
    1.33 +}
    1.34 +
    1.35 +/* Forth evaluate the expression contained in 'fstring'. */
    1.36 +void
    1.37 +prom_feval(char *fstring)
    1.38 +{
    1.39 +	unsigned long flags;
    1.40 +	if(!fstring || fstring[0] == 0)
    1.41 +		return;
    1.42 +	spin_lock_irqsave(&prom_lock, flags);
    1.43 +	if(prom_vers == PROM_V0)
    1.44 +		(*(romvec->pv_fortheval.v0_eval))(strlen(fstring), fstring);
    1.45 +	else
    1.46 +		(*(romvec->pv_fortheval.v2_eval))(fstring);
    1.47 +	restore_current();
    1.48 +	spin_unlock_irqrestore(&prom_lock, flags);
    1.49 +}
    1.50 +
    1.51 +/* We want to do this more nicely some day. */
    1.52 +extern void (*prom_palette)(int);
    1.53 +
    1.54 +/* Drop into the prom, with the chance to continue with the 'go'
    1.55 + * prom command.
    1.56 + */
    1.57 +void
    1.58 +prom_cmdline(void)
    1.59 +{
    1.60 +	extern void install_obp_ticker(void);
    1.61 +	extern void install_linux_ticker(void);
    1.62 +	unsigned long flags;
    1.63 +
    1.64 +	if(!serial_console && prom_palette)
    1.65 +		prom_palette (1);
    1.66 +	spin_lock_irqsave(&prom_lock, flags);
    1.67 +	install_obp_ticker();
    1.68 +	(*(romvec->pv_abort))();
    1.69 +	restore_current();
    1.70 +	install_linux_ticker();
    1.71 +	spin_unlock_irqrestore(&prom_lock, flags);
    1.72 +#ifdef CONFIG_SUN_AUXIO
    1.73 +	set_auxio(AUXIO_LED, 0);
    1.74 +#endif
    1.75 +	if(!serial_console && prom_palette)
    1.76 +		prom_palette (0);
    1.77 +}
    1.78 +
    1.79 +/* Drop into the prom, but completely terminate the program.
    1.80 + * No chance of continuing.
    1.81 + */
    1.82 +void
    1.83 +prom_halt(void)
    1.84 +{
    1.85 +	unsigned long flags;
    1.86 +again:
    1.87 +	spin_lock_irqsave(&prom_lock, flags);
    1.88 +	(*(romvec->pv_halt))();
    1.89 +	/* Never get here. */
    1.90 +	restore_current();
    1.91 +	spin_unlock_irqrestore(&prom_lock, flags);
    1.92 +	goto again; /* PROM is out to get me -DaveM */
    1.93 +}
    1.94 +
    1.95 +typedef void (*sfunc_t)(void);
    1.96 +
    1.97 +/* Set prom sync handler to call function 'funcp'. */
    1.98 +void
    1.99 +prom_setsync(sfunc_t funcp)
   1.100 +{
   1.101 +	if(!funcp) return;
   1.102 +	*romvec->pv_synchook = funcp;
   1.103 +}
   1.104 +
   1.105 +/* Get the idprom and stuff it into buffer 'idbuf'.  Returns the
   1.106 + * format type.  'num_bytes' is the number of bytes that your idbuf
   1.107 + * has space for.  Returns 0xff on error.
   1.108 + */
   1.109 +unsigned char
   1.110 +prom_get_idprom(char *idbuf, int num_bytes)
   1.111 +{
   1.112 +	int len;
   1.113 +
   1.114 +	len = prom_getproplen(prom_root_node, "idprom");
   1.115 +	if((len>num_bytes) || (len==-1)) return 0xff;
   1.116 +	if(!prom_getproperty(prom_root_node, "idprom", idbuf, num_bytes))
   1.117 +		return idbuf[0];
   1.118 +
   1.119 +	return 0xff;
   1.120 +}
   1.121 +
   1.122 +/* Get the major prom version number. */
   1.123 +int
   1.124 +prom_version(void)
   1.125 +{
   1.126 +	return romvec->pv_romvers;
   1.127 +}
   1.128 +
   1.129 +/* Get the prom plugin-revision. */
   1.130 +int
   1.131 +prom_getrev(void)
   1.132 +{
   1.133 +	return prom_rev;
   1.134 +}
   1.135 +
   1.136 +/* Get the prom firmware print revision. */
   1.137 +int
   1.138 +prom_getprev(void)
   1.139 +{
   1.140 +	return prom_prev;
   1.141 +}