Example #1
0
uint_32 DHCPSRV_ippool_add
   (
      _ip_address             ipstart,
      uint_32                 ipnum,
      DHCPSRV_DATA_STRUCT_PTR params,
      uchar_ptr               optptr,
      uint_32                 optlen
   )
{ /* Body */
   DHCPSRV_OPTIONS_STRUCT_PTR    options;
   DHCPSRV_ADDR_STRUCT_PTR       addr;
   uchar_ptr                     moreoptions = NULL;

   options = RTCS_mem_alloc_system(sizeof(DHCPSRV_OPTIONS_STRUCT) + optlen);
   if (!options) {
      return RTCSERR_OUT_OF_MEMORY;
   } /* Endif */
   _mem_set_type(options, MEM_TYPE_DHCPSRV_OPTIONS_STRUCT);

   moreoptions = (uchar_ptr)(options+1);
   _mem_copy(optptr, moreoptions, optlen);

   options->COUNT = 0;
   options->SERVERID   = params->SERVERID;
   options->LEASE      = params->LEASE;
   options->MASK       = params->MASK;
   options->OPTION_PTR = moreoptions;
   options->OPTION_LEN = optlen;
   options->SADDR      = params->SADDR;
   _mem_copy(params->SNAME, options->SNAME, sizeof(options->SNAME) - 1);
   options->SNAME[sizeof(options->SNAME) - 1] = '\0';
   _mem_copy(params->FILE,  options->FILE,  sizeof(options->FILE)  - 1);
   options->FILE[sizeof(options->FILE) - 1] = '\0';

   RTCS_mutex_lock(&DHCPSRV_cfg->IPLIST_SEM);

   for (; ipnum; ipnum--, ipstart++) {
      addr = RTCS_mem_alloc_system(sizeof(DHCPSRV_ADDR_STRUCT));
      if (!addr) {
         if (options->COUNT == 0) {
            _mem_free(options);
         } /* Endif */
         RTCS_mutex_unlock(&DHCPSRV_cfg->IPLIST_SEM);
         return RTCSERR_OUT_OF_MEMORY;
      } /* Endif */
      _mem_set_type(options, MEM_TYPE_DHCPSRV_ADDR_STRUCT);

      addr->CLIENTID_LEN = 0;
      addr->CLIENTID_PTR = NULL;
      addr->IP_ADDR      = ipstart;
      addr->OPTIONS      = options;
      options->COUNT++;
      DHCPSRV_lease_start(&DHCPSRV_cfg->IP_AVAIL, addr, 0);
   } /* Endfor */

   RTCS_mutex_unlock(&DHCPSRV_cfg->IPLIST_SEM);
   return RTCS_OK;

} /* Endbody */
Example #2
0
USB_STATUS _usb_host_iso_packet_desc_pool_create
(
   uint_32 num_descs
)
{
   uchar_ptr   mem_ptr;
   uint_32     pool_num_bytes;
   uint_32     i;
   
   pool_num_bytes = sizeof (USB_ISO_PACKET_DESC_STRUCT) * num_descs;

   mem_ptr = (uchar_ptr)USB_mem_alloc_zero(pool_num_bytes);
   
   if (mem_ptr == NULL)
   {
      return USB_log_error(__FILE__,__LINE__,USBERR_ALLOC);
   }

   _mem_set_type(mem_ptr, MEM_TYPE_USB_ISO_PACKET_DESC_STRUCT);

   usb_host_iso_packet_desc_pool.mem_ptr = mem_ptr;   
   _mqx_dll_list_init ((MQX_DLL_LIST_PTR)&usb_host_iso_packet_desc_pool.free_list);
   
   for (i = 0; i < num_descs; i++)
   {
      _mqx_dll_node_init (&((USB_ISO_PACKET_DESC_STRUCT_PTR)mem_ptr)[i].node);
      _mqx_dll_insert_at_tail ((MQX_DLL_LIST_PTR)&usb_host_iso_packet_desc_pool.free_list, &((USB_ISO_PACKET_DESC_STRUCT_PTR)mem_ptr)[i].node);
      ((USB_ISO_PACKET_DESC_STRUCT_PTR)mem_ptr)[i].buf_offset = 0;
      ((USB_ISO_PACKET_DESC_STRUCT_PTR)mem_ptr)[i].buf_length = 0;
      ((USB_ISO_PACKET_DESC_STRUCT_PTR)mem_ptr)[i].packet_status = USB_OK;
   }
   
   return USB_OK;
}
Example #3
0
_mqx_uint _io_ras_install
   (
      /* [IN] A string that identifies the device for fopen */
      char_ptr    identifier
   )
{ /* Body */
   IODUN_DEV_STRUCT_PTR dev_ptr = _mem_alloc_system_zero(sizeof(IODUN_DEV_STRUCT));

#if MQX_CHECK_MEMORY_ALLOCATION_ERRORS
   if (dev_ptr == NULL) {
      return(MQX_OUT_OF_MEMORY);
   } /* Endif */
#endif
   _mem_set_type(dev_ptr,MEM_TYPE_IO_DUN_DEV);               

   dev_ptr->RECV      = "CLIENTSERVER";
   dev_ptr->SEND      = "CLIENTCLIENT";
   dev_ptr->RECV_SIZE = 12;
   dev_ptr->SEND_SIZE = 12;

   return (_io_dev_install(identifier,
      _io_dun_open,
      _io_dun_close,
      _io_dun_read,
      _io_dun_write,
      _io_dun_ioctl,
      dev_ptr)); 
 
} /* Endbody */
Example #4
0
/*!
 * \brief This function sets up the FLOATING POINT context of a new task descriptor.
 * 
 * \param[in] td_ptr the address of the task descriptor
 */
bool _psp_build_float_context
   (
      /* [IN] the address of the task descriptor */
      TD_STRUCT_PTR    td_ptr
   )
{
    PSP_BLOCKED_FP_STRUCT_PTR fp_ptr;

    /* Allocate space for saving/restoring the DSP registers */
    fp_ptr = (PSP_BLOCKED_FP_STRUCT_PTR)_mem_alloc_zero((_mem_size)sizeof(PSP_BLOCKED_FP_STRUCT));

#if MQX_CHECK_MEMORY_ALLOCATION_ERRORS
    if (!fp_ptr) {
        /* Couldn't allocate memory for the DSP register context */
        _task_set_error_td_internal(td_ptr, MQX_OUT_OF_MEMORY);
        return FALSE;
    }
#endif

    _mem_set_type(fp_ptr, MEM_TYPE_FP_CONTEXT);
    /*
    ** Transfer the block to the task being created. This will ensure the
    ** float context will be freed if the task is destroyed.
    */
    _mem_transfer_internal((void *)fp_ptr, td_ptr);

    /* This field should never be overwitten */
    fp_ptr->TID = td_ptr->TASK_ID;

    td_ptr->FLOAT_CONTEXT_PTR = (void *)fp_ptr;

    return TRUE;
}
Example #5
0
uint_32 _io_apcflash_install
   (
      /* [IN] A string that identifies the device for fopen */
      char_ptr                      identifier
   )
{ /* Body */
   IO_PCFLASH_STRUCT_PTR            info_ptr;

   /* Allocate memory for the state structure */
   info_ptr = _mem_alloc_system_zero((uint_32)sizeof(IO_PCFLASH_STRUCT));
#if MQX_CHECK_MEMORY_ALLOCATION_ERRORS
   if (info_ptr == NULL) {
      return(MQX_OUT_OF_MEMORY);
   } /* Endif */
#endif
   _mem_set_type(info_ptr,MEM_TYPE_IO_PCFLASH);

   /* Fill in the state structure with the info we know */
   info_ptr->DRIVE         = 0;    /* always use ATA device 0 */     
   info_ptr->SECTOR_SIZE   = ATA_SECTOR_SIZE;          
   info_ptr->TEMP_BUFF_PTR = NULL;
   info_ptr->ERROR_CODE    = IO_OK;

   _lwsem_create(&info_ptr->LWSEM, 1L);
    
   return (_io_dev_install(identifier,
      (_mqx_int (_CODE_PTR_)(MQX_FILE_PTR, char _PTR_, char _PTR_))_io_apcflash_open,
      (_mqx_int (_CODE_PTR_)(MQX_FILE_PTR))                        _io_apcflash_close,
      (_mqx_int (_CODE_PTR_)(MQX_FILE_PTR, char_ptr, _mqx_int))    _io_apcflash_read,
      (_mqx_int (_CODE_PTR_)(MQX_FILE_PTR, char_ptr, _mqx_int))    _io_apcflash_write,
      (_mqx_int (_CODE_PTR_)(MQX_FILE_PTR, _mqx_uint, pointer))    _io_apcflash_ioctl,
      (pointer)info_ptr)); 

} /* Endbody */
Example #6
0
static _mqx_uint _io_serial_mix_install
   (
      /* [IN] A string that identifies the device for fopen */
      char             *identifier,
  
      /* [IN] The I/O init function */
      _mqx_uint (_CODE_PTR_ init)(void *, char *),

      /* [IN] The enable interrupts function */
      _mqx_uint (_CODE_PTR_ enable_ints)(void *),

      /* [IN] The I/O de-init function */
      _mqx_uint (_CODE_PTR_ deinit)(void *, void *),

      /* [IN] The output function */
      void    (_CODE_PTR_  putc)(void *, char),

      /* [IN] The I/O ioctl function */
      _mqx_uint (_CODE_PTR_ ioctl)(void *, _mqx_uint, void *),

      /* [IN] The I/O init data pointer */
      void                *init_data_ptr,
      
      /* [IN] The I/O queue size to use */
      _mqx_uint             oqueue_size,
      _mqx_uint             iqueue_size
   )
{ /* Body */
   IO_SERIAL_INT_DEVICE_STRUCT_PTR int_io_dev_ptr;
   uint32_t                         result;

   int_io_dev_ptr = _mem_alloc_system_zero(
      (_mem_size)sizeof(IO_SERIAL_INT_DEVICE_STRUCT));
#if MQX_CHECK_MEMORY_ALLOCATION_ERRORS
   if (int_io_dev_ptr == NULL) {
      return(MQX_OUT_OF_MEMORY);
   } /* Endif */
#endif
   _mem_set_type(int_io_dev_ptr,MEM_TYPE_IO_SERIAL_INT_DEVICE_STRUCT);    

   int_io_dev_ptr->DEV_INIT          = init;
   int_io_dev_ptr->DEV_ENABLE_INTS   = enable_ints;
   int_io_dev_ptr->DEV_DEINIT        = deinit;
   int_io_dev_ptr->DEV_PUTC          = putc;
   int_io_dev_ptr->DEV_IOCTL         = ioctl;
   int_io_dev_ptr->DEV_INIT_DATA_PTR = init_data_ptr;
   int_io_dev_ptr->QUEUE_SIZE        = oqueue_size;
   int_io_dev_ptr->OQUEUE_SIZE       = oqueue_size;
   int_io_dev_ptr->IQUEUE_SIZE       = iqueue_size;
   
   result = _io_dev_install(identifier,
      _io_serial_mix_open, _io_serial_mix_close,
      _io_serial_mix_read, _io_serial_mix_write,
      _io_serial_mix_ioctl,
      (void *)int_io_dev_ptr); 
   
   return result;
} /* Endbody */
Example #7
0
_mqx_uint _partition_create_component
   ( 
      void
   )
{ /* Body */
   KERNEL_DATA_STRUCT_PTR          kernel_data;
   PARTITION_COMPONENT_STRUCT_PTR  part_component_ptr;

   _GET_KERNEL_DATA(kernel_data);

   _KLOGE1(KLOG_partition_create_component);

#if MQX_CHECK_ERRORS
   if (kernel_data->IN_ISR) {
      _KLOGX2(KLOG_partition_create_component, MQX_CANNOT_CALL_FUNCTION_FROM_ISR);
      return(MQX_CANNOT_CALL_FUNCTION_FROM_ISR);
   } /* Endif */
#endif

   _lwsem_wait((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM);

#if MQX_CHECK_ERRORS
   if (kernel_data->KERNEL_COMPONENTS[KERNEL_PARTITIONS] != NULL) {
      _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM);
      _KLOGX2(KLOG_partition_create_component, MQX_OK);
      return(MQX_OK);
   } /* Endif */
#endif

   part_component_ptr = _mem_alloc_system_zero(
      (_mem_size)sizeof(PARTITION_COMPONENT_STRUCT));
#if MQX_CHECK_MEMORY_ALLOCATION_ERRORS
   if (part_component_ptr == NULL) {
      _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM);
      _KLOGX2(KLOG_partition_create_component, MQX_OUT_OF_MEMORY);
      return(MQX_OUT_OF_MEMORY);
   } /* Endif */
#endif
   _mem_set_type(part_component_ptr, MEM_TYPE_PARTITION_COMPONENT);

   kernel_data->KERNEL_COMPONENTS[KERNEL_PARTITIONS] = part_component_ptr;
/* START CR 308 */
   part_component_ptr->VALID = PARTITION_VALID;
/* END CR 308 */

   _QUEUE_INIT(&part_component_ptr->PARTITIONS, 0);

#if MQX_COMPONENT_DESTRUCTION
   kernel_data->COMPONENT_CLEANUP[KERNEL_PARTITIONS] = _partition_cleanup;
#endif

   _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->COMPONENT_CREATE_LWSEM);

   _KLOGX2(KLOG_partition_create_component, MQX_OK);

   return(MQX_OK);

} /* Endbody */
Example #8
0
static _mqx_int _io_serial_mix_open
   (
      /* [IN] the file handle for the device being opened */
      FILE_DEVICE_STRUCT_PTR fd_ptr,
       
      /* [IN] the remaining portion of the name of the device */
      char              *open_name_ptr,

      /* [IN] the flags to be used during operation:
      ** echo, translation, xon/xoff
      */
      char        *flags
   )
{ /* Body */
   IO_DEVICE_STRUCT_PTR            io_dev_ptr;
   IO_SERIAL_INT_DEVICE_STRUCT_PTR int_io_dev_ptr;
   _mqx_uint                       result = MQX_OK;
   _mqx_uint                       ioctl_val;

   io_dev_ptr     = fd_ptr->DEV_PTR;
   int_io_dev_ptr = (void *)io_dev_ptr->DRIVER_INIT_PTR;
   
   if (int_io_dev_ptr->COUNT) {
      /* Device is already opened */
      int_io_dev_ptr->COUNT++;
      fd_ptr->FLAGS = int_io_dev_ptr->FLAGS;
      return(result);
   } /* Endif */

   int_io_dev_ptr->IN_WAITING_TASKS  = _taskq_create(MQX_TASK_QUEUE_FIFO);
   int_io_dev_ptr->OUT_WAITING_TASKS = _taskq_create(MQX_TASK_QUEUE_FIFO);

   int_io_dev_ptr->OUT_QUEUE = (void *)_mem_alloc_system(
      sizeof(CHARQ_STRUCT) - (4 * sizeof(char)) + int_io_dev_ptr->OQUEUE_SIZE);
   _mem_set_type(int_io_dev_ptr->OUT_QUEUE,MEM_TYPE_IO_SERIAL_OUT_QUEUE);      
   _CHARQ_INIT(int_io_dev_ptr->OUT_QUEUE, int_io_dev_ptr->OQUEUE_SIZE);



   int_io_dev_ptr->FLAGS = (_mqx_uint)flags;
   fd_ptr->FLAGS      = (_mqx_uint)flags;

   result = (*int_io_dev_ptr->DEV_INIT)(int_io_dev_ptr, open_name_ptr);
   
   if (result == MQX_OK) {
       result = (*int_io_dev_ptr->DEV_ENABLE_INTS)(int_io_dev_ptr->DEV_INFO_PTR);
   } /* Endif */
   
   if (result != MQX_OK) {
      _mem_free(int_io_dev_ptr->OUT_QUEUE);
      _taskq_destroy(int_io_dev_ptr->IN_WAITING_TASKS);
      _taskq_destroy(int_io_dev_ptr->OUT_WAITING_TASKS);
   }
   int_io_dev_ptr->COUNT = 1;
   return(result);

} /* Endbody */
Example #9
0
/*!
 * \brief This function sets up the kernel priority ready queues
 */
uint32_t _psp_init_readyqs
   (
      void
   )
{ /* Body */
   KERNEL_DATA_STRUCT_PTR kernel_data;
   READY_Q_STRUCT_PTR     q_ptr;
   uint32_t                priority_levels;
   uint32_t                n;
   uint16_t                sr;

   _GET_KERNEL_DATA(kernel_data);
   kernel_data->READY_Q_LIST = (READY_Q_STRUCT_PTR) NULL;
   priority_levels = kernel_data->LOWEST_TASK_PRIORITY + 3; // IDLE TASK, INIT TASK

   q_ptr = (READY_Q_STRUCT_PTR)
      _mem_alloc_zero(sizeof(READY_Q_STRUCT) * priority_levels);
#if MQX_CHECK_MEMORY_ALLOCATION_ERRORS
   if ( q_ptr == NULL ) {
      return (MQX_OUT_OF_MEMORY);
   } /* Endif */
#endif
   _mem_set_type(q_ptr, MEM_TYPE_READYQ);

   n = priority_levels;
   while (n--) {
      q_ptr->HEAD_READY_Q  = (TD_STRUCT_PTR)q_ptr;
      q_ptr->TAIL_READY_Q  = (TD_STRUCT_PTR)q_ptr;
      q_ptr->PRIORITY      = (uint16_t)n;
      q_ptr->NEXT_Q        = kernel_data->READY_Q_LIST;
      kernel_data->READY_Q_LIST = q_ptr++;
   } /* Endwhile */

   /* 
   ** Set the current ready q (where the ready queue searches start) to
   ** the head of the list of ready queues.
   */
   kernel_data->CURRENT_READY_Q = kernel_data->READY_Q_LIST;


   /* Initialize the ENABLE_SR fields in the ready queues */
   sr = (uint16_t)0x2000 | 
      (uint16_t)((kernel_data->INIT.MQX_HARDWARE_INTERRUPT_LEVEL_MAX - 1) << 8);
   n  = priority_levels;
   q_ptr =  kernel_data->READY_Q_LIST;
   while (n--) {
      q_ptr->ENABLE_SR = sr;
      if (  ((uint16_t) 0xF00 & sr) > 0  ) {
         sr = (uint16_t)sr - (uint16_t)0x100; 
      } /* Endif */
      q_ptr = q_ptr->NEXT_Q;
   } /* Endwhile */

   return MQX_OK;

} /* Endbody */
Example #10
0
pointer _taskq_create
   ( 
      /* [IN] the policy of this task queue (fifo or priority queueing) */
      _mqx_uint policy
   )
{ /* Body */
   KERNEL_DATA_STRUCT_PTR kernel_data;
   TASK_QUEUE_STRUCT_PTR  task_queue_ptr;

   _GET_KERNEL_DATA(kernel_data);

   _KLOGE2(KLOG_taskq_create, policy);

#if MQX_CHECK_ERRORS
   if (! ((policy == MQX_TASK_QUEUE_FIFO) ||
          (policy == MQX_TASK_QUEUE_BY_PRIORITY)))
   {
      _task_set_error(MQX_INVALID_PARAMETER);
      _KLOGX2(KLOG_taskq_create, NULL);
      return (NULL);
   } /* Endif */
   if (kernel_data->IN_ISR) {
      _task_set_error(MQX_CANNOT_CALL_FUNCTION_FROM_ISR);
      _KLOGX2(KLOG_taskq_create, NULL);
      return(NULL);
   }/* Endif */
#endif

   task_queue_ptr = (TASK_QUEUE_STRUCT_PTR)_mem_alloc_system((_mem_size)
      sizeof(TASK_QUEUE_STRUCT));
#if MQX_CHECK_MEMORY_ALLOCATION_ERRORS
   if (task_queue_ptr == NULL) {
      _KLOGX2(KLOG_taskq_create, NULL);
      return(NULL);
   } /* Endif */
#endif

   _mem_set_type(task_queue_ptr, MEM_TYPE_TASK_Q);

   task_queue_ptr->POLICY = policy;
   _QUEUE_INIT(&task_queue_ptr->TD_QUEUE, 0);
   task_queue_ptr->VALID  = TASK_QUEUE_VALID;
   _int_disable();
   if (kernel_data->KERNEL_TASK_QUEUES.NEXT == NULL) {
       /* Initialize the task queue */
      _QUEUE_INIT(&kernel_data->KERNEL_TASK_QUEUES,0);
   
   } /* Endif */
   _QUEUE_ENQUEUE(&kernel_data->KERNEL_TASK_QUEUES, task_queue_ptr);
   _int_enable();

   _KLOGX2(KLOG_taskq_create, task_queue_ptr);

   return(task_queue_ptr);
   
} /* Endbody */
Example #11
0
/*FUNCTION*-------------------------------------------------------------
*
*  Function Name  : _usb_host_new_tr_element
*  Returned Value : pointer to new host tr struct, NULL if error
*  Comments       :
*         This function will allocate and link a new TR element in the 
*  list of TRs for the specified pipe. It is assumed the caller has issued 
*  USB_lock() before entry.
*
*END*-----------------------------------------------------------------*/
static TR_STRUCT_PTR _usb_host_new_tr_element
   (
      /* [IN] the pipe handle */
      _usb_pipe_handle  pipe_handle
   )
{ /* Body */

   PIPE_STRUCT_PTR     pipe_ptr = (PIPE_STRUCT_PTR) pipe_handle;
   DEV_INSTANCE_PTR    dev_ptr = (DEV_INSTANCE_PTR) pipe_ptr->DEV_INSTANCE;
   USB_HOST_STATE_STRUCT_PTR host_ptr = (USB_HOST_STATE_STRUCT_PTR) dev_ptr->host;

   TR_STRUCT_PTR       tr_ptr, temp_tr_ptr;
   

   #ifdef _HOST_DEBUG_
      DEBUG_LOG_TRACE("_usb_host_new_tr_element");
   #endif

   tr_ptr = (TR_STRUCT_PTR)USB_mem_alloc_uncached_zero(host_ptr->TR_SIZE);

   if (tr_ptr == NULL)
   {
      #ifdef _HOST_DEBUG_
      DEBUG_LOG_TRACE("_usb_host_new_tr_element malloc failed");
      #endif
      return NULL;
   }
   _mem_set_type(tr_ptr, MEM_TYPE_USB_HOST_PIPE_TR_STRUCT);

   /* Link pipe's TR structs in circular list of 1 or more items,
   ** where the pipe descriptor's tr list pointer holds the
   ** address of the next struct for scheduling (i.e. the
   ** "beginning" of the list).  
   */
   temp_tr_ptr = pipe_ptr->tr_list_ptr;

   if (temp_tr_ptr == NULL) { 
      /* No existing items, make a circle of one */
      pipe_ptr->tr_list_ptr = tr_ptr->NEXT = tr_ptr;
   } else {
      /* Add new item to the "end" of the existing list */
      while (temp_tr_ptr->NEXT != pipe_ptr->tr_list_ptr)
         temp_tr_ptr = temp_tr_ptr->NEXT;

      temp_tr_ptr->NEXT = tr_ptr;  
      tr_ptr->NEXT = pipe_ptr->tr_list_ptr;
   } /* EndIf */

   #ifdef _HOST_DEBUG_
      DEBUG_LOG_TRACE("_usb_host_new_tr_element SUCCESSFUL");
   #endif
   return tr_ptr;

} /* Endbody */
Example #12
0
uint32_t ENET_open
   (
      /* [IN] the Ethernet state structure */
      _enet_handle      handle,

      /* [IN] the protocol */
      uint16_t           type,

      /* [IN] the callback function */
      void (_CODE_PTR_  service)(PCB_PTR, void *),

      /* [IN] private data for the callback */
      void             *prv
   )
{ 
   ENET_CONTEXT_STRUCT_PTR enet_ptr = (ENET_CONTEXT_STRUCT_PTR)handle;
   ENET_ECB_STRUCT_PTR     ecb_ptr, * search_ptr;

   /*
   ** This function can be called from any context, and it needs mutual
   ** exclusion with itself, ENET_close(), and ENET_ISR().
   */
   ENET_lock_context(enet_ptr);

   // Search for an existing entry for type
   for (search_ptr = (ENET_ECB_STRUCT_PTR *)&enet_ptr->ECB_HEAD; *search_ptr; search_ptr = &(*search_ptr)->NEXT) {
      if ((*search_ptr)->TYPE == type) {
         /* Found an existing entry */
         ENET_unlock_context(enet_ptr);
         return ENETERR_OPEN_PROT;
      } 
   } 

   // No existing entry found -- create a new one
   ecb_ptr = (ENET_ECB_STRUCT_PTR)_mem_alloc_system_zero(sizeof(ENET_ECB_STRUCT));
   if (!ecb_ptr) {
      ENET_unlock_context(enet_ptr);
      return ENETERR_ALLOC_ECB;
   } 
   _mem_set_type(ecb_ptr, MEM_TYPE_IO_ENET_ECB);
   
   ecb_ptr->TYPE     = type;
   ecb_ptr->SERVICE  = service;
   ecb_ptr->MCB_HEAD = NULL;
   ecb_ptr->PRIVATE  = prv;
   ecb_ptr->NEXT     = NULL;
   *search_ptr       = ecb_ptr;

   ENET_unlock_context(enet_ptr);
   return ENET_OK;

}
Example #13
0
/*FUNCTION****************************************************************
* 
* Function Name    : _io_spi_int_install
* Returned Value   : MQX error code
* Comments         :
*    Install the interrupt SPI device.
*
*END**********************************************************************/
_mqx_uint _io_spi_int_install
   (
      /* [IN] A string that identifies the device for fopen */
      char_ptr              identifier,
  
      /* [IN] The I/O init function */
      _mqx_uint (_CODE_PTR_ init)(pointer,char _PTR_),

      /* [IN] The enable interrupts function */
      _mqx_uint (_CODE_PTR_ enable_ints)(pointer),
      
      /* [IN] The I/O de-init function */
      _mqx_uint (_CODE_PTR_ deinit)(pointer, pointer),
      
      /* [IN] The input function */
      _mqx_int  (_CODE_PTR_ recv)(pointer, char _PTR_, _mqx_int),
     
      /* [IN] The output function */
      _mqx_int  (_CODE_PTR_ xmit)(pointer, char _PTR_, _mqx_int),

      /* [IN] The I/O ioctl function */
      _mqx_int  (_CODE_PTR_ ioctl)(pointer, _mqx_uint, _mqx_uint_ptr, _mqx_uint),

      /* [IN] The I/O init data pointer */
      pointer               init_data_ptr
      
   )
{ /* Body */
   IO_SPI_INT_DEVICE_STRUCT_PTR int_dev_ptr;

   int_dev_ptr = (IO_SPI_INT_DEVICE_STRUCT_PTR)_mem_alloc_system_zero((_mem_size)sizeof(IO_SPI_INT_DEVICE_STRUCT));
   if (int_dev_ptr == NULL) 
   {
      return(MQX_OUT_OF_MEMORY);
   }
   _mem_set_type(int_dev_ptr,MEM_TYPE_IO_SPI_INT_DEVICE_STRUCT);       

   int_dev_ptr->DEV_INIT          = init;
   int_dev_ptr->DEV_DEINIT        = deinit;
   int_dev_ptr->DEV_ENABLE_INTS   = enable_ints;
   int_dev_ptr->DEV_READ          = recv;
   int_dev_ptr->DEV_WRITE         = xmit;
   int_dev_ptr->DEV_IOCTL         = ioctl;
   int_dev_ptr->DEV_INIT_DATA_PTR = init_data_ptr;
   
   return (_io_dev_install_ext(identifier,
      _io_spi_int_open, _io_spi_int_close,
      (_mqx_int (_CODE_PTR_)(MQX_FILE_PTR, char_ptr,  _mqx_int))_io_spi_int_read, 
      (_mqx_int (_CODE_PTR_)(MQX_FILE_PTR, char_ptr,  _mqx_int))_io_spi_int_write, 
      (_mqx_int (_CODE_PTR_)(MQX_FILE_PTR, _mqx_uint, pointer))_io_spi_int_ioctl, _io_spi_int_uninstall,
      (pointer)int_dev_ptr));
} /* Endbody */
Example #14
0
/*!
 * \brief
 *
 * \param path_ptr_ptr
 *
 * \return _mfs_error
 */
_mfs_error MFS_alloc_path(char **path_ptr_ptr)
{
    char *path_ptr;

    path_ptr = MFS_mem_alloc_system(PATHNAME_SIZE + 1);
    if (path_ptr == NULL)
    {
        return MFS_INSUFFICIENT_MEMORY;
    }
    _mem_set_type(path_ptr, MEM_TYPE_MFS_PATHNAME);
    *path_ptr_ptr = path_ptr;
    return MFS_NO_ERROR;
}
Example #15
0
/*!
 * \brief Set PSP_SUPPORT_STRUCT to kernel data
 * 
 * \param psp_sup_ptr 
 */
void _psp_set_support_ptr(PSP_SUPPORT_STRUCT_PTR psp_sup_ptr)
{
   KERNEL_DATA_STRUCT_PTR kernel_data;

   if (psp_sup_ptr != NULL)
   {
      _GET_KERNEL_DATA(kernel_data);

      _mem_set_type(psp_sup_ptr, MEM_TYPE_PSP_SUPPORT_STRUCT);

      kernel_data->PSP_SUPPORT_PTR = psp_sup_ptr;
   }
}
Example #16
0
/*!
 * \brief Allocates and initializes drive context structure.
 *
 * \param drive_ptr_ptr
 *
 * \return _mfs_error
 */
_mfs_error MFS_Create_drive(
    MFS_DRIVE_STRUCT_PTR *drive_ptr_ptr)
{
    MFS_DRIVE_STRUCT_PTR drive_ptr;
    _mfs_error error_code = MFS_NO_ERROR;

    if (drive_ptr_ptr == NULL)
    {
        return MFS_INVALID_POINTER;
    }

    drive_ptr = MFS_mem_alloc_system_zero(sizeof(MFS_DRIVE_STRUCT));
    if (drive_ptr == NULL)
    {
        return MFS_INSUFFICIENT_MEMORY;
    }
    _mem_set_type(drive_ptr, MEM_TYPE_MFS_DRIVE_STRUCT);

#if MFSCFG_USE_MUTEX
    {
        MUTEX_ATTR_STRUCT mutex_attr;

        error_code = _mutatr_init(&mutex_attr);
        if (error_code == MFS_NO_ERROR)
        {
            error_code = _mutatr_set_sched_protocol(&mutex_attr, MUTEX_PRIO_INHERIT);
            if (error_code == MFS_NO_ERROR)
            {
                error_code = _mutatr_set_wait_protocol(&mutex_attr, MUTEX_PRIORITY_QUEUEING);
            }

            if (error_code == MFS_NO_ERROR)
            {
                error_code = _mutex_init(&drive_ptr->MUTEX, &mutex_attr);
            }

            _mutatr_destroy(&mutex_attr);
        }
    }
#else
    error_code = _lwsem_create(&drive_ptr->LWSEM, 1);
#endif

    if (error_code)
    {
        MFS_mem_free(drive_ptr);
    }

    *drive_ptr_ptr = drive_ptr;
    return error_code;
}
Example #17
0
_mqx_uint _io_usb_dcd_polled_install
   (
      /* [IN] A string that identifies the device for fopen */
      char_ptr               identifier,
  
      /* [IN] The I/O init function */
      _mqx_uint (_CODE_PTR_ init)(pointer, pointer _PTR_, char_ptr),
      
      /* [IN] The I/O de-init function */
      _mqx_uint (_CODE_PTR_ deinit)(pointer, pointer),
      
      /* [IN] The input function */
      _mqx_int  (_CODE_PTR_ recv)(pointer, char_ptr, _mqx_int),
     
      /* [IN] The output function */
      _mqx_int  (_CODE_PTR_ xmit)(pointer, char_ptr, _mqx_int),

      /* [IN] The I/O ioctl function */
      _mqx_int  (_CODE_PTR_ ioctl)(pointer, _mqx_uint, _mqx_uint_ptr),

      /* [IN] The I/O init data pointer */
      pointer               init_data_ptr
      
   )

{ /* Body */
   IO_USB_DCD_POLLED_DEVICE_STRUCT_PTR pol_io_dev_ptr;

   pol_io_dev_ptr = (IO_USB_DCD_POLLED_DEVICE_STRUCT_PTR)_mem_alloc_system_zero ((_mem_size)sizeof (IO_USB_DCD_POLLED_DEVICE_STRUCT));
   if (pol_io_dev_ptr == NULL) 
   {
      return MQX_OUT_OF_MEMORY;
   }
   _mem_set_type (pol_io_dev_ptr, MEM_TYPE_IO_USB_DCD_POLLED_DEVICE_STRUCT);            

   pol_io_dev_ptr->DEV_INIT          = init;
   pol_io_dev_ptr->DEV_DEINIT        = deinit;
   pol_io_dev_ptr->DEV_READ          = recv;
   pol_io_dev_ptr->DEV_WRITE         = xmit;
   pol_io_dev_ptr->DEV_IOCTL         = ioctl;
   pol_io_dev_ptr->DEV_INIT_DATA_PTR = init_data_ptr;
   
   return (_io_dev_install_ext (identifier,
      _io_usb_dcd_polled_open,  _io_usb_dcd_polled_close,
      _io_usb_dcd_polled_read,  _io_usb_dcd_polled_write,
      _io_usb_dcd_polled_ioctl, _io_usb_dcd_polled_uninstall,
      (pointer)pol_io_dev_ptr));

} /* Endbody */
Example #18
0
/*!
 * \cond DOXYGEN_PRIVATE
 * \private
 * 
 * \brief Initializes a name component.
 * 
 * This function provides the storage and retrieval of a name associated with a 
 * number.
 * \n The name component can be used by any other kernel components. Each may have 
 * a separate set of names.
 * 
 * \param[out] name_handle    An address where the name data structure pointer is 
 * to be stored.
 * \param[in]  initial_number The initial number of names that can be stored.
 * \param[in]  grow_number    The number of names to be added when table is full.
 * \param[in]  maximum_number The maximum number of names that can be stored.
 * \param[in]  total_so_far   The total number of name spaces in all chained pools.
 * 
 * \return MQX_OK
 * \return MQX_OUT_OF_MEMORY (MQX cannot allocate memory for the name component.) 
 */ 
_mqx_uint _name_create_handle_internal
(
    void    **name_handle,
    _mqx_uint     initial_number,
    _mqx_uint     grow_number,
    _mqx_uint     maximum_number,
    _mqx_uint     total_so_far
)
{ /* Body */
    register NAME_COMPONENT_STRUCT_PTR name_manager_ptr;

    name_manager_ptr = (NAME_COMPONENT_STRUCT_PTR) _mem_alloc_system_zero((_mem_size) (sizeof(NAME_COMPONENT_STRUCT)
                    + ((initial_number - 1) * sizeof(NAME_STRUCT))));
#if MQX_CHECK_MEMORY_ALLOCATION_ERRORS
    if (name_manager_ptr == NULL)
    {
        return (MQX_OUT_OF_MEMORY);
    } /* Endif */
#endif /* MQX_CHECK_MEMORY_ALLOCATION_ERRORS */
    _mem_set_type(name_manager_ptr, MEM_TYPE_NAME_COMPONENT);

    /* The name component has been created, so we must create the semaphore */
    if (initial_number == total_so_far)
    {
        /* Initialize the semaphore for this name component */
        _lwsem_create((LWSEM_STRUCT_PTR) (&name_manager_ptr->SEM), 1);
    } /* Endif */

    name_manager_ptr->GROW_NUMBER = grow_number;
    if (maximum_number == 0)
    {
        name_manager_ptr->MAX_NUMBER = MAX_MQX_UINT;
    }
    else if (maximum_number < initial_number)
    {
        name_manager_ptr->MAX_NUMBER = initial_number;
    }
    else
    {
        name_manager_ptr->MAX_NUMBER = maximum_number;
    } /* Endif */
    name_manager_ptr->NUMBER_IN_BLOCK = initial_number;
    name_manager_ptr->TOTAL_NUMBER = total_so_far;
    name_manager_ptr->VALID = NAME_VALID;

    *(NAME_COMPONENT_STRUCT_PTR *) name_handle = name_manager_ptr;

    return (MQX_OK);
} /* Endbody */
Example #19
0
void _kinetis_initialize_support
   (
      /* [IN] dummy parameter */
      uint_32 param
   )
{ /* Body */
#if PSP_HAS_SUPPORT_STRUCT

    KERNEL_DATA_STRUCT_PTR kernel_data;
    _GET_KERNEL_DATA(kernel_data);

    kernel_data->PSP_SUPPORT_PTR = _mem_alloc_system_zero((uint_32)sizeof(PSP_SUPPORT_STRUCT));
    _mem_set_type(kernel_data->PSP_SUPPORT_PTR, MEM_TYPE_PSP_SUPPORT_STRUCT);
#endif
} /* Endbody */
Example #20
0
/*!
 * \brief Initilize the support functions for the A5 platforms
 */
void _a5_initialize_support(void)
{
    KERNEL_DATA_STRUCT_PTR kernel_data;
    PSP_SUPPORT_STRUCT_PTR psp_sup_ptr;

    _GET_KERNEL_DATA(kernel_data);

    psp_sup_ptr = _mem_alloc_system_zero((uint32_t)sizeof(PSP_SUPPORT_STRUCT));

    if (psp_sup_ptr)
    {
       _mem_set_type(psp_sup_ptr, MEM_TYPE_PSP_SUPPORT_STRUCT);
       kernel_data->PSP_SUPPORT_PTR = psp_sup_ptr;
    }
}
Example #21
0
/*!
 * \brief This function creates a kernel component providing a lightweight log
 * service for all user tasks.
 *
 * The lightweight log component provides a maximum of 16 logs, all with the same
 * size of entries. Log number 0 is reserved for kernel log.
 * \n An application subsequently creates lightweight logs with _lwlog_create() or
 * _lwlog_create_at().
 *
 * \return MQX_OK
 * \return MQX_OUT_OF_MEMORY (MQX is out of memory.)
 * \return MQX_CANNOT_CALL_FUNCTION_FROM_ISR (Function cannot be called from an ISR.)
 *
 * \warning Cannot be called from an ISR.
 *
 * \see _lwlog_create
 * \see _lwlog_create_at
 * \see _klog_create
 * \see _klog_create_at
 */
_mqx_uint _lwlog_create_component(void)
{ /* Body */
    KERNEL_DATA_STRUCT_PTR     kernel_data;
    LWLOG_COMPONENT_STRUCT_PTR log_component_ptr;

    _GET_KERNEL_DATA(kernel_data);

#if MQX_CHECK_ERRORS
    if (kernel_data->IN_ISR)
    {
        _task_set_error(MQX_CANNOT_CALL_FUNCTION_FROM_ISR);
        return MQX_CANNOT_CALL_FUNCTION_FROM_ISR;
    } /* Endif */
#endif

    _lwsem_wait((LWSEM_STRUCT_PTR) &kernel_data->COMPONENT_CREATE_LWSEM);

#if MQX_CHECK_ERRORS
    if (kernel_data->KERNEL_COMPONENTS[KERNEL_LWLOG] != NULL)
    {
        _lwsem_post((LWSEM_STRUCT_PTR) &kernel_data->COMPONENT_CREATE_LWSEM);
        return (MQX_OK);
    } /* Endif */
#endif

#if MQX_LITE_VERSION_NUMBER
    log_component_ptr = &lwlog_struct;
#else
    log_component_ptr = _mem_alloc_system_zero((_mem_size) sizeof(LWLOG_COMPONENT_STRUCT));
#if MQX_CHECK_MEMORY_ALLOCATION_ERRORS
    if (log_component_ptr == NULL)
    {
        _lwsem_post((LWSEM_STRUCT_PTR) &kernel_data->COMPONENT_CREATE_LWSEM);
        return (MQX_OUT_OF_MEMORY);
    } /* Endif */
#endif
    _mem_set_type(log_component_ptr, MEM_TYPE_LWLOG_COMPONENT);
#endif /* MQX_LITE_VERSION_NUMBER */

    kernel_data->KERNEL_COMPONENTS[KERNEL_LWLOG] = log_component_ptr;
    log_component_ptr->VALID = LWLOG_VALID;

    _lwsem_post((LWSEM_STRUCT_PTR) &kernel_data->COMPONENT_CREATE_LWSEM);

    return (MQX_OK);

} /* Endbody */
Example #22
0
uint_32 _psp_init_readyqs
   (
      void
   )
{ /* Body */
   KERNEL_DATA_STRUCT_PTR kernel_data;
   READY_Q_STRUCT_PTR     q_ptr;
   _mqx_uint              priority_levels;
   _mqx_uint              n;

   _GET_KERNEL_DATA(kernel_data);
   kernel_data->READY_Q_LIST = (READY_Q_STRUCT_PTR) NULL;
   priority_levels = kernel_data->LOWEST_TASK_PRIORITY + 2;

   q_ptr = (READY_Q_STRUCT_PTR)
      _mem_alloc_zero(sizeof(READY_Q_STRUCT) * priority_levels);
#if MQX_CHECK_MEMORY_ALLOCATION_ERRORS
   if ( q_ptr == NULL ) {
      return (MQX_OUT_OF_MEMORY);
   } /* Endif */
#endif
   _mem_set_type(q_ptr, MEM_TYPE_READYQ);

   n = priority_levels;
   while (n--) {
      q_ptr->HEAD_READY_Q  = (TD_STRUCT_PTR)((pointer)q_ptr);
      q_ptr->TAIL_READY_Q  = (TD_STRUCT_PTR)((pointer)q_ptr);
      q_ptr->PRIORITY      = (uint_16)n;
      q_ptr->NEXT_Q        = kernel_data->READY_Q_LIST;
      kernel_data->READY_Q_LIST = q_ptr++;
   } /* Endwhile */

   /* 
   ** Set the current ready q (where the ready queue searches start) to
   ** the head of the list of ready queues.
   */
   kernel_data->CURRENT_READY_Q = kernel_data->READY_Q_LIST;

   /* Initialize the ENABLE_SR fields in the ready queues */
   q_ptr =  kernel_data->READY_Q_LIST;
   q_ptr->ENABLE_SR = 1;  /* Interrupts disabled for this level */

   return MQX_OK;

} /* Endbody */
Example #23
0
uint32_t _io_tfs_install
   (
      /*[IN] the name that should be given to tfs (ex: "C:", "TFS1:", etc..) */
      char              *identifier,
      
      /*[IN] pointer to the first entry of the root TFS directory  */  
      const TFS_DIR_ENTRY   *root
   )
{ /* Body */
   uint32_t                      error_code;
   TFS_DRIVE_STRUCT_PTR         drive_ptr;
   
   drive_ptr = _mem_alloc_system_zero( sizeof(TFS_DRIVE_STRUCT) );
   if ( drive_ptr == NULL ) {
      return( TFS_INSUFFICIENT_MEMORY );
   }/* Endif */
   _mem_set_type(drive_ptr,MEM_TYPE_IO_TFS_DRIVE_STRUCT);      
   
   _int_disable();

   error_code = _io_dev_install_ext( identifier, 
      _io_tfs_open,                     
      _io_tfs_close, 
      _io_tfs_read,                      
      _io_tfs_write,                     
      _io_tfs_ioctl,
      _io_tfs_uninstall,
      (void *)drive_ptr);

   if (error_code != IO_OK) {
      _mem_free(drive_ptr);
      drive_ptr = NULL;
      _int_enable();      
      return error_code;
   } /* Endif */

   drive_ptr->IDENTIFIER = identifier;
   drive_ptr->ROOT     = root;
 
   _int_enable();

   return(error_code);

} /* Endbody */
Example #24
0
bool SOCK_Add_owner
   (
      SOCKET_STRUCT_PTR    socket_ptr,
      _rtcs_taskid         task_ptr
   )
{ /* Body */
#if RTCSCFG_SOCKET_OWNERSHIP
   SOCKET_OWNER_STRUCT_PTR owner_ptr, new_owner_ptr;
   uint32_t                 i;
   void                  **saved_ptr = NULL;

   owner_ptr = &socket_ptr->OWNERS;

   while (owner_ptr != NULL) {
      for (i=0;i<SOCKET_NUMOWNERS;i++) {
         if (owner_ptr->TASK[i] == task_ptr) {
            /* already here, just return */
            return TRUE;
         } else if ((owner_ptr->TASK[i] == 0) && (saved_ptr == NULL)) {
            saved_ptr = &owner_ptr->TASK[i];
         } /* Endif */
      } /* Endfor */
      owner_ptr = owner_ptr->NEXT;
   } /* Endwhile */

   if (saved_ptr != NULL) {
      *saved_ptr = task_ptr;
   } else {
      new_owner_ptr = RTCS_mem_alloc_zero(sizeof(SOCKET_OWNER_STRUCT));
      if (new_owner_ptr == NULL) {
         return FALSE;
      } /* Endif */

      _mem_set_type(new_owner_ptr, MEM_TYPE_SOCKET_OWNER_STRUCT);

      new_owner_ptr->TASK[0] = task_ptr;
      owner_ptr->NEXT = new_owner_ptr;
   } /* Endif */
   return TRUE;
#else
   return TRUE;
#endif
} /* Endbody */
Example #25
0
/*FUNCTION*-------------------------------------------------------------------
* 
* Function Name    : _allocate_sector_cache
* Returned Value   : True, False
* Comments         : Allocate the flash sector cache
* 
*END*----------------------------------------------------------------------*/
bool _allocate_sector_cache(MQX_FILE_PTR fd_ptr) 
{
    IO_FLASHX_FILE_STRUCT_PTR file_ptr = (IO_FLASHX_FILE_STRUCT_PTR) fd_ptr->DEV_DATA_PTR;

    /* test for sector cache enable */
    if (!(file_ptr->FLAGS & FLASHX_SECTOR_CACHE_ENABLED))
        return FALSE;
    
    if (file_ptr->CACHE_PTR == NULL) {
        file_ptr->CACHE_PTR  = _mem_alloc_system(file_ptr->MAX_SECT_SIZE);
#if MQX_CHECK_MEMORY_ALLOCATION_ERRORS
        /* test for memory allocation */
        if(file_ptr->CACHE_PTR == NULL)
            return FALSE;
#endif
        _mem_set_type(file_ptr->CACHE_PTR, MEM_TYPE_IO_FLASHX_SECTOR_CACHE);
    }
    return TRUE;
}
Example #26
0
/*!
 * \brief Creates the lightweight log.
 *
 * Each entry in the log is the same size and contains a sequence number, a timestamp,
 * and a seven-element array of application-defined data.
 *
 * \param[in] log_number Log number to create ( 1 through 15; 0 is reserved for
 * kernel log).
 * \param[in] max_size   Maximum number of entries in the log.
 * \param[in] flags      LOG_OVERWRITE (when the log is full, write new entries
 * over oldest ones), NULL (when the log is full, do not write entries; the default
 * behavior).
 *
 * \return MQX_OK
 * \return LOG_EXISTS (Lightweight log with log number log_number exists.)
 * \return LOG_INVALID (Log_number is out of range.)
 * \return LOG_INVALID_SIZE (Max_size is 0.)
 * \return MQX_INVALID_COMPONENT_BASE (Data for the lightweight log component is
 * not valid.)
 * \return MQX_OUT_OF_MEMORY (MQX is out of memory.)
 * \return MQX_CANNOT_CALL_FUNCTION_FROM_ISR (Function cannot be called from an ISR.)
 *
 * \warning Creates the lightweight log component if it was not created.
 *
 * \see _lwlog_create_at
 * \see _lwlog_create_component
 * \see _klog_create
 * \see _klog_create_at
 */
_mqx_uint _lwlog_create
(
    _mqx_uint log_number,
    _mqx_uint max_size,
    _mqx_uint flags
)
{ /* Body */
    LWLOG_HEADER_STRUCT_PTR log_header_ptr;
    _mqx_uint               result;

#if MQX_CHECK_ERRORS
    if (max_size == 0)
    {
        return LOG_INVALID_SIZE;
    } /* Endif */
#endif

    log_header_ptr = _mem_alloc_system_zero((_mem_size) sizeof(LWLOG_HEADER_STRUCT) + (_mem_size) (max_size - 1)
                    * (_mem_size) sizeof(LWLOG_ENTRY_STRUCT));
#if MQX_CHECK_MEMORY_ALLOCATION_ERRORS
    if (log_header_ptr == NULL)
    {
        return (MQX_OUT_OF_MEMORY);
    } /* Endif */
#endif
    _mem_set_type(log_header_ptr, MEM_TYPE_LWLOG);

    result = _lwlog_create_internal(log_number, max_size, flags, log_header_ptr);
    if (result == MQX_OK)
    {
        log_header_ptr->TYPE = LWLOG_DYNAMIC;
    }
    else
    {
        _mem_free(log_header_ptr);
    } /* Endif */

    return (result);

} /* Endbody */
Example #27
0
uint32_t ICMP_init
   (
      void
   )
{ /* Body */
   ICMP_CFG_STRUCT_PTR  icmp_cfg_ptr;
   uint32_t              status = RTCS_OK;     /* return code */

   icmp_cfg_ptr = RTCS_mem_alloc_zero(sizeof(ICMP_CFG_STRUCT));
   if (icmp_cfg_ptr == NULL) {
      return RTCSERR_OUT_OF_MEMORY;
   }

   _mem_set_type(icmp_cfg_ptr, MEM_TYPE_ICMP_CFG_STRUCT);
   
   RTCS_setcfg(ICMP, icmp_cfg_ptr);

   IP_open(IPPROTO_ICMP, ICMP_service, NULL, &status);

   return status;

} /* Endbody */
Example #28
0
static DHCPSRV_ADDR_STRUCT_PTR _PTR_ DHCPSRV_update_clientid
   (
      DHCPSRV_ADDR_STRUCT_PTR _PTR_ addrhead,
      uchar_ptr                     cid_ptr,
      uint_32                       cid_len
   )
{ /* Body */
   DHCPSRV_ADDR_STRUCT_PTR addr = *addrhead;
   uchar_ptr               cid;

   cid = RTCS_mem_alloc(cid_len);
   if (!cid) return NULL;
   _mem_set_type(cid, MEM_TYPE_DHCPSRV_CID);

   if (addr->CLIENTID_PTR) _mem_free(addr->CLIENTID_PTR);

   _mem_copy(cid_ptr, cid, cid_len);
   addr->CLIENTID_PTR = cid;
   addr->CLIENTID_LEN = cid_len;

   return addrhead;

} /* Endbody */
Example #29
0
_mqx_int _io_socket_open
   (
      MQX_FILE_PTR fd_ptr,
      char _PTR_  open_name_ptr,
      char _PTR_  flags_ptr
   )
{ /* Body */
   IO_SOCKET_PTR io_ptr;

   io_ptr = RTCS_mem_alloc_zero(sizeof(*io_ptr));
   if (io_ptr == NULL) {
      return MQX_OUT_OF_MEMORY;
   } /* Endif */
   
   _mem_set_type(io_ptr, MEM_TYPE_IO_SOCKET);
   
   fd_ptr->DEV_DATA_PTR = io_ptr;

   io_ptr->SOCKET = (uint_32)flags_ptr;

   return MQX_OK;

} /* Endbody */
Example #30
0
_mqx_uint _log_create_component
   (
      void
   )
{ /* Body */
   KERNEL_DATA_STRUCT_PTR   kernel_data;
   LOG_COMPONENT_STRUCT_PTR log_component_ptr;

   _GET_KERNEL_DATA(kernel_data);

   log_component_ptr = (LOG_COMPONENT_STRUCT_PTR)
      _mem_alloc_system_zero((_mem_size)sizeof(LOG_COMPONENT_STRUCT));
#if MQX_CHECK_MEMORY_ALLOCATION_ERRORS
   if (log_component_ptr == NULL) {
      return(MQX_OUT_OF_MEMORY);
   } /* Endif */
#endif
   _mem_set_type(log_component_ptr, MEM_TYPE_LOG_COMPONENT);

   /* We must exclude all ISRs at this point */
   _int_disable();

#if MQX_CHECK_ERRORS
   if (kernel_data->KERNEL_COMPONENTS[KERNEL_LOG] != NULL) {
      _int_enable();
      _mem_free(log_component_ptr);
      return(MQX_OK);
   } /* Endif */
#endif

   kernel_data->KERNEL_COMPONENTS[KERNEL_LOG] = log_component_ptr;
   log_component_ptr->VALID = LOG_VALID;
   _int_enable();

   return(MQX_OK);

} /* Endbody */