xref: /haiku/headers/private/kernel/low_resource_manager.h (revision b671e9bbdbd10268a042b4f4cc4317ccd03d105e)
1 /*
2  * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Copyright 2005-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
4  * Distributed under the terms of the MIT License.
5  */
6 #ifndef _KERNEL_LOW_RESOURCE_MANAGER_H
7 #define _KERNEL_LOW_RESOURCE_MANAGER_H
8 
9 
10 #include <SupportDefs.h>
11 
12 
13 /* warning levels for low resource handlers */
14 enum {
15 	B_NO_LOW_RESOURCE = 0,
16 	B_LOW_RESOURCE_NOTE,
17 	B_LOW_RESOURCE_WARNING,
18 	B_LOW_RESOURCE_CRITICAL,
19 };
20 
21 enum {
22 	B_KERNEL_RESOURCE_PAGES			= 0x01,	/* physical pages */
23 	B_KERNEL_RESOURCE_MEMORY		= 0x02,	/* reservable memory */
24 	B_KERNEL_RESOURCE_SEMAPHORES	= 0x04,	/* semaphores */
25 
26 	B_ALL_KERNEL_RESOURCES			= B_KERNEL_RESOURCE_PAGES
27 										| B_KERNEL_RESOURCE_MEMORY
28 										| B_KERNEL_RESOURCE_SEMAPHORES
29 };
30 
31 typedef void (*low_resource_func)(void *data, uint32 resources, int32 level);
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 status_t low_resource_manager_init(void);
38 status_t low_resource_manager_init_post_thread(void);
39 int32 low_resource_state(uint32 resources);
40 void low_resource(uint32 resource, uint64 requirements, uint32 flags,
41 	uint32 timeout);
42 
43 // these calls might get public some day
44 status_t register_low_resource_handler(low_resource_func function, void *data,
45 			uint32 resources, int32 priority);
46 status_t unregister_low_resource_handler(low_resource_func function,
47 			void *data);
48 
49 #ifdef __cplusplus
50 }
51 #endif
52 
53 #endif	/* _KERNEL_LOW_RESOURCE_MANAGER_H */
54