1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 24*7c478bd9Sstevel@tonic-gate 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate /* 27*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 28*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 29*7c478bd9Sstevel@tonic-gate */ 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #ifndef _SYS_SYSTM_H 32*7c478bd9Sstevel@tonic-gate #define _SYS_SYSTM_H 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 37*7c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 38*7c478bd9Sstevel@tonic-gate #include <sys/proc.h> 39*7c478bd9Sstevel@tonic-gate #include <sys/dditypes.h> 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 42*7c478bd9Sstevel@tonic-gate extern "C" { 43*7c478bd9Sstevel@tonic-gate #endif 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate /* 46*7c478bd9Sstevel@tonic-gate * The pc_t is the type of the kernel's program counter. In general, a 47*7c478bd9Sstevel@tonic-gate * pc_t is a uintptr_t -- except for a sparcv9 kernel, in which case all 48*7c478bd9Sstevel@tonic-gate * instruction text is below 4G, and a pc_t is thus a uint32_t. 49*7c478bd9Sstevel@tonic-gate */ 50*7c478bd9Sstevel@tonic-gate #ifdef __sparcv9 51*7c478bd9Sstevel@tonic-gate typedef uint32_t pc_t; 52*7c478bd9Sstevel@tonic-gate #else 53*7c478bd9Sstevel@tonic-gate typedef uintptr_t pc_t; 54*7c478bd9Sstevel@tonic-gate #endif 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate /* 57*7c478bd9Sstevel@tonic-gate * Random set of variables used by more than one routine. 58*7c478bd9Sstevel@tonic-gate */ 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 61*7c478bd9Sstevel@tonic-gate #include <sys/varargs.h> 62*7c478bd9Sstevel@tonic-gate 63*7c478bd9Sstevel@tonic-gate extern int hz; /* system clock rate */ 64*7c478bd9Sstevel@tonic-gate extern struct vnode *rootdir; /* pointer to vnode of root directory */ 65*7c478bd9Sstevel@tonic-gate extern struct vnode *devicesdir; /* pointer to /devices vnode */ 66*7c478bd9Sstevel@tonic-gate extern volatile clock_t lbolt; /* time in HZ since last boot */ 67*7c478bd9Sstevel@tonic-gate extern volatile int64_t lbolt64; /* lbolt computed as 64-bit value */ 68*7c478bd9Sstevel@tonic-gate extern int interrupts_unleashed; /* set after the spl0() in main() */ 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate extern char runin; /* scheduling flag */ 71*7c478bd9Sstevel@tonic-gate extern char runout; /* scheduling flag */ 72*7c478bd9Sstevel@tonic-gate extern char wake_sched; /* causes clock to wake swapper on next tick */ 73*7c478bd9Sstevel@tonic-gate extern char wake_sched_sec; /* causes clock to wake swapper after a sec */ 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate extern pgcnt_t maxmem; /* max available memory (pages) */ 76*7c478bd9Sstevel@tonic-gate extern pgcnt_t physmem; /* physical memory (pages) on this CPU */ 77*7c478bd9Sstevel@tonic-gate extern pfn_t physmax; /* highest numbered physical page present */ 78*7c478bd9Sstevel@tonic-gate extern pgcnt_t physinstalled; /* physical pages including PROM/boot use */ 79*7c478bd9Sstevel@tonic-gate 80*7c478bd9Sstevel@tonic-gate extern caddr_t s_text; /* start of kernel text segment */ 81*7c478bd9Sstevel@tonic-gate extern caddr_t e_text; /* end of kernel text segment */ 82*7c478bd9Sstevel@tonic-gate extern caddr_t s_data; /* start of kernel text segment */ 83*7c478bd9Sstevel@tonic-gate extern caddr_t e_data; /* end of kernel text segment */ 84*7c478bd9Sstevel@tonic-gate #if defined(__ia64) 85*7c478bd9Sstevel@tonic-gate extern caddr_t s_sdata; /* start of kernel small data segment */ 86*7c478bd9Sstevel@tonic-gate extern caddr_t e_sdata; /* end of kernel small data segment */ 87*7c478bd9Sstevel@tonic-gate #endif /* __ia64 */ 88*7c478bd9Sstevel@tonic-gate 89*7c478bd9Sstevel@tonic-gate extern pgcnt_t availrmem; /* Available resident (not swapable) */ 90*7c478bd9Sstevel@tonic-gate /* memory in pages. */ 91*7c478bd9Sstevel@tonic-gate extern pgcnt_t availrmem_initial; /* initial value of availrmem */ 92*7c478bd9Sstevel@tonic-gate extern pgcnt_t segspt_minfree; /* low water mark for availrmem in seg_spt */ 93*7c478bd9Sstevel@tonic-gate extern pgcnt_t freemem; /* Current free memory. */ 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate extern dev_t rootdev; /* device of the root */ 96*7c478bd9Sstevel@tonic-gate extern struct vnode *rootvp; /* vnode of root device */ 97*7c478bd9Sstevel@tonic-gate extern int root_is_svm; /* root is a mirrored device flag */ 98*7c478bd9Sstevel@tonic-gate extern char *volatile panicstr; /* panic string pointer */ 99*7c478bd9Sstevel@tonic-gate extern va_list panicargs; /* panic arguments */ 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate extern int rstchown; /* 1 ==> restrictive chown(2) semantics */ 102*7c478bd9Sstevel@tonic-gate extern int klustsize; 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate extern int abort_enable; /* Platform input-device abort policy */ 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate #ifdef C2_AUDIT 107*7c478bd9Sstevel@tonic-gate extern int audit_active; /* C2 auditing activate 1, absent 0. */ 108*7c478bd9Sstevel@tonic-gate #endif 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate extern int avenrun[]; /* array of load averages */ 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate extern char *isa_list; /* For sysinfo's isalist option */ 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate extern int noexec_user_stack; /* patchable via /etc/system */ 115*7c478bd9Sstevel@tonic-gate extern int noexec_user_stack_log; /* patchable via /etc/system */ 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate extern void report_stack_exec(proc_t *, caddr_t); 118*7c478bd9Sstevel@tonic-gate 119*7c478bd9Sstevel@tonic-gate extern void startup(void); 120*7c478bd9Sstevel@tonic-gate extern void clkstart(void); 121*7c478bd9Sstevel@tonic-gate extern void post_startup(void); 122*7c478bd9Sstevel@tonic-gate extern void kern_setup1(void); 123*7c478bd9Sstevel@tonic-gate extern void ka_init(void); 124*7c478bd9Sstevel@tonic-gate extern void nodename_set(void); 125*7c478bd9Sstevel@tonic-gate 126*7c478bd9Sstevel@tonic-gate /* 127*7c478bd9Sstevel@tonic-gate * for tod fault detection 128*7c478bd9Sstevel@tonic-gate */ 129*7c478bd9Sstevel@tonic-gate enum tod_fault_type { 130*7c478bd9Sstevel@tonic-gate TOD_REVERSED = 0, 131*7c478bd9Sstevel@tonic-gate TOD_STALLED, 132*7c478bd9Sstevel@tonic-gate TOD_JUMPED, 133*7c478bd9Sstevel@tonic-gate TOD_RATECHANGED, 134*7c478bd9Sstevel@tonic-gate TOD_NOFAULT 135*7c478bd9Sstevel@tonic-gate }; 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate extern time_t tod_validate(time_t); 138*7c478bd9Sstevel@tonic-gate extern void tod_fault_reset(void); 139*7c478bd9Sstevel@tonic-gate extern void plat_tod_fault(enum tod_fault_type); 140*7c478bd9Sstevel@tonic-gate #pragma weak plat_tod_fault 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate #ifndef _LP64 143*7c478bd9Sstevel@tonic-gate #ifndef min 144*7c478bd9Sstevel@tonic-gate int min(int, int); 145*7c478bd9Sstevel@tonic-gate #endif 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate #ifndef max 148*7c478bd9Sstevel@tonic-gate int max(int, int); 149*7c478bd9Sstevel@tonic-gate #endif 150*7c478bd9Sstevel@tonic-gate 151*7c478bd9Sstevel@tonic-gate uint_t umin(uint_t, uint_t); 152*7c478bd9Sstevel@tonic-gate uint_t umax(uint_t, uint_t); 153*7c478bd9Sstevel@tonic-gate #endif /* !_LP64 */ 154*7c478bd9Sstevel@tonic-gate int grow(caddr_t); 155*7c478bd9Sstevel@tonic-gate int grow_internal(caddr_t, uint_t); 156*7c478bd9Sstevel@tonic-gate int brk_internal(caddr_t, uint_t); 157*7c478bd9Sstevel@tonic-gate timeout_id_t timeout(void (*)(void *), void *, clock_t); 158*7c478bd9Sstevel@tonic-gate timeout_id_t realtime_timeout(void (*)(void *), void *, clock_t); 159*7c478bd9Sstevel@tonic-gate clock_t untimeout(timeout_id_t); 160*7c478bd9Sstevel@tonic-gate void delay(clock_t); 161*7c478bd9Sstevel@tonic-gate int delay_sig(clock_t); 162*7c478bd9Sstevel@tonic-gate int nodev(); 163*7c478bd9Sstevel@tonic-gate int nulldev(); 164*7c478bd9Sstevel@tonic-gate major_t getudev(void); 165*7c478bd9Sstevel@tonic-gate int cmpldev(dev32_t *, dev_t); 166*7c478bd9Sstevel@tonic-gate dev_t expldev(dev32_t); 167*7c478bd9Sstevel@tonic-gate int bcmp(const void *, const void *, size_t) __PURE; 168*7c478bd9Sstevel@tonic-gate int stoi(char **); 169*7c478bd9Sstevel@tonic-gate void numtos(ulong_t, char *); 170*7c478bd9Sstevel@tonic-gate size_t strlen(const char *) __PURE; 171*7c478bd9Sstevel@tonic-gate char *strcat(char *, const char *); 172*7c478bd9Sstevel@tonic-gate char *strncat(char *, const char *, size_t); 173*7c478bd9Sstevel@tonic-gate char *strcpy(char *, const char *); 174*7c478bd9Sstevel@tonic-gate char *strncpy(char *, const char *, size_t); 175*7c478bd9Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definitions */ 176*7c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L 177*7c478bd9Sstevel@tonic-gate extern const char *strchr(const char *, int); 178*7c478bd9Sstevel@tonic-gate #ifndef _STRCHR_INLINE 179*7c478bd9Sstevel@tonic-gate #define _STRCHR_INLINE 180*7c478bd9Sstevel@tonic-gate extern "C++" { 181*7c478bd9Sstevel@tonic-gate inline char *strchr(char *__s, int __c) { 182*7c478bd9Sstevel@tonic-gate return (char *)strchr((const char *)__s, __c); 183*7c478bd9Sstevel@tonic-gate } 184*7c478bd9Sstevel@tonic-gate } 185*7c478bd9Sstevel@tonic-gate #endif /* _STRCHR_INLINE */ 186*7c478bd9Sstevel@tonic-gate extern const char *strrchr(const char *, int); 187*7c478bd9Sstevel@tonic-gate #ifndef _STRRCHR_INLINE 188*7c478bd9Sstevel@tonic-gate #define _STRRCHR_INLINE 189*7c478bd9Sstevel@tonic-gate extern "C++" { 190*7c478bd9Sstevel@tonic-gate inline char *strrchr(char *__s, int __c) { 191*7c478bd9Sstevel@tonic-gate return (char *)strrchr((const char *)__s, __c); 192*7c478bd9Sstevel@tonic-gate } 193*7c478bd9Sstevel@tonic-gate } 194*7c478bd9Sstevel@tonic-gate #endif /* _STRRCHR_INLINE */ 195*7c478bd9Sstevel@tonic-gate extern const char *strstr(const char *, const char *); 196*7c478bd9Sstevel@tonic-gate #ifndef _STRSTR_INLINE 197*7c478bd9Sstevel@tonic-gate #define _STRSTR_INLINE 198*7c478bd9Sstevel@tonic-gate extern "C++" { 199*7c478bd9Sstevel@tonic-gate inline char *strstr(char *__s1, const char *__s2) { 200*7c478bd9Sstevel@tonic-gate return (char *)strstr((const char *)__s1, __s2); 201*7c478bd9Sstevel@tonic-gate } 202*7c478bd9Sstevel@tonic-gate } 203*7c478bd9Sstevel@tonic-gate #endif /* _STRSTR_INLINE */ 204*7c478bd9Sstevel@tonic-gate #else /* __cplusplus >= 199711L */ 205*7c478bd9Sstevel@tonic-gate char *strchr(const char *, int); 206*7c478bd9Sstevel@tonic-gate char *strrchr(const char *, int); 207*7c478bd9Sstevel@tonic-gate char *strstr(const char *, const char *); 208*7c478bd9Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */ 209*7c478bd9Sstevel@tonic-gate char *strnrchr(const char *, int, size_t); 210*7c478bd9Sstevel@tonic-gate int strcmp(const char *, const char *) __PURE; 211*7c478bd9Sstevel@tonic-gate int strncmp(const char *, const char *, size_t) __PURE; 212*7c478bd9Sstevel@tonic-gate int strcasecmp(const char *, const char *) __PURE; 213*7c478bd9Sstevel@tonic-gate int strncasecmp(const char *, const char *, size_t) __PURE; 214*7c478bd9Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definitions */ 215*7c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L 216*7c478bd9Sstevel@tonic-gate extern const char *strpbrk(const char *, const char *); 217*7c478bd9Sstevel@tonic-gate #ifndef _STRPBRK_INLINE 218*7c478bd9Sstevel@tonic-gate #define _STRPBRK_INLINE 219*7c478bd9Sstevel@tonic-gate extern "C++" { 220*7c478bd9Sstevel@tonic-gate inline char *strpbrk(char *__s1, const char *__s2) { 221*7c478bd9Sstevel@tonic-gate return (char *)strpbrk((const char *)__s1, __s2); 222*7c478bd9Sstevel@tonic-gate } 223*7c478bd9Sstevel@tonic-gate } 224*7c478bd9Sstevel@tonic-gate #endif /* _STRPBRK_INLINE */ 225*7c478bd9Sstevel@tonic-gate #else /* __cplusplus >= 199711L */ 226*7c478bd9Sstevel@tonic-gate char *strpbrk(const char *, const char *); 227*7c478bd9Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */ 228*7c478bd9Sstevel@tonic-gate int strident_valid(const char *); 229*7c478bd9Sstevel@tonic-gate void strident_canon(char *, size_t); 230*7c478bd9Sstevel@tonic-gate int getsubopt(char **optionsp, char * const *tokens, char **valuep); 231*7c478bd9Sstevel@tonic-gate char *append_subopt(const char *, size_t, char *, const char *); 232*7c478bd9Sstevel@tonic-gate int ffs(long); 233*7c478bd9Sstevel@tonic-gate int copyin(const void *, void *, size_t); 234*7c478bd9Sstevel@tonic-gate void copyin_noerr(const void *, void *, size_t); 235*7c478bd9Sstevel@tonic-gate int xcopyin(const void *, void *, size_t); 236*7c478bd9Sstevel@tonic-gate int xcopyin_nta(const void *, void *, size_t, int); 237*7c478bd9Sstevel@tonic-gate int copyout(const void *, void *, size_t); 238*7c478bd9Sstevel@tonic-gate void copyout_noerr(const void *, void *, size_t); 239*7c478bd9Sstevel@tonic-gate int xcopyout(const void *, void *, size_t); 240*7c478bd9Sstevel@tonic-gate int xcopyout_nta(const void *, void *, size_t, int); 241*7c478bd9Sstevel@tonic-gate int copyinstr(const char *, char *, size_t, size_t *); 242*7c478bd9Sstevel@tonic-gate int copyinstr_noerr(const char *, char *, size_t, size_t *); 243*7c478bd9Sstevel@tonic-gate int copyoutstr(const char *, char *, size_t, size_t *); 244*7c478bd9Sstevel@tonic-gate int copyoutstr_noerr(const char *, char *, size_t, size_t *); 245*7c478bd9Sstevel@tonic-gate int copystr(const char *, char *, size_t, size_t *); 246*7c478bd9Sstevel@tonic-gate void bcopy(const void *, void *, size_t); 247*7c478bd9Sstevel@tonic-gate void ucopy(const void *, void *, size_t); 248*7c478bd9Sstevel@tonic-gate void pgcopy(const void *, void *, size_t); 249*7c478bd9Sstevel@tonic-gate void ovbcopy(const void *, void *, size_t); 250*7c478bd9Sstevel@tonic-gate void bzero(void *, size_t); 251*7c478bd9Sstevel@tonic-gate void uzero(void *, size_t); 252*7c478bd9Sstevel@tonic-gate int kcopy(const void *, void *, size_t); 253*7c478bd9Sstevel@tonic-gate int kcopy_nta(const void *, void *, size_t, int); 254*7c478bd9Sstevel@tonic-gate int kzero(void *, size_t); 255*7c478bd9Sstevel@tonic-gate 256*7c478bd9Sstevel@tonic-gate extern void *memset(void *, int, size_t); 257*7c478bd9Sstevel@tonic-gate extern void *memcpy(void *, const void *, size_t); 258*7c478bd9Sstevel@tonic-gate extern void *memmove(void *, const void *, size_t); 259*7c478bd9Sstevel@tonic-gate extern int memcmp(const void *, const void *, size_t); 260*7c478bd9Sstevel@tonic-gate 261*7c478bd9Sstevel@tonic-gate int fuword8(const void *, uint8_t *); 262*7c478bd9Sstevel@tonic-gate int fuword16(const void *, uint16_t *); 263*7c478bd9Sstevel@tonic-gate int fuword32(const void *, uint32_t *); 264*7c478bd9Sstevel@tonic-gate int fulword(const void *, ulong_t *); 265*7c478bd9Sstevel@tonic-gate void fuword8_noerr(const void *, uint8_t *); 266*7c478bd9Sstevel@tonic-gate void fuword16_noerr(const void *, uint16_t *); 267*7c478bd9Sstevel@tonic-gate void fuword32_noerr(const void *, uint32_t *); 268*7c478bd9Sstevel@tonic-gate void fulword_noerr(const void *, ulong_t *); 269*7c478bd9Sstevel@tonic-gate 270*7c478bd9Sstevel@tonic-gate #ifdef _LP64 271*7c478bd9Sstevel@tonic-gate int fuword64(const void *, uint64_t *); 272*7c478bd9Sstevel@tonic-gate void fuword64_noerr(const void *, uint64_t *); 273*7c478bd9Sstevel@tonic-gate #endif 274*7c478bd9Sstevel@tonic-gate 275*7c478bd9Sstevel@tonic-gate int subyte(void *, uint8_t); 276*7c478bd9Sstevel@tonic-gate int suword8(void *, uint8_t); 277*7c478bd9Sstevel@tonic-gate int suword16(void *, uint16_t); 278*7c478bd9Sstevel@tonic-gate int suword32(void *, uint32_t); 279*7c478bd9Sstevel@tonic-gate int sulword(void *, ulong_t); 280*7c478bd9Sstevel@tonic-gate void subyte_noerr(void *, uint8_t); 281*7c478bd9Sstevel@tonic-gate void suword8_noerr(void *, uint8_t); 282*7c478bd9Sstevel@tonic-gate void suword16_noerr(void *, uint16_t); 283*7c478bd9Sstevel@tonic-gate void suword32_noerr(void *, uint32_t); 284*7c478bd9Sstevel@tonic-gate void sulword_noerr(void *, ulong_t); 285*7c478bd9Sstevel@tonic-gate 286*7c478bd9Sstevel@tonic-gate #ifdef _LP64 287*7c478bd9Sstevel@tonic-gate int suword64(void *, uint64_t); 288*7c478bd9Sstevel@tonic-gate void suword64_noerr(void *, uint64_t); 289*7c478bd9Sstevel@tonic-gate #endif 290*7c478bd9Sstevel@tonic-gate 291*7c478bd9Sstevel@tonic-gate #if !defined(_BOOT) 292*7c478bd9Sstevel@tonic-gate int setjmp(label_t *); 293*7c478bd9Sstevel@tonic-gate extern void longjmp(label_t *) 294*7c478bd9Sstevel@tonic-gate __NORETURN; 295*7c478bd9Sstevel@tonic-gate #pragma unknown_control_flow(setjmp) 296*7c478bd9Sstevel@tonic-gate #endif 297*7c478bd9Sstevel@tonic-gate 298*7c478bd9Sstevel@tonic-gate caddr_t caller(void); 299*7c478bd9Sstevel@tonic-gate caddr_t callee(void); 300*7c478bd9Sstevel@tonic-gate int getpcstack(pc_t *, int); 301*7c478bd9Sstevel@tonic-gate int on_fault(label_t *); 302*7c478bd9Sstevel@tonic-gate void no_fault(void); 303*7c478bd9Sstevel@tonic-gate void halt(char *); 304*7c478bd9Sstevel@tonic-gate int scanc(size_t, uchar_t *, uchar_t *, uchar_t); 305*7c478bd9Sstevel@tonic-gate int movtuc(size_t, uchar_t *, uchar_t *, uchar_t *); 306*7c478bd9Sstevel@tonic-gate int splr(int); 307*7c478bd9Sstevel@tonic-gate int splhigh(void); 308*7c478bd9Sstevel@tonic-gate int splhi(void); 309*7c478bd9Sstevel@tonic-gate int splzs(void); 310*7c478bd9Sstevel@tonic-gate int spl0(void); 311*7c478bd9Sstevel@tonic-gate int spl6(void); 312*7c478bd9Sstevel@tonic-gate int spl7(void); 313*7c478bd9Sstevel@tonic-gate int spl8(void); 314*7c478bd9Sstevel@tonic-gate void splx(int); 315*7c478bd9Sstevel@tonic-gate void set_base_spl(void); 316*7c478bd9Sstevel@tonic-gate int __ipltospl(int); 317*7c478bd9Sstevel@tonic-gate 318*7c478bd9Sstevel@tonic-gate void softcall_init(void); 319*7c478bd9Sstevel@tonic-gate void softcall(void (*)(void *), void *); 320*7c478bd9Sstevel@tonic-gate void softint(void); 321*7c478bd9Sstevel@tonic-gate 322*7c478bd9Sstevel@tonic-gate extern void sync_icache(caddr_t, uint_t); 323*7c478bd9Sstevel@tonic-gate extern void sync_data_memory(caddr_t, size_t); 324*7c478bd9Sstevel@tonic-gate extern void hot_patch_kernel_text(caddr_t, uint32_t, uint_t); 325*7c478bd9Sstevel@tonic-gate 326*7c478bd9Sstevel@tonic-gate void _insque(caddr_t, caddr_t); 327*7c478bd9Sstevel@tonic-gate void _remque(caddr_t); 328*7c478bd9Sstevel@tonic-gate 329*7c478bd9Sstevel@tonic-gate /* casts to keep lint happy */ 330*7c478bd9Sstevel@tonic-gate #define insque(q, p) _insque((caddr_t)q, (caddr_t)p) 331*7c478bd9Sstevel@tonic-gate #define remque(q) _remque((caddr_t)q) 332*7c478bd9Sstevel@tonic-gate 333*7c478bd9Sstevel@tonic-gate #pragma unknown_control_flow(on_fault) 334*7c478bd9Sstevel@tonic-gate 335*7c478bd9Sstevel@tonic-gate struct timeval; 336*7c478bd9Sstevel@tonic-gate extern void uniqtime(struct timeval *); 337*7c478bd9Sstevel@tonic-gate struct timeval32; 338*7c478bd9Sstevel@tonic-gate extern void uniqtime32(struct timeval32 *); 339*7c478bd9Sstevel@tonic-gate 340*7c478bd9Sstevel@tonic-gate uint_t page_num_pagesizes(void); 341*7c478bd9Sstevel@tonic-gate size_t page_get_pagesize(uint_t n); 342*7c478bd9Sstevel@tonic-gate 343*7c478bd9Sstevel@tonic-gate extern int maxusers; 344*7c478bd9Sstevel@tonic-gate extern int pidmax; 345*7c478bd9Sstevel@tonic-gate 346*7c478bd9Sstevel@tonic-gate extern void param_preset(void); 347*7c478bd9Sstevel@tonic-gate extern void param_calc(int); 348*7c478bd9Sstevel@tonic-gate extern void param_init(void); 349*7c478bd9Sstevel@tonic-gate extern void param_check(void); 350*7c478bd9Sstevel@tonic-gate 351*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 352*7c478bd9Sstevel@tonic-gate 353*7c478bd9Sstevel@tonic-gate /* 354*7c478bd9Sstevel@tonic-gate * Structure of the system-entry table. 355*7c478bd9Sstevel@tonic-gate * 356*7c478bd9Sstevel@tonic-gate * Changes to struct sysent should maintain binary compatibility with 357*7c478bd9Sstevel@tonic-gate * loadable system calls, although the interface is currently private. 358*7c478bd9Sstevel@tonic-gate * 359*7c478bd9Sstevel@tonic-gate * This means it should only be expanded on the end, and flag values 360*7c478bd9Sstevel@tonic-gate * should not be reused. 361*7c478bd9Sstevel@tonic-gate * 362*7c478bd9Sstevel@tonic-gate * It is desirable to keep the size of this struct a power of 2 for quick 363*7c478bd9Sstevel@tonic-gate * indexing. 364*7c478bd9Sstevel@tonic-gate */ 365*7c478bd9Sstevel@tonic-gate struct sysent { 366*7c478bd9Sstevel@tonic-gate char sy_narg; /* total number of arguments */ 367*7c478bd9Sstevel@tonic-gate #ifdef _LP64 368*7c478bd9Sstevel@tonic-gate unsigned short sy_flags; /* various flags as defined below */ 369*7c478bd9Sstevel@tonic-gate #else 370*7c478bd9Sstevel@tonic-gate unsigned char sy_flags; /* various flags as defined below */ 371*7c478bd9Sstevel@tonic-gate #endif 372*7c478bd9Sstevel@tonic-gate int (*sy_call)(); /* argp, rvalp-style handler */ 373*7c478bd9Sstevel@tonic-gate krwlock_t *sy_lock; /* lock for loadable system calls */ 374*7c478bd9Sstevel@tonic-gate int64_t (*sy_callc)(); /* C-style call hander or wrapper */ 375*7c478bd9Sstevel@tonic-gate }; 376*7c478bd9Sstevel@tonic-gate 377*7c478bd9Sstevel@tonic-gate extern struct sysent sysent[]; 378*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 379*7c478bd9Sstevel@tonic-gate extern struct sysent sysent32[]; 380*7c478bd9Sstevel@tonic-gate #endif 381*7c478bd9Sstevel@tonic-gate 382*7c478bd9Sstevel@tonic-gate extern struct sysent nosys_ent; /* entry for invalid system call */ 383*7c478bd9Sstevel@tonic-gate 384*7c478bd9Sstevel@tonic-gate #define NSYSCALL 256 /* number of system calls */ 385*7c478bd9Sstevel@tonic-gate 386*7c478bd9Sstevel@tonic-gate #define LOADABLE_SYSCALL(s) (s->sy_flags & SE_LOADABLE) 387*7c478bd9Sstevel@tonic-gate #define LOADED_SYSCALL(s) (s->sy_flags & SE_LOADED) 388*7c478bd9Sstevel@tonic-gate 389*7c478bd9Sstevel@tonic-gate /* 390*7c478bd9Sstevel@tonic-gate * sy_flags values 391*7c478bd9Sstevel@tonic-gate * Values 1, 2, and 4 were used previously for SETJUMP, ASYNC, and IOSYS. 392*7c478bd9Sstevel@tonic-gate */ 393*7c478bd9Sstevel@tonic-gate #define SE_32RVAL1 0x0 /* handler returns int32_t in rval1 */ 394*7c478bd9Sstevel@tonic-gate #define SE_32RVAL2 0x1 /* handler returns int32_t in rval2 */ 395*7c478bd9Sstevel@tonic-gate #define SE_64RVAL 0x2 /* handler returns int64_t in rvals */ 396*7c478bd9Sstevel@tonic-gate #define SE_RVAL_MASK 0x3 /* mask of rval_t bits */ 397*7c478bd9Sstevel@tonic-gate 398*7c478bd9Sstevel@tonic-gate #define SE_LOADABLE 0x08 /* syscall is loadable */ 399*7c478bd9Sstevel@tonic-gate #define SE_LOADED 0x10 /* syscall is completely loaded */ 400*7c478bd9Sstevel@tonic-gate #define SE_NOUNLOAD 0x20 /* syscall never needs unload */ 401*7c478bd9Sstevel@tonic-gate #define SE_ARGC 0x40 /* syscall takes C-style args */ 402*7c478bd9Sstevel@tonic-gate 403*7c478bd9Sstevel@tonic-gate /* 404*7c478bd9Sstevel@tonic-gate * Structure of the return-value parameter passed by reference to 405*7c478bd9Sstevel@tonic-gate * system entries. 406*7c478bd9Sstevel@tonic-gate */ 407*7c478bd9Sstevel@tonic-gate union rval { 408*7c478bd9Sstevel@tonic-gate struct { 409*7c478bd9Sstevel@tonic-gate int r_v1; 410*7c478bd9Sstevel@tonic-gate int r_v2; 411*7c478bd9Sstevel@tonic-gate } r_v; 412*7c478bd9Sstevel@tonic-gate off_t r_off; 413*7c478bd9Sstevel@tonic-gate offset_t r_offset; 414*7c478bd9Sstevel@tonic-gate time_t r_time; 415*7c478bd9Sstevel@tonic-gate int64_t r_vals; 416*7c478bd9Sstevel@tonic-gate }; 417*7c478bd9Sstevel@tonic-gate #define r_val1 r_v.r_v1 418*7c478bd9Sstevel@tonic-gate #define r_val2 r_v.r_v2 419*7c478bd9Sstevel@tonic-gate 420*7c478bd9Sstevel@tonic-gate typedef union rval rval_t; 421*7c478bd9Sstevel@tonic-gate 422*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 423*7c478bd9Sstevel@tonic-gate 424*7c478bd9Sstevel@tonic-gate extern void reset_syscall_args(void); 425*7c478bd9Sstevel@tonic-gate extern int save_syscall_args(void); 426*7c478bd9Sstevel@tonic-gate extern uint_t get_syscall_args(klwp_t *lwp, long *argp, int *nargsp); 427*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 428*7c478bd9Sstevel@tonic-gate extern uint_t get_syscall32_args(klwp_t *lwp, int *argp, int *nargp); 429*7c478bd9Sstevel@tonic-gate #endif 430*7c478bd9Sstevel@tonic-gate 431*7c478bd9Sstevel@tonic-gate extern uint_t set_errno(uint_t error); 432*7c478bd9Sstevel@tonic-gate #pragma rarely_called(set_errno) 433*7c478bd9Sstevel@tonic-gate 434*7c478bd9Sstevel@tonic-gate extern int64_t syscall_ap(void); 435*7c478bd9Sstevel@tonic-gate extern int64_t loadable_syscall(long, long, long, long, long, long, long, long); 436*7c478bd9Sstevel@tonic-gate extern int64_t nosys(void); 437*7c478bd9Sstevel@tonic-gate 438*7c478bd9Sstevel@tonic-gate extern void swtch(void); 439*7c478bd9Sstevel@tonic-gate 440*7c478bd9Sstevel@tonic-gate extern uint_t kcpc_key; /* TSD key for performance counter context */ 441*7c478bd9Sstevel@tonic-gate 442*7c478bd9Sstevel@tonic-gate #ifdef __lint 443*7c478bd9Sstevel@tonic-gate extern int __lintzero; /* for spoofing lint */ 444*7c478bd9Sstevel@tonic-gate #endif 445*7c478bd9Sstevel@tonic-gate 446*7c478bd9Sstevel@tonic-gate 447*7c478bd9Sstevel@tonic-gate /* 448*7c478bd9Sstevel@tonic-gate * initname holds the path to init. It is defined by main.c, may be set by 449*7c478bd9Sstevel@tonic-gate * bootflags.c, and is used by main.c:exec_init(). 450*7c478bd9Sstevel@tonic-gate */ 451*7c478bd9Sstevel@tonic-gate #define INITNAME_SZ 32 452*7c478bd9Sstevel@tonic-gate #define INITARGS_SZ 80 453*7c478bd9Sstevel@tonic-gate 454*7c478bd9Sstevel@tonic-gate extern char initname[INITNAME_SZ]; 455*7c478bd9Sstevel@tonic-gate extern char initargs[INITARGS_SZ]; 456*7c478bd9Sstevel@tonic-gate 457*7c478bd9Sstevel@tonic-gate extern int exec_init(const char *, int, const char *); 458*7c478bd9Sstevel@tonic-gate 459*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 460*7c478bd9Sstevel@tonic-gate 461*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 462*7c478bd9Sstevel@tonic-gate } 463*7c478bd9Sstevel@tonic-gate #endif 464*7c478bd9Sstevel@tonic-gate 465*7c478bd9Sstevel@tonic-gate #endif /* _SYS_SYSTM_H */ 466