1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
14 * Copyright 2017 RackTop Systems.
15 */
16
17 #include <sys/types.h>
18 #include <sys/time.h>
19 #include <sys/thread.h>
20 #include <sys/proc.h>
21 #include <sys/zone.h>
22
23 #include <sys/poll.h>
24
25 #include <time.h>
26 #include <stdlib.h>
27 #include <unistd.h>
28 #include <errno.h>
29
30 #include <fakekernel.h>
31
32 pri_t minclsyspri = 60;
33
34 /* Some kernel code takes the address of this. */
35 proc_t p0;
36
37 proc_t *
38 _curproc(void)
39 {
40 return (&p0);
41 }
42
43 zone_t zone0 = {
44 .zone_name = "global",
45 .zone_zsched = &p0, 0
46 };
47
48 zone_t *
49 _curzone(void)
50 {
51 return (&zone0);
52 }
53
54 pid_t
55 ddi_get_pid(void)
75 h += 16; i >>= 16;
76 }
77 if (i & 0xff00) {
78 h += 8; i >>= 8;
79 }
80 if (i & 0xf0) {
81 h += 4; i >>= 4;
82 }
83 if (i & 0xc) {
84 h += 2; i >>= 2;
85 }
86 if (i & 0x2) {
87 h += 1;
88 }
89 return (h);
90 }
91
92 int
93 ddi_strtoul(const char *str, char **endp, int base, unsigned long *res)
94 {
95 *res = strtoul(str, endp, base);
96 if (*res == 0)
97 return (errno);
98 return (0);
99 }
100
101 int
102 ddi_strtoull(const char *str, char **nptr, int base, u_longlong_t *res)
103 {
104 char *end;
105
106 *res = strtoull(str, &end, base);
107 if (*res == 0)
108 return (errno);
109 return (0);
110 }
111
112 void
113 delay(clock_t ticks)
114 {
115 int msec = ticks; /* NB: hz==1000 */
116 (void) poll(0, 0, msec);
117 }
118
119 int
120 issig(int why)
121 {
122 return (0);
123 }
124
125 /*
126 * This library does not really need an "init" function, but
127 * providing one the main program can call is an easy way to
128 * make sure this library is loaded into the debugger, and
129 * gives us a way to avoid elfcheck complaints in the build.
130 */
131 void
132 fakekernel_init(void)
133 {
134 }
|
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
14 * Copyright 2017 RackTop Systems.
15 */
16
17 #include <sys/types.h>
18 #include <sys/time.h>
19 #include <sys/thread.h>
20 #include <sys/proc.h>
21 #include <sys/zone.h>
22 #include <sys/poll.h>
23
24 #include <errno.h>
25 #include <time.h>
26 #include <stdlib.h>
27 #include <unistd.h>
28 #include <string.h>
29 #include <errno.h>
30
31 #include <fakekernel.h>
32
33 pri_t minclsyspri = 60;
34 extern zone_t zone0;
35
36 /* Some kernel code takes the address of this. */
37 proc_t p0 = {
38 .p_zone = &zone0, 0
39 };
40
41 proc_t *
42 _curproc(void)
43 {
44 return (&p0);
45 }
46
47 zone_t zone0 = {
48 .zone_name = "global",
49 .zone_zsched = &p0, 0
50 };
51
52 zone_t *
53 _curzone(void)
54 {
55 return (&zone0);
56 }
57
58 pid_t
59 ddi_get_pid(void)
79 h += 16; i >>= 16;
80 }
81 if (i & 0xff00) {
82 h += 8; i >>= 8;
83 }
84 if (i & 0xf0) {
85 h += 4; i >>= 4;
86 }
87 if (i & 0xc) {
88 h += 2; i >>= 2;
89 }
90 if (i & 0x2) {
91 h += 1;
92 }
93 return (h);
94 }
95
96 int
97 ddi_strtoul(const char *str, char **endp, int base, unsigned long *res)
98 {
99 errno = 0;
100 *res = strtoul(str, endp, base);
101 return (errno);
102 }
103
104 int
105 ddi_strtoull(const char *str, char **endp, int base, u_longlong_t *res)
106 {
107 errno = 0;
108 *res = strtoull(str, endp, base);
109 if (*res == 0)
110 return (errno);
111 return (0);
112 }
113
114 void
115 delay(clock_t ticks)
116 {
117 int msec = ticks; /* NB: hz==1000 */
118 (void) poll(0, 0, msec);
119 }
120
121 int
122 highbit(ulong_t i)
123 {
124 return (fls(i));
125 }
126
127 /* ARGSUSED */
128 int
129 issig(int why)
130 {
131 return (0);
132 }
133
134 /*
135 * This library does not really need an "init" function, but
136 * providing one the main program can call is an easy way to
137 * make sure this library is loaded into the debugger, and
138 * gives us a way to avoid elfcheck complaints in the build.
139 */
140 void
141 fakekernel_init(void)
142 {
143 }
|