Linux Audio

Check our new training course

Loading...
v6.2
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 * misc.c:  Miscellaneous prom functions that don't belong
  4 *          anywhere else.
  5 *
  6 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  7 */
  8
  9#include <linux/types.h>
 10#include <linux/kernel.h>
 11#include <linux/sched.h>
 12#include <linux/module.h>
 13
 14#include <asm/openprom.h>
 15#include <asm/oplib.h>
 16#include <asm/auxio.h>
 17
 18extern void restore_current(void);
 19
 20DEFINE_SPINLOCK(prom_lock);
 21
 22/* Reset and reboot the machine with the command 'bcommand'. */
 23void
 24prom_reboot(char *bcommand)
 25{
 26	unsigned long flags;
 27	spin_lock_irqsave(&prom_lock, flags);
 28	(*(romvec->pv_reboot))(bcommand);
 29	/* Never get here. */
 30	restore_current();
 31	spin_unlock_irqrestore(&prom_lock, flags);
 32}
 33
 34/* Forth evaluate the expression contained in 'fstring'. */
 35void
 36prom_feval(char *fstring)
 37{
 38	unsigned long flags;
 39	if(!fstring || fstring[0] == 0)
 40		return;
 41	spin_lock_irqsave(&prom_lock, flags);
 42	if(prom_vers == PROM_V0)
 43		(*(romvec->pv_fortheval.v0_eval))(strlen(fstring), fstring);
 44	else
 45		(*(romvec->pv_fortheval.v2_eval))(fstring);
 46	restore_current();
 47	spin_unlock_irqrestore(&prom_lock, flags);
 48}
 49EXPORT_SYMBOL(prom_feval);
 50
 51/* Drop into the prom, with the chance to continue with the 'go'
 52 * prom command.
 53 */
 54void
 55prom_cmdline(void)
 56{
 57	unsigned long flags;
 58
 59	spin_lock_irqsave(&prom_lock, flags);
 60	(*(romvec->pv_abort))();
 61	restore_current();
 62	spin_unlock_irqrestore(&prom_lock, flags);
 63	set_auxio(AUXIO_LED, 0);
 64}
 65
 66/* Drop into the prom, but completely terminate the program.
 67 * No chance of continuing.
 68 */
 69void __noreturn
 70prom_halt(void)
 71{
 72	unsigned long flags;
 73again:
 74	spin_lock_irqsave(&prom_lock, flags);
 75	(*(romvec->pv_halt))();
 76	/* Never get here. */
 77	restore_current();
 78	spin_unlock_irqrestore(&prom_lock, flags);
 79	goto again; /* PROM is out to get me -DaveM */
 80}
 81
 82typedef void (*sfunc_t)(void);
 83
 84/* Set prom sync handler to call function 'funcp'. */
 85void
 86prom_setsync(sfunc_t funcp)
 87{
 88	if(!funcp) return;
 89	*romvec->pv_synchook = funcp;
 90}
 91
 92/* Get the idprom and stuff it into buffer 'idbuf'.  Returns the
 93 * format type.  'num_bytes' is the number of bytes that your idbuf
 94 * has space for.  Returns 0xff on error.
 95 */
 96unsigned char
 97prom_get_idprom(char *idbuf, int num_bytes)
 98{
 99	int len;
100
101	len = prom_getproplen(prom_root_node, "idprom");
102	if((len>num_bytes) || (len==-1)) return 0xff;
103	if(!prom_getproperty(prom_root_node, "idprom", idbuf, num_bytes))
104		return idbuf[0];
105
106	return 0xff;
107}
108
109/* Get the major prom version number. */
110int
111prom_version(void)
112{
113	return romvec->pv_romvers;
114}
115
116/* Get the prom plugin-revision. */
117int
118prom_getrev(void)
119{
120	return prom_rev;
121}
122
123/* Get the prom firmware print revision. */
124int
125prom_getprev(void)
126{
127	return prom_prev;
128}
v3.5.6
 
  1/*
  2 * misc.c:  Miscellaneous prom functions that don't belong
  3 *          anywhere else.
  4 *
  5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  6 */
  7
  8#include <linux/types.h>
  9#include <linux/kernel.h>
 10#include <linux/sched.h>
 11#include <linux/module.h>
 12
 13#include <asm/openprom.h>
 14#include <asm/oplib.h>
 15#include <asm/auxio.h>
 16
 17extern void restore_current(void);
 18
 19DEFINE_SPINLOCK(prom_lock);
 20
 21/* Reset and reboot the machine with the command 'bcommand'. */
 22void
 23prom_reboot(char *bcommand)
 24{
 25	unsigned long flags;
 26	spin_lock_irqsave(&prom_lock, flags);
 27	(*(romvec->pv_reboot))(bcommand);
 28	/* Never get here. */
 29	restore_current();
 30	spin_unlock_irqrestore(&prom_lock, flags);
 31}
 32
 33/* Forth evaluate the expression contained in 'fstring'. */
 34void
 35prom_feval(char *fstring)
 36{
 37	unsigned long flags;
 38	if(!fstring || fstring[0] == 0)
 39		return;
 40	spin_lock_irqsave(&prom_lock, flags);
 41	if(prom_vers == PROM_V0)
 42		(*(romvec->pv_fortheval.v0_eval))(strlen(fstring), fstring);
 43	else
 44		(*(romvec->pv_fortheval.v2_eval))(fstring);
 45	restore_current();
 46	spin_unlock_irqrestore(&prom_lock, flags);
 47}
 48EXPORT_SYMBOL(prom_feval);
 49
 50/* Drop into the prom, with the chance to continue with the 'go'
 51 * prom command.
 52 */
 53void
 54prom_cmdline(void)
 55{
 56	unsigned long flags;
 57
 58	spin_lock_irqsave(&prom_lock, flags);
 59	(*(romvec->pv_abort))();
 60	restore_current();
 61	spin_unlock_irqrestore(&prom_lock, flags);
 62	set_auxio(AUXIO_LED, 0);
 63}
 64
 65/* Drop into the prom, but completely terminate the program.
 66 * No chance of continuing.
 67 */
 68void __noreturn
 69prom_halt(void)
 70{
 71	unsigned long flags;
 72again:
 73	spin_lock_irqsave(&prom_lock, flags);
 74	(*(romvec->pv_halt))();
 75	/* Never get here. */
 76	restore_current();
 77	spin_unlock_irqrestore(&prom_lock, flags);
 78	goto again; /* PROM is out to get me -DaveM */
 79}
 80
 81typedef void (*sfunc_t)(void);
 82
 83/* Set prom sync handler to call function 'funcp'. */
 84void
 85prom_setsync(sfunc_t funcp)
 86{
 87	if(!funcp) return;
 88	*romvec->pv_synchook = funcp;
 89}
 90
 91/* Get the idprom and stuff it into buffer 'idbuf'.  Returns the
 92 * format type.  'num_bytes' is the number of bytes that your idbuf
 93 * has space for.  Returns 0xff on error.
 94 */
 95unsigned char
 96prom_get_idprom(char *idbuf, int num_bytes)
 97{
 98	int len;
 99
100	len = prom_getproplen(prom_root_node, "idprom");
101	if((len>num_bytes) || (len==-1)) return 0xff;
102	if(!prom_getproperty(prom_root_node, "idprom", idbuf, num_bytes))
103		return idbuf[0];
104
105	return 0xff;
106}
107
108/* Get the major prom version number. */
109int
110prom_version(void)
111{
112	return romvec->pv_romvers;
113}
114
115/* Get the prom plugin-revision. */
116int
117prom_getrev(void)
118{
119	return prom_rev;
120}
121
122/* Get the prom firmware print revision. */
123int
124prom_getprev(void)
125{
126	return prom_prev;
127}