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