Exemplo n.º 1
0
static void mmal_port_name_update(MMAL_PORT_T *port)
{
   MMAL_PORT_PRIVATE_CORE_T* core = port->priv->core;

   vcos_snprintf(core->name, core->name_size - 1, PORT_NAME_FORMAT,
            port->component->name, mmal_port_type_to_string(port->type), (int)port->index,
            port->format && port->format->encoding ? '(' : '\0',
            port->format && port->format->encoding ? (char *)&port->format->encoding : "");
}
Exemplo n.º 2
0
void
vchiq_dump_platform_state(void *dump_context)
{
        char buf[80];
        int len;
        len = vcos_snprintf(buf, sizeof(buf),
                "  Platform: 2835 (VC master)");
        vchiq_dump(dump_context, buf, len + 1);
}
Exemplo n.º 3
0
/** Create an endpoint. Each thread should need no more than one of these - if you 
  * find yourself needing a second one, you've done something wrong.
  */
VCOS_STATUS_T vcos_msgq_endpoint_create(VCOS_MSG_ENDPOINT_T *ep, const char *name)
{
   VCOS_STATUS_T st;
   if (strlen(name) > sizeof(ep->name)-1)
      return VCOS_EINVAL;
   vcos_snprintf(ep->name, sizeof(ep->name), "%s", name);

   st = vcos_msgq_create(&ep->primary);
   if (st == VCOS_SUCCESS)
   {
      st = vcos_msgq_create(&ep->secondary);
   }

   if (st != VCOS_SUCCESS)
   {
      vcos_msgq_delete(&ep->primary);
   }
   else
   {
      VCOS_ENDPOINT_WAITER_T **pwaiter;
      vcos_mutex_lock(&lock);
      ep->next = endpoints;
      endpoints = ep;
      vcos_tls_set(tls_key,ep);

      /* is anyone waiting for this endpoint to come into existence? */
      for (pwaiter = &waiters; *pwaiter != NULL;)
      {
         VCOS_ENDPOINT_WAITER_T *waiter = *pwaiter;
         if (vcos_strcasecmp(waiter->name, name) == 0)
         {
            *pwaiter = waiter->next;
            vcos_semaphore_post(&waiter->sem);
         }
         else
            pwaiter = &(*pwaiter)->next;
      }
      vcos_mutex_unlock(&lock);
   }
   return st;
}
VCOS_STATUS_T
vcos_win32_named_semaphore_create(VCOS_NAMED_SEMAPHORE_T *sem, const char *name, VCOS_UNSIGNED count)
{
   char buf[64];
   HANDLE h;
   int ret = vcos_snprintf(buf, sizeof(buf), "Global\\%s", name);
   if (ret < 0)
   {
      vcos_assert(0);
      return VCOS_ENOSPC;
   }

   h = CreateSemaphoreA(NULL, count, 1<<16, buf);
   if (h != NULL)
   {
      sem->sem = h;
      return VCOS_SUCCESS;
   }
   else
      return vcos_win32_map_error();
}
Exemplo n.º 5
0
void vcos_log_dump_mem_impl( const VCOS_LOG_CAT_T *cat,
                             const char           *label,
                             uint32_t              addr,
                             const void           *voidMem,
                             size_t                numBytes )
{
   const uint8_t  *mem = (const uint8_t *)voidMem;
   size_t          offset;
   char            lineBuf[ 100 ];
   char           *s;

   while ( numBytes > 0 )
   {
       s = lineBuf;

       for ( offset = 0; offset < 16; offset++ )
       {
           if ( offset < numBytes )
           {
               s += vcos_snprintf( s, 4, "%02x ", mem[ offset ]);
           }
           else
           {
               s += vcos_snprintf( s, 4, "   " );
           }
       }

       for ( offset = 0; offset < 16; offset++ )
       {
           if ( offset < numBytes )
           {
               uint8_t ch = mem[ offset ];

               if (( ch < ' ' ) || ( ch > '~' ))
               {
                   ch = '.';
               }
               *s++ = (char)ch;
           }
       }
       *s++ = '\0';

       if (( label != NULL ) && ( *label != '\0' ))
       {
          vcos_log_impl( cat, VCOS_LOG_INFO, "%s: %08" PRIx32 ": %s", label, addr, lineBuf );
       }
       else
       {
          vcos_log_impl( cat, VCOS_LOG_INFO, "%08" PRIx32 ": %s", addr, lineBuf );
       }

       addr += 16;
       mem += 16;
       if ( numBytes > 16 )
       {
           numBytes -= 16;
       }
       else
       {
           numBytes = 0;
       }
   }

}
VCOS_STATUS_T khronos_platform_semaphore_create(PLATFORM_SEMAPHORE_T *sem, int name[3], int count)
{
   char buf[64];
   vcos_snprintf(buf,sizeof(buf),"KhanSemaphore%08x%08x%08x", name[0], name[1], name[2]);
   return vcos_named_semaphore_create(sem, buf, count);
}