Beispiel #1
0
VMK_ReturnStatus 
LogFS_CommonInit(void)
{
   logfsHeap = Heap_Create("logfs",
                           VMK_PAGE_SIZE,
                           LogFS_HEAP_MAX,
                           MM_PHYS_ANY_CONTIGUITY,
                           MM_TYPE_ANY);

   if (logfsHeap == INVALID_HEAP_ID) {
      Warning("Unable to create heap for logfs module");
      return VMK_NO_MEMORY;
   }

   return VMK_OK;
}
Beispiel #2
0
/**
 * @brief Initializes the TLSF based PAL dynamic memory subsystem.
 *
 * FYI: TLSF == Two-Level Segregated Fit
 *
 * Initialize Heap with static pool if it isn't already initialized.
 *
 * @return SIRF_SUCCESS if successful, SIRF_FAILURE otherwise.
 */
tSIRF_RESULT SIRF_PAL_OS_MEM_Init(void)
{
   tSIRF_RESULT result = SIRF_SUCCESS;
   if (SIRF_FALSE == s_mem_initialized)
   {
      result = SIRF_PAL_OS_MUTEX_Create(&s_MemoryMutex);
      if (SIRF_SUCCESS != result)
      {
         return result;
      }

      s_MemoryHeap = Heap_Create(NullHeapNotify, s_HeapMem, sizeof(s_HeapMem));
      if (NULL == s_MemoryHeap)
      {
         result = SIRF_FAILURE;
      }
      else
      {
         s_mem_initialized = SIRF_TRUE;
      }
  }

  return result;
}
void
LB_superblock_formation (L_Func * fn)
{
  LB_TraceRegion_Header *header;
  LB_TraceRegion *tr_index;
  Heap *tr_heap;
  int list_size, i, code_size = 0, max_code_size, growth, do_frp;

  if (fn->n_cb == 0)
    return;

  do_frp = !strcmp (LB_predicate_formation_type, "frp");

  header = LB_function_init (fn);

  L_partial_dead_code_removal (fn);
  L_do_flow_analysis (fn, DOMINATOR_CB|SUPPRESS_PG);
  L_loop_detection (fn, 0);

  L_compute_oper_weight (fn, 0, 1);
  LB_convert_to_strict_basic_block_code (fn,
		     L_CB_SUPERBLOCK | L_CB_HYPERBLOCK |
		     L_CB_ENTRANCE_BOUNDARY | L_CB_EXIT_BOUNDARY);

  L_do_flow_analysis (fn, DOMINATOR_CB);
  L_compute_oper_weight (fn, 0, 1);

  LB_mark_jrg_flag (fn);

  LB_make_traceregions (fn, TRUE, header);
  LB_order_traceregions (fn, header);
  LB_layout_function (fn, header);

  tr_heap = Heap_Create (HEAP_MAX);

  List_start (header->traceregions);
  while ((tr_index = (LB_TraceRegion *) List_next (header->traceregions)))
    {
      code_size += LB_traceregion_code_size (tr_index);
      Graph_dfs_topo_sort (tr_index->flow_graph);
      if ((tr_index->weight >= LB_minimum_superblock_weight) &&
	  !(tr_index->flags & 
	    (L_TRACEREGION_HYPERBLOCK | L_TRACEREGION_SUPERBLOCK)) &&
	  (tr_index->header != LB_last_cb_in_region (tr_index)))
	Heap_Insert (tr_heap, tr_index, tr_index->weight);
    }

  max_code_size = (int) (LB_maximum_code_growth * code_size);

  LB_predicate_init ();

  while ((tr_heap->size > 0) && (code_size < max_code_size))
    {
      tr_index = (LB_TraceRegion *) Heap_ExtractTop (tr_heap);

      growth = LB_tail_duplication (fn, tr_index, LB_DUP_INSIDE_REGION, 1);

      if ((code_size + growth) > max_code_size)
	continue;

      code_size += LB_tail_duplication (fn, tr_index, LB_DUP_INSIDE_REGION, 0);

      LB_predicate_traceregion (fn, tr_index, do_frp);
      L_set_hb_no_fallthru_flag (fn);
      L_check_func (fn);

      tr_index->flags |= L_TRACEREGION_SUPERBLOCK;

      L_rebuild_src_flow (fn);
      LB_mark_jrg_flag (fn);

      /* Make traces with the new end cb's */
      list_size = List_size (header->traceregions);
      LB_make_traceregions (fn, FALSE, header);
      LB_order_traceregions (fn, header);
      LB_layout_function (fn, header);

      i = 0;
      while ((tr_index = (LB_TraceRegion *) List_next (header->traceregions)))
	{
	  if (++i <= list_size)
	    continue;

	  Graph_dfs_topo_sort (tr_index->flow_graph);

	  if ((tr_index->weight >= LB_minimum_superblock_weight) &&
	      !(tr_index->flags & (L_TRACEREGION_HYPERBLOCK |
				   L_TRACEREGION_SUPERBLOCK)) &&
	      (tr_index->header != LB_last_cb_in_region (tr_index)))
	    Heap_Insert (tr_heap, tr_index, tr_index->weight);
	}
    }

  tr_heap = Heap_Dispose (tr_heap, NULL);

  LB_predicate_deinit (fn);

  fn->flags = L_SET_BIT_FLAG (fn->flags, L_FUNC_SUPERBLOCK);
  L_rebuild_src_flow (fn);

  if (do_frp || LB_hb_do_combine_exits)
    {
      L_create_uncond_pred_defines (fn);
      L_combine_pred_defines (fn);
    }

  /* For each source code function we process deinit */
  LB_function_deinit (header);
  return;
}
/** 
 * Create the AT Command server instance
 * 
 * @param port_name Name of the uart port the Modem is connected
 * 
 * @return Success if the port was opened successfully
 */
tSIRF_RESULT SIRF_GPRS_AT_COMMAND_SERVER_Create( 
   tSIRF_CHAR const * const port_name,
   tSIRF_CHAR const * const apn )
{
   tSIRF_RESULT result;
   tSIRF_MSG_SSB_EXT_UART_OPEN_PORT port_settings;

   /* This only works initially if gprs_at_command is in ZI data */
   if (NULL != gprs_at_command.listener_mx)
   {
      return SIRF_GPRS_AT_COMMAND_SERVER_ALREADY_CREATED;
   }

   /* This is necessar if Create is ever called a second time */
   memset( &gprs_at_command, 0, sizeof(gprs_at_command) );

   /* Initialize the queues.  These fucntion cannot fail */
   fifo_queue_init( &gprs_at_command.msg_queue_gprs );
   fifo_queue_init( &gprs_at_command.msg_queue_gprs_input );
   gprs_at_command.command_timeout = DEFAULT_GPRS_RESPONSE_TIMEOUT;

   /* Open a uart port to the modem */
   strlcpy(port_settings.port_name,port_name,sizeof(port_settings.port_name));
   port_settings.baud_rate    = SIRF_GPRS_AT_COMMAND_BAUD_RATE;
   port_settings.flow_control = SIRF_GPRS_AT_COMMAND_FLOW_CONTROL;

   /* Create the semaphore */
   result = SIRF_PAL_OS_SEMAPHORE_Create(&gprs_at_command.semaphore,0);
   if ( SIRF_SUCCESS != result )
   {
      return result;
   }

   result = SIRF_PAL_OS_MUTEX_Create( &gprs_at_command.listener_mx );
   if ( SIRF_SUCCESS != result )
   {
      goto GPRS_ERROR_1;
   }

   result = SIRF_PAL_OS_MUTEX_Create( &gprs_at_command.queue_mx );
   if ( SIRF_SUCCESS != result )
   {
      goto GPRS_ERROR_2;
   }

   gprs_at_command.msg_heap = Heap_Create( GprsMsgQueueHeap_notify,
                                           gprs_heap_space,
                                           sizeof(gprs_heap_space) );
   if (NULL == gprs_at_command.msg_heap)
   {
      goto GPRS_ERROR_3;
   }

   /* Must open the UART last since it might call the callback fuctnion which
    * uses the heap and queues mutex's and semaphores, but before the 
    * queue reading thread since the queue reading thread calls into the
    * uart */
   result = SIRF_EXT_UART_Open(&gprs_at_command.uartno,
                               &port_settings,
                               SIRF_GPRS_AT_COMMAND_UartPacketCallbackATCommand,
                               SIRF_PROTO_GPRS_AT_COMMAND_Parser);

   if ( SIRF_SUCCESS != result )
   {
      goto GPRS_ERROR_4;
   }

   gprs_at_command.thread_running = SIRF_TRUE;
   result = SIRF_PAL_OS_THREAD_Create( 
      SIRFLPL_THREAD_GPRS, 
      (tSIRF_HANDLE)SIRF_GPRS_AT_COMMAND_ReadThread, 
      &gprs_at_command.server_thread );

   if (SIRF_SUCCESS != result)
   {
      goto GPRS_ERROR_5;
   }

   result = gprs_start(gprs_at_command.uartno,
                       SIRF_GPRS_AT_COMMAND_FLOW_CONTROL,
                       apn);
   if (SIRF_SUCCESS != result)
   {
      goto GPRS_ERROR_5;
   }

   return SIRF_SUCCESS;

   

GPRS_ERROR_5:
   /* Must kill our own thread and delete it */
   gprs_at_command.thread_running = SIRF_FALSE;
   (void)SIRF_PAL_OS_SEMAPHORE_Release(gprs_at_command.semaphore);
   (void)SIRF_PAL_OS_THREAD_Delete(gprs_at_command.server_thread);

GPRS_ERROR_4:
   /* Heap_Create doesn't have a Heap Destroy */

GPRS_ERROR_3:
   (void)SIRF_PAL_OS_MUTEX_Delete(gprs_at_command.queue_mx);
   gprs_at_command.queue_mx = NULL;

GPRS_ERROR_2:
   (void)SIRF_PAL_OS_MUTEX_Delete(gprs_at_command.listener_mx);
   gprs_at_command.listener_mx = NULL;

GPRS_ERROR_1:
   (void)SIRF_PAL_OS_SEMAPHORE_Delete(gprs_at_command.semaphore);
   gprs_at_command.semaphore = NULL;
   return result;

} /* SIRF_GPRS_AT_COMMAND_Create()*/
Beispiel #5
0
void scalanative_init() {
    heap = Heap_Create(INITIAL_HEAP_SIZE);
    stack = Stack_Alloc(INITIAL_STACK_SIZE);
}