1 /* $NetBSD: prom.h,v 1.16 2020/10/03 17:31:46 thorpej Exp $ */ 2 3 /* 4 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. 5 * All rights reserved. 6 * 7 * Author: Keith Bostic, Chris G. Demetriou 8 * 9 * Permission to use, copy, modify and distribute this software and 10 * its documentation is hereby granted, provided that both the copyright 11 * notice and this permission notice appear in all copies of the 12 * software, derivative works or modified versions, and any portions 13 * thereof, and that both notices appear in supporting documentation. 14 * 15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 18 * 19 * Carnegie Mellon requests users of this software to return to 20 * 21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 22 * School of Computer Science 23 * Carnegie Mellon University 24 * Pittsburgh PA 15213-3890 25 * 26 * any improvements or extensions that they make and grant Carnegie the 27 * rights to redistribute these changes. 28 */ 29 30 #ifndef ASSEMBLER 31 struct prom_vec { 32 uint64_t routine; 33 void *routine_arg; 34 }; 35 36 /* The return value from a prom call. */ 37 typedef union { 38 struct { 39 uint64_t 40 retval : 32, /* return value. */ 41 unit : 8, 42 mbz : 8, 43 error : 13, 44 status : 3; 45 } u; 46 uint64_t bits; 47 } prom_return_t; 48 49 /* Linux kernel parameter block filled out by Qemu. */ 50 struct linux_kernel_params { 51 char kernel_cmdline[256]; 52 uint64_t initrd_base; 53 uint64_t initrd_size; 54 }; 55 56 #ifdef _STANDALONE 57 int getchar(void); 58 void putchar(int); 59 #endif 60 61 void prom_halt(int) __attribute__((__noreturn__)); 62 int prom_getenv(int, char *, int); 63 bool prom_qemu_getenv(const char *, char *, size_t); 64 65 void hwrpb_primary_init(void); 66 void hwrpb_restart_setup(void); 67 #endif 68 69 /* Prom operation values. */ 70 #define PROM_R_CLOSE 0x11 71 #define PROM_R_GETC 0x01 72 #define PROM_R_GETENV 0x22 73 #define PROM_R_OPEN 0x10 74 #define PROM_R_PUTS 0x02 75 #define PROM_R_READ 0x13 76 #define PROM_R_WRITE 0x14 77 #define PROM_R_IOCTL 0x12 78 79 /* Prom IOCTL operation subcodes */ 80 #define PROM_I_SKIP2IRG 1 81 #define PROM_I_SKIP2MARK 2 82 #define PROM_I_REWIND 3 83 #define PROM_I_WRITEMARK 4 84 85 /* Environment variable values. */ 86 #define PROM_E_BOOTED_DEV 0x4 87 #define PROM_E_BOOTED_FILE 0x6 88 #define PROM_E_BOOTED_OSFLAGS 0x8 89 #define PROM_E_TTY_DEV 0xf 90 #define PROM_E_SCSIID 0x42 91 #define PROM_E_SCSIFAST 0x43 92 93 #if defined(_STANDALONE) || defined(ENABLEPROM) 94 /* 95 * These can't be called from the kernel without great care. 96 * 97 * There have to be stub routines to do the copying that ensures that the 98 * PROM doesn't get called with an address larger than 32 bits. Calls that 99 * either don't need to copy anything, or don't need the copy because it's 100 * already being done elsewhere, are defined here. 101 */ 102 #define prom_open(dev, len) \ 103 prom_dispatch(PROM_R_OPEN, (dev), (len), 0, 0) 104 #define prom_close(chan) \ 105 prom_dispatch(PROM_R_CLOSE, chan, 0, 0, 0) 106 #define prom_read(chan, len, buf, blkno) \ 107 prom_dispatch(PROM_R_READ, chan, len, (uint64_t)buf, blkno) 108 #define prom_write(chan, len, buf, blkno) \ 109 prom_dispatch(PROM_R_WRITE, chan, len, (uint64_t)buf, blkno) 110 #define prom_ioctl(chan, op, count) \ 111 prom_dispatch(PROM_R_IOCTL, chan, op, (int64_t)count, 0, 0) 112 #define prom_putstr(chan, str, len) \ 113 prom_dispatch(PROM_R_PUTS, chan, (uint64_t)str, len, 0) 114 #define prom_getc(chan) \ 115 prom_dispatch(PROM_R_GETC, chan, 0, 0, 0) 116 #define prom_getenv_disp(id, buf, len) \ 117 prom_dispatch(PROM_R_GETENV, id, (uint64_t)buf, len, 0) 118 #endif 119 120 #ifndef ASSEMBLER 121 #ifdef _KERNEL 122 123 #ifdef _KERNEL_OPT 124 #include "opt_dec_kn8ae.h" 125 126 #if defined(DEC_KN8AE) 127 #define _PROM_MAY_USE_PROM_CONSOLE 128 #endif /* DEC_KN8AE */ 129 #endif /* _KERNEL_OPT */ 130 131 extern bool prom_interface_initialized; 132 133 bool prom_uses_prom_console(void); 134 135 void prom_enter(void); 136 void prom_leave(void); 137 138 void promcnputc(dev_t, int); 139 int promcngetc(dev_t); 140 int promcnlookc(dev_t, char *); 141 142 uint64_t prom_dispatch(uint64_t, uint64_t, uint64_t, uint64_t, 143 uint64_t); 144 #endif /* _KERNEL */ 145 #endif /* ASSEMBLER */ 146