area.h

Go to the documentation of this file.
00001 /*
00002 ** area.h for lseos in lseos-lib/libarea
00003 ** 
00004 ** Copyright (c)2004 Vianney Rancurel, Julien Quintard
00005 ** Login   <vianney@epita.fr>
00006 ** 
00007 ** Started on  Tue Jan 20 16:46:06 2004 Vianney Rancurel
00008  ** Last update Fri Feb 18 16:44:52 2005 Olivier Dembour
00009 */
00010 #ifndef __LIBAREA_AREA_H__
00011 #define __LIBAREA_AREA_H__      1
00012 typedef int     (*t_area_printf_fn)(const char *fmt, ...);
00013 
00014 typedef unsigned int    t_area_uint;
00015 typedef signed int      t_area_int;
00016 
00021 typedef int     (*t_area_data_coalesce_fn)(void *data1,
00022                                            void *data2);
00023 
00027 typedef void    (*t_area_data_print_fn)(void    *data);
00028 
00032 typedef void    (*t_area_data_copy_fn)(void     *data_src,
00033                                        void     *data_dst);
00038 typedef void    (*t_area_xlate_fn)(void *data,
00039                                     signed int  diff_pgs);
00040 
00044 typedef int     (*t_area_match_fn)(void *data, void *val);
00045 
00046 typedef int     (*t_area_foreach_fn)(void *data, void *val);
00047 #define AREA_FOREACH_CONT       0
00048 #define AREA_FOREACH_STOP       1
00049 
00050 struct s_area;
00051 typedef struct                  s_area
00052 {
00053   union
00054   {
00055     LIST_ENTRY(s_area)          list;
00056   } u;
00057 
00058   t_area_uint                   blk;
00059   t_area_uint                   nb_blks;/* number of blocks             */
00060   void                          *data;  /* specific data                */
00061 }                               t_area;
00062 
00063 typedef enum
00064   {
00065     AREA_EZERO,                 /* 0 */
00066     AREA_ECOLLIDE,              /* 1 */
00067     AREA_ENOROOM,               /* 2 */
00068     AREA_EINVAL,                /* 3 */
00069     AREA_ELIMIT,                /* 4 */
00070     AREA_ENODEV,                /* 5 */
00071     AREA_ENOMATCH,              /* 6 */
00072     AREA_ENOFIT,                /* 7 there is room but we dont fit */
00073   }                             t_area_status;
00074 
00075 typedef enum
00076   {
00077     AREA_FIRST_FIT,
00078     AREA_WORST_FIT,
00079     AREA_ANY_FIT,               
00080   }                             t_area_fit_method;
00081 
00082 #define AREA_FITOPT_NOPAGE0     (1<<0u) 
00083 #define AREA_FITOPT_NOFIRSTMEG  (1<<1u) 
00086 LIST_HEAD(s_area_list, s_area);
00087 typedef struct s_area_list      t_area_list;
00088 
00089 struct s_area_set;
00090 #include <llarea.h>
00091 #include <bptarea.h>
00092 
00093 typedef struct                  s_area_set
00094 {
00095 #define AREA_LL         0
00096 #define AREA_BPT        1
00097 #define AREA_MAXTYPE    1
00098   int                           type;
00099   union
00100   {
00101     t_area_list                 area_list;
00102     t_bpt(area_tree)            area_tree;
00103   } u;
00104   t_area_data_coalesce_fn       coalesce;
00105   t_area_data_print_fn          print;
00106   t_area_data_copy_fn           copy;
00107   t_area_xlate_fn               xlate;
00108   t_area_uint                   blk_size;
00109   t_area_uint                   first_blk;
00110   t_area_uint                   last_blk; /* could be the same as first_blk */
00111   void                          *set_data;
00112   struct
00113   {
00114     u_int                       nb_coal;
00115   } stats;
00116   char                          mem[512]; /* used internally            */
00117 }                               t_area_set;
00118 
00119 #define AREA_SET_SIZE(Set) \
00120   ((t_area_uint)(((Set)->last_blk - (Set)->first_blk + 1)))
00121 
00122 /*
00123  * stubs prototypes
00124  */
00125 typedef void
00126 (*t_area_set_subinit_fn)(t_area_set *set);
00127 
00135 typedef t_area_status 
00136 (*t_area_set_add_fn)(t_area_set *set,
00137                      t_area **io);
00138 
00139 typedef t_area_status
00140 (*t_area_set_collide_fn)(t_area_set *set,
00141                          t_area_uint blk, 
00142                          int nb_blks);
00143 
00144 typedef t_area_status
00145 (*t_area_set_get_area_fn)(t_area_set *set,
00146                           t_area_uint blk,
00147                           int nb_blks, 
00148                           t_area **area);
00149 
00160 typedef t_area_status 
00161 (*t_area_set_remove_fn)(t_area_set *set,
00162                         t_area **io,
00163                         int no_alloc);
00164 
00176 typedef t_area_status
00177 (*t_area_set_modify_fn)(t_area_set *set,
00178                         t_area **io,
00179                         int no_alloc);
00180 
00181 typedef t_area_status
00182  (*t_area_set_find_space_fn)(t_area_set *set,
00183                              int nb_blks,
00184                              t_area_fit_method fit,
00185                              u_int32_t fitopts,
00186                              t_area_uint *addr_returned);
00187 
00188 typedef t_area_status
00189 (*t_area_set_find_coalescible_space_fn)(t_area_set *set,
00190                                         t_area *ref_area,
00191                                         t_area_fit_method fit,
00192                                         u_int32_t fitopts,
00193                                         t_area_uint *blk_returned);
00194 
00195 typedef void
00196 (*t_area_set_dump_fn)(t_area_printf_fn printf_fn,
00197                       t_area_set *set,
00198                       t_area_match_fn match,
00199                       void *val);
00200 
00201 typedef t_area_uint
00202 (*t_area_set_used_fn)(t_area_set *set, 
00203                       t_area_match_fn match,
00204                       void *val,
00205                       int *nb_areas);
00206 
00207 typedef int
00208 (*t_area_set_foreach_fn)(t_area_set *set,
00209                          t_area_foreach_fn foreach,
00210                          void *val);
00211 
00212 typedef int
00213 (*t_area_set_empty_fn)(t_area_set *set);
00214 
00215 typedef int
00216 (*t_area_set_add_alloc_fn)(t_area_set *set);
00217 
00218 typedef int
00219 (*t_area_set_add_size_fn)(t_area_set *set);
00220 
00221 typedef int
00222 (*t_area_set_modify_alloc_fn)(t_area_set *set);
00223 
00224 typedef int
00225 (*t_area_set_modify_size_fn)(t_area_set *set);
00226 
00227 typedef int
00228 (*t_area_set_remove_alloc_fn)(t_area_set *set);
00229 
00230 typedef int
00231 (*t_area_set_remove_size_fn)(t_area_set *set);
00232 
00233 #ifdef __AREA_OLD_CODE__
00234 typedef t_area_status 
00235 (*t_area_set_old_add_fn)(t_area_set *set,
00236                          t_area **new,
00237                          t_area **unused1);
00238 
00239 typedef t_area_status 
00240 (*t_area_set_old_remove_fn)(t_area_set *set,
00241                             t_area **todel,
00242                             t_area **unused1,
00243                             int no_alloc);
00244 
00245 typedef t_area_status
00246 (*t_area_set_old_modify_fn)(t_area_set *set,
00247                             t_area **new,
00248                             t_area **new2,
00249                             t_area **unused1,
00250                             t_area **unused2,
00251                             int no_alloc);
00252 #endif
00253 
00254 typedef struct                  s_area_fns
00255 {
00256   t_area_set_subinit_fn         subinit;
00257   t_area_set_find_space_fn      find_space;
00258   t_area_set_add_fn             add;
00259   t_area_set_collide_fn         collide;
00260   t_area_set_find_coalescible_space_fn find_coalescible_space;
00261   t_area_set_get_area_fn        get_area;
00262   t_area_set_remove_fn          remove;
00263   t_area_set_modify_fn          modify;
00264   t_area_set_foreach_fn         foreach;
00265   t_area_set_dump_fn            dump;
00266   t_area_set_used_fn            used;
00267   t_area_set_empty_fn           empty;
00268   t_area_set_add_alloc_fn       add_alloc;
00269   t_area_set_add_size_fn        add_size;
00270   t_area_set_modify_alloc_fn    modify_alloc;
00271   t_area_set_modify_size_fn     modify_size;
00272   t_area_set_remove_alloc_fn    remove_alloc;
00273   t_area_set_remove_size_fn     remove_size;
00274 #ifdef __AREA_OLD_CODE__
00275   t_area_set_old_add_fn         old_add;
00276   t_area_set_old_remove_fn      old_remove;
00277   t_area_set_old_modify_fn      old_modify;
00278 #endif
00279 }                               t_area_fns;
00280 
00281 /* PROTO area.c */
00282 /* area.c */
00283 char *area_get_err_str(t_area_status status);
00284 int area_collide(t_area *area1, t_area *area2);
00285 t_area_status area_set_init(int type, t_area_set *new, t_area_data_coalesce_fn coalesce, t_area_data_print_fn print, t_area_data_copy_fn copy, t_area_xlate_fn xlate, t_area_uint blk_size, t_area_uint first_blk, t_area_uint last_blk, void *set_data);
00286 void area_set_subinit(t_area_set *set);
00287 t_area_status area_set_find_space(t_area_set *set, int nb_blks, t_area_fit_method fit, u_int32_t fitopts, t_area_uint *addr_returned);
00288 t_area_status area_set_add(t_area_set *set, t_area **io);
00289 t_area_status area_set_collide(t_area_set *set, t_area_uint blk, int nb_blks);
00290 t_area_status area_set_find_coalescible_space(t_area_set *set, t_area *ref_area, t_area_fit_method fit, u_int32_t fitopts, t_area_uint *blk_returned);
00291 t_area_status area_set_get_area(t_area_set *set, t_area_uint blk, int nb_blks, t_area **area);
00292 t_area_status area_set_remove(t_area_set *set, t_area **io, int no_alloc);
00293 t_area_status area_set_modify(t_area_set *set, t_area **io, int no_alloc);
00294 int area_set_foreach(t_area_set *set, t_area_foreach_fn foreach, void *val);
00295 void area_set_dump(t_area_printf_fn printf_fn, t_area_set *set, t_area_match_fn match, void *val);
00296 t_area_uint area_set_used(t_area_set *set, t_area_match_fn match, void *val, int *nb_areas);
00297 int area_set_empty(t_area_set *set);
00298 int area_set_add_alloc(t_area_set *set);
00299 int area_set_add_size(t_area_set *set);
00300 int area_set_modify_alloc(t_area_set *set);
00301 int area_set_modify_size(t_area_set *set);
00302 int area_set_remove_alloc(t_area_set *set);
00303 int area_set_remove_size(t_area_set *set);
00304 t_area_status area_set_old_add(t_area_set *set, t_area **new, t_area **unused1);
00305 t_area_status area_set_old_remove(t_area_set *set, t_area **todel, t_area **unused1, int no_alloc);
00306 t_area_status area_set_old_modify(t_area_set *set, t_area **new, t_area **new2, t_area **unused1, t_area **unused2, int no_alloc);
00307 #endif

Generated on Wed May 24 23:04:16 2006 for LSE/OS by  doxygen 1.4.6