]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
Added frsh_resource.c
authorMartin Molnar <molnam1@fel.cvut.cz>
Wed, 9 Jul 2008 00:20:02 +0000 (02:20 +0200)
committerMartin Molnar <molnam1@fel.cvut.cz>
Wed, 9 Jul 2008 00:20:02 +0000 (02:20 +0200)
frsh/frsh_contract.h
frsh/frsh_resource.c [new file with mode: 0644]
frsh/frsh_resource.h

index 0483dd2ae7df150e68d690ad62bd6015319ce3b9..860abd62c4fdffc6c78940371f1a2d9b805ccbaa 100644 (file)
@@ -11,17 +11,22 @@ typedef struct frsh_contract_params {
        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 */
diff --git a/frsh/frsh_resource.c b/frsh/frsh_resource.c
new file mode 100644 (file)
index 0000000..92e7c66
--- /dev/null
@@ -0,0 +1,20 @@
+#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;
+}
index b2ea10d10e42ae6001a81f910f646247f6a1153b..55c7b0036869b1d8a7a5de2112397a6b4eb20a83 100644 (file)
@@ -9,20 +9,21 @@
 #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 */