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