]>
Commit | Line | Data |
---|---|---|
e9ce8d39 A |
1 | /* |
2 | * @OSF_COPYRIGHT@ | |
3 | */ | |
4 | ||
5 | /* | |
6 | * Mach Operating System | |
7 | * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University | |
8 | * All Rights Reserved. | |
9 | * | |
10 | * Permission to use, copy, modify and distribute this software and its | |
11 | * documentation is hereby granted, provided that both the copyright | |
12 | * notice and this permission notice appear in all copies of the | |
13 | * software, derivative works or modified versions, and any portions | |
14 | * thereof, and that both notices appear in supporting documentation. | |
15 | * | |
16 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
17 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
18 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
19 | * | |
20 | * Carnegie Mellon requests users of this software to return to | |
21 | * | |
22 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
23 | * School of Computer Science | |
24 | * Carnegie Mellon University | |
25 | * Pittsburgh PA 15213-3890 | |
26 | * | |
27 | * any improvements or extensions that they make and grant Carnegie Mellon | |
28 | * the rights to redistribute these changes. | |
29 | */ | |
30 | ||
31 | #include <mach/mach.h> | |
32 | #include "externs.h" | |
33 | ||
34 | mach_port_t bootstrap_port = MACH_PORT_NULL; | |
35 | mach_port_t name_server_port = MACH_PORT_NULL; | |
36 | mach_port_t environment_port = MACH_PORT_NULL; | |
37 | mach_port_t service_port = MACH_PORT_NULL; | |
38 | mach_port_t clock_port = MACH_PORT_NULL; | |
39 | mach_port_t thread_recycle_port = MACH_PORT_NULL; | |
40 | ||
41 | void | |
42 | mach_init_ports(void) | |
43 | { | |
44 | mach_port_array_t ports; | |
45 | mach_msg_type_number_t ports_count; | |
46 | kern_return_t kr; | |
47 | ||
48 | /* | |
49 | * Find those ports important to every task. | |
50 | */ | |
51 | kr = task_get_special_port(mach_task_self(), | |
52 | TASK_BOOTSTRAP_PORT, | |
53 | &bootstrap_port); | |
54 | if (kr != KERN_SUCCESS) | |
55 | return; | |
56 | ||
57 | kr = mach_ports_lookup(mach_task_self(), &ports, | |
58 | &ports_count); | |
59 | if ((kr != KERN_SUCCESS) || | |
60 | (ports_count < MACH_PORTS_SLOTS_USED)) | |
61 | return; | |
62 | ||
63 | name_server_port = ports[NAME_SERVER_SLOT]; | |
64 | environment_port = ports[ENVIRONMENT_SLOT]; | |
65 | service_port = ports[SERVICE_SLOT]; | |
66 | ||
67 | /* get rid of out-of-line data so brk has a chance of working */ | |
68 | ||
69 | (void) vm_deallocate(mach_task_self(), | |
70 | (vm_offset_t) ports, | |
71 | (vm_size_t) (ports_count * sizeof *ports)); | |
72 | ||
73 | /* Get the clock service port for nanosleep */ | |
74 | kr = host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &clock_port); | |
75 | if (kr != KERN_SUCCESS) { | |
76 | abort(); | |
77 | } | |
78 | kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &thread_recycle_port); | |
79 | if (kr != KERN_SUCCESS) { | |
80 | abort(); | |
81 | } | |
82 | kr = mach_port_insert_right(mach_task_self(), thread_recycle_port, thread_recycle_port, MACH_MSG_TYPE_MAKE_SEND); | |
83 | if (kr != KERN_SUCCESS) { | |
84 | abort(); | |
85 | } | |
86 | } | |
87 | ||
88 | #ifdef notdef | |
89 | /* will have problems with dylib build --> not needed anyway */ | |
90 | #ifndef lint | |
91 | /* | |
92 | * Routines which our library must suck in, to avoid | |
93 | * a later library from referencing them and getting | |
94 | * the wrong version. | |
95 | */ | |
96 | extern void _replacements(void); | |
97 | ||
98 | void | |
99 | _replacements(void) | |
100 | { | |
101 | (void)sbrk(0); /* Pull in our sbrk/brk */ | |
102 | (void)malloc(0); /* Pull in our malloc package */ | |
103 | } | |
104 | #endif /* lint */ | |
105 | #endif /* notdef */ |