]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Start of integration with FRSH API
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 12 Sep 2008 14:31:54 +0000 (16:31 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 12 Sep 2008 14:31:54 +0000 (16:31 +0200)
Makefile.omk
contract.c
contract.h
contract_internal.h [new file with mode: 0644]
frsh_contract.c [new file with mode: 0644]
frsh_opaque_types.h [new file with mode: 0644]

index 7eb64efcf4b624c1abc96204e3c42d3635bbb7c3..88ebbc640889483cf853219329f64a27373304c8 100644 (file)
@@ -1,6 +1,12 @@
+default_CONFIG = CONFIG_FRSH_FORB=y
+
+ifeq ($(CONFIG_FRSH_FORB),y)
 shared_LIBRARIES = frsh
 
-frsh_SOURCES = contract.c
+frsh_SOURCES = contract.c frsh_contract.c
 frsh_CLIENT_IDL = contract-idl.idl
 
+include_HEADERS = contract.h frsh_opaque_types.h
+
 include_GEN_HEADERS = contract-idl.h
+endif
index 35183f25ea85efd5e5666c2f87048d425b5043b2..661157095ce64f6792a496485b1faaf84fb1dc11 100644 (file)
@@ -1,12 +1,10 @@
-#include "contract.h"
+#include <contract.h>
+#include "contract_internal.h"
 #include <stdbool.h>
 #include <ul_list.h>
 #include <string.h>
 #include <frsh_error.h>
 
-#define TYPE_VALID(type)                       \
-       ((type) < _FRSH_CONTRACT_NUM_PARAMS &&  \
-        (type) >= 0)
 
 struct contract *
 contract_new(void)
@@ -97,7 +95,9 @@ contract_serialize(CDR_Codec *codec, const struct contract *contract)
                        count++;
        }
 
-       CORBA_long_serialize(codec, &count);
+       if (!CORBA_long_serialize(codec, &count))
+               goto err;
+       
        for (i=0; i<_FRSH_CONTRACT_NUM_PARAMS; i++) {
                if (contract->parts[i].state != CONTRACT_PART_EMPTY) {
                        s = i;
@@ -105,54 +105,8 @@ contract_serialize(CDR_Codec *codec, const struct contract *contract)
                        
                }
        }
-
-}
-
-
-/**********************************/
-/* -----===== FRSH API =====----- */
-/**********************************/
-
-int
-frsh_contract_init(frsh_contract_t *contract)
-{
-       struct frsh_contract *c;
-
-       if (!contract) {
-               return FRSH_ERR_BAD_ARGUMENT;
-       }
-       *contract = c = contract_new();
-       if (!c) {
-               return FOSA_ENOMEM;
-       }
-       
-       
-       return 0;
-}
-
-int frsh_contract_set_resource_and_label
-  (frsh_contract_t *contract,
-   const frsh_resource_type_t resource_type,
-   const frsh_resource_id_t resource_id,
-   const char *contract_label)
-{
-       struct contract *c = *contract;
-       if (!c)
-               return FRSH_ERR_BAD_ARGUMENT;
-       
-       c->resource_type = resource_type;
-       c->resource_id = resource_id;
-       /* contract_label is currently ignored */
-       return 0;
+       return CORBA_TRUE;
+err:
+       return CORBA_FALSE;
 }
 
-/* int frsh_contract_set_timing_reqs */
-/*   (frsh_contract_t *contract, */
-/*    const bool                   d_equals_t, */
-/*    const frsh_rel_time_t        *deadline, */
-/*    const frsh_signal_t          budget_overrun_signal, */
-/*    const frsh_signal_info_t     budget_overrun_siginfo, */
-/*    const frsh_signal_t          deadline_miss_signal, */
-/*    const frsh_signal_info_t     deadline_miss_siginfo); */
-/* { */
-/* } */
index f2fb740b13a273e9900f65df11007719c496c58b..f933f040af1d002e71871542893a8eea49469b49 100644 (file)
@@ -1,34 +1,19 @@
 #ifndef CONTRACT_H
 #define CONTRACT_H
 
+
 #include <forb/basic_types.h>
-#include <fosa_platform_values.h>
+#include <frsh_cpp_macros.h>
+#include <fosa_types.h>
+#include <frsh_core_types.h>
 #include <contract-idl.h>
 
-/*================ From frsh_code_types.h ====================================*/
-
-/** Contract ressource type:  processor, network, memory **/
-typedef enum {
-    FRSH_RT_PROCESSOR = 0,
-    FRSH_RT_NETWORK   = 1,
-    FRSH_RT_MEMORY    = 2,
-    FRSH_RT_DISK      = 3
-} frsh_resource_type_t;
-
-/** Ressource Id: processor_id or network_id **/
-/**********************************************/
-typedef fosa_resource_id_t frsh_resource_id_t;
-
-/** Kind of contract: regular, background or dummy **/
-typedef enum {
-        FRSH_CT_REGULAR    = 0,
-        FRSH_CT_BACKGROUND = 1,
-        FRSH_CT_DUMMY      = 2
-} frsh_contract_type_t;
-
 /*============================================================================*/
 
-typedef struct contract *frsh_contract_t;
+/**
+ * Incomplete declaration of contract type
+ */
+struct contract;
 
 enum contract_part_type {
        FRSH_CONTRACT_BASIC_PARAMS,
@@ -36,30 +21,6 @@ enum contract_part_type {
        _FRSH_CONTRACT_NUM_PARAMS
 };
 
-enum contract_part_state {
-       CONTRACT_PART_EMPTY,
-       CONTRACT_PART_DATA,
-       CONTRACT_PART_STREAM
-};
-
-struct contract_part {
-       enum contract_part_state state;
-       union {
-               void *data; /**< Pointer to data according to part_type */
-               stream seq;
-       } u;
-};
-
-struct contract {
-       /** Processor Id or Network Id **/
-       frsh_resource_id_t   resource_id;
-
-       /** Whether processor or network **/
-       frsh_resource_type_t resource_type;
-
-       struct contract_part parts[_FRSH_CONTRACT_NUM_PARAMS];
-};
-
 struct contract *
 contract_new(void);
 
diff --git a/contract_internal.h b/contract_internal.h
new file mode 100644 (file)
index 0000000..fd851ae
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef CONTRACT_INTERNAL_H
+#define CONTRACT_INTERNAL_H
+
+enum contract_part_state {
+       CONTRACT_PART_EMPTY,
+       CONTRACT_PART_DATA,
+       CONTRACT_PART_STREAM
+};
+
+struct contract_part {
+       enum contract_part_state state;
+       union {
+               void *data; /**< Pointer to data according to part_type */
+               stream seq;
+       } u;
+};
+
+struct contract {
+       /** Processor Id or Network Id **/
+       frsh_resource_id_t   resource_id;
+
+       /** Whether processor or network **/
+       frsh_resource_type_t resource_type;
+
+       struct contract_part parts[_FRSH_CONTRACT_NUM_PARAMS];
+};
+
+#define TYPE_VALID(type)                       \
+       ((type) < _FRSH_CONTRACT_NUM_PARAMS &&  \
+        (type) >= 0)
+
+
+#endif
diff --git a/frsh_contract.c b/frsh_contract.c
new file mode 100644 (file)
index 0000000..9959013
--- /dev/null
@@ -0,0 +1,54 @@
+#include <contract.h>
+#include "contract_internal.h"
+#include <frsh_core.h>
+#include <frsh_error.h>
+
+
+/**********************************/
+/* -----===== FRSH API =====----- */
+/**********************************/
+
+int
+frsh_contract_init(frsh_contract_t *contract)
+{
+       struct contract *c;
+
+       if (!contract) {
+               return FRSH_ERR_BAD_ARGUMENT;
+       }
+       c = contract_new();
+       *contract = c;
+       if (!c) {
+               return FOSA_ENOMEM;
+       }
+       
+       
+       return 0;
+}
+
+int frsh_contract_set_resource_and_label
+  (frsh_contract_t *contract,
+   const frsh_resource_type_t resource_type,
+   const frsh_resource_id_t resource_id,
+   const char *contract_label)
+{
+       struct contract *c = *contract;
+       if (!c)
+               return FRSH_ERR_BAD_ARGUMENT;
+       
+       c->resource_type = resource_type;
+       c->resource_id = resource_id;
+       /* contract_label is currently ignored */
+       return 0;
+}
+
+int frsh_contract_set_timing_reqs
+  (frsh_contract_t *contract,
+   const bool                   d_equals_t,
+   const frsh_rel_time_t        *deadline,
+   const frsh_signal_t          budget_overrun_signal,
+   const frsh_signal_info_t     budget_overrun_siginfo,
+   const frsh_signal_t          deadline_miss_signal,
+   const frsh_signal_info_t     deadline_miss_siginfo)
+{
+}
diff --git a/frsh_opaque_types.h b/frsh_opaque_types.h
new file mode 100644 (file)
index 0000000..4c1c4cb
--- /dev/null
@@ -0,0 +1,137 @@
+// -----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2008 FRESCOR consortium partners:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politécnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    Visual Tools S.A.                      SPAIN
+//    Rapita Systems Ltd                     UK
+//    Evidence                               ITALY
+//
+//    See http://www.frescor.org for a link to partners' websites
+//
+//           FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//
+//  based on previous work (FSF) done in the FIRST project
+//
+//   Copyright (C) 2005  Mälardalen University, SWEDEN
+//                       Scuola Superiore S.Anna, ITALY
+//                       Universidad de Cantabria, SPAIN
+//                       University of York, UK
+//
+//   FSF API web pages: http://marte.unican.es/fsf/docs
+//                      http://shark.sssup.it/contrib/first/docs/
+//
+//   This file is part of FRSH_FORB (FRescor ScHeduler based on FORB)
+//
+//  FRSH is free software; you can redistribute it and/or modify it
+//  under terms of the GNU General Public License as published by the
+//  Free Software Foundation; either version 2, or (at your option) any
+//  later version.  FRSH is distributed in the hope that it will be
+//  useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+//  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//  General Public License for more details. You should have received a
+//  copy of the GNU General Public License along with FRSH; see file
+//  COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
+//  Cambridge, MA 02139, USA.
+//
+//  As a special exception, including FRSH header files in a file,
+//  instantiating FRSH generics or templates, or linking other files
+//  with FRSH objects to produce an executable application, does not
+//  by itself cause the resulting executable application to be covered
+//  by the GNU General Public License. This exception does not
+//  however invalidate any other reasons why the executable file might be
+//  covered by the GNU Public License.
+// -----------------------------------------------------------------------
+//frsh_opaque_types.h
+//==============================================
+//  ******** *******    ********  **      **
+//  **///// /**////**  **//////  /**     /**
+//  **      /**   /** /**        /**     /**
+//  ******* /*******  /********* /**********
+//  **////  /**///**  ////////** /**//////**
+//  **      /**  //**        /** /**     /**
+//  **      /**   //** ********  /**     /**
+//  //       //     // ////////   //      // 
+//
+// FRSH(FRescor ScHeduler), pronounced "fresh"
+//==============================================
+
+// Implementation dependent definitions
+#ifndef _FRSH_OPAQUE_TYPES_H_
+#define _FRSH_OPAQUE_TYPES_H_
+
+#include <contract.h>
+
+FRSH_CPP_BEGIN_DECLS
+
+/**
+ * @file frsh_opaque_types.h
+ **/
+
+/**
+ * @defgroup opaque Opaque types
+ *
+ * This module specifies some #defines for privates types in the
+ * interface.  In this way we warn the FRSH user never to access the internal
+ * members of the types directly allowing us to change their internal
+ * definitions to suit our needs.
+ *
+ * Note that in Ada the FRSH user would never be allowed to access the
+ * members directly, however in C the compiler does not prevent this.
+ * But this is the best we can do in this language.
+ *
+ * @{
+ **/
+
+/** frsh_contract_parameters_t **/
+#define FRSH_CONTRACT_T_OPAQUE struct contract *
+
+
+typedef int FRSH_SYNCHOBJ_HANDLE_T_OPAQUE;
+
+typedef int FRSH_SHAREDOBJ_HANDLE_T_OPAQUE;
+
+/**
+ * Critical section data
+ * - comon parameters
+ *     op_kind;     // kind of operation (READ or WRITE)
+ *     obj_handle;  // handle to shared object
+ *     wcet;        // Execution time
+ *     blocking;    // Blocking time (execution time + protection overheads)
+ * - attributes used only for protected shared objects
+ *     op;          // pointer to the operation
+ * - attributes used only for protected write operations
+ *     areas;       // memory areas to be protected
+ * 
+ **/
+#define FRSH_CSECT_T_OPAQUE struct { \
+  frsh_csect_op_kind_t op_kind;                 \
+  frsh_sharedobj_handle_t obj_handle;               \
+  frsh_rel_time_t wcet;                              \
+  frsh_rel_time_t blocking;                              \
+  frsh_csect_op_t op;                           \
+  frsh_memory_areas_t areas;                         \
+  frsh_memory_areas_t storage;                         \
+}
+
+
+//opaque types for frsh endpoints
+typedef int FRSH_SEND_ENDPOINT_T_OPAQUE;
+
+typedef int FRSH_RECEIVE_ENDPOINT_T_OPAQUE;
+
+/*@}*/
+
+FRSH_CPP_END_DECLS
+
+#endif // _FRSH_OPAQUE_TYPES_H_