frsh_period_t period;
} frsh_contract_params_t;
+typedef frsh_contract{
+ frsh_resource_type type;
+ frsh_vres_d_t vresd;
+ frsh_contract_status_t status;
+} frsh_contract_t;
+
typedef frsh_contract_t* frsh_contract_d_t;
typedef struct frsh_contract_ops {
- /*frsh_contract_d_t* (*create)(frsh_resource_t* resource);*/
int (*reserve)(frsh_contract_params_t* params,
frsh_contract_d_t* contractdp);
int (*commit)(frsh_contract_d_t contractd);
/* just for compability, combination of previous functions */
int (*negotiate)(frsh_contract_params_t* params,
frsh_contract_d_t* contractdp);
- int (*create_vres)(frsh_contract_d_t contractd, frsh_vresd_t* vresdp);
+ int (*get_vres)(frsh_contract_d_t contractd, frsh_vres_d_t* vresdp);
}
#endif /* FRSH_CONTRACT_H */
--- /dev/null
+#include "frsh_resource.h"
+
+frsh_resource_t* frsh_resources[FRSH_RESOURCE_NUM+1];
+
+int frsh_resource_register(frsh_resource_type_t type, frsh_resource_t* resource)
+{
+ if (frsh_resources[type]) {
+ errno = EPERM;
+ return (-errno);
+ } else
+ frsh_resources[type] = resource;
+
+ return 0;
+}
+
+int frsh_resource_unregister(frsh_resource_type_t type)
+{
+ frsh_resources[type] = NULL;
+ return 0;
+}
#ifndef _FRSH_RESOURCE_H
#define _FRSH_RESOURCE_H
-typedef struct frsh_resource_id {
- unsigned int type; /* cpu, wlan */
- unsigned int unit; /* 0, 1, 2 */
-} frsh_resource_id_t;
+#define FRSH_RESOURCE_NUM 5
+
+typedef enum {
+ FRSH_CPU = 1,
+ FRSH_MEMORY = 2,
+ FRSH_DISK = 3,
+ FRSH_CAN = 4,
+ FRSH_WIFI = 5,
+} frsh_resource_type;
typedef struct frsh_resource {
- frsh_resource_id_t id;
frsh_contract_ops_t *contract_ops;
} frsh_resource_t;
-/* Resource descriptor
- * ( Yes , we could just use frsh_resource_t* but in case of changes
- * in API ..)
- **/
-typedef frsh_resource_t* frsh_resource_d_t;
+int frsh_resource_register(frsh_resource_type_t type, frsh_resource_t* resource);
+int frsh_resource_unregister(frsh_resource_type_t type);
#endif /* _FRSH_RESOURCE_H */