9 static int do_invoke_ds(int type
, const char *ds_name
)
15 if(type
== DS_CHECK
|| type
== DS_RETRIEVE_LABEL
) {
16 len_key
= DS_MAX_KEYLEN
;
19 len_key
= strlen(ds_name
)+1;
24 g_key
= cpf_grant_direct(DS_PROC_NR
, (vir_bytes
) ds_name
,
26 if(!GRANT_VALID(g_key
))
29 m
.DS_KEY_GRANT
= g_key
;
30 m
.DS_KEY_LEN
= len_key
;
32 r
= _taskcall(DS_PROC_NR
, type
, &m
);
38 int ds_publish_label(const char *ds_name
, endpoint_t endpoint
, int flags
)
40 m
.DS_VAL
= (u32_t
) endpoint
;
41 m
.DS_FLAGS
= DSF_TYPE_LABEL
| flags
;
42 return do_invoke_ds(DS_PUBLISH
, ds_name
);
45 int ds_publish_u32(const char *ds_name
, u32_t value
, int flags
)
48 m
.DS_FLAGS
= DSF_TYPE_U32
| flags
;
49 return do_invoke_ds(DS_PUBLISH
, ds_name
);
52 static int ds_publish_raw(const char *ds_name
, void *vaddr
, size_t length
,
58 /* Grant for memory range. */
59 gid
= cpf_grant_direct(DS_PROC_NR
, (vir_bytes
)vaddr
, length
, CPF_READ
);
64 m
.DS_VAL_LEN
= length
;
67 r
= do_invoke_ds(DS_PUBLISH
, ds_name
);
73 int ds_publish_str(const char *ds_name
, char *value
, int flags
)
76 length
= strlen(value
) + 1;
77 value
[length
- 1] = '\0';
78 return ds_publish_raw(ds_name
, value
, length
, flags
| DSF_TYPE_STR
);
81 int ds_publish_mem(const char *ds_name
, void *vaddr
, size_t length
, int flags
)
83 return ds_publish_raw(ds_name
, vaddr
, length
, flags
| DSF_TYPE_MEM
);
86 int ds_snapshot_map(const char *ds_name
, int *nr_snapshot
)
89 r
= do_invoke_ds(DS_SNAPSHOT
, ds_name
);
90 *nr_snapshot
= m
.DS_NR_SNAPSHOT
;
94 int ds_retrieve_label_name(char *ds_name
, endpoint_t endpoint
)
97 m
.DS_VAL
= (u32_t
) endpoint
;
98 r
= do_invoke_ds(DS_RETRIEVE_LABEL
, ds_name
);
102 int ds_retrieve_label_endpt(const char *ds_name
, endpoint_t
*endpoint
)
105 m
.DS_FLAGS
= DSF_TYPE_LABEL
;
106 r
= do_invoke_ds(DS_RETRIEVE
, ds_name
);
107 *endpoint
= (endpoint_t
) m
.DS_VAL
;
111 int ds_retrieve_u32(const char *ds_name
, u32_t
*value
)
114 m
.DS_FLAGS
= DSF_TYPE_U32
;
115 r
= do_invoke_ds(DS_RETRIEVE
, ds_name
);
120 static int ds_retrieve_raw(const char *ds_name
, char *vaddr
, size_t *length
,
126 /* Grant for memory range. */
127 gid
= cpf_grant_direct(DS_PROC_NR
, (vir_bytes
)vaddr
, *length
, CPF_WRITE
);
128 if(!GRANT_VALID(gid
))
132 m
.DS_VAL_LEN
= *length
;
134 r
= do_invoke_ds(DS_RETRIEVE
, ds_name
);
135 *length
= m
.DS_VAL_LEN
;
141 int ds_retrieve_str(const char *ds_name
, char *value
, size_t len_str
)
144 size_t length
= len_str
+ 1;
145 r
= ds_retrieve_raw(ds_name
, value
, &length
, DSF_TYPE_STR
);
146 value
[length
- 1] = '\0';
150 int ds_retrieve_mem(const char *ds_name
, char *vaddr
, size_t *length
)
152 return ds_retrieve_raw(ds_name
, vaddr
, length
, DSF_TYPE_MEM
);
155 int ds_delete_u32(const char *ds_name
)
157 m
.DS_FLAGS
= DSF_TYPE_U32
;
158 return do_invoke_ds(DS_DELETE
, ds_name
);
161 int ds_delete_str(const char *ds_name
)
163 m
.DS_FLAGS
= DSF_TYPE_STR
;
164 return do_invoke_ds(DS_DELETE
, ds_name
);
167 int ds_delete_mem(const char *ds_name
)
169 m
.DS_FLAGS
= DSF_TYPE_MEM
;
170 return do_invoke_ds(DS_DELETE
, ds_name
);
173 int ds_delete_label(const char *ds_name
)
175 m
.DS_FLAGS
= DSF_TYPE_LABEL
;
176 return do_invoke_ds(DS_DELETE
, ds_name
);
179 int ds_subscribe(const char *regexp
, int flags
)
182 return do_invoke_ds(DS_SUBSCRIBE
, regexp
);
185 int ds_check(char *ds_key
, int *type
, endpoint_t
*owner_e
)
188 r
= do_invoke_ds(DS_CHECK
, ds_key
);
189 if(type
) *type
= m
.DS_FLAGS
;
190 if(owner_e
) *owner_e
= m
.DS_OWNER
;