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