1 #include <minix/syslib.h>
2 #include <minix/sysutil.h>
5 #include <minix/type.h>
9 #include <magic_analysis.h>
10 #include <st/state_transfer.h>
12 const char* sef_sf_typename_keys
[] = { "dsi_u", NULL
};
15 /*===========================================================================*
16 * sef_cb_sf_transfer_dsi_u *
17 *===========================================================================*/
18 static int sef_cb_sf_transfer_dsi_u(_magic_selement_t
*selement
, _magic_sel_analyzed_t
*sel_analyzed
, _magic_sel_stats_t
*sel_stats
, struct st_cb_info
*cb_info
) {
19 static struct dsi_mem noxfer_dsi_mem_stub
;
20 static const struct _magic_type
* _magic_dsi_mem_type
= NULL
;
21 struct data_store
* dsp
;
22 _magic_selement_t parent_selement
;
24 VOLATILE
int keep_stubs
= (int)&noxfer_dsi_mem_stub
;
27 if(magic_selement_get_parent(selement
, &parent_selement
) == NULL
) {
28 ST_CB_PRINT(ST_CB_ERR
, "sef_cb_sf_transfer_dsi_u: magic_selement_get_parent failed", selement
, sel_analyzed
, sel_stats
, cb_info
);
31 dsp
= (struct data_store
*) parent_selement
.address
;
32 if(!(dsp
->flags
& DSF_IN_USE
)) {
33 /* Skip when unused. */
34 return MAGIC_SENTRY_ANALYZE_SKIP_PATH
;
36 switch(dsp
->flags
& DSF_MASK_TYPE
) {
39 /* Identity transfer when no ptr is involved. */
40 ret
= st_cb_transfer_identity(selement
, sel_analyzed
, sel_stats
, cb_info
);
44 /* Transfer as dsp->u.mem struct. */
45 if(!_magic_dsi_mem_type
&& !(_magic_dsi_mem_type
= magic_type_lookup_by_name("dsi_mem"))) {
46 ST_CB_PRINT(ST_CB_ERR
, "sef_cb_sf_transfer_dsi_u: type dsi_mem not found", selement
, sel_analyzed
, sel_stats
, cb_info
);
49 st_cb_selement_type_cast(_magic_dsi_mem_type
, _magic_dsi_mem_type
, selement
, sel_analyzed
, sel_stats
, cb_info
);
50 ret
= st_cb_transfer_selement_generic(selement
, sel_analyzed
, sel_stats
, cb_info
);
53 /* Unknown? Report error. */
54 ST_CB_PRINT(ST_CB_ERR
, "sef_cb_sf_transfer_dsi_u: bad flags", selement
, sel_analyzed
, sel_stats
, cb_info
);
61 /*===========================================================================*
62 * sef_cb_sf_transfer_typename *
63 *===========================================================================*/
64 static int sef_cb_sf_transfer_typename(_magic_selement_t
*selement
, _magic_sel_analyzed_t
*sel_analyzed
, _magic_sel_stats_t
*sel_stats
, struct st_cb_info
*cb_info
) {
65 const char *typename_key
= ST_TYPE_NAME_KEY(selement
->type
);
66 if(ST_TYPE_NAME_MATCH(sef_sf_typename_keys
[dsi_u_idx
],typename_key
))
68 return sef_cb_sf_transfer_dsi_u(selement
, sel_analyzed
, sel_stats
, cb_info
);
71 return ST_CB_NOT_PROCESSED
;
74 /*===========================================================================*
76 *===========================================================================*/
77 void _magic_ds_st_init(void)
79 st_register_typename_keys(sef_sf_typename_keys
);
80 st_setcb_selement_transfer(sef_cb_sf_transfer_typename
, ST_CB_TYPE_TYPENAME
);