1 /****************************************************************************** 2 / 3 / File: image.h 4 / 5 / Description: Kernel interface for managing executable images. 6 / 7 / Copyright 1993-98, Be Incorporated 8 / 9 ******************************************************************************/ 10 11 #ifndef _IMAGE_H 12 #define _IMAGE_H 13 14 #include <BeBuild.h> 15 #include <OS.h> 16 #include <sys/param.h> 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 23 /*---------------------------------------------------------*/ 24 /*----- Image types, info, and functions ------------------*/ 25 26 #define B_INIT_BEFORE_FUNCTION_NAME "initialize_before" 27 #define B_INIT_AFTER_FUNCTION_NAME "initialize_after" 28 #define B_TERM_BEFORE_FUNCTION_NAME "terminate_before" 29 #define B_TERM_AFTER_FUNCTION_NAME "terminate_after" 30 31 typedef int32 image_id; 32 33 typedef enum { 34 B_APP_IMAGE = 1, 35 B_LIBRARY_IMAGE, 36 B_ADD_ON_IMAGE, 37 B_SYSTEM_IMAGE 38 } image_type; 39 40 typedef struct { 41 image_id id; 42 image_type type; 43 int32 sequence; 44 int32 init_order; 45 void (*init_routine)(); 46 void (*term_routine)(); 47 dev_t device; 48 ino_t node; 49 char name[MAXPATHLEN]; 50 void *text; 51 void *data; 52 int32 text_size; 53 int32 data_size; 54 } image_info; 55 56 // flags for _kern_load_image() 57 enum { 58 B_WAIT_TILL_LOADED = 0x01, // Wait till the loader has loaded and relocated 59 // (but not yet initialized) the application 60 // image and all dependencies. If not supplied, 61 // the function returns before the loader 62 // started to do anything at all, i.e. it 63 // returns success, even if the executable 64 // doesn't exist. 65 }; 66 67 extern _IMPEXP_ROOT thread_id load_image(int32 argc, const char **argv, 68 const char **envp); 69 extern _IMPEXP_ROOT image_id load_add_on(const char *path); 70 extern _IMPEXP_ROOT status_t unload_add_on(image_id imageID); 71 72 /* private; use the macros, below */ 73 extern _IMPEXP_ROOT status_t _get_image_info (image_id imageID, 74 image_info *info, size_t size); 75 extern _IMPEXP_ROOT status_t _get_next_image_info (team_id team, int32 *cookie, 76 image_info *info, size_t size); 77 /* use these */ 78 #define get_image_info(image, info) \ 79 _get_image_info((image), (info), sizeof(*(info))) 80 #define get_next_image_info(team, cookie, info) \ 81 _get_next_image_info((team), (cookie), (info), sizeof(*(info))) 82 83 84 /*---------------------------------------------------------*/ 85 /*----- symbol types and functions ------------------------*/ 86 87 #define B_SYMBOL_TYPE_DATA 0x1 88 #define B_SYMBOL_TYPE_TEXT 0x2 89 #define B_SYMBOL_TYPE_ANY 0x5 90 91 extern _IMPEXP_ROOT status_t get_image_symbol(image_id imid, 92 const char *name, int32 sclass, void **ptr); 93 extern _IMPEXP_ROOT status_t get_nth_image_symbol(image_id imid, int32 index, 94 char *buf, int32 *bufsize, int32 *sclass, 95 void **ptr); 96 97 98 /*---------------------------------------------------------*/ 99 /*----- cache manipulation --------------------------------*/ 100 101 #define B_FLUSH_DCACHE 0x0001 /* dcache = data cache */ 102 #define B_FLUSH_ICACHE 0x0004 /* icache = instruction cache */ 103 #define B_INVALIDATE_DCACHE 0x0002 104 #define B_INVALIDATE_ICACHE 0x0008 105 106 extern _IMPEXP_ROOT void clear_caches(void *addr, size_t len, uint32 flags); 107 108 /*---------------------------------------------------------*/ 109 110 #ifdef __cplusplus 111 } 112 #endif 113 114 #endif /* _IMAGE_H */ 115