]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/commitdiff
rtems_test application: fixed required RTEMS configuration
authorPetr Benes <benesp16@fel.cvut.cz>
Sat, 3 Sep 2011 13:45:38 +0000 (15:45 +0200)
committerPetr Benes <benesp16@fel.cvut.cz>
Sat, 3 Sep 2011 13:45:38 +0000 (15:45 +0200)
Necessary to have CBS scheduler, POSIX maximum POSIX features configured,
file descriptors, file system, networking initialized.

Linking the application needs one overall static library called frsh-forb

src/rtems_tests/Makefile [new file with mode: 0644]
src/rtems_tests/Makefile.omk
src/rtems_tests/app_def.h
src/rtems_tests/init.c
src/rtems_tests/rootfs/tmp/ahoj.txt [new file with mode: 0644]
src/rtems_tests/system.h

diff --git a/src/rtems_tests/Makefile b/src/rtems_tests/Makefile
new file mode 100644 (file)
index 0000000..b22a357
--- /dev/null
@@ -0,0 +1,14 @@
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ;  while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd`  ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+       @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
index 66588c621b3d8e56a8a08bf3d727ca1aed3338a8..bd70ba828fcaac6fa6b3247833015b52465b989f 100644 (file)
@@ -1,18 +1,16 @@
 default_CONFIG += CONFIG_OC_BUILD4RTEMS=y
 default_CONFIG += CONFIG_OC_GDBSTUB=n
 
-bin_PROGRAMS = test_init
-
-#lib_LIBRARIES = 
+#LIBGCC_SYNC=yes
 
-#include_HEADERS = 
+bin_PROGRAMS = test_init
 
-test_init_SOURCES += init.c 
-#task.c
+test_init_SOURCES += init.c
 
-#test_init_EMBEDTARFILES = rootfs
+test_init_EMBEDTARFILES = rootfs
 
 #lib_LOADLIBES += bar
 
-test_init_LIBS = frm_rtemscpu frshrtemscpu frm fcb sharedobj synchobj frsh fra fra_dummy contract fna edf forb forbrun ulut fosa
+#test_init_LIBS = frm_rtemscpu frshrtemscpu frm fcb sharedobj synchobj frsh fra fra_dummy contract fna forb forbrun ulut fosa
+test_init_LIBS = frsh-forb
 
index 42416b7a459db59dcf18d59387d442eda599c219..e687cc86a22a3c2ffad26880f4b5d48f92bfc255 100644 (file)
 extern "C" {
 #endif
 
-//COND_EXTERN rtems_id   Task_1_id;           /* Task 1 id */
-//COND_EXTERN rtems_name Task_1_name;         /* Task 1 name */
+COND_EXTERN rtems_id   Task_1_id;           /* Task 1 id */
+COND_EXTERN rtems_name Task_1_name;         /* Task 1 name */
 
 //COND_EXTERN rtems_id   Task_2_id;           /* Task 2 id */
 //COND_EXTERN rtems_name Task_2_name;         /* Task 2 name */
 
 
-//rtems_task Task_1(
-//  rtems_task_argument argument
-//);
+rtems_task Task_1(
+  rtems_task_argument argument
+);
 //rtems_task Task_2(
 //  rtems_task_argument argument
 //);
index 951d5d203d5ffeeeb4c8633a10730173359291dc..7ff9376582c86d804be451bf2a425e877488b5b2 100644 (file)
@@ -1,25 +1,3 @@
-/*  Init
- *
- *  This routine is the initialization task for this test program.
- *  It is called from init_exec and has the responsibility for creating
- *  and starting the tasks that make up the test.  If the time of day
- *  clock is required for the test, it should also be set to a known
- *  value by this function.
- *
- *  Input parameters:  NONE
- *
- *  Output parameters:  NONE
- *
- *  COPYRIGHT (c) 1989-1999.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.com/license/LICENSE.
- *
- *  $Id: init.c,v 1.12.4.1 2003/09/04 18:46:30 joel Exp $
- */
-
 #define CONFIGURE_INIT
 #include "system_def.h"
 #include "system.h"
@@ -30,7 +8,36 @@
 #include <rtems/monitor.h>
 #include <rtems/shell.h>
 
+#include <errno.h>
 #include <frsh.h>
+#include <getopt.h>
+#include <ul_logreg.h>
+#include <ul_log.h>
+#include <rtems/rtems_bsdnet.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+
+
+struct rtems_bsdnet_config rtems_bsdnet_config = {
+    NULL,                   /* Network interface */
+    NULL,                   /* Use fixed network configuration */
+    0,                      /* Default network task priority */
+    0,                      /* Default mbuf capacity */
+    0,                      /* Default mbuf cluster capacity */
+    "testSystem",           /* Host name */
+    "nowhere.com",          /* Domain name */
+    "127.0.0.1",            /* Gateway */
+    "127.0.0.1",            /* Log host */
+    {"127.0.0.1" },         /* Name server(s) */
+    {"127.0.0.1" },         /* NTP server(s) */
+    0,
+    0,
+    0,
+    0,
+    0
+};
+
 
 
 #define BUILD_VERSION_STRING(major,minor,patch) \
           rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait)
 #endif
 
+//--------------------------
+#include <rtems/untar.h>
+
+extern int _binary_rootfs_tarfile_start;
+extern int _binary_rootfs_tarfile_size;
+#define TARFILE_START _binary_rootfs_tarfile_start
+#define TARFILE_SIZE _binary_rootfs_tarfile_size
+
+int setup_root_imfs (void) {
+   rtems_status_code status;
+   status = Untar_FromMemory((unsigned char *)(&TARFILE_START), (long)&TARFILE_SIZE);
+   printf("Untar_FromMemory returned %s\n",rtems_status_text(status));
+   return 0;
+}
+
+//--------------------------
+int ul_log_levels_forshell_cb(ul_log_domain_t *domain, void *context)
+{
+  char s[30];
+
+  s[sizeof(s)-1]=0;
+  printf("%s (%d)\n",domain->name, domain->level);
+  return 0;
+}
+
+int ul_log_levels_forshell(int argc, char **argv)
+{
+  int all_fl=0;
+  int res=0;
+  char *line;
+  line = argv[1];
+
+  if(argc<2) all_fl=1;
+  else if(!strcmp(line,"?")) all_fl=1;
+
+  if(all_fl) {
+    printf("Possible log domains are:\n");
+    ul_logreg_for_each_domain(ul_log_levels_forshell_cb, NULL);
+  } else {
+    res=ul_log_domain_arg2levels(line); // option: call this explicitly with "5" => debug mode
+  }
+
+  return res>=0?0:1;
+}
+
+//--------------------------
 void 
 bad_rtems_status(rtems_status_code status, int fail_level, const char *text)
 {
@@ -65,12 +118,58 @@ int testcmd_forshell(int argc, char **argv)
   return 0;
 }
 
+
+rtems_task Task_1(
+  rtems_task_argument argument
+)
+{
+       int ret;
+       unsigned long i = 0;
+       volatile int j;
+       frsh_vres_id_t vres_id;
+       frsh_rel_time_t budget;
+       frsh_rel_time_t period;
+
+       while(1) {
+               i++;
+               
+               for (j=0; j<1000000; j++);
+               
+               ret = frsh_thread_get_vres_id(fosa_thread_self(), &vres_id);
+               if (ret) PERROR_AND_EXIT(ret, "frsh_get_vres_id");
+
+               ret = frsh_vres_get_budget_and_period(vres_id, &budget, &period);
+               if (ret) PERROR_AND_EXIT(ret, "frsh_vres_get_budget_and_period");
+
+               printf("Consuming budget %ld ms - %lu\n",
+                      fosa_rel_time_to_msec(budget), i);
+       }
+
+       return;
+}
+
+
+
+#define MSEC(x) { x/1000, (x%1000) * 1000000 }
+frsh_utilization_set_t utilization_set = {
+       .size = 3,
+       .utilizations = {
+               { .budget = MSEC(10),  .period = MSEC(100),  .deadline = MSEC(100) },
+               { .budget = MSEC(20),  .period = MSEC(100),  .deadline = MSEC(100) },
+               { .budget = MSEC(30),  .period = MSEC(100),  .deadline = MSEC(100) },
+       },
+};
+
 rtems_task Init(
   rtems_task_argument ignored
 )
 {
-  rtems_status_code status;
-  int ret;
+       frsh_vres_id_t vres;
+       frsh_thread_attr_t attr;
+       frsh_thread_id_t thread;
+       frsh_contract_t contract;
+       int ret;
+       rtems_status_code status;
 
   printf( "\n\nRTEMS v "
           BUILD_VERSION_STRING(__RTEMS_MAJOR__ ,__RTEMS_MINOR__ ,__RTEMS_REVISION__)
@@ -82,9 +181,34 @@ rtems_task Init(
   printf( "Starting application " SW_VER_ID " v "
           BUILD_VERSION_STRING(SW_VER_MAJOR,SW_VER_MINOR,SW_VER_PATCH)
          "\n" );
+       
+  setup_root_imfs(); // file system
+
+  rtems_bsdnet_initialize_network();
   
-// Task 1 ==============================================  
-/*  Task_1_name = rtems_build_name( 'T', 'S', 'K', '1' );
+  ul_log_domain_arg2levels("5"); // log level
+  
+  rtems_shell_init("SHLL",RTEMS_MINIMUM_STACK_SIZE+0x1000,
+              SHELL_TASK_PRIORITY,"/dev/console",1,0, NULL);
+
+  rtems_shell_add_cmd("testcmd", "app",
+                "test command for shell",
+                testcmd_forshell);
+
+  rtems_shell_add_cmd("loglevel", "app",
+                "set log level for specific domain",
+                 ul_log_levels_forshell);
+                
+  rtems_monitor_wakeup();
+
+  printf("POSIX: m %d, c %d \n", Configuration_POSIX_API.maximum_mutexes, 
+                                Configuration_POSIX_API.maximum_condition_variables);
+//  status = rtems_task_delete( RTEMS_SELF );
+  
+       ret = frsh_init();
+       if (ret) PERROR_AND_EXIT(ret, "frsh_init");
+       
+  Task_1_name = rtems_build_name( 'T', 'W', 'R', 'K' );
 
   status = rtems_task_create(
      Task_1_name,
@@ -97,41 +221,60 @@ rtems_task Init(
   check_rtems_status(status, 0, "rtems_task_create of Task_1");
   status = rtems_task_start( Task_1_id, Task_1, 0 );
   check_rtems_status(status, 0, "rtems_task_start of Task_1\n");
-*/
-  
-// Task 2 ==============================================  
-/*  Task_2_name = rtems_build_name( 'T', 'S', 'K', '2' );
-  
-  status = rtems_task_create(
-     Task_2_name,
-     TASK_2_PRIORITY,
-     RTEMS_MINIMUM_STACK_SIZE+0x10000,
-     RTEMS_DEFAULT_MODES & ~(RTEMS_TIMESLICE_MASK) | RTEMS_TIMESLICE,
-     RTEMS_DEFAULT_ATTRIBUTES,
-     &Task_2_id
-  );  
-  
-  check_rtems_status(status, 0, "rtems_task_create of Task_2");
 
 
-  status = rtems_task_start( Task_2_id, Task_2, 0 );
-  check_rtems_status(status, 0, "rtems_task_start of Task_2\n");
-*/
-//  ====================================================
+       
+       /* Contract negotiation for CPU */
+       ret = frsh_contract_init(&contract);
+       if (ret) PERROR_AND_EXIT(ret, "frsh_contract_init");
 
-  ret = frsh_init();
-  
-  rtems_shell_init("SHLL",RTEMS_MINIMUM_STACK_SIZE+0x1000,
-              SHELL_TASK_PRIORITY,"/dev/console",1,0, NULL);
+       int variant = 0;
+       bool first = true;
+       while (1) {
+               
+               ret = frsh_contract_set_basic_params(&contract,
+                                                    &utilization_set.utilizations[variant].budget,
+                                                    &utilization_set.utilizations[variant].period,
+                                                    FRSH_WT_BOUNDED,
+                                                    FRSH_CT_REGULAR);
+               if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_basic_params");
 
-  rtems_shell_add_cmd("testcmd", "app",
-                "test command for shell",
-                testcmd_forshell);
+               ret = frsh_contract_set_resource_and_label(&contract, FRSH_RT_PROCESSOR,
+                                                          FRSH_CPU_ID_DEFAULT, "renegotiation test");
+               if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_resource_and_label");
 
-  //rtems_monitor_wakeup();
+               if (first) {
+                       ret = frsh_contract_negotiate(&contract, &vres);
+                       if (ret) PERROR_AND_EXIT(ret, "frsh_contract_negotiate");
+
+                       printf("Aqcpu vres negotiated, vres-ID: %p\n", vres);
+                       pthread_attr_init(&attr); //FIXME: fosa
+                       ret = frsh_thread_create_and_bind(vres, &thread, &attr, 
+                                                         (void*) NULL, (void*) NULL);
+                       if (ret) PERROR_AND_EXIT(ret, "frsh_thread_create_and_bind");
+                       first = false;
+               } else {
+                       ret = frsh_contract_renegotiate_sync(&contract, vres);
+                       if (ret == 0) {
+                               printf("Renegotiation accepted\n");
+                       } else if (ret == FRSH_ERR_CONTRACT_REJECTED) {
+                               printf("Renegotiaton REJECTED\n");
+                       } else
+                               PERROR_AND_EXIT(ret, "frsh_contract_renegotiate_sync");
+               }
+               sleep(5);
+               variant++;
+               if (variant >= utilization_set.size) variant = 0;
+       }
+       
+       pthread_join(thread.pthread_id, (void**) NULL); //FIXME:fosa
+
+       ret = frsh_contract_cancel(vres);
+       if (ret) PERROR_AND_EXIT(ret, "frsh_contract_cancel");
 
   status = rtems_task_delete( RTEMS_SELF );
   
   printf( "*** END OF TEST3 ***\n" );
-  exit( 0 );
+  exit( 0 );   
 }
+
diff --git a/src/rtems_tests/rootfs/tmp/ahoj.txt b/src/rtems_tests/rootfs/tmp/ahoj.txt
new file mode 100644 (file)
index 0000000..36a0e7c
--- /dev/null
@@ -0,0 +1 @@
+ahoj
index ce940f80cd5c74ffd3315c526ff708bbd5b85032..22a6e6daa99683f9376d388bf58813f59a7a26da 100644 (file)
@@ -37,13 +37,16 @@ rtems_task Init(
 #define CONFIGURE_MAXIMUM_TASKS                  32
 #define CONFIGURE_MAXIMUM_PERIODS                4
 #define CONFIGURE_MAXIMUM_USER_EXTENSIONS        2
-#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 100
+#define CONFIGURE_NUMBER_OF_TERMIOS_PORTS        10
 #define CONFIGURE_MAXIMUM_DRIVERS (CONFIGURE_NUMBER_OF_DRIVERS+10)
 
 #ifdef RTEMS_POSIX_API
 #define CONFIGURE_MAXIMUM_POSIX_THREADS          32
-#define CONFIGURE_MAXIMUM_POSIX_MUTEXES          20
+#define CONFIGURE_MAXIMUM_POSIX_MUTEXES          30
 #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES       10
+#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 20
+#define CONFIGURE_MAXIMUM_POSIX_KEYS             5
 #endif /*RTEMS_POSIX_API*/
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
@@ -82,19 +85,7 @@ rtems_task Init(
  */
                 
 /// Enable yur own scheduler
-#define CONFIGURE_SCHEDULER_USER
-
-/**
- *  EDF scheduler configuration.
- */
-#ifdef CONFIGURE_SCHEDULER_USER
-       #define CONFIGURE_SCHEDULER_USER_ENTRY_POINTS 
-       #include "scheduler_edf.h"
-       #define SCHEDULER_ENTRY_POINTS SCHEDULER_EDF_ENTRY_POINTS
-       #define CONFIGURE_MEMORY_FOR_SCHEDULER (_Configure_From_workspace(sizeof(EDF_Chain_Control)))
-       #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER (_Configure_From_workspace(sizeof(RBT_Node)))
-#endif
-
+#define CONFIGURE_SCHEDULER_CBS
 
 
 #include <rtems/confdefs.h>