blob: b8c95940d0897aa702027e3ac26c8146cf8c0915 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001// 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 <asm/sun3-head.h>
13#include <asm/idprom.h>
14#include <asm/openprom.h>
15#include <asm/oplib.h>
16#include <asm/movs.h>
17
18/* Reset and reboot the machine with the command 'bcommand'. */
19void
20prom_reboot(char *bcommand)
21{
22 unsigned long flags;
23 local_irq_save(flags);
24 (*(romvec->pv_reboot))(bcommand);
25 local_irq_restore(flags);
26}
27
28/* Drop into the prom, with the chance to continue with the 'go'
29 * prom command.
30 */
31void
32prom_cmdline(void)
33{
34}
35
36/* Drop into the prom, but completely terminate the program.
37 * No chance of continuing.
38 */
39void
40prom_halt(void)
41{
42 unsigned long flags;
43again:
44 local_irq_save(flags);
45 (*(romvec->pv_halt))();
46 local_irq_restore(flags);
47 goto again; /* PROM is out to get me -DaveM */
48}
49
50typedef void (*sfunc_t)(void);
51
52/* Get the idprom and stuff it into buffer 'idbuf'. Returns the
53 * format type. 'num_bytes' is the number of bytes that your idbuf
54 * has space for. Returns 0xff on error.
55 */
56unsigned char
57prom_get_idprom(char *idbuf, int num_bytes)
58{
59 int i, oldsfc;
60 GET_SFC(oldsfc);
61 SET_SFC(FC_CONTROL);
62 for(i=0;i<num_bytes; i++)
63 {
64 /* There is a problem with the GET_CONTROL_BYTE
65 macro; defining the extra variable
66 gets around it.
67 */
68 int c;
69 GET_CONTROL_BYTE(SUN3_IDPROM_BASE + i, c);
70 idbuf[i] = c;
71 }
72 SET_SFC(oldsfc);
73 return idbuf[0];
74}
75
76/* Get the major prom version number. */
77int
78prom_version(void)
79{
80 return romvec->pv_romvers;
81}
82
83/* Get the prom plugin-revision. */
84int
85prom_getrev(void)
86{
87 return prom_rev;
88}
89
90/* Get the prom firmware print revision. */
91int
92prom_getprev(void)
93{
94 return prom_prev;
95}