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 extern status_t _kern_set_scheduler_mode(int32 mode); 196 extern int32 _kern_get_scheduler_mode(void); 197 198 // user/group functions 199 extern gid_t _kern_getgid(bool effective); 200 extern uid_t _kern_getuid(bool effective); 201 extern status_t _kern_setregid(gid_t rgid, gid_t egid, 202 bool setAllIfPrivileged); 203 extern status_t _kern_setreuid(uid_t ruid, uid_t euid, 204 bool setAllIfPrivileged); 205 extern ssize_t _kern_getgroups(int groupCount, gid_t* groupList); 206 extern status_t _kern_setgroups(int groupCount, const gid_t* groupList); 207 208 // signal functions 209 extern status_t _kern_send_signal(int32 id, uint32 signal, 210 const union sigval* userValue, uint32 flags); 211 extern status_t _kern_set_signal_mask(int how, const sigset_t *set, 212 sigset_t *oldSet); 213 extern status_t _kern_sigaction(int sig, const struct sigaction *action, 214 struct sigaction *oldAction); 215 extern status_t _kern_sigwait(const sigset_t *set, siginfo_t *info, 216 uint32 flags, bigtime_t timeout); 217 extern status_t _kern_sigsuspend(const sigset_t *mask); 218 extern status_t _kern_sigpending(sigset_t *set); 219 extern status_t _kern_set_signal_stack(const stack_t *newStack, 220 stack_t *oldStack); 221 222 // image functions 223 extern image_id _kern_register_image(image_info *info, size_t size); 224 extern status_t _kern_unregister_image(image_id id); 225 extern void _kern_image_relocated(image_id id); 226 extern void _kern_loading_app_failed(status_t error); 227 extern status_t _kern_get_image_info(image_id id, image_info *info, 228 size_t size); 229 extern status_t _kern_get_next_image_info(team_id team, int32 *cookie, 230 image_info *info, size_t size); 231 extern status_t _kern_read_kernel_image_symbols(image_id id, 232 elf_sym* symbolTable, int32* _symbolCount, 233 char* stringTable, size_t* _stringTableSize, 234 addr_t* _imageDelta); 235 236 // VFS functions 237 extern dev_t _kern_mount(const char *path, const char *device, 238 const char *fs_name, uint32 flags, const char *args, 239 size_t argsLength); 240 extern status_t _kern_unmount(const char *path, uint32 flags); 241 extern status_t _kern_read_fs_info(dev_t device, struct fs_info *info); 242 extern status_t _kern_write_fs_info(dev_t device, const struct fs_info *info, 243 int mask); 244 extern dev_t _kern_next_device(int32 *_cookie); 245 extern status_t _kern_sync(void); 246 extern status_t _kern_entry_ref_to_path(dev_t device, ino_t inode, 247 const char *leaf, char *userPath, size_t pathLength); 248 extern status_t _kern_normalize_path(const char* userPath, 249 bool traverseLink, char* buffer); 250 extern int _kern_open_entry_ref(dev_t device, ino_t inode, 251 const char *name, int openMode, int perms); 252 extern int _kern_open(int fd, const char *path, int openMode, 253 int perms); 254 extern int _kern_open_dir_entry_ref(dev_t device, ino_t inode, 255 const char *name); 256 extern int _kern_open_dir(int fd, const char *path); 257 extern int _kern_open_parent_dir(int fd, char *name, 258 size_t nameLength); 259 extern status_t _kern_fcntl(int fd, int op, size_t argument); 260 extern status_t _kern_fsync(int fd); 261 extern status_t _kern_flock(int fd, int op); 262 extern off_t _kern_seek(int fd, off_t pos, int seekType); 263 extern status_t _kern_create_dir_entry_ref(dev_t device, ino_t inode, 264 const char *name, int perms); 265 extern status_t _kern_create_dir(int fd, const char *path, int perms); 266 extern status_t _kern_remove_dir(int fd, const char *path); 267 extern status_t _kern_read_link(int fd, const char *path, char *buffer, 268 size_t *_bufferSize); 269 extern status_t _kern_create_symlink(int fd, const char *path, 270 const char *toPath, int mode); 271 extern status_t _kern_create_link(int pathFD, const char *path, int toFD, 272 const char *toPath, bool traverseLeafLink); 273 extern status_t _kern_unlink(int fd, const char *path); 274 extern status_t _kern_rename(int oldDir, const char *oldpath, int newDir, 275 const char *newpath); 276 extern status_t _kern_create_fifo(int fd, const char *path, mode_t perms); 277 extern status_t _kern_create_pipe(int *fds); 278 extern status_t _kern_access(int fd, const char *path, int mode, 279 bool effectiveUserGroup); 280 extern ssize_t _kern_select(int numfds, struct fd_set *readSet, 281 struct fd_set *writeSet, struct fd_set *errorSet, 282 bigtime_t timeout, const sigset_t *sigMask); 283 extern ssize_t _kern_poll(struct pollfd *fds, int numFDs, 284 bigtime_t timeout); 285 286 extern int _kern_open_attr_dir(int fd, const char *path, 287 bool traverseLeafLink); 288 extern ssize_t _kern_read_attr(int fd, const char *attribute, off_t pos, 289 void *buffer, size_t readBytes); 290 extern ssize_t _kern_write_attr(int fd, const char *attribute, uint32 type, 291 off_t pos, const void *buffer, size_t readBytes); 292 extern status_t _kern_stat_attr(int fd, const char *attribute, 293 struct attr_info *attrInfo); 294 extern int _kern_open_attr(int fd, const char* path, const char *name, 295 uint32 type, int openMode); 296 extern status_t _kern_remove_attr(int fd, const char *name); 297 extern status_t _kern_rename_attr(int fromFile, const char *fromName, 298 int toFile, const char *toName); 299 extern int _kern_open_index_dir(dev_t device); 300 extern status_t _kern_create_index(dev_t device, const char *name, 301 uint32 type, uint32 flags); 302 extern status_t _kern_read_index_stat(dev_t device, const char *name, 303 struct stat *stat); 304 extern status_t _kern_remove_index(dev_t device, const char *name); 305 extern status_t _kern_getcwd(char *buffer, size_t size); 306 extern status_t _kern_setcwd(int fd, const char *path); 307 extern int _kern_open_query(dev_t device, const char *query, 308 size_t queryLength, uint32 flags, port_id port, 309 int32 token); 310 311 // file descriptor functions 312 extern ssize_t _kern_read(int fd, off_t pos, void *buffer, 313 size_t bufferSize); 314 extern ssize_t _kern_readv(int fd, off_t pos, const struct iovec *vecs, 315 size_t count); 316 extern ssize_t _kern_write(int fd, off_t pos, const void *buffer, 317 size_t bufferSize); 318 extern ssize_t _kern_writev(int fd, off_t pos, const struct iovec *vecs, 319 size_t count); 320 extern status_t _kern_ioctl(int fd, uint32 cmd, void *data, size_t length); 321 extern ssize_t _kern_read_dir(int fd, struct dirent *buffer, 322 size_t bufferSize, uint32 maxCount); 323 extern status_t _kern_rewind_dir(int fd); 324 extern status_t _kern_read_stat(int fd, const char *path, bool traverseLink, 325 struct stat *stat, size_t statSize); 326 extern status_t _kern_write_stat(int fd, const char *path, 327 bool traverseLink, const struct stat *stat, 328 size_t statSize, int statMask); 329 extern status_t _kern_close(int fd); 330 extern int _kern_dup(int fd); 331 extern int _kern_dup2(int ofd, int nfd); 332 extern status_t _kern_lock_node(int fd); 333 extern status_t _kern_unlock_node(int fd); 334 extern status_t _kern_get_next_fd_info(team_id team, uint32 *_cookie, 335 struct fd_info *info, size_t infoSize); 336 337 // socket functions 338 extern int _kern_socket(int family, int type, int protocol); 339 extern status_t _kern_bind(int socket, const struct sockaddr *address, 340 socklen_t addressLength); 341 extern status_t _kern_shutdown_socket(int socket, int how); 342 extern status_t _kern_connect(int socket, const struct sockaddr *address, 343 socklen_t addressLength); 344 extern status_t _kern_listen(int socket, int backlog); 345 extern int _kern_accept(int socket, struct sockaddr *address, 346 socklen_t *_addressLength); 347 extern ssize_t _kern_recv(int socket, void *data, size_t length, 348 int flags); 349 extern ssize_t _kern_recvfrom(int socket, void *data, size_t length, 350 int flags, struct sockaddr *address, 351 socklen_t *_addressLength); 352 extern ssize_t _kern_recvmsg(int socket, struct msghdr *message, 353 int flags); 354 extern ssize_t _kern_send(int socket, const void *data, size_t length, 355 int flags); 356 extern ssize_t _kern_sendto(int socket, const void *data, size_t length, 357 int flags, const struct sockaddr *address, 358 socklen_t addressLength); 359 extern ssize_t _kern_sendmsg(int socket, const struct msghdr *message, 360 int flags); 361 extern status_t _kern_getsockopt(int socket, int level, int option, 362 void *value, socklen_t *_length); 363 extern status_t _kern_setsockopt(int socket, int level, int option, 364 const void *value, socklen_t length); 365 extern status_t _kern_getpeername(int socket, struct sockaddr *address, 366 socklen_t *_addressLength); 367 extern status_t _kern_getsockname(int socket, struct sockaddr *address, 368 socklen_t *_addressLength); 369 extern int _kern_sockatmark(int socket); 370 extern status_t _kern_socketpair(int family, int type, int protocol, 371 int *socketVector); 372 extern status_t _kern_get_next_socket_stat(int family, uint32 *cookie, 373 struct net_stat *stat); 374 375 // node monitor functions 376 extern status_t _kern_stop_notifying(port_id port, uint32 token); 377 extern status_t _kern_start_watching(dev_t device, ino_t node, uint32 flags, 378 port_id port, uint32 token); 379 extern status_t _kern_stop_watching(dev_t device, ino_t node, port_id port, 380 uint32 token); 381 382 // time functions 383 extern status_t _kern_set_real_time_clock(bigtime_t time); 384 extern status_t _kern_set_timezone(int32 timezoneOffset, const char *name, 385 size_t nameLength); 386 extern status_t _kern_get_timezone(int32 *_timezoneOffset, char *name, 387 size_t nameLength); 388 extern status_t _kern_set_real_time_clock_is_gmt(bool isGMT); 389 extern status_t _kern_get_real_time_clock_is_gmt(bool *_isGMT); 390 391 extern status_t _kern_get_clock(clockid_t clockID, bigtime_t* _time); 392 extern status_t _kern_set_clock(clockid_t clockID, bigtime_t time); 393 394 extern bigtime_t _kern_system_time(); 395 extern status_t _kern_snooze_etc(bigtime_t time, int timebase, int32 flags, 396 bigtime_t* _remainingTime); 397 398 extern int32 _kern_create_timer(clockid_t clockID, thread_id threadID, 399 uint32 flags, const struct sigevent* event, 400 const struct thread_creation_attributes* 401 threadAttributes); 402 extern status_t _kern_delete_timer(int32 timerID, thread_id threadID); 403 extern status_t _kern_get_timer(int32 timerID, thread_id threadID, 404 struct user_timer_info* info); 405 extern status_t _kern_set_timer(int32 timerID, thread_id threadID, 406 bigtime_t startTime, bigtime_t interval, uint32 flags, 407 struct user_timer_info* oldInfo); 408 409 // area functions 410 extern area_id _kern_create_area(const char *name, void **address, 411 uint32 addressSpec, size_t size, uint32 lock, 412 uint32 protection); 413 extern status_t _kern_delete_area(area_id area); 414 extern area_id _kern_area_for(void *address); 415 extern area_id _kern_find_area(const char *name); 416 extern status_t _kern_get_area_info(area_id area, area_info *info); 417 extern status_t _kern_get_next_area_info(team_id team, ssize_t *cookie, 418 area_info *info); 419 extern status_t _kern_resize_area(area_id area, size_t newSize); 420 extern area_id _kern_transfer_area(area_id area, void **_address, 421 uint32 addressSpec, team_id target); 422 extern status_t _kern_set_area_protection(area_id area, 423 uint32 newProtection); 424 extern area_id _kern_clone_area(const char *name, void **_address, 425 uint32 addressSpec, uint32 protection, 426 area_id sourceArea); 427 extern status_t _kern_reserve_address_range(addr_t* _address, 428 uint32 addressSpec, addr_t size); 429 extern status_t _kern_unreserve_address_range(addr_t address, addr_t size); 430 431 extern area_id _kern_map_file(const char *name, void **address, 432 uint32 addressSpec, size_t size, uint32 protection, 433 uint32 mapping, bool unmapAddressRange, int fd, 434 off_t offset); 435 extern status_t _kern_unmap_memory(void *address, size_t size); 436 extern status_t _kern_set_memory_protection(void *address, size_t size, 437 uint32 protection); 438 extern status_t _kern_sync_memory(void *address, size_t size, int flags); 439 extern status_t _kern_memory_advice(void *address, size_t size, 440 uint32 advice); 441 442 extern status_t _kern_get_memory_properties(team_id teamID, 443 const void *address, uint32* _protected, uint32* _lock); 444 445 /* kernel port functions */ 446 extern port_id _kern_create_port(int32 queue_length, const char *name); 447 extern status_t _kern_close_port(port_id id); 448 extern status_t _kern_delete_port(port_id id); 449 extern port_id _kern_find_port(const char *port_name); 450 extern status_t _kern_get_port_info(port_id id, struct port_info *info); 451 extern status_t _kern_get_next_port_info(team_id team, int32 *cookie, 452 struct port_info *info); 453 extern ssize_t _kern_port_buffer_size_etc(port_id port, uint32 flags, 454 bigtime_t timeout); 455 extern int32 _kern_port_count(port_id port); 456 extern ssize_t _kern_read_port_etc(port_id port, int32 *msgCode, 457 void *msgBuffer, size_t bufferSize, uint32 flags, 458 bigtime_t timeout); 459 extern status_t _kern_set_port_owner(port_id port, team_id team); 460 extern status_t _kern_write_port_etc(port_id port, int32 msgCode, 461 const void *msgBuffer, size_t bufferSize, uint32 flags, 462 bigtime_t timeout); 463 extern status_t _kern_writev_port_etc(port_id id, int32 msgCode, 464 const struct iovec *msgVecs, size_t vecCount, 465 size_t bufferSize, uint32 flags, bigtime_t timeout); 466 extern status_t _kern_get_port_message_info_etc(port_id port, 467 port_message_info *info, size_t infoSize, uint32 flags, 468 bigtime_t timeout); 469 470 // debug support functions 471 extern status_t _kern_kernel_debugger(const char *message); 472 extern void _kern_debugger(const char *message); 473 extern int _kern_disable_debugger(int state); 474 475 extern status_t _kern_install_default_debugger(port_id debuggerPort); 476 extern port_id _kern_install_team_debugger(team_id team, 477 port_id debuggerPort); 478 extern status_t _kern_remove_team_debugger(team_id team); 479 extern status_t _kern_debug_thread(thread_id thread); 480 extern void _kern_wait_for_debugger(void); 481 482 extern status_t _kern_set_debugger_breakpoint(void *address, uint32 type, 483 int32 length, bool watchpoint); 484 extern status_t _kern_clear_debugger_breakpoint(void *address, 485 bool watchpoint); 486 487 extern status_t _kern_system_profiler_start( 488 struct system_profiler_parameters* parameters); 489 extern status_t _kern_system_profiler_next_buffer(size_t bytesRead, 490 uint64* _droppedEvents); 491 extern status_t _kern_system_profiler_stop(); 492 extern status_t _kern_system_profiler_recorded( 493 struct system_profiler_parameters* parameters); 494 495 /* atomic_* ops (needed for CPUs that don't support them directly) */ 496 #ifdef ATOMIC_FUNCS_ARE_SYSCALLS 497 extern void _kern_atomic_set(int32 *value, int32 newValue); 498 extern int32 _kern_atomic_get_and_set(int32 *value, int32 newValue); 499 extern int32 _kern_atomic_test_and_set(int32 *value, int32 newValue, 500 int32 testAgainst); 501 extern int32 _kern_atomic_add(int32 *value, int32 addValue); 502 extern int32 _kern_atomic_and(int32 *value, int32 andValue); 503 extern int32 _kern_atomic_or(int32 *value, int32 orValue); 504 extern int32 _kern_atomic_get(int32 *value); 505 #endif // ATOMIC_FUNCS_ARE_SYSCALLS 506 507 #ifdef ATOMIC64_FUNCS_ARE_SYSCALLS 508 extern void _kern_atomic_set64(int64 *value, int64 newValue); 509 extern int64 _kern_atomic_get_and_set64(int64 *value, int64 newValue); 510 extern int64 _kern_atomic_test_and_set64(int64 *value, int64 newValue, 511 int64 testAgainst); 512 extern int64 _kern_atomic_add64(int64 *value, int64 addValue); 513 extern int64 _kern_atomic_and64(int64 *value, int64 andValue); 514 extern int64 _kern_atomic_or64(int64 *value, int64 orValue); 515 extern int64 _kern_atomic_get64(int64 *value); 516 #endif // ATOMIC64_FUNCS_ARE_SYSCALLS 517 518 /* System informations */ 519 extern status_t _kern_get_system_info(system_info* info); 520 extern status_t _kern_get_cpu_info(uint32 firstCPU, uint32 cpuCount, 521 cpu_info* info); 522 extern status_t _kern_get_cpu_topology_info( 523 cpu_topology_node_info* topologyInfos, 524 uint32* topologyInfoCount); 525 526 extern status_t _kern_analyze_scheduling(bigtime_t from, bigtime_t until, 527 void* buffer, size_t size, 528 struct scheduling_analysis* analysis); 529 530 /* Debug output */ 531 extern void _kern_debug_output(const char *message); 532 extern void _kern_ktrace_output(const char *message); 533 extern status_t _kern_frame_buffer_update(addr_t baseAddress, int32 width, 534 int32 height, int32 depth, int32 bytesPerRow); 535 536 /* messaging service */ 537 extern area_id _kern_register_messaging_service(sem_id lockingSem, 538 sem_id counterSem); 539 extern status_t _kern_unregister_messaging_service(); 540 541 extern void _kern_clear_caches(void *address, size_t length, 542 uint32 flags); 543 extern bool _kern_cpu_enabled(int32 cpu); 544 extern status_t _kern_set_cpu_enabled(int32 cpu, bool enabled); 545 546 #if defined(__INTEL__) || defined(__x86_64__) 547 // our only x86 only syscall 548 extern status_t _kern_get_cpuid(cpuid_info *info, uint32 eax, uint32 cpu); 549 #endif 550 551 552 /* Disk Device Manager syscalls */ 553 554 // iterating, retrieving device/partition data 555 extern partition_id _kern_get_next_disk_device_id(int32 *cookie, 556 size_t *neededSize); 557 extern partition_id _kern_find_disk_device(const char *filename, 558 size_t *neededSize); 559 extern partition_id _kern_find_partition(const char *filename, 560 size_t *neededSize); 561 extern partition_id _kern_find_file_disk_device(const char *filename, 562 size_t *neededSize); 563 extern status_t _kern_get_disk_device_data(partition_id deviceID, 564 bool deviceOnly, struct user_disk_device_data *buffer, 565 size_t bufferSize, size_t *neededSize); 566 extern partition_id _kern_register_file_device(const char *filename); 567 extern status_t _kern_unregister_file_device(partition_id deviceID, 568 const char *filename); 569 // Only a valid deviceID or filename need to be passed. The other one 570 // is -1/NULL. If both is given only filename is ignored. 571 extern status_t _kern_get_file_disk_device_path(partition_id id, 572 char* buffer, size_t bufferSize); 573 574 // disk systems 575 extern status_t _kern_get_disk_system_info(disk_system_id id, 576 struct user_disk_system_info *info); 577 extern status_t _kern_get_next_disk_system_info(int32 *cookie, 578 struct user_disk_system_info *info); 579 extern status_t _kern_find_disk_system(const char *name, 580 struct user_disk_system_info *info); 581 582 // disk device modification 583 extern status_t _kern_defragment_partition(partition_id partitionID, 584 int32* changeCounter); 585 extern status_t _kern_repair_partition(partition_id partitionID, 586 int32* changeCounter, bool checkOnly); 587 extern status_t _kern_resize_partition(partition_id partitionID, 588 int32* changeCounter, partition_id childID, 589 int32* childChangeCounter, off_t size, 590 off_t contentSize); 591 extern status_t _kern_move_partition(partition_id partitionID, 592 int32* changeCounter, partition_id childID, 593 int32* childChangeCounter, off_t newOffset, 594 partition_id* descendantIDs, 595 int32* descendantChangeCounters, int32 descendantCount); 596 extern status_t _kern_set_partition_name(partition_id partitionID, 597 int32* changeCounter, partition_id childID, 598 int32* childChangeCounter, const char* name); 599 extern status_t _kern_set_partition_content_name(partition_id partitionID, 600 int32* changeCounter, const char* name); 601 extern status_t _kern_set_partition_type(partition_id partitionID, 602 int32* changeCounter, partition_id childID, 603 int32* childChangeCounter, const char* type); 604 extern status_t _kern_set_partition_parameters(partition_id partitionID, 605 int32* changeCounter, partition_id childID, 606 int32* childChangeCounter, const char* parameters); 607 extern status_t _kern_set_partition_content_parameters( 608 partition_id partitionID, int32* changeCounter, 609 const char* parameters); 610 extern status_t _kern_initialize_partition(partition_id partitionID, 611 int32* changeCounter, const char* diskSystemName, 612 const char* name, const char* parameters); 613 extern status_t _kern_uninitialize_partition(partition_id partitionID, 614 int32* changeCounter); 615 extern status_t _kern_create_child_partition(partition_id partitionID, 616 int32* changeCounter, off_t offset, off_t size, 617 const char* type, const char* name, 618 const char* parameters, partition_id* childID, 619 int32* childChangeCounter); 620 extern status_t _kern_delete_child_partition(partition_id partitionID, 621 int32* changeCounter, partition_id childID, 622 int32 childChangeCounter); 623 624 // disk change notification 625 extern status_t _kern_start_watching_disks(uint32 eventMask, port_id port, 626 int32 token); 627 extern status_t _kern_stop_watching_disks(port_id port, int32 token); 628 629 630 // The end mark for gensyscallinfos. 631 #ifdef GEN_SYSCALL_INFOS_PROCESSING 632 #pragma syscalls end 633 #endif 634 635 #undef __NO_RETURN 636 637 #ifdef __cplusplus 638 } 639 #endif 640 641 #endif /* _SYSTEM_SYSCALLS_H */ 642