]>
Commit | Line | Data |
---|---|---|
1815bff5 A |
1 | /* |
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights | |
7 | * Reserved. This file contains Original Code and/or Modifications of | |
8 | * Original Code as defined in and that are subject to the Apple Public | |
9 | * Source License Version 1.0 (the 'License'). You may not use this file | |
10 | * except in compliance with the License. Please obtain a copy of the | |
11 | * License at http://www.apple.com/publicsource and read it before using | |
12 | * this file. | |
13 | * | |
14 | * The Original Code and all software distributed under the License are | |
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the | |
19 | * License for the specific language governing rights and limitations | |
20 | * under the License." | |
21 | * | |
22 | * @APPLE_LICENSE_HEADER_END@ | |
23 | */ | |
24 | /* | |
25 | * bootstrap -- fundamental service initiator and port server | |
26 | * Mike DeMoney, NeXT, Inc. | |
27 | * Copyright, 1990. All rights reserved. | |
28 | * | |
29 | * lists.h -- interface to list routines | |
30 | */ | |
31 | ||
32 | #import <mach/mach.h> | |
33 | #import <mach/boolean.h> | |
34 | #import <servers/bootstrap_defs.h> | |
35 | ||
36 | #ifndef NULL | |
37 | #define NULL ((void *)0) | |
38 | #endif NULL | |
39 | ||
40 | typedef struct bootstrap bootstrap_info_t; | |
41 | typedef struct service service_t; | |
42 | typedef struct server server_t; | |
43 | ||
44 | /* Bootstrap info */ | |
45 | struct bootstrap { | |
46 | bootstrap_info_t *next; /* list of all bootstraps */ | |
47 | bootstrap_info_t *prev; | |
48 | bootstrap_info_t *parent; | |
49 | mach_port_name_t bootstrap_port; | |
50 | mach_port_name_t requestor_port; | |
51 | }; | |
52 | ||
53 | /* Service types */ | |
54 | typedef enum { | |
55 | DECLARED, /* Declared in config file */ | |
56 | REGISTERED, /* Registered dynamically */ | |
57 | SELF /* Name bound bootstrap service itself */ | |
58 | } servicetype_t; | |
59 | ||
60 | struct service { | |
61 | service_t *next; /* list of all services */ | |
62 | service_t *prev; | |
63 | name_t name; /* service name */ | |
64 | mach_port_name_t port; /* service port, | |
65 | may have all rights if inactive */ | |
66 | bootstrap_info_t *bootstrap; /* bootstrap port(s) used at this | |
67 | * level. */ | |
68 | boolean_t isActive; /* server is running */ | |
69 | servicetype_t servicetype; /* Declared, Registered, or Machport */ | |
70 | server_t *server; /* server, declared services only */ | |
71 | }; | |
72 | ||
73 | /* Server types */ | |
74 | typedef enum { | |
75 | SERVER, /* Launchable server */ | |
76 | RESTARTABLE, /* Restartable server */ | |
77 | ETCINIT, /* Special processing for /etc/init */ | |
78 | MACHINIT /* mach_init doesn't get launched. */ | |
79 | } servertype_t; | |
80 | ||
81 | #define NULL_SERVER NULL | |
82 | #define ACTIVE TRUE | |
83 | ||
84 | struct server { | |
85 | server_t *next; /* list of all servers */ | |
86 | server_t *prev; | |
87 | servertype_t servertype; | |
88 | cmd_t cmd; /* server command to exec */ | |
89 | int priority; /* priority to give server */ | |
90 | mach_port_t port; /* server's priv bootstrap port */ | |
91 | mach_port_name_t task_port; /* server's task port */ | |
92 | }; | |
93 | ||
94 | #define NO_PID (-1) | |
95 | ||
96 | extern void init_lists(void); | |
97 | extern server_t *new_server( | |
98 | servertype_t servertype, | |
99 | const char *cmd, | |
100 | int priority); | |
101 | extern service_t *new_service( | |
102 | bootstrap_info_t *bootstrap, | |
103 | const char *name, | |
104 | mach_port_t service_port, | |
105 | boolean_t isActive, | |
106 | servicetype_t servicetype, | |
107 | server_t *serverp); | |
108 | extern bootstrap_info_t *new_bootstrap( | |
109 | bootstrap_info_t *parent, | |
110 | mach_port_name_t bootstrap_port, | |
111 | mach_port_name_t requestor_port); | |
112 | ||
113 | extern server_t *lookup_server_by_port(mach_port_t port); | |
114 | extern server_t *lookup_server_by_task_port(mach_port_t port); | |
115 | extern bootstrap_info_t *lookup_bootstrap_by_port(mach_port_t port); | |
116 | extern bootstrap_info_t *lookup_bootstrap_req_by_port(mach_port_t port); | |
117 | extern service_t *lookup_service_by_name(bootstrap_info_t *bootstrap, name_t name); | |
118 | extern service_t *lookup_service_by_port(mach_port_t port); | |
119 | extern server_t *find_init_server(void); | |
120 | extern void delete_service(service_t *servicep); | |
121 | extern void delete_bootstrap(bootstrap_info_t *bootstrap); | |
122 | extern void *ckmalloc(unsigned nbytes); | |
123 | ||
124 | extern bootstrap_info_t bootstraps; /* head of list of bootstrap ports */ | |
125 | extern server_t servers; /* head of list of all servers */ | |
126 | extern service_t services; /* head of list of all services */ | |
127 | extern unsigned nservices; /* number of services in list */ | |
128 | ||
129 | #define FIRST(q) ((q).next) | |
130 | #define NEXT(qe) ((qe)->next) | |
131 | #define PREV(qe) ((qe)->prev) | |
132 | #define IS_END(qe, q) ((qe) == &(q)) |