Esempio n. 1
0
NOSSEMA_t POSCALL nosSemaCreate(INT_t initcount, UVAR_t options, 
                                const char *name)
{
  POSSEMA_t sem;
  REGELEM_t re;

  re = nos_regNewSysKey(REGTYPE_SEMAPHORE,
                        name == NULL ? (const char*)"s*" : name);
  if (re == NULL)
    return NULL;

  (void) options;
  sem = posSemaCreate(initcount);

  if (sem == NULL)
  {
    nos_regDelSysKey(REGTYPE_SEMAPHORE, NULL, re);
  }
  else
  {
    nos_regEnableSysKey(re, sem);
    POS_SETEVENTNAME(sem, re->name);
  }
  return (NOSSEMA_t) sem;
}
Esempio n. 2
0
void netInit()
{
  POSTASK_t t;
  int i;

  uipGiant = posSemaCreate(0);
  uipMutex = posMutexCreate();

  pollTicks = INFINITE;
  P_ASSERT("netInit", uipGiant != NULL && uipMutex != NULL);

  POS_SETEVENTNAME(uipGiant, "uip:giant");
  POS_SETEVENTNAME(uipMutex, "uip:mutex");

// uosFS setup

  netFS.base.mountPoint = "/socket";
  netFS.base.cf = &netFSConf;
 
  uosMount(&netFS.base);
  
// Initialize contiki-style timers (used by uip code)

  etimer_init();

  dataToSend = 0;

  for(i = 0; i < UIP_CONNS; i++)
    uip_conns[i].appstate.file = NULL;

#if UIP_UDP
  for(i = 0; i < UIP_UDP_CONNS; i++)
    uip_udp_conns[i].appstate.file = NULL;
#endif /* UIP_UDP */

  netInterfaceInit();
  uip_init();

#if NETSTACK_CONF_WITH_IPV6 == 0
  uip_arp_init();
#endif

  t = posTaskCreate(netMainThread, NULL, NETCFG_TASK_PRIORITY, NETCFG_STACK_SIZE);
  P_ASSERT("netInit2", t != NULL);
  POS_SETTASKNAME(t, "uip:main");
}
Esempio n. 3
0
void POSCALL nos_initRegistry(void)
{
  NOSREGTYPE_t  rt;

  reglist_free_g = NULL;
  reglist_sema_g = posSemaCreate(1);
  while (reglist_sema_g == NULL);
  POS_SETEVENTNAME(reglist_sema_g, "registry sync");

  for (rt = MIN_REGTYPE; rt <= MAX_REGTYPE; ++rt)
    reglist_syselem_g[rt] = NULL;
}
Esempio n. 4
0
UosFile* netSockAlloc(NetSockState initialState)
{
  int      slot;

  UosFile* file = uosFileAlloc();
  if (file == NULL)
    return NULL;

  slot = UOS_BITTAB_ALLOC(netSocketTable);
  if (slot == -1) {

    uosFileFree(file);
    nosPrintf("netSockAlloc: table full\n");
    return NULL;
  }

  NetSock* sock = UOS_BITTAB_ELEM(netSocketTable, slot);
  sock->state = initialState;
  sock->mutex = posMutexCreate();
  sock->sockChange = posFlagCreate();
  sock->uipChange = posFlagCreate();
  sock->timeout = INFINITE;
  sock->buf = NULL;
  sock->len = 0;
  sock->max = 0;

  P_ASSERT("netSockAlloc", sock->mutex != NULL && sock->sockChange != NULL && sock->uipChange != NULL);

  POS_SETEVENTNAME(sock->mutex, "sock:mutex");
  POS_SETEVENTNAME(sock->sockChange, "sock:api");
  POS_SETEVENTNAME(sock->uipChange, "sock:uip");

  file->fs     = &netFS.base;
  file->cf     = &netSockConf;
  file->fsPriv = sock;

  return file;
}
Esempio n. 5
0
NOSFLAG_t POSCALL nosFlagCreate(const char* name)
{
  POSFLAG_t flg;
  REGELEM_t re;

  re = nos_regNewSysKey(REGTYPE_FLAG,
                        name == NULL ? (const char*)"f*" : name);
  if (re == NULL)
    return NULL;

  flg = posFlagCreate();
  if (flg == NULL)
  {
    nos_regDelSysKey(REGTYPE_FLAG, NULL, re);
  }
  else
  {
    nos_regEnableSysKey(re, flg);
    POS_SETEVENTNAME(flg, re->name);
  }
  return (NOSFLAG_t) flg;
}
Esempio n. 6
0
NOSMUTEX_t POSCALL nosMutexCreate(UVAR_t options, const char *name)
{
  POSMUTEX_t mtx;
  REGELEM_t re;

  re = nos_regNewSysKey(REGTYPE_MUTEX,
                        name == NULL ? (const char*)"m*" : name);
  if (re == NULL)
    return NULL;

  (void) options;
  mtx = posMutexCreate();

  if (mtx == NULL)
  {
    nos_regDelSysKey(REGTYPE_MUTEX, NULL, re);
  }
  else
  {
    nos_regEnableSysKey(re, mtx);
    POS_SETEVENTNAME(mtx, re->name);
  }
  return (NOSMUTEX_t) mtx;
}