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