xref: /haiku/headers/private/kernel/team.h (revision b809279cd8dd40ef5deca391e44f4bb19eb2e54f)
114f5ad8cSAxel Dörfler /*
24535495dSIngo Weinhold  * Copyright 2004-2011, Haiku Inc. All Rights Reserved.
3545ecbe8SAxel Dörfler  * Distributed under the terms of the MIT License.
414f5ad8cSAxel Dörfler  */
514f5ad8cSAxel Dörfler #ifndef _TEAM_H
614f5ad8cSAxel Dörfler #define _TEAM_H
714f5ad8cSAxel Dörfler 
814f5ad8cSAxel Dörfler 
914f5ad8cSAxel Dörfler #include <thread_types.h>
1014f5ad8cSAxel Dörfler 
1114f5ad8cSAxel Dörfler 
12efd536ffSIngo Weinhold // team notifications
1351755cf8SAxel Dörfler #define TEAM_MONITOR	'_Tm_'
14efd536ffSIngo Weinhold #define TEAM_ADDED		0x01
15efd536ffSIngo Weinhold #define TEAM_REMOVED	0x02
16efd536ffSIngo Weinhold #define TEAM_EXEC		0x04
1751755cf8SAxel Dörfler 
1851755cf8SAxel Dörfler 
1914f5ad8cSAxel Dörfler #ifdef __cplusplus
2014f5ad8cSAxel Dörfler extern "C" {
2114f5ad8cSAxel Dörfler #endif
2214f5ad8cSAxel Dörfler 
2397dda329SAxel Dörfler status_t team_init(struct kernel_args *args);
2414f5ad8cSAxel Dörfler status_t wait_for_team(team_id id, status_t *returnCode);
2524df6592SIngo Weinhold 
2624df6592SIngo Weinhold void team_remove_team(Team *team, pid_t& _signalGroup);
2724df6592SIngo Weinhold port_id team_shutdown_team(Team *team);
284535495dSIngo Weinhold void team_delete_team(Team *team, port_id debuggerPort);
2924df6592SIngo Weinhold 
304535495dSIngo Weinhold Team *team_get_kernel_team(void);
3114f5ad8cSAxel Dörfler team_id team_get_kernel_team_id(void);
3214f5ad8cSAxel Dörfler team_id team_get_current_team_id(void);
3374c0424aSAxel Dörfler status_t team_get_address_space(team_id id,
34b0db552cSIngo Weinhold 			struct VMAddressSpace **_addressSpace);
3514f5ad8cSAxel Dörfler char **user_team_get_arguments(void);
3614f5ad8cSAxel Dörfler int user_team_get_arg_count(void);
374535495dSIngo Weinhold struct job_control_entry* team_get_death_entry(Team *team,
3824bcf559SIngo Weinhold 			thread_id child, bool* _deleteEntry);
399437559dSIngo Weinhold void team_init_exit_info_on_error(Team* team);
4014f5ad8cSAxel Dörfler bool team_is_valid(team_id id);
414535495dSIngo Weinhold Team *team_get_team_struct_locked(team_id id);
42545ecbe8SAxel Dörfler int32 team_max_teams(void);
43545ecbe8SAxel Dörfler int32 team_used_teams(void);
4414f5ad8cSAxel Dörfler 
455ecc4b37SIngo Weinhold thread_id load_image_etc(int32 argCount, const char* const* args,
465ecc4b37SIngo Weinhold 	const char* const* env, int32 priority, team_id parentID, uint32 flags);
475ecc4b37SIngo Weinhold 
484535495dSIngo Weinhold void team_set_job_control_state(Team* team, job_control_state newState,
4903fb2d88SPawel Dziepak 			Signal* signal);
500c2a5bb5SAugustin Cavalier void team_set_controlling_tty(void* tty);
510c2a5bb5SAugustin Cavalier void* team_get_controlling_tty();
520c2a5bb5SAugustin Cavalier status_t team_set_foreground_process_group(void *tty, pid_t processGroup);
532f6dc2bbSAugustin Cavalier uid_t team_geteuid(team_id id);
5424bcf559SIngo Weinhold 
5574c0424aSAxel Dörfler status_t start_watching_team(team_id team, void (*hook)(team_id, void *),
5674c0424aSAxel Dörfler 			void *data);
5774c0424aSAxel Dörfler status_t stop_watching_team(team_id team, void (*hook)(team_id, void *),
5874c0424aSAxel Dörfler 			void *data);
5999c566f6SAxel Dörfler 
604535495dSIngo Weinhold struct user_thread* team_allocate_user_thread(Team* team);
6124df6592SIngo Weinhold void team_free_user_thread(Team* team, struct user_thread* userThread);
62d648afb8SIngo Weinhold 
632d8d1cdbSIngo Weinhold bool team_associate_data(AssociatedData* data);
642d8d1cdbSIngo Weinhold bool team_dissociate_data(AssociatedData* data);
652d8d1cdbSIngo Weinhold 
6614f5ad8cSAxel Dörfler // used in syscalls.c
672965c99fSIngo Weinhold thread_id _user_load_image(const char* const* flatArgs, size_t flatArgsSize,
682965c99fSIngo Weinhold 			int32 argCount, int32 envCount, int32 priority, uint32 flags,
6974c0424aSAxel Dörfler 			port_id errorPort, uint32 errorToken);
7014f5ad8cSAxel Dörfler status_t _user_wait_for_team(team_id id, status_t *_returnCode);
71a32c8f26SAxel Dörfler void _user_exit_team(status_t returnValue);
7214f5ad8cSAxel Dörfler status_t _user_kill_team(thread_id thread);
73a295d3f4SJérôme Duval pid_t _user_wait_for_child(thread_id child, uint32 flags, siginfo_t* info,
74a295d3f4SJérôme Duval 			team_usage_info* usageInfo);
752965c99fSIngo Weinhold status_t _user_exec(const char *path, const char* const* flatArgs,
76db033113SOliver Tappe 			size_t flatArgsSize, int32 argCount, int32 envCount, mode_t umask);
77367fa74aSAxel Dörfler thread_id _user_fork(void);
7814f5ad8cSAxel Dörfler team_id _user_get_current_team(void);
7967c504a2SAxel Dörfler pid_t _user_process_info(pid_t process, int32 which);
8067c504a2SAxel Dörfler pid_t _user_setpgid(pid_t process, pid_t group);
8167c504a2SAxel Dörfler pid_t _user_setsid(void);
8214f5ad8cSAxel Dörfler 
83*b809279cSTrung Nguyen status_t _user_get_team_info(team_id id, team_info *info, size_t size);
84*b809279cSTrung Nguyen status_t _user_get_next_team_info(int32 *cookie, team_info *info, size_t size);
8574c0424aSAxel Dörfler status_t _user_get_team_usage_info(team_id team, int32 who,
8674c0424aSAxel Dörfler 			team_usage_info *info, size_t size);
8756d734a1SIngo Weinhold status_t _user_get_extended_team_info(team_id teamID, uint32 flags,
8856d734a1SIngo Weinhold 			void* buffer, size_t size, size_t* _sizeNeeded);
8914f5ad8cSAxel Dörfler 
9014f5ad8cSAxel Dörfler #ifdef __cplusplus
9114f5ad8cSAxel Dörfler }
9214f5ad8cSAxel Dörfler #endif
9314f5ad8cSAxel Dörfler 
9474c0424aSAxel Dörfler #endif /* _TEAM_H */
95