GNU Linux-libre 4.14.332-gnu1
[releases.git] / arch / mips / include / asm / dec / prom.h
1 /*
2  *      include/asm-mips/dec/prom.h
3  *
4  *      DECstation PROM interface.
5  *
6  *      Copyright (C) 2002  Maciej W. Rozycki
7  *
8  *      This program is free software; you can redistribute it and/or
9  *      modify it under the terms of the GNU General Public License
10  *      as published by the Free Software Foundation; either version
11  *      2 of the License, or (at your option) any later version.
12  *
13  *      Based on arch/mips/dec/prom/prom.h by the Anonymous.
14  */
15 #ifndef _ASM_DEC_PROM_H
16 #define _ASM_DEC_PROM_H
17
18 #include <linux/types.h>
19
20 #include <asm/addrspace.h>
21
22 /*
23  * PMAX/3MAX PROM entry points for DS2100/3100's and DS5000/2xx's.
24  * Many of these will work for MIPSen as well!
25  */
26 #define VEC_RESET               (u64 *)CKSEG1ADDR(0x1fc00000)
27                                                         /* Prom base address */
28
29 #define PMAX_PROM_ENTRY(x)      (VEC_RESET + (x))       /* Prom jump table */
30
31 #define PMAX_PROM_HALT          PMAX_PROM_ENTRY(2)      /* valid on MIPSen */
32 #define PMAX_PROM_AUTOBOOT      PMAX_PROM_ENTRY(5)      /* valid on MIPSen */
33 #define PMAX_PROM_OPEN          PMAX_PROM_ENTRY(6)
34 #define PMAX_PROM_READ          PMAX_PROM_ENTRY(7)
35 #define PMAX_PROM_CLOSE         PMAX_PROM_ENTRY(10)
36 #define PMAX_PROM_LSEEK         PMAX_PROM_ENTRY(11)
37 #define PMAX_PROM_GETCHAR       PMAX_PROM_ENTRY(12)
38 #define PMAX_PROM_PUTCHAR       PMAX_PROM_ENTRY(13)     /* 12 on MIPSen */
39 #define PMAX_PROM_GETS          PMAX_PROM_ENTRY(15)
40 #define PMAX_PROM_PRINTF        PMAX_PROM_ENTRY(17)
41 #define PMAX_PROM_GETENV        PMAX_PROM_ENTRY(33)     /* valid on MIPSen */
42
43
44 /*
45  * Magic number indicating REX PROM available on DECstation.  Found in
46  * register a2 on transfer of control to program from PROM.
47  */
48 #define REX_PROM_MAGIC          0x30464354
49
50 /* KN04 and KN05 are REX PROMs, so only do the check for R3k systems.  */
51 static inline bool prom_is_rex(u32 magic)
52 {
53         return !IS_ENABLED(CONFIG_CPU_R3000) || magic == REX_PROM_MAGIC;
54 }
55
56 /*
57  * 3MIN/MAXINE PROM entry points for DS5000/1xx's, DS5000/xx's and
58  * DS5000/2x0.
59  */
60 #define REX_PROM_GETBITMAP      0x84/4  /* get mem bitmap */
61 #define REX_PROM_GETCHAR        0x24/4  /* getch() */
62 #define REX_PROM_GETENV         0x64/4  /* get env. variable */
63 #define REX_PROM_GETSYSID       0x80/4  /* get system id */
64 #define REX_PROM_GETTCINFO      0xa4/4
65 #define REX_PROM_PRINTF         0x30/4  /* printf() */
66 #define REX_PROM_SLOTADDR       0x6c/4  /* slotaddr */
67 #define REX_PROM_BOOTINIT       0x54/4  /* open() */
68 #define REX_PROM_BOOTREAD       0x58/4  /* read() */
69 #define REX_PROM_CLEARCACHE     0x7c/4
70
71
72 /*
73  * Used by rex_getbitmap().
74  */
75 typedef struct {
76         int pagesize;
77         unsigned char bitmap[];
78 } memmap;
79
80
81 /*
82  * Function pointers as read from a PROM's callback vector.
83  */
84 extern int (*__rex_bootinit)(void);
85 extern int (*__rex_bootread)(void);
86 extern int (*__rex_getbitmap)(memmap *);
87 extern unsigned long *(*__rex_slot_address)(int);
88 extern void *(*__rex_gettcinfo)(void);
89 extern int (*__rex_getsysid)(void);
90 extern void (*__rex_clear_cache)(void);
91
92 extern int (*__prom_getchar)(void);
93 extern char *(*__prom_getenv)(char *);
94 extern int (*__prom_printf)(char *, ...);
95
96 extern int (*__pmax_open)(char*, int);
97 extern int (*__pmax_lseek)(int, long, int);
98 extern int (*__pmax_read)(int, void *, int);
99 extern int (*__pmax_close)(int);
100
101
102 #ifdef CONFIG_64BIT
103
104 /*
105  * On MIPS64 we have to call PROM functions via a helper
106  * dispatcher to accommodate ABI incompatibilities.
107  */
108 #define __DEC_PROM_O32(fun, arg) fun arg __asm__(#fun); \
109                                  __asm__(#fun " = call_o32")
110
111 int __DEC_PROM_O32(_rex_bootinit, (int (*)(void), void *));
112 int __DEC_PROM_O32(_rex_bootread, (int (*)(void), void *));
113 int __DEC_PROM_O32(_rex_getbitmap, (int (*)(memmap *), void *, memmap *));
114 unsigned long *__DEC_PROM_O32(_rex_slot_address,
115                              (unsigned long *(*)(int), void *, int));
116 void *__DEC_PROM_O32(_rex_gettcinfo, (void *(*)(void), void *));
117 int __DEC_PROM_O32(_rex_getsysid, (int (*)(void), void *));
118 void __DEC_PROM_O32(_rex_clear_cache, (void (*)(void), void *));
119
120 int __DEC_PROM_O32(_prom_getchar, (int (*)(void), void *));
121 char *__DEC_PROM_O32(_prom_getenv, (char *(*)(char *), void *, char *));
122 int __DEC_PROM_O32(_prom_printf, (int (*)(char *, ...), void *, char *, ...));
123
124
125 #define rex_bootinit()          _rex_bootinit(__rex_bootinit, NULL)
126 #define rex_bootread()          _rex_bootread(__rex_bootread, NULL)
127 #define rex_getbitmap(x)        _rex_getbitmap(__rex_getbitmap, NULL, x)
128 #define rex_slot_address(x)     _rex_slot_address(__rex_slot_address, NULL, x)
129 #define rex_gettcinfo()         _rex_gettcinfo(__rex_gettcinfo, NULL)
130 #define rex_getsysid()          _rex_getsysid(__rex_getsysid, NULL)
131 #define rex_clear_cache()       _rex_clear_cache(__rex_clear_cache, NULL)
132
133 #define prom_getchar()          _prom_getchar(__prom_getchar, NULL)
134 #define prom_getenv(x)          _prom_getenv(__prom_getenv, NULL, x)
135 #define prom_printf(x...)       _prom_printf(__prom_printf, NULL, x)
136
137 #else /* !CONFIG_64BIT */
138
139 /*
140  * On plain MIPS we just call PROM functions directly.
141  */
142 #define rex_bootinit            __rex_bootinit
143 #define rex_bootread            __rex_bootread
144 #define rex_getbitmap           __rex_getbitmap
145 #define rex_slot_address        __rex_slot_address
146 #define rex_gettcinfo           __rex_gettcinfo
147 #define rex_getsysid            __rex_getsysid
148 #define rex_clear_cache         __rex_clear_cache
149
150 #define prom_getchar            __prom_getchar
151 #define prom_getenv             __prom_getenv
152 #define prom_printf             __prom_printf
153
154 #define pmax_open               __pmax_open
155 #define pmax_lseek              __pmax_lseek
156 #define pmax_read               __pmax_read
157 #define pmax_close              __pmax_close
158
159 #endif /* !CONFIG_64BIT */
160
161
162 extern void prom_meminit(u32);
163 extern void prom_identify_arch(u32);
164 extern void prom_init_cmdline(s32, s32 *, u32);
165
166 extern void register_prom_console(void);
167 extern void unregister_prom_console(void);
168
169 #endif /* _ASM_DEC_PROM_H */