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