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 extern _IMPEXP_ROOT thread_id load_image(int32 argc, const char **argv, 57 const char **envp); 58 extern _IMPEXP_ROOT image_id load_add_on(const char *path); 59 extern _IMPEXP_ROOT status_t unload_add_on(image_id imageID); 60 61 /* private; use the macros, below */ 62 extern _IMPEXP_ROOT status_t _get_image_info (image_id imageID, 63 image_info *info, size_t size); 64 extern _IMPEXP_ROOT status_t _get_next_image_info (team_id team, int32 *cookie, 65 image_info *info, size_t size); 66 /* use these */ 67 #define get_image_info(image, info) \ 68 _get_image_info((image), (info), sizeof(*(info))) 69 #define get_next_image_info(team, cookie, info) \ 70 _get_next_image_info((team), (cookie), (info), sizeof(*(info))) 71 72 73 /*---------------------------------------------------------*/ 74 /*----- symbol types and functions ------------------------*/ 75 76 #define B_SYMBOL_TYPE_DATA 0x1 77 #define B_SYMBOL_TYPE_TEXT 0x2 78 #define B_SYMBOL_TYPE_ANY 0x5 79 80 extern _IMPEXP_ROOT status_t get_image_symbol(image_id imid, 81 const char *name, int32 sclass, void **ptr); 82 extern _IMPEXP_ROOT status_t get_nth_image_symbol(image_id imid, int32 index, 83 char *buf, int32 *bufsize, int32 *sclass, 84 void **ptr); 85 86 87 /*---------------------------------------------------------*/ 88 /*----- cache manipulation --------------------------------*/ 89 90 #define B_FLUSH_DCACHE 0x0001 /* dcache = data cache */ 91 #define B_FLUSH_ICACHE 0x0004 /* icache = instruction cache */ 92 #define B_INVALIDATE_DCACHE 0x0002 93 #define B_INVALIDATE_ICACHE 0x0008 94 95 extern _IMPEXP_ROOT void clear_caches(void *addr, size_t len, uint32 flags); 96 97 /*---------------------------------------------------------*/ 98 99 #ifdef __cplusplus 100 } 101 #endif 102 103 #endif /* _IMAGE_H */ 104