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