xref: /haiku/headers/private/system/syscalls.h (revision 5146c41132f25460eccea5d225aa7fb98ae7326a)
1 /*
2  * Copyright 2004-2015, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _SYSTEM_SYSCALLS_H
6 #define _SYSTEM_SYSCALLS_H
7 
8 
9 #include <arch_config.h>
10 #include <DiskDeviceDefs.h>
11 #include <elf_private.h>
12 #include <image.h>
13 #include <image_defs.h>
14 #include <OS.h>
15 
16 #include <signal.h>
17 #include <sys/socket.h>
18 
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 struct attr_info;
25 struct dirent;
26 struct fd_info;
27 struct fd_set;
28 struct fs_info;
29 struct iovec;
30 struct msqid_ds;
31 struct net_stat;
32 struct pollfd;
33 struct rlimit;
34 struct scheduling_analysis;
35 struct _sem_t;
36 struct sembuf;
37 union semun;
38 struct sigaction;
39 struct signal_frame_data;
40 struct stat;
41 struct system_profiler_parameters;
42 struct user_timer_info;
43 
44 struct disk_device_job_progress_info;
45 struct partitionable_space_data;
46 struct thread_creation_attributes;
47 struct user_disk_device_data;
48 struct user_disk_device_job_info;
49 struct user_disk_system_info;
50 
51 // This marks the beginning of the syscalls prototypes for gensyscallinfos.
52 // NOTE:
53 // * Nothing but those prototypes may live here.
54 // * The arguments of the functions must be named to be processed properly.
55 
56 #ifdef GEN_SYSCALL_INFOS_PROCESSING
57 #	define __NO_RETURN
58 #	pragma syscalls begin
59 #else
60 #	define __NO_RETURN	__attribute__((noreturn))
61 #endif
62 
63 extern int			_kern_is_computer_on(void);
64 extern status_t		_kern_generic_syscall(const char *subsystem, uint32 function,
65 						void *buffer, size_t bufferSize);
66 
67 extern int			_kern_getrlimit(int resource, struct rlimit * rlp);
68 extern int			_kern_setrlimit(int resource, const struct rlimit * rlp);
69 
70 extern status_t		_kern_shutdown(bool reboot);
71 extern status_t		_kern_get_safemode_option(const char *parameter,
72 						char *buffer, size_t *_bufferSize);
73 
74 extern ssize_t		_kern_wait_for_objects(object_wait_info* infos, int numInfos,
75 						uint32 flags, bigtime_t timeout);
76 
77 /* user mutex functions */
78 extern status_t		_kern_mutex_lock(int32* mutex, const char* name,
79 						uint32 flags, bigtime_t timeout);
80 extern status_t		_kern_mutex_unblock(int32* mutex, uint32 flags);
81 extern status_t		_kern_mutex_switch_lock(int32* fromMutex, int32* toMutex,
82 						const char* name, uint32 flags, bigtime_t timeout);
83 extern status_t		_kern_mutex_sem_acquire(int32* sem, const char* name,
84 						uint32 flags, bigtime_t timeout);
85 extern status_t		_kern_mutex_sem_release(int32* sem);
86 
87 /* sem functions */
88 extern sem_id		_kern_create_sem(int count, const char *name);
89 extern status_t		_kern_delete_sem(sem_id id);
90 extern status_t		_kern_switch_sem(sem_id releaseSem, sem_id id);
91 extern status_t		_kern_switch_sem_etc(sem_id releaseSem, sem_id id,
92 						uint32 count, uint32 flags, bigtime_t timeout);
93 extern status_t		_kern_acquire_sem(sem_id id);
94 extern status_t		_kern_acquire_sem_etc(sem_id id, uint32 count, uint32 flags,
95 						bigtime_t timeout);
96 extern status_t		_kern_release_sem(sem_id id);
97 extern status_t		_kern_release_sem_etc(sem_id id, uint32 count, uint32 flags);
98 extern status_t		_kern_get_sem_count(sem_id id, int32* thread_count);
99 extern status_t		_kern_get_sem_info(sem_id semaphore, struct sem_info *info,
100 						size_t size);
101 extern status_t		_kern_get_next_sem_info(team_id team, int32 *cookie,
102 						struct sem_info *info, size_t size);
103 extern status_t		_kern_set_sem_owner(sem_id id, team_id proc);
104 
105 /* POSIX realtime sem syscalls */
106 extern status_t		_kern_realtime_sem_open(const char* name,
107 						int openFlagsOrShared, mode_t mode, uint32 semCount,
108 						struct _sem_t* userSem, struct _sem_t** _usedUserSem);
109 extern status_t		_kern_realtime_sem_close(sem_id semID,
110 						struct _sem_t** _deleteUserSem);
111 extern status_t		_kern_realtime_sem_unlink(const char* name);
112 
113 extern status_t		_kern_realtime_sem_get_value(sem_id semID, int* value);
114 extern status_t		_kern_realtime_sem_post(sem_id semID);
115 extern status_t		_kern_realtime_sem_wait(sem_id semID, uint32 flags,
116 						bigtime_t timeout);
117 
118 /* POSIX XSI semaphore syscalls */
119 extern int			_kern_xsi_semget(key_t key, int numSems, int flags);
120 extern int			_kern_xsi_semctl(int semID, int semNumber, int command,
121 						union semun* args);
122 extern status_t		_kern_xsi_semop(int semID, struct sembuf *semOps,
123 						size_t numSemOps);
124 
125 /* POSIX XSI message queue syscalls */
126 extern int			_kern_xsi_msgctl(int messageQueueID, int command,
127 						struct msqid_ds *buffer);
128 extern int			_kern_xsi_msgget(key_t key, int messageQueueFlags);
129 extern ssize_t		_kern_xsi_msgrcv(int messageQueueID, void *messagePointer,
130 						size_t messageSize, long messageType, int messageFlags);
131 extern int			_kern_xsi_msgsnd(int messageQueueID,
132 						const void *messagePointer, size_t messageSize,
133 						int messageFlags);
134 
135 /* team & thread syscalls */
136 extern thread_id	_kern_load_image(const char* const* flatArgs,
137 						size_t flatArgsSize, int32 argCount, int32 envCount,
138 						int32 priority, uint32 flags, port_id errorPort,
139 						uint32 errorToken);
140 extern void __NO_RETURN _kern_exit_team(status_t returnValue);
141 extern status_t		_kern_kill_team(team_id team);
142 extern team_id		_kern_get_current_team();
143 extern status_t		_kern_wait_for_team(team_id team, status_t *_returnCode);
144 extern pid_t		_kern_wait_for_child(thread_id child, uint32 flags,
145 						siginfo_t* info, team_usage_info* usageInfo);
146 extern status_t		_kern_exec(const char *path, const char* const* flatArgs,
147 						size_t flatArgsSize, int32 argCount, int32 envCount,
148 						mode_t umask);
149 extern thread_id	_kern_fork(void);
150 extern pid_t		_kern_process_info(pid_t process, int32 which);
151 extern pid_t		_kern_setpgid(pid_t process, pid_t group);
152 extern pid_t		_kern_setsid(void);
153 extern status_t		_kern_change_root(const char *path);
154 
155 extern thread_id	_kern_spawn_thread(
156 						struct thread_creation_attributes* attributes);
157 extern thread_id	_kern_find_thread(const char *name);
158 extern status_t		_kern_suspend_thread(thread_id thread);
159 extern status_t		_kern_resume_thread(thread_id thread);
160 extern status_t		_kern_rename_thread(thread_id thread, const char *newName);
161 extern status_t		_kern_set_thread_priority(thread_id thread,
162 						int32 newPriority);
163 extern status_t		_kern_kill_thread(thread_id thread);
164 extern void			_kern_exit_thread(status_t returnValue);
165 extern status_t		_kern_cancel_thread(thread_id threadID,
166 						void (*cancelFunction)(int));
167 extern void			_kern_thread_yield(void);
168 extern status_t		_kern_wait_for_thread(thread_id thread,
169 						status_t *_returnCode);
170 extern status_t		_kern_wait_for_thread_etc(thread_id thread, uint32 flags,
171 						bigtime_t timeout, status_t *_returnCode);
172 extern bool			_kern_has_data(thread_id thread);
173 extern status_t		_kern_send_data(thread_id thread, int32 code,
174 						const void *buffer, size_t bufferSize);
175 extern int32		_kern_receive_data(thread_id *_sender, void *buffer,
176 						size_t bufferSize);
177 extern int64		_kern_restore_signal_frame(
178 						struct signal_frame_data* signalFrameData);
179 
180 extern status_t		_kern_get_thread_info(thread_id id, thread_info *info);
181 extern status_t		_kern_get_next_thread_info(team_id team, int32 *cookie,
182 						thread_info *info);
183 extern status_t		_kern_get_team_info(team_id id, team_info *info,
184 						size_t size);
185 extern status_t		_kern_get_next_team_info(int32 *cookie, team_info *info,
186 						size_t size);
187 extern status_t		_kern_get_team_usage_info(team_id team, int32 who,
188 						team_usage_info *info, size_t size);
189 extern status_t		_kern_get_extended_team_info(team_id teamID, uint32 flags,
190 						void* buffer, size_t size, size_t* _sizeNeeded);
191 
192 extern status_t		_kern_start_watching_system(int32 object, uint32 flags,
193 						port_id port, int32 token);
194 extern status_t		_kern_stop_watching_system(int32 object, uint32 flags,
195 						port_id port, int32 token);
196 
197 extern status_t		_kern_block_thread(uint32 flags, bigtime_t timeout);
198 extern status_t		_kern_unblock_thread(thread_id thread, status_t status);
199 extern status_t		_kern_unblock_threads(thread_id* threads, uint32 count,
200 						status_t status);
201 
202 extern bigtime_t	_kern_estimate_max_scheduling_latency(thread_id thread);
203 
204 extern status_t		_kern_set_scheduler_mode(int32 mode);
205 extern int32		_kern_get_scheduler_mode(void);
206 
207 // user/group functions
208 extern gid_t		_kern_getgid(bool effective);
209 extern uid_t		_kern_getuid(bool effective);
210 extern status_t		_kern_setregid(gid_t rgid, gid_t egid,
211 						bool setAllIfPrivileged);
212 extern status_t		_kern_setreuid(uid_t ruid, uid_t euid,
213 						bool setAllIfPrivileged);
214 extern ssize_t		_kern_getgroups(int groupCount, gid_t* groupList);
215 extern status_t		_kern_setgroups(int groupCount, const gid_t* groupList);
216 
217 // signal functions
218 extern status_t		_kern_send_signal(int32 id, uint32 signal,
219 						const union sigval* userValue, uint32 flags);
220 extern status_t		_kern_set_signal_mask(int how, const sigset_t *set,
221 						sigset_t *oldSet);
222 extern status_t		_kern_sigaction(int sig, const struct sigaction *action,
223 						struct sigaction *oldAction);
224 extern status_t		_kern_sigwait(const sigset_t *set, siginfo_t *info,
225 						uint32 flags, bigtime_t timeout);
226 extern status_t		_kern_sigsuspend(const sigset_t *mask);
227 extern status_t		_kern_sigpending(sigset_t *set);
228 extern status_t		_kern_set_signal_stack(const stack_t *newStack,
229 						stack_t *oldStack);
230 
231 // image functions
232 extern image_id		_kern_register_image(extended_image_info *info,
233 						size_t size);
234 extern status_t		_kern_unregister_image(image_id id);
235 extern void			_kern_image_relocated(image_id id);
236 extern void			_kern_loading_app_failed(status_t error);
237 extern status_t		_kern_get_image_info(image_id id, image_info *info,
238 						size_t size);
239 extern status_t		_kern_get_next_image_info(team_id team, int32 *cookie,
240 						image_info *info, size_t size);
241 extern status_t		_kern_read_kernel_image_symbols(image_id id,
242 						elf_sym* symbolTable, int32* _symbolCount,
243 						char* stringTable, size_t* _stringTableSize,
244 						addr_t* _imageDelta);
245 
246 // VFS functions
247 extern dev_t		_kern_mount(const char *path, const char *device,
248 						const char *fs_name, uint32 flags, const char *args,
249 						size_t argsLength);
250 extern status_t		_kern_unmount(const char *path, uint32 flags);
251 extern status_t		_kern_read_fs_info(dev_t device, struct fs_info *info);
252 extern status_t		_kern_write_fs_info(dev_t device, const struct fs_info *info,
253 						int mask);
254 extern dev_t		_kern_next_device(int32 *_cookie);
255 extern status_t		_kern_sync(void);
256 extern status_t		_kern_entry_ref_to_path(dev_t device, ino_t inode,
257 						const char *leaf, char *userPath, size_t pathLength);
258 extern status_t		_kern_normalize_path(const char* userPath,
259 						bool traverseLink, char* buffer);
260 extern int			_kern_open_entry_ref(dev_t device, ino_t inode,
261 						const char *name, int openMode, int perms);
262 extern int			_kern_open(int fd, const char *path, int openMode,
263 						int perms);
264 extern int			_kern_open_dir_entry_ref(dev_t device, ino_t inode,
265 						const char *name);
266 extern int			_kern_open_dir(int fd, const char *path);
267 extern int			_kern_open_parent_dir(int fd, char *name,
268 						size_t nameLength);
269 extern status_t		_kern_fcntl(int fd, int op, size_t argument);
270 extern status_t		_kern_fsync(int fd);
271 extern status_t		_kern_flock(int fd, int op);
272 extern off_t		_kern_seek(int fd, off_t pos, int seekType);
273 extern status_t		_kern_create_dir_entry_ref(dev_t device, ino_t inode,
274 						const char *name, int perms);
275 extern status_t		_kern_create_dir(int fd, const char *path, int perms);
276 extern status_t		_kern_remove_dir(int fd, const char *path);
277 extern status_t		_kern_read_link(int fd, const char *path, char *buffer,
278 						size_t *_bufferSize);
279 extern status_t		_kern_create_symlink(int fd, const char *path,
280 						const char *toPath, int mode);
281 extern status_t		_kern_create_link(int pathFD, const char *path, int toFD,
282 						const char *toPath, bool traverseLeafLink);
283 extern status_t		_kern_unlink(int fd, const char *path);
284 extern status_t		_kern_rename(int oldDir, const char *oldpath, int newDir,
285 						const char *newpath);
286 extern status_t		_kern_create_fifo(int fd, const char *path, mode_t perms);
287 extern status_t		_kern_create_pipe(int *fds);
288 extern status_t		_kern_access(int fd, const char *path, int mode,
289 						bool effectiveUserGroup);
290 extern ssize_t		_kern_select(int numfds, struct fd_set *readSet,
291 						struct fd_set *writeSet, struct fd_set *errorSet,
292 						bigtime_t timeout, const sigset_t *sigMask);
293 extern ssize_t		_kern_poll(struct pollfd *fds, int numFDs,
294 						bigtime_t timeout, const sigset_t *sigMask);
295 
296 extern int			_kern_open_attr_dir(int fd, const char *path,
297 						bool traverseLeafLink);
298 extern ssize_t		_kern_read_attr(int fd, const char *attribute, off_t pos,
299 						void *buffer, size_t readBytes);
300 extern ssize_t		_kern_write_attr(int fd, const char *attribute, uint32 type,
301 						off_t pos, const void *buffer, size_t readBytes);
302 extern status_t		_kern_stat_attr(int fd, const char *attribute,
303 						struct attr_info *attrInfo);
304 extern int			_kern_open_attr(int fd, const char* path, const char *name,
305 						uint32 type, int openMode);
306 extern status_t		_kern_remove_attr(int fd, const char *name);
307 extern status_t		_kern_rename_attr(int fromFile, const char *fromName,
308 						int toFile, const char *toName);
309 extern int			_kern_open_index_dir(dev_t device);
310 extern status_t		_kern_create_index(dev_t device, const char *name,
311 						uint32 type, uint32 flags);
312 extern status_t		_kern_read_index_stat(dev_t device, const char *name,
313 						struct stat *stat);
314 extern status_t		_kern_remove_index(dev_t device, const char *name);
315 extern status_t		_kern_getcwd(char *buffer, size_t size);
316 extern status_t		_kern_setcwd(int fd, const char *path);
317 extern int			_kern_open_query(dev_t device, const char *query,
318 						size_t queryLength, uint32 flags, port_id port,
319 						int32 token);
320 
321 // file descriptor functions
322 extern ssize_t		_kern_read(int fd, off_t pos, void *buffer,
323 						size_t bufferSize);
324 extern ssize_t		_kern_readv(int fd, off_t pos, const struct iovec *vecs,
325 						size_t count);
326 extern ssize_t		_kern_write(int fd, off_t pos, const void *buffer,
327 						size_t bufferSize);
328 extern ssize_t		_kern_writev(int fd, off_t pos, const struct iovec *vecs,
329 						size_t count);
330 extern status_t		_kern_ioctl(int fd, uint32 cmd, void *data, size_t length);
331 extern ssize_t		_kern_read_dir(int fd, struct dirent *buffer,
332 						size_t bufferSize, uint32 maxCount);
333 extern status_t		_kern_rewind_dir(int fd);
334 extern status_t		_kern_read_stat(int fd, const char *path, bool traverseLink,
335 						struct stat *stat, size_t statSize);
336 extern status_t		_kern_write_stat(int fd, const char *path,
337 						bool traverseLink, const struct stat *stat,
338 						size_t statSize, int statMask);
339 extern status_t		_kern_close(int fd);
340 extern int			_kern_dup(int fd);
341 extern int			_kern_dup2(int ofd, int nfd);
342 extern status_t		_kern_lock_node(int fd);
343 extern status_t		_kern_unlock_node(int fd);
344 extern status_t		_kern_get_next_fd_info(team_id team, uint32 *_cookie,
345 						struct fd_info *info, size_t infoSize);
346 extern status_t		_kern_preallocate(int fd, off_t offset, off_t length);
347 
348 // socket functions
349 extern int			_kern_socket(int family, int type, int protocol);
350 extern status_t		_kern_bind(int socket, const struct sockaddr *address,
351 						socklen_t addressLength);
352 extern status_t		_kern_shutdown_socket(int socket, int how);
353 extern status_t		_kern_connect(int socket, const struct sockaddr *address,
354 						socklen_t addressLength);
355 extern status_t		_kern_listen(int socket, int backlog);
356 extern int			_kern_accept(int socket, struct sockaddr *address,
357 						socklen_t *_addressLength);
358 extern ssize_t		_kern_recv(int socket, void *data, size_t length,
359 						int flags);
360 extern ssize_t		_kern_recvfrom(int socket, void *data, size_t length,
361 						int flags, struct sockaddr *address,
362 						socklen_t *_addressLength);
363 extern ssize_t		_kern_recvmsg(int socket, struct msghdr *message,
364 						int flags);
365 extern ssize_t		_kern_send(int socket, const void *data, size_t length,
366 						int flags);
367 extern ssize_t		_kern_sendto(int socket, const void *data, size_t length,
368 						int flags, const struct sockaddr *address,
369 						socklen_t addressLength);
370 extern ssize_t		_kern_sendmsg(int socket, const struct msghdr *message,
371 						int flags);
372 extern status_t		_kern_getsockopt(int socket, int level, int option,
373 						void *value, socklen_t *_length);
374 extern status_t		_kern_setsockopt(int socket, int level, int option,
375 						const void *value, socklen_t length);
376 extern status_t		_kern_getpeername(int socket, struct sockaddr *address,
377 						socklen_t *_addressLength);
378 extern status_t		_kern_getsockname(int socket, struct sockaddr *address,
379 						socklen_t *_addressLength);
380 extern int			_kern_sockatmark(int socket);
381 extern status_t		_kern_socketpair(int family, int type, int protocol,
382 						int *socketVector);
383 extern status_t		_kern_get_next_socket_stat(int family, uint32 *cookie,
384 						struct net_stat *stat);
385 
386 // node monitor functions
387 extern status_t		_kern_stop_notifying(port_id port, uint32 token);
388 extern status_t		_kern_start_watching(dev_t device, ino_t node, uint32 flags,
389 						port_id port, uint32 token);
390 extern status_t		_kern_stop_watching(dev_t device, ino_t node, port_id port,
391 						uint32 token);
392 
393 // time functions
394 extern status_t		_kern_set_real_time_clock(bigtime_t time);
395 extern status_t		_kern_set_timezone(int32 timezoneOffset, const char *name,
396 						size_t nameLength);
397 extern status_t		_kern_get_timezone(int32 *_timezoneOffset, char *name,
398 						size_t nameLength);
399 extern status_t		_kern_set_real_time_clock_is_gmt(bool isGMT);
400 extern status_t		_kern_get_real_time_clock_is_gmt(bool *_isGMT);
401 
402 extern status_t		_kern_get_clock(clockid_t clockID, bigtime_t* _time);
403 extern status_t		_kern_set_clock(clockid_t clockID, bigtime_t time);
404 
405 extern bigtime_t	_kern_system_time();
406 extern status_t		_kern_snooze_etc(bigtime_t time, int timebase, int32 flags,
407 						bigtime_t* _remainingTime);
408 
409 extern int32		_kern_create_timer(clockid_t clockID, thread_id threadID,
410 						uint32 flags, const struct sigevent* event,
411 						const struct thread_creation_attributes*
412 							threadAttributes);
413 extern status_t		_kern_delete_timer(int32 timerID, thread_id threadID);
414 extern status_t		_kern_get_timer(int32 timerID, thread_id threadID,
415 						struct user_timer_info* info);
416 extern status_t		_kern_set_timer(int32 timerID, thread_id threadID,
417 						bigtime_t startTime, bigtime_t interval, uint32 flags,
418 						struct user_timer_info* oldInfo);
419 
420 // area functions
421 extern area_id		_kern_create_area(const char *name, void **address,
422 						uint32 addressSpec, size_t size, uint32 lock,
423 						uint32 protection);
424 extern status_t		_kern_delete_area(area_id area);
425 extern area_id		_kern_area_for(void *address);
426 extern area_id		_kern_find_area(const char *name);
427 extern status_t		_kern_get_area_info(area_id area, area_info *info);
428 extern status_t		_kern_get_next_area_info(team_id team, ssize_t *cookie,
429 						area_info *info);
430 extern status_t		_kern_resize_area(area_id area, size_t newSize);
431 extern area_id		_kern_transfer_area(area_id area, void **_address,
432 						uint32 addressSpec, team_id target);
433 extern status_t		_kern_set_area_protection(area_id area,
434 						uint32 newProtection);
435 extern area_id		_kern_clone_area(const char *name, void **_address,
436 						uint32 addressSpec, uint32 protection,
437 						area_id sourceArea);
438 extern status_t		_kern_reserve_address_range(addr_t* _address,
439 						uint32 addressSpec, addr_t size);
440 extern status_t		_kern_unreserve_address_range(addr_t address, addr_t size);
441 
442 extern area_id		_kern_map_file(const char *name, void **address,
443 						uint32 addressSpec, size_t size, uint32 protection,
444 						uint32 mapping, bool unmapAddressRange, int fd,
445 						off_t offset);
446 extern status_t		_kern_unmap_memory(void *address, size_t size);
447 extern status_t		_kern_set_memory_protection(void *address, size_t size,
448 						uint32 protection);
449 extern status_t		_kern_sync_memory(void *address, size_t size, int flags);
450 extern status_t		_kern_memory_advice(void *address, size_t size,
451 						uint32 advice);
452 
453 extern status_t		_kern_get_memory_properties(team_id teamID,
454 						const void *address, uint32* _protected, uint32* _lock);
455 
456 extern status_t		_kern_mlock(const void* address, size_t size);
457 extern status_t		_kern_munlock(const void* address, size_t size);
458 
459 /* kernel port functions */
460 extern port_id		_kern_create_port(int32 queue_length, const char *name);
461 extern status_t		_kern_close_port(port_id id);
462 extern status_t		_kern_delete_port(port_id id);
463 extern port_id		_kern_find_port(const char *port_name);
464 extern status_t		_kern_get_port_info(port_id id, struct port_info *info);
465 extern status_t		_kern_get_next_port_info(team_id team, int32 *cookie,
466 						struct port_info *info);
467 extern ssize_t		_kern_port_buffer_size_etc(port_id port, uint32 flags,
468 						bigtime_t timeout);
469 extern int32		_kern_port_count(port_id port);
470 extern ssize_t		_kern_read_port_etc(port_id port, int32 *msgCode,
471 						void *msgBuffer, size_t bufferSize, uint32 flags,
472 						bigtime_t timeout);
473 extern status_t		_kern_set_port_owner(port_id port, team_id team);
474 extern status_t		_kern_write_port_etc(port_id port, int32 msgCode,
475 						const void *msgBuffer, size_t bufferSize, uint32 flags,
476 						bigtime_t timeout);
477 extern status_t		_kern_writev_port_etc(port_id id, int32 msgCode,
478 						const struct iovec *msgVecs, size_t vecCount,
479 						size_t bufferSize, uint32 flags, bigtime_t timeout);
480 extern status_t		_kern_get_port_message_info_etc(port_id port,
481 						port_message_info *info, size_t infoSize, uint32 flags,
482 						bigtime_t timeout);
483 
484 // debug support functions
485 extern status_t		_kern_kernel_debugger(const char *message);
486 extern void			_kern_register_syslog_daemon(port_id port);
487 extern void			_kern_debugger(const char *message);
488 extern int			_kern_disable_debugger(int state);
489 
490 extern status_t		_kern_install_default_debugger(port_id debuggerPort);
491 extern port_id		_kern_install_team_debugger(team_id team,
492 						port_id debuggerPort);
493 extern status_t		_kern_remove_team_debugger(team_id team);
494 extern status_t		_kern_debug_thread(thread_id thread);
495 extern void			_kern_wait_for_debugger(void);
496 
497 extern status_t		_kern_set_debugger_breakpoint(void *address, uint32 type,
498 						int32 length, bool watchpoint);
499 extern status_t		_kern_clear_debugger_breakpoint(void *address,
500 						bool watchpoint);
501 
502 extern status_t		_kern_system_profiler_start(
503 						struct system_profiler_parameters* parameters);
504 extern status_t		_kern_system_profiler_next_buffer(size_t bytesRead,
505 						uint64* _droppedEvents);
506 extern status_t		_kern_system_profiler_stop();
507 extern status_t		_kern_system_profiler_recorded(
508 						struct system_profiler_parameters* parameters);
509 
510 /* atomic_* ops (needed for CPUs that don't support them directly) */
511 #ifdef ATOMIC_FUNCS_ARE_SYSCALLS
512 extern void		_kern_atomic_set(int32 *value, int32 newValue);
513 extern int32		_kern_atomic_get_and_set(int32 *value, int32 newValue);
514 extern int32		_kern_atomic_test_and_set(int32 *value, int32 newValue,
515 						int32 testAgainst);
516 extern int32		_kern_atomic_add(int32 *value, int32 addValue);
517 extern int32		_kern_atomic_and(int32 *value, int32 andValue);
518 extern int32		_kern_atomic_or(int32 *value, int32 orValue);
519 extern int32		_kern_atomic_get(int32 *value);
520 #endif	// ATOMIC_FUNCS_ARE_SYSCALLS
521 
522 #ifdef ATOMIC64_FUNCS_ARE_SYSCALLS
523 extern void		_kern_atomic_set64(int64 *value, int64 newValue);
524 extern int64		_kern_atomic_get_and_set64(int64 *value, int64 newValue);
525 extern int64		_kern_atomic_test_and_set64(int64 *value, int64 newValue,
526 						int64 testAgainst);
527 extern int64		_kern_atomic_add64(int64 *value, int64 addValue);
528 extern int64		_kern_atomic_and64(int64 *value, int64 andValue);
529 extern int64		_kern_atomic_or64(int64 *value, int64 orValue);
530 extern int64		_kern_atomic_get64(int64 *value);
531 #endif	// ATOMIC64_FUNCS_ARE_SYSCALLS
532 
533 /* System informations */
534 extern status_t		_kern_get_system_info(system_info* info);
535 extern status_t		_kern_get_cpu_info(uint32 firstCPU, uint32 cpuCount,
536 						cpu_info* info);
537 extern status_t		_kern_get_cpu_topology_info(
538 						cpu_topology_node_info* topologyInfos,
539 						uint32* topologyInfoCount);
540 
541 extern status_t		_kern_analyze_scheduling(bigtime_t from, bigtime_t until,
542 						void* buffer, size_t size,
543 						struct scheduling_analysis* analysis);
544 
545 /* Debug output */
546 extern void			_kern_debug_output(const char *message);
547 extern void			_kern_ktrace_output(const char *message);
548 extern status_t		_kern_frame_buffer_update(addr_t baseAddress, int32 width,
549 						int32 height, int32 depth, int32 bytesPerRow);
550 
551 /* messaging service */
552 extern area_id		_kern_register_messaging_service(sem_id lockingSem,
553 						sem_id counterSem);
554 extern status_t		_kern_unregister_messaging_service();
555 
556 extern void			_kern_clear_caches(void *address, size_t length,
557 						uint32 flags);
558 extern bool			_kern_cpu_enabled(int32 cpu);
559 extern status_t		_kern_set_cpu_enabled(int32 cpu, bool enabled);
560 
561 #if defined(__i386__) || defined(__x86_64__)
562 // our only x86 only syscall
563 extern status_t		_kern_get_cpuid(cpuid_info *info, uint32 eax, uint32 cpu);
564 #endif
565 
566 
567 /* Disk Device Manager syscalls */
568 
569 // iterating, retrieving device/partition data
570 extern partition_id	_kern_get_next_disk_device_id(int32 *cookie,
571 						size_t *neededSize);
572 extern partition_id	_kern_find_disk_device(const char *filename,
573 						size_t *neededSize);
574 extern partition_id	_kern_find_partition(const char *filename,
575 						size_t *neededSize);
576 extern partition_id	_kern_find_file_disk_device(const char *filename,
577 						size_t *neededSize);
578 extern status_t		_kern_get_disk_device_data(partition_id deviceID,
579 						bool deviceOnly, struct user_disk_device_data *buffer,
580 						size_t bufferSize, size_t *neededSize);
581 extern partition_id	_kern_register_file_device(const char *filename);
582 extern status_t		_kern_unregister_file_device(partition_id deviceID,
583 						const char *filename);
584 	// Only a valid deviceID or filename need to be passed. The other one
585 	// is -1/NULL. If both is given only filename is ignored.
586 extern status_t		_kern_get_file_disk_device_path(partition_id id,
587 						char* buffer, size_t bufferSize);
588 
589 // disk systems
590 extern status_t		_kern_get_disk_system_info(disk_system_id id,
591 						struct user_disk_system_info *info);
592 extern status_t		_kern_get_next_disk_system_info(int32 *cookie,
593 						struct user_disk_system_info *info);
594 extern status_t		_kern_find_disk_system(const char *name,
595 						struct user_disk_system_info *info);
596 
597 // disk device modification
598 extern status_t		_kern_defragment_partition(partition_id partitionID,
599 						int32* changeCounter);
600 extern status_t		_kern_repair_partition(partition_id partitionID,
601 						int32* changeCounter, bool checkOnly);
602 extern status_t		_kern_resize_partition(partition_id partitionID,
603 						int32* changeCounter, partition_id childID,
604 						int32* childChangeCounter, off_t size,
605 						off_t contentSize);
606 extern status_t		_kern_move_partition(partition_id partitionID,
607 						int32* changeCounter, partition_id childID,
608 						int32* childChangeCounter, off_t newOffset,
609 						partition_id* descendantIDs,
610 						int32* descendantChangeCounters, int32 descendantCount);
611 extern status_t		_kern_set_partition_name(partition_id partitionID,
612 						int32* changeCounter, partition_id childID,
613 						int32* childChangeCounter, const char* name);
614 extern status_t		_kern_set_partition_content_name(partition_id partitionID,
615 						int32* changeCounter, const char* name);
616 extern status_t		_kern_set_partition_type(partition_id partitionID,
617 						int32* changeCounter, partition_id childID,
618 						int32* childChangeCounter, const char* type);
619 extern status_t		_kern_set_partition_parameters(partition_id partitionID,
620 						int32* changeCounter, partition_id childID,
621 						int32* childChangeCounter, const char* parameters);
622 extern status_t		_kern_set_partition_content_parameters(
623 						partition_id partitionID, int32* changeCounter,
624 						const char* parameters);
625 extern status_t		_kern_initialize_partition(partition_id partitionID,
626 						int32* changeCounter, const char* diskSystemName,
627 						const char* name, const char* parameters);
628 extern status_t		_kern_uninitialize_partition(partition_id partitionID,
629 						int32* changeCounter, partition_id parentID,
630 						int32* parentChangeCounter);
631 extern status_t		_kern_create_child_partition(partition_id partitionID,
632 						int32* changeCounter, off_t offset, off_t size,
633 						const char* type, const char* name,
634 						const char* parameters, partition_id* childID,
635 						int32* childChangeCounter);
636 extern status_t		_kern_delete_child_partition(partition_id partitionID,
637 						int32* changeCounter, partition_id childID,
638 						int32 childChangeCounter);
639 
640 // disk change notification
641 extern status_t		_kern_start_watching_disks(uint32 eventMask, port_id port,
642 						int32 token);
643 extern status_t		_kern_stop_watching_disks(port_id port, int32 token);
644 
645 
646 // The end mark for gensyscallinfos.
647 #ifdef GEN_SYSCALL_INFOS_PROCESSING
648 #pragma syscalls end
649 #endif
650 
651 #undef __NO_RETURN
652 
653 #ifdef __cplusplus
654 }
655 #endif
656 
657 #endif	/* _SYSTEM_SYSCALLS_H */
658