1*b819cea2SGordon Ross /* 2*b819cea2SGordon Ross * This file and its contents are supplied under the terms of the 3*b819cea2SGordon Ross * Common Development and Distribution License ("CDDL"), version 1.0. 4*b819cea2SGordon Ross * You may only use this file in accordance with the terms of version 5*b819cea2SGordon Ross * 1.0 of the CDDL. 6*b819cea2SGordon Ross * 7*b819cea2SGordon Ross * A full copy of the text of the CDDL should have accompanied this 8*b819cea2SGordon Ross * source. A copy of the CDDL is also available via the Internet at 9*b819cea2SGordon Ross * http://www.illumos.org/license/CDDL. 10*b819cea2SGordon Ross */ 11*b819cea2SGordon Ross 12*b819cea2SGordon Ross /* 13*b819cea2SGordon Ross * Copyright 2014 Nexenta Systems, Inc. All rights reserved. 14*b819cea2SGordon Ross */ 15*b819cea2SGordon Ross 16*b819cea2SGordon Ross #include <sys/types.h> 17*b819cea2SGordon Ross #include <sys/time.h> 18*b819cea2SGordon Ross #include <sys/thread.h> 19*b819cea2SGordon Ross #include <sys/proc.h> 20*b819cea2SGordon Ross #include <sys/zone.h> 21*b819cea2SGordon Ross 22*b819cea2SGordon Ross #include <sys/poll.h> 23*b819cea2SGordon Ross 24*b819cea2SGordon Ross #include <time.h> 25*b819cea2SGordon Ross #include <stdlib.h> 26*b819cea2SGordon Ross #include <unistd.h> 27*b819cea2SGordon Ross 28*b819cea2SGordon Ross #include <fakekernel.h> 29*b819cea2SGordon Ross 30*b819cea2SGordon Ross pri_t minclsyspri = 60; 31*b819cea2SGordon Ross 32*b819cea2SGordon Ross /* Some kernel code takes the address of this. */ 33*b819cea2SGordon Ross proc_t p0; 34*b819cea2SGordon Ross 35*b819cea2SGordon Ross proc_t * 36*b819cea2SGordon Ross _curproc(void) 37*b819cea2SGordon Ross { 38*b819cea2SGordon Ross return (&p0); 39*b819cea2SGordon Ross } 40*b819cea2SGordon Ross 41*b819cea2SGordon Ross zone_t zone0 = { 42*b819cea2SGordon Ross .zone_name = "global", 43*b819cea2SGordon Ross .zone_zsched = &p0, 0 44*b819cea2SGordon Ross }; 45*b819cea2SGordon Ross 46*b819cea2SGordon Ross zone_t * 47*b819cea2SGordon Ross _curzone(void) 48*b819cea2SGordon Ross { 49*b819cea2SGordon Ross return (&zone0); 50*b819cea2SGordon Ross } 51*b819cea2SGordon Ross 52*b819cea2SGordon Ross pid_t 53*b819cea2SGordon Ross ddi_get_pid(void) 54*b819cea2SGordon Ross { 55*b819cea2SGordon Ross return ((pid_t)getpid()); 56*b819cea2SGordon Ross } 57*b819cea2SGordon Ross 58*b819cea2SGordon Ross int 59*b819cea2SGordon Ross ddi_strtoul(const char *str, char **endp, int base, unsigned long *res) 60*b819cea2SGordon Ross { 61*b819cea2SGordon Ross *res = strtoul(str, endp, base); 62*b819cea2SGordon Ross return (0); 63*b819cea2SGordon Ross } 64*b819cea2SGordon Ross 65*b819cea2SGordon Ross void 66*b819cea2SGordon Ross delay(clock_t ticks) 67*b819cea2SGordon Ross { 68*b819cea2SGordon Ross int msec = ticks; /* NB: hz==1000 */ 69*b819cea2SGordon Ross (void) poll(0, 0, msec); 70*b819cea2SGordon Ross } 71*b819cea2SGordon Ross 72*b819cea2SGordon Ross /* 73*b819cea2SGordon Ross * This library does not really need an "init" function, but 74*b819cea2SGordon Ross * providing one the main program can call is an easy way to 75*b819cea2SGordon Ross * make sure this library is loaded into the debugger, and 76*b819cea2SGordon Ross * gives us a way to avoid elfcheck complaints in the build. 77*b819cea2SGordon Ross */ 78*b819cea2SGordon Ross void 79*b819cea2SGordon Ross fakekernel_init(void) 80*b819cea2SGordon Ross { 81*b819cea2SGordon Ross } 82