1 /* 2 * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Copyright 2005-2009, Axel Dörfler, axeld@pinc-software.de. 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 B_KERNEL_RESOURCE_ADDRESS_SPACE = 0x08, /* address space */ 26 27 B_ALL_KERNEL_RESOURCES = B_KERNEL_RESOURCE_PAGES 28 | B_KERNEL_RESOURCE_MEMORY 29 | B_KERNEL_RESOURCE_SEMAPHORES 30 | B_KERNEL_RESOURCE_ADDRESS_SPACE 31 }; 32 33 typedef void (*low_resource_func)(void *data, uint32 resources, int32 level); 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 status_t low_resource_manager_init(void); 40 status_t low_resource_manager_init_post_thread(void); 41 int32 low_resource_state(uint32 resources); 42 void low_resource(uint32 resource, uint64 requirements, uint32 flags, 43 uint32 timeout); 44 45 // these calls might get public some day 46 status_t register_low_resource_handler(low_resource_func function, void *data, 47 uint32 resources, int32 priority); 48 status_t unregister_low_resource_handler(low_resource_func function, 49 void *data); 50 51 #ifdef __cplusplus 52 } 53 #endif 54 55 #endif /* _KERNEL_LOW_RESOURCE_MANAGER_H */ 56