xref: /haiku/headers/private/kernel/team.h (revision db0331134210bf63c82a298bb734f5fda4167a38)
114f5ad8cSAxel Dörfler /*
251755cf8SAxel Dörfler  * Copyright 2004-2009, 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);
254a7f236bSIngo Weinhold void team_remove_team(struct team *team);
265662ae45SIngo Weinhold port_id team_shutdown_team(struct team *team, cpu_status& state);
275662ae45SIngo Weinhold void team_delete_team(struct team *team, port_id debuggerPort);
2874c0424aSAxel Dörfler struct process_group *team_get_process_group_locked(
2974c0424aSAxel Dörfler 			struct process_session *session, pid_t id);
3067c504a2SAxel Dörfler void team_delete_process_group(struct process_group *group);
3114f5ad8cSAxel Dörfler struct team *team_get_kernel_team(void);
3214f5ad8cSAxel Dörfler team_id team_get_kernel_team_id(void);
3314f5ad8cSAxel Dörfler team_id team_get_current_team_id(void);
3474c0424aSAxel Dörfler status_t team_get_address_space(team_id id,
35b0db552cSIngo Weinhold 			struct VMAddressSpace **_addressSpace);
3614f5ad8cSAxel Dörfler char **user_team_get_arguments(void);
3714f5ad8cSAxel Dörfler int user_team_get_arg_count(void);
3824bcf559SIngo Weinhold struct job_control_entry* team_get_death_entry(struct team *team,
3924bcf559SIngo Weinhold 			thread_id child, bool* _deleteEntry);
4014f5ad8cSAxel Dörfler bool team_is_valid(team_id id);
4114f5ad8cSAxel Dörfler struct 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 
45efd536ffSIngo Weinhold typedef bool (*team_iterator_callback)(struct team* team, void* cookie);
46efd536ffSIngo Weinhold struct team* team_iterate_through_teams(team_iterator_callback callback,
47efd536ffSIngo Weinhold 	void* cookie);
48efd536ffSIngo Weinhold 
495ecc4b37SIngo Weinhold thread_id load_image_etc(int32 argCount, const char* const* args,
505ecc4b37SIngo Weinhold 	const char* const* env, int32 priority, team_id parentID, uint32 flags);
515ecc4b37SIngo Weinhold 
5224bcf559SIngo Weinhold void team_set_job_control_state(struct team* team, job_control_state newState,
5324bcf559SIngo Weinhold 			int signal, bool threadsLocked);
54923efaa8SIngo Weinhold void team_set_controlling_tty(int32 index);
55923efaa8SIngo Weinhold int32 team_get_controlling_tty();
56923efaa8SIngo Weinhold status_t team_set_foreground_process_group(int32 ttyIndex, pid_t processGroup);
5724bcf559SIngo Weinhold 
5874c0424aSAxel Dörfler status_t start_watching_team(team_id team, void (*hook)(team_id, void *),
5974c0424aSAxel Dörfler 			void *data);
6074c0424aSAxel Dörfler status_t stop_watching_team(team_id team, void (*hook)(team_id, void *),
6174c0424aSAxel Dörfler 			void *data);
6299c566f6SAxel Dörfler 
63d648afb8SIngo Weinhold struct user_thread* team_allocate_user_thread(struct team* team);
64d648afb8SIngo Weinhold void team_free_user_thread(struct thread* thread);
65d648afb8SIngo Weinhold 
662d8d1cdbSIngo Weinhold bool team_associate_data(AssociatedData* data);
672d8d1cdbSIngo Weinhold bool team_dissociate_data(AssociatedData* data);
682d8d1cdbSIngo Weinhold 
6914f5ad8cSAxel Dörfler // used in syscalls.c
702965c99fSIngo Weinhold thread_id _user_load_image(const char* const* flatArgs, size_t flatArgsSize,
712965c99fSIngo Weinhold 			int32 argCount, int32 envCount, int32 priority, uint32 flags,
7274c0424aSAxel Dörfler 			port_id errorPort, uint32 errorToken);
7314f5ad8cSAxel Dörfler status_t _user_wait_for_team(team_id id, status_t *_returnCode);
74a32c8f26SAxel Dörfler void _user_exit_team(status_t returnValue);
7514f5ad8cSAxel Dörfler status_t _user_kill_team(thread_id thread);
7674c0424aSAxel Dörfler thread_id _user_wait_for_child(thread_id child, uint32 flags, int32 *_reason,
7774c0424aSAxel Dörfler 			status_t *_returnCode);
782965c99fSIngo Weinhold status_t _user_exec(const char *path, const char* const* flatArgs,
79*db033113SOliver Tappe 			size_t flatArgsSize, int32 argCount, int32 envCount, mode_t umask);
80367fa74aSAxel Dörfler thread_id _user_fork(void);
8114f5ad8cSAxel Dörfler team_id _user_get_current_team(void);
8267c504a2SAxel Dörfler pid_t _user_process_info(pid_t process, int32 which);
8367c504a2SAxel Dörfler pid_t _user_setpgid(pid_t process, pid_t group);
8467c504a2SAxel Dörfler pid_t _user_setsid(void);
8514f5ad8cSAxel Dörfler 
8614f5ad8cSAxel Dörfler status_t _user_get_team_info(team_id id, team_info *info);
8714f5ad8cSAxel Dörfler status_t _user_get_next_team_info(int32 *cookie, team_info *info);
8874c0424aSAxel Dörfler status_t _user_get_team_usage_info(team_id team, int32 who,
8974c0424aSAxel Dörfler 			team_usage_info *info, size_t size);
9056d734a1SIngo Weinhold status_t _user_get_extended_team_info(team_id teamID, uint32 flags,
9156d734a1SIngo Weinhold 			void* buffer, size_t size, size_t* _sizeNeeded);
9214f5ad8cSAxel Dörfler 
9314f5ad8cSAxel Dörfler #ifdef __cplusplus
9414f5ad8cSAxel Dörfler }
9514f5ad8cSAxel Dörfler #endif
9614f5ad8cSAxel Dörfler 
9774c0424aSAxel Dörfler #endif /* _TEAM_H */
98