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