コード例 #1
0
ファイル: vcos_pthreads.c プロジェクト: ms-iot/userland
VCOS_STATUS_T vcos_platform_init(void)
{
   VCOS_STATUS_T st;
   uint32_t flags = 0;

   st = _vcos_named_semaphore_init();
   if (!vcos_verify(st == VCOS_SUCCESS))
      goto end;

   flags |= VCOS_INIT_NAMED_SEM;

   st = vcos_once(&current_thread_key_once, current_thread_key_init);
   if (!vcos_verify(st == VCOS_SUCCESS))
      goto end;

   /* Initialise a VCOS wrapper for the thread which called vcos_init. */
   st = vcos_semaphore_create(&vcos_thread_main.suspend, NULL, 0);
   if (!vcos_verify(st == VCOS_SUCCESS))
      goto end;

   flags |= VCOS_INIT_MAIN_SEM;

#ifdef WIN32_KERN 
   vcos_thread_main.thread = PsGetCurrentThreadId();

   // TODO Implement thread context for kernel mode
#else
   int pst;

   vcos_thread_main.thread = GetCurrentThread();

   // For windows zero return value is failure
   pst = TlsSetValue(_vcos_thread_current_key, &vcos_thread_main);
   if (!vcos_verify(pst != 0))
   {
       st = VCOS_EINVAL;
       goto end;
   }
#endif

   st = vcos_msgq_init();
   if (!vcos_verify(st == VCOS_SUCCESS))
      goto end;

   flags |= VCOS_INIT_MSGQ;

   vcos_logging_init();

end:
   if (st != VCOS_SUCCESS)
      vcos_term(flags);

   return st;
}
コード例 #2
0
VCOS_STATUS_T vcos_init(void)
{
   VCOS_STATUS_T status;

   status = _vcos_thread_create_attach(&vcos_none_vpu0_thread, "vpu0");
   if (status != VCOS_SUCCESS)
      return status;

   vcos_none_vpu1_thread = NULL;

   vcos_none_spinlock_claim[0] = 0;
   vcos_none_spinlock_claim[1] = 0;

   vcos_logging_init();

   return VCOS_SUCCESS;
}
コード例 #3
0
VCOS_STATUS_T vcos_init(void)
{
   if ( vcos_cfg_mkdir( &vcos_cfg_dir, NULL, "vcos" ) != VCOS_SUCCESS )
   {
      printk( KERN_ERR "%s: Unable to create vcos cfg entry\n", __func__ );
   }
   vcos_logging_init();

#ifdef HAVE_VCOS_VERSION
   if ( vcos_cfg_create_entry( &vcos_version_cfg, &vcos_cfg_dir, "version",
                               show_version, NULL, NULL ) != VCOS_SUCCESS )
   {
      printk( KERN_ERR "%s: Unable to create vcos cfg entry 'version'\n", __func__ );
   }
#endif

   return VCOS_SUCCESS;
}
コード例 #4
0
VCOS_STATUS_T vcos_platform_init(void)
{
   VCOS_STATUS_T st;
   uint32_t flags = 0;
   int pst;

   st = _vcos_named_semaphore_init();
   if (!vcos_verify(st == VCOS_SUCCESS))
      goto end;

   flags |= VCOS_INIT_NAMED_SEM;

#ifdef HAVE_MTRACE
   /* enable glibc memory debugging, if the environment
    * variable MALLOC_TRACE names a valid file.
    */
   mtrace();
#endif

#ifdef ANDROID
   st = vcos_mutex_create(&printf_lock, "printf");
   if (!vcos_verify(st == VCOS_SUCCESS))
      goto end;

   flags |= VCOS_INIT_PRINTF_LOCK;
#endif

   st = vcos_once(&current_thread_key_once, current_thread_key_init);
   if (!vcos_verify(st == VCOS_SUCCESS))
      goto end;

   /* Initialise a VCOS wrapper for the thread which called vcos_init. */
   st = vcos_semaphore_create(&vcos_thread_main.suspend, NULL, 0);
   if (!vcos_verify(st == VCOS_SUCCESS))
      goto end;

   flags |= VCOS_INIT_MAIN_SEM;

   vcos_thread_main.thread = pthread_self();

   pst = pthread_setspecific(_vcos_thread_current_key, &vcos_thread_main);
   if (!vcos_verify(pst == 0))
   {
      st = VCOS_EINVAL;
      goto end;
   }

   st = vcos_msgq_init();
   if (!vcos_verify(st == VCOS_SUCCESS))
      goto end;

   flags |= VCOS_INIT_MSGQ;

   vcos_logging_init();

end:
   if (st != VCOS_SUCCESS)
      vcos_term(flags);

   return st;
}