コード例 #1
0
ファイル: vcmmu.c プロジェクト: gaodebang/eth-com-project
_mqx_uint _mmu_create_vcontext
   (
      /* [IN] the task to which a virtual context is to be added */
      _task_id task_id
   )
{ /* Body */
   TD_STRUCT_PTR                  td_ptr;
   PSP_VIRTUAL_CONTEXT_STRUCT_PTR context_ptr;

   td_ptr = _task_get_td(task_id);
   if (td_ptr == NULL) {
      return(MQX_INVALID_TASK_ID);
   }/* Endif */
   context_ptr = _mem_alloc_system_zero(sizeof(PSP_VIRTUAL_CONTEXT_STRUCT));
   if (context_ptr == NULL) {
      return(MQX_OUT_OF_MEMORY);
   }/* Endif */
   _queue_init(&context_ptr->PAGE_INFO,0);
   _int_disable();
   if (td_ptr->FLAGS & TASK_MMU_CONTEXT_EXISTS) {
      _int_enable();
      _mem_free(context_ptr);
      return(MQX_MMU_CONTEXT_EXISTS);
   } /* Endif */

   td_ptr->MMU_VIRTUAL_CONTEXT_PTR = context_ptr;
   td_ptr->FLAGS |= TASK_MMU_CONTEXT_EXISTS;
   _int_enable();
   return(MQX_OK);

} /* Endbody */
コード例 #2
0
ファイル: i2c_pol_mcf52xx.c プロジェクト: Vinhuit/Freescale
uint32_t _mcf52xx_i2c_polled_deinit
   (
      /* [IN] the initialization information for the device being opened */
      IO_I2C_POLLED_DEVICE_STRUCT_PTR pol_io_dev_ptr,

      /* [IN] the address of the device specific information */
      VMCF52XX_I2C_INFO_STRUCT_PTR    io_info_ptr
   )
{ /* Body */
   VMCF52XX_I2C_STRUCT_PTR            i2c_ptr;

   if ((NULL == io_info_ptr) || (NULL == pol_io_dev_ptr)) 
   {
      return I2C_ERROR_INVALID_PARAMETER;
   }
      
   i2c_ptr = io_info_ptr->I2C_PTR;
   if (i2c_ptr->I2SR & MCF52XX_I2C_I2SR_IBB) 
   {
      return I2C_ERROR_DEVICE_BUSY;
   }
   
   /* Disable the I2C */
   i2c_ptr->I2CR = 0x00;

   /* Clear the I2C events */
   i2c_ptr->I2SR = 0x00; 
 
   /* Free info struct */
   _mem_free (pol_io_dev_ptr->DEV_INFO_PTR);
   pol_io_dev_ptr->DEV_INFO_PTR = NULL;

   return MQX_OK;

} /* Endbody */
コード例 #3
0
ファイル: usb_dcd_pol_kn.c プロジェクト: Vinhuit/Freescale
uint32_t _kusb_dcd_polled_deinit
   (
      /* [IN] the initialization information for the device being opened */
      IO_USB_DCD_POLLED_DEVICE_STRUCT_PTR pol_io_dev_ptr,

      /* [IN] the address of the device specific information */
      KUSB_DCD_INFO_STRUCT_PTR     io_info_ptr
   )
{ /* Body */
   USBDCD_MemMapPtr            usb_dcd_ptr;

   if ((NULL == io_info_ptr) || (NULL == pol_io_dev_ptr))
   {
      return USB_DCD_ERROR_INVALID_PARAMETER;
   }

   usb_dcd_ptr = io_info_ptr->USB_DCD_PTR;

   /* Disable the USB DCD module */
   usb_dcd_ptr->CONTROL = USBDCD_CONTROL_IACK_MASK | USBDCD_CONTROL_SR_MASK;

   /* Free info struct */
   _mem_free (pol_io_dev_ptr->DEV_INFO_PTR);
   pol_io_dev_ptr->DEV_INFO_PTR = NULL;

   return MQX_OK;

} /* Endbody */
コード例 #4
0
ファイル: dnat.c プロジェクト: kylemanna/kinetis-sdk1
void  DNAT_delete_rule_internal
   (
      DNAT_PARM_PTR           dparm_ptr      /* [IN] */
    )
{ /* Body */   
   NAT_CFG_STRUCT_PTR      nat_cfg_ptr = RTCS_getcfg(NAT);
   DNAT_ELEMENT_STRUCT_PTR element_ptr;
   uint32_t                 priority = dparm_ptr->RULE.PRIORITY;

   if (nat_cfg_ptr == NULL) {
      RTCSCMD_complete(dparm_ptr, RTCSERR_NAT_NOT_INITIALIZED);
      return;
   }

   element_ptr = (DNAT_ELEMENT_STRUCT_PTR) _queue_head(&nat_cfg_ptr->RULE_QUEUE); 

   while (element_ptr != NULL) {
      if (element_ptr->RULE.PRIORITY == priority) {
         _queue_unlink(&nat_cfg_ptr->RULE_QUEUE, &element_ptr->ELEMENT); 
         _mem_free((void *)element_ptr);
         RTCSCMD_complete(dparm_ptr, RTCS_OK);
         return;
      } 
      element_ptr = (DNAT_ELEMENT_STRUCT_PTR) _queue_next(&nat_cfg_ptr->RULE_QUEUE, &element_ptr->ELEMENT);
   }
   
   RTCSCMD_complete(dparm_ptr, RTCSERR_NAT_INVALID_RULE);
} /* Endbody */
コード例 #5
0
ファイル: ipcp.c プロジェクト: kylemanna/kinetis-sdk1
uint32_t IPCP_destroy
   (
      IP_IF_PTR   if_ptr
         /* [IN] the IP interface structure */
   )
{ /* Body */

#if RTCSCFG_ENABLE_IP4 

   IPCP_CFG_STRUCT_PTR  ipcp_ptr = if_ptr->HANDLE;

   PPP_unregister(ipcp_ptr->HANDLE, PPP_PROT_IP);
   PPP_unregister(ipcp_ptr->HANDLE, PPP_PROT_IPCP);
   PPPFSM_lowerdown(&ipcp_ptr->FSM);
   PPPFSM_destroy(&ipcp_ptr->FSM);
   _mem_free(ipcp_ptr);
   if_ptr->HANDLE = NULL;

   return RTCS_OK;

#else
    
    return RTCSERR_IP_IS_DISABLED;    
    
#endif /* RTCSCFG_ENABLE_IP4 */   

} /* Endbody */
コード例 #6
0
ファイル: i2c_pol_ki2c.c プロジェクト: gxliu/MQX_3.8.0
uint_32 _ki2c_polled_deinit
   (
      /* [IN] the initialization information for the device being opened */
      IO_I2C_POLLED_DEVICE_STRUCT_PTR pol_io_dev_ptr,

      /* [IN] the address of the device specific information */
      VKI2C_INFO_STRUCT_PTR           io_info_ptr
   )
{ /* Body */
   I2C_MemMapPtr                      i2c_ptr;

   if ((NULL == io_info_ptr) || (NULL == pol_io_dev_ptr)) 
   {
      return I2C_ERROR_INVALID_PARAMETER;
   }
      
   i2c_ptr = io_info_ptr->I2C_PTR;
   if (i2c_ptr->S & I2C_S_BUSY_MASK) 
   {
      return I2C_ERROR_DEVICE_BUSY;
   }
   
   /* Disable the I2C */
   i2c_ptr->C1 = 0x00;

   /* Clear the I2C events */
   i2c_ptr->S = 0xFF; 
 
   /* Free info struct */
   _mem_free (pol_io_dev_ptr->DEV_INFO_PTR);
   pol_io_dev_ptr->DEV_INFO_PTR = NULL;

   return MQX_OK;

} /* Endbody */
コード例 #7
0
ファイル: rip.c プロジェクト: Wangwenxue/FutureMove-T-box
uint32_t RIP_init (void)
{ /* Body */
    RIP_CFG_STRUCT_PTR  cfg = RTCS_getcfg(RIP);
    uint32_t err;

    if (RTCS_getcfg(RIP)) return RTCS_OK;
    /* allocate the memory */
    cfg = RTCS_mem_alloc_zero(sizeof(*cfg));
    if (!cfg)  return RTCSERR_OUT_OF_MEMORY;
    /* bind the udp port */
    err = UDP_openbind_internal(IPPORT_RIP, RIP_service, &cfg->UCB);
    if (err){
        _mem_free(cfg);
        return err;
    }

    RTCS_setcfg(RIP, cfg);
    ROUTE_register(&RIP_routefn);

    /* Start the retransmission timer to start sending immediately */
    cfg->TIMER_PERIODIC.TIME    = 0;
    cfg->TIMER_PERIODIC.EVENT   = RIP_expire_periodic;
    cfg->TIMER_PERIODIC.PRIVATE = NULL;
    TCPIP_Event_add(&cfg->TIMER_PERIODIC);

    /* probe all the interfaces now to build the route table faster */
    err = RIP_send_req();

    return RTCS_OK;
} /* Endbody */
コード例 #8
0
ファイル: io_pcb2.c プロジェクト: gxliu/MQX_3.8.0
_mqx_uint _io_pcb_destroy_pool
   (
      /* The PCB pool to destroy */
      _io_pcb_pool_id pool
   )
{ /* Body */
   KERNEL_DATA_STRUCT_PTR kernel_data;
   IO_PCB_POOL_STRUCT_PTR pool_ptr = IO_PCB_GET_POOL_PTR(pool);
   _mqx_uint              result;
   
#if MQX_CHECK_VALIDITY
   if (pool_ptr->VALID != IO_PCB_VALID) {
      return(IO_PCB_POOL_INVALID);
   }/* Endif */
#endif

   pool_ptr->VALID = 0;
  
   result = _partition_destroy(pool_ptr->PARTITION);
   if (result != MQX_OK ) {
      return(result);
   }/* Endif */

  _lwsem_destroy(&pool_ptr->PCB_LWSEM);
   _GET_KERNEL_DATA(kernel_data);
  _queue_unlink((QUEUE_STRUCT_PTR)(&kernel_data->IO_PCB_POOLS), 
     &pool_ptr->QUEUE);
  return(_mem_free(pool_ptr));

} /* Endbody */
コード例 #9
0
ファイル: spi.c プロジェクト: Wangwenxue/FutureMove-T-box
/*FUNCTION****************************************************************
*
* Function Name    : _io_spi_uninstall
* Returned Value   : MQX error code
* Comments         :
*    Uninstalls SPI device.
*
*END**********************************************************************/
static _mqx_int _io_spi_uninstall
    (
        /* [IN] The IO device structure for the device */
        IO_DEVICE_STRUCT_PTR           io_dev_ptr
    )
{
    SPI_DRIVER_DATA_STRUCT_PTR driver_data;

    _mqx_int error_code = MQX_OK;

    driver_data = (SPI_DRIVER_DATA_STRUCT_PTR)(io_dev_ptr->DRIVER_INIT_PTR);

    /* deinitialize low level driver */
    if (driver_data->DEVIF->DEINIT)
        error_code = driver_data->DEVIF->DEINIT(driver_data->DEVIF_DATA);

    if (error_code != MQX_OK)
    {
        return error_code;
    }

    _lwsem_destroy(&driver_data->BUS_LOCK);
    _mem_free(driver_data);

    return MQX_OK;
}
コード例 #10
0
ファイル: dhcpsrv.c プロジェクト: gxliu/MQX_3.8.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 */
コード例 #11
0
ファイル: hmi_client.c プロジェクト: tsbiberdorf/MqxSrc
/*FUNCTION*----------------------------------------------------------------
*
* Function Name    : hmi_add_provider
* Returned Value   : TRUE if adding success, else FALSE
* Comments         :
*   This function adds provider
*
*END*--------------------------------------------------------------------*/
boolean hmi_add_provider(HMI_CLIENT_STRUCT_PTR client_handle, HMI_PROVIDER_STRUCT_PTR provider_handle)
{
    boolean result = FALSE;
    uint_32 i;

    if((provider_handle == NULL) || (client_handle==NULL))
    {
        return result;
    }
    /* add provider into the table*/
    for(i=0; i<client_handle->MAX_PROVIDER_COUNT; i++)
    {
        if(client_handle->PROVIDER_TABLE[i] == NULL)
        {
            result = TRUE;
            client_handle->PROVIDER_TABLE[i] = provider_handle;
            client_handle->PROVIDER_TABLE[i]->ATTACH_CLIENT(provider_handle, client_handle);
            if (client_handle->PROVIDER_TABLE[i]->INSTALL_INTERRUPT_PTR != NULL)
            {
                /* register callback */
                client_handle->PROVIDER_TABLE[i]->INSTALL_INTERRUPT_PTR(provider_handle);
            }
            break;
        }
    }
    /* if array is full do re-alloc */
    if(result == FALSE)
    {
        HMI_PROVIDER_STRUCT_PTR     provider_table_new;

        provider_table_new = _mem_alloc_system_zero(client_handle->MAX_PROVIDER_COUNT * HMI_GROW_UP_PROVIDER_COUNT * sizeof(HMI_PROVIDER_STRUCT_PTR));
        if(provider_table_new == NULL)
        {
            return FALSE;
        }
        /* copy smaller array to bigger array*/
        _mem_copy(client_handle->PROVIDER_TABLE, provider_table_new, client_handle->MAX_PROVIDER_COUNT * sizeof(client_handle->PROVIDER_TABLE));
        _mem_free(client_handle->PROVIDER_TABLE);
        client_handle->PROVIDER_TABLE = (pointer) provider_table_new;
        client_handle->MAX_PROVIDER_COUNT = client_handle->MAX_PROVIDER_COUNT * HMI_GROW_UP_PROVIDER_COUNT;
        for(i=0; i<client_handle->MAX_PROVIDER_COUNT; i++)
        {
            if(client_handle->PROVIDER_TABLE[i] == NULL)
            {
                result = TRUE;
                client_handle->PROVIDER_TABLE[i] = provider_handle;
                client_handle->PROVIDER_TABLE[i]->ATTACH_CLIENT(provider_handle,client_handle);
                if (client_handle->PROVIDER_TABLE[i]->INSTALL_INTERRUPT_PTR != NULL)
                {
                    /* register callback */
                    client_handle->PROVIDER_TABLE[i]->INSTALL_INTERRUPT_PTR(provider_handle);
                }
                break;
            }
        }
    }

    return result;
}
コード例 #12
0
ファイル: io_mem.c プロジェクト: Vinhuit/Freescale
_mqx_int _io_mem_uninstall
    (
        /* [IN] The devices context */
        IO_DEVICE_STRUCT_PTR  io_dev_ptr
    )
{
    IO_MEM_STRUCT_PTR     handle_ptr = (IO_MEM_STRUCT_PTR)io_dev_ptr->DRIVER_INIT_PTR;

    _lwsem_destroy(&handle_ptr->LWSEM);

    if (handle_ptr->TYPE == MEM_TYPE_DYNAMIC) {
        _mem_free(handle_ptr->BASE_ADDR);
    }
    _mem_free(handle_ptr);

    return(MQX_OK);
}
コード例 #13
0
/*FUNCTION*-------------------------------------------------------------------
*
* Function Name    : mcf52xx_flash_deinit
* Returned Value   :
* Comments         :
*
*
*END*----------------------------------------------------------------------*/
void mcf52xx_flash_deinit
(
    /* [IN] File pointer */
    IO_FLASHX_STRUCT_PTR dev_ptr
)
{
    MCF52XX_FLASH_INTERNAL_STRUCT_PTR dev_spec_ptr = (MCF52XX_FLASH_INTERNAL_STRUCT_PTR) dev_ptr->DEVICE_SPECIFIC_DATA;

    /* de-allocate the ram function buffer */
    if(dev_spec_ptr->flash_execute_code_ptr) {
        _mem_free(dev_spec_ptr->flash_execute_code_ptr);
    }
    dev_spec_ptr->flash_execute_code_ptr = NULL;
    /* de-allocate device specific structure */
    _mem_free(dev_ptr->DEVICE_SPECIFIC_DATA);
    dev_ptr->DEVICE_SPECIFIC_DATA = NULL;
}
コード例 #14
0
ファイル: lwlog.c プロジェクト: Vinhuit/Freescale
/*!
 * \brief Destroys an existing lightweight log.
 *
 * \param[in] log_number Log number of a previously created lightweight log (if
 * log_number is 0, kernel log is destroyed).
 *
 * \return MQX_OK
 * \return LOG_DOES_NOT_EXIST (Log_number was not previously created.)
 * \return LOG_INVALID (Log_number is out of range.)
 * \return MQX_COMPONENT_DOES_NOT_EXIST (Lightweight log component is not created.)
 * \return MQX_INVALID_COMPONENT_HANDLE (Lightweight log component data is not valid.)
 *
 * \see _lwlog_create
 * \see _lwlog_create_at
 * \see _lwlog_create_component
 */
_mqx_uint _lwlog_destroy
(
    _mqx_uint log_number
)
{ /* Body */
    KERNEL_DATA_STRUCT_PTR     kernel_data;
    LWLOG_COMPONENT_STRUCT_PTR log_component_ptr;
    LWLOG_HEADER_STRUCT_PTR    log_header_ptr;

    _GET_KERNEL_DATA(kernel_data);

#if MQX_CHECK_ERRORS
    if (log_number >= LOG_MAXIMUM_NUMBER)
    {
        return (LOG_INVALID);
    } /* Endif */
#endif

    log_component_ptr = (LWLOG_COMPONENT_STRUCT_PTR) kernel_data->KERNEL_COMPONENTS[KERNEL_LWLOG];

#if MQX_CHECK_ERRORS
    if (log_component_ptr == NULL)
    {
        return (MQX_COMPONENT_DOES_NOT_EXIST);
    } /* Endif */
#endif

#if MQX_CHECK_VALIDITY
    if (log_component_ptr->VALID != LWLOG_VALID)
    {
        return (MQX_INVALID_COMPONENT_HANDLE);
    } /* Endif */
#endif

    _int_disable();

    log_header_ptr = log_component_ptr->LOGS[log_number];
#if MQX_CHECK_ERRORS
    if (log_header_ptr == NULL)
    {
        _int_enable();
        return (LOG_DOES_NOT_EXIST);
    } /* Endif */
#endif

    log_component_ptr->LOGS[log_number] = NULL;
    _int_enable();

#if !MQX_LITE_VERSION_NUMBER
    if (log_header_ptr->TYPE == LWLOG_DYNAMIC)
    {
        _mem_free(log_header_ptr);
    } /* Endif */
#endif

    return (MQX_OK);

} /* Endbody */
コード例 #15
0
ファイル: USB_Task.c プロジェクト: zhouglu/K60F120M
void usb_host_mass_device_event
   (
      /* [IN] pointer to device instance */
      _usb_device_instance_handle      dev_handle,

      /* [IN] pointer to interface descriptor */
      _usb_interface_descriptor_handle intf_handle,

      /* [IN] code number for event causing callback */
      uint_32           event_code
   )
{
   DEVICE_STRUCT_PTR          device;
   usb_msg_t                  msg;

   switch (event_code) {
      case USB_CONFIG_EVENT:
         /* Drop through into attach, same processing */
      case USB_ATTACH_EVENT:
         /* Here, the device starts its lifetime */
         device = (DEVICE_STRUCT_PTR) _mem_alloc_zero(sizeof(DEVICE_STRUCT));
         if (device == NULL)
            break;

         if (USB_OK != _usb_hostdev_select_interface(dev_handle, intf_handle, &device->ccs))
            break;
         msg.ccs = &device->ccs;
         msg.body = USB_EVENT_ATTACH;
         if (LWMSGQ_FULL == _lwmsgq_send(usb_taskq, (uint_32 *) &msg, 0)) {
            printf("Could not inform USB task about device attached\n");
         }
         break;

      case USB_INTF_EVENT:
         if (USB_OK != usb_class_mass_get_app(dev_handle, intf_handle, (CLASS_CALL_STRUCT_PTR *) &device))
            break;
         msg.ccs = &device->ccs;
         msg.body = USB_EVENT_INTF;
         if (LWMSGQ_FULL == _lwmsgq_send(usb_taskq, (uint_32 *) &msg, 0)) {
            printf("Could not inform USB task about device interfaced\n");
         }
         break;

      case USB_DETACH_EVENT:
         if (USB_OK != usb_class_mass_get_app(dev_handle, intf_handle, (CLASS_CALL_STRUCT_PTR *) &device))
            break;
         msg.ccs = &device->ccs;
         msg.body = USB_EVENT_DETACH;
         if (LWMSGQ_FULL == _lwmsgq_send(usb_taskq, (uint_32 *) &msg, 0)) {
            printf("Could not inform USB task about device detached\n");
         }
         _mem_free(device);
         break;

      default:
         break;
   } 
} 
コード例 #16
0
ファイル: serl_mix_kuart.c プロジェクト: BillyZhangZ/wifi
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 */
コード例 #17
0
ファイル: dd_prof.c プロジェクト: shikhasuresh/MQX_3.8.0
void __rta_free
(
    void _PTR_ p
)
{   /* Body */

    _mem_free(p);

} /* Endbody */
コード例 #18
0
ファイル: mem.c プロジェクト: thatking/sample
int mem_free(void *_ptr)
{
    MEM_T *mem = NULL;
    if(_ptr)
    {
        mem = _void2mem(_ptr);
    }
    return _mem_free(mem);
}
コード例 #19
0
ファイル: bmalloc.c プロジェクト: ahamid/sartoris
void free(void *ptr)
{
#	ifdef SAFE
	wait_mutex(&malloc_mutex);
#	endif
	_mem_free(ptr);
#	ifdef SAFE
	leave_mutex(&malloc_mutex);
#	endif
}
コード例 #20
0
ファイル: mcf5xxx_fec_util.c プロジェクト: mihaSoro/MQX-3.7.0
void MCF5XXX_FEC_free_context( MCF5XXX_FEC_CONTEXT_STRUCT_PTR fec_context_ptr ) 
{
   if (fec_context_ptr) {
      if (fec_context_ptr->UNALIGNED_BUFFERS) {
         _mem_free((pointer)fec_context_ptr->UNALIGNED_BUFFERS);
      }
      if (fec_context_ptr->RX_PCB_BASE) {
         _mem_free((pointer)fec_context_ptr->RX_PCB_BASE);
      }
      if (fec_context_ptr->TxPCBS_PTR) {
         _mem_free((pointer)fec_context_ptr->TxPCBS_PTR);
      }
      if (fec_context_ptr->UNALIGNED_RING_PTR) {
         _mem_free((pointer)fec_context_ptr->UNALIGNED_RING_PTR);
      }
   
      _mem_free((pointer)fec_context_ptr);
   }
}
コード例 #21
0
ファイル: flash_mcf51xx.c プロジェクト: mihaSoro/MQX-3.7.0
/*FUNCTION*-------------------------------------------------------------------
* 
* Function Name    : mcf51xx_flash_deinit
* Returned Value   : 
* Comments         :
*    release used memory      
*
*END*----------------------------------------------------------------------*/
void mcf_51xx_flash_deinit( IO_FLASHX_STRUCT_PTR flash_ptr )
{

    INTERNAL_51XX_STRUCT_PTR    dev_spec_ptr;
    
    dev_spec_ptr = flash_ptr->DEVICE_SPECIFIC_DATA;

    /* if the flash write,erase code run form RAM, free memory */
    if ( flash_ptr->FLAGS & FLASHX_WR_ERASE_FROM_FLASH_ENABLED == 0 ){              
        /* de-allocate the ram function buffer */
        if(dev_spec_ptr->flash_execute_code_ptr){
            _mem_free(dev_spec_ptr->flash_execute_code_ptr);
        }
    }
    dev_spec_ptr->flash_execute_code_ptr = NULL;
    /* de-allocate device specific structure */
    _mem_free(flash_ptr->DEVICE_SPECIFIC_DATA);
    flash_ptr->DEVICE_SPECIFIC_DATA = NULL; 
}   
コード例 #22
0
ファイル: mfs_misc.c プロジェクト: kylemanna/kinetis-sdk1
/*!
 * \brief
 *
 * \param path_ptr
 *
 * \return bool
 */
bool MFS_free_path(char *path_ptr)
{
    if (path_ptr != NULL)
    {
        _mem_free(path_ptr);
        return true;
    }

    return false;
}
コード例 #23
0
ファイル: macnet_util.c プロジェクト: tsbiberdorf/MqxSrc
void MACNET_free_context( MACNET_CONTEXT_STRUCT_PTR macnet_context_ptr ) 
{
   if (macnet_context_ptr) {
      if (macnet_context_ptr->UNALIGNED_BUFFERS) {
         _mem_free((pointer)macnet_context_ptr->UNALIGNED_BUFFERS);
      }
      if (macnet_context_ptr->RX_PCB_BASE) {
         _mem_free((pointer)macnet_context_ptr->RX_PCB_BASE);
      }
      if (macnet_context_ptr->TxPCBS_PTR) {
         _mem_free((pointer)macnet_context_ptr->TxPCBS_PTR);
      }
      if (macnet_context_ptr->UNALIGNED_RING_PTR) {
         _mem_free((pointer)macnet_context_ptr->UNALIGNED_RING_PTR);
      }
   
      _mem_free((pointer)macnet_context_ptr);
   }
}
コード例 #24
0
/*
** Function for CGI request processing
**
** IN:
**      HTTPSRV_SESSION_STRUCT* session - session structure pointer.
**      HTTPSRV_STRUCT*         server - pointer to server structure (needed for session parameters).
**      char*                   cgi_name - name of cgi function.
**
** OUT:
**      none
**
** Return Value: 
**      none
*/
void httpsrv_process_cgi(HTTPSRV_STRUCT *server, HTTPSRV_SESSION_STRUCT *session, char* cgi_name)
{
    HTTPSRV_SCRIPT_MSG* msg_ptr;

    msg_ptr = _msg_alloc(server->script_msg_pool);

    if (msg_ptr == NULL)
    {
        /* Out of memory - report server error */
        session->response.status_code = HTTPSRV_CODE_INTERNAL_ERROR;
        return;
    }

    msg_ptr->header.TARGET_QID = server->script_msgq;
    msg_ptr->header.SOURCE_QID = server->script_msgq;
    msg_ptr->header.SIZE = sizeof(HTTPSRV_SCRIPT_MSG);
    msg_ptr->session = session;
    msg_ptr->type = HTTPSRV_CGI_CALLBACK;
    msg_ptr->name = cgi_name;
    msg_ptr->ses_tid = _task_get_id();
    _msgq_send(msg_ptr);
    /* wait until CGI is processed */
    _task_block();

    /*
    ** There is some unread content from client after CGI finished. 
    ** It must be read and discarded if we have keep-alive enabled
    ** so it does not affect next request.
    */
    if (session->request.content_length)
    {
        char *tmp = NULL;

        tmp = _mem_alloc(HTTPSRV_TMP_BUFFER_SIZE);
        if (tmp != NULL)
        {
            uint32_t length = session->request.content_length;

            while(length)
            {
                uint32_t retval;

                retval = httpsrv_read(session, tmp, HTTPSRV_TMP_BUFFER_SIZE);
                if (!retval)
                {
                    break;
                }
                length -= retval;
            }
            _mem_free(tmp);
            session->request.content_length = 0;
        } 
    }
    return;
}
コード例 #25
0
ファイル: serl_int.c プロジェクト: gxliu/MQX_3.8.0
_mqx_int _io_serial_int_close
   (
      /* [IN] the file handle for the device being closed */
      FILE_DEVICE_STRUCT_PTR fd_ptr
   )
{ /* Body */
   IO_DEVICE_STRUCT_PTR            io_dev_ptr;
   IO_SERIAL_INT_DEVICE_STRUCT_PTR int_io_dev_ptr;
   _mqx_int                        result = MQX_OK;
   _mqx_int                        ioctl_val;

   io_dev_ptr     = fd_ptr->DEV_PTR;
   int_io_dev_ptr = (pointer)io_dev_ptr->DRIVER_INIT_PTR;

   if (--int_io_dev_ptr->COUNT == 0) {

      if (int_io_dev_ptr->DEV_IOCTL != NULL) {
         if (fd_ptr->FLAGS & IO_SERIAL_HW_FLOW_CONTROL) {
            ioctl_val = IO_SERIAL_RTS;
            (*int_io_dev_ptr->DEV_IOCTL)(int_io_dev_ptr->DEV_INFO_PTR, IO_IOCTL_SERIAL_CLEAR_HW_SIGNAL, &ioctl_val);
         }
      }
      if (int_io_dev_ptr->DEV_DEINIT) {
          
#if MQX_ENABLE_LOW_POWER          
         _lwsem_wait (&(int_io_dev_ptr->LPM_INFO.LOCK));
#endif
         result = (*int_io_dev_ptr->DEV_DEINIT)(int_io_dev_ptr->DEV_INIT_DATA_PTR,
            int_io_dev_ptr->DEV_INFO_PTR);
#if MQX_ENABLE_LOW_POWER          
         _lwsem_post (&(int_io_dev_ptr->LPM_INFO.LOCK));
#endif
          
      } /* Endif */
      _mem_free(int_io_dev_ptr->IN_QUEUE);
      _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);
   } /* Endif */
   return(result);

} /* Endbody */
コード例 #26
0
ファイル: WDog1.c プロジェクト: mihaSoro/MQX-3.7.0
/*
** ===================================================================
**     Method      :  WDog1_Deinit (component WatchDog_LDD)
**
**     Description :
**         De-initializes the device and frees the device data
**         structure memory.
**         Note: De-initialization on some devices is impossible.
**         Method Deinit does nothing in this case.
**     Parameters  :
**         NAME            - DESCRIPTION
**       * DeviceDataPtr   - Device data structure
**                           pointer returned by Init method
**     Returns     : Nothing
** ===================================================================
*/
void WDog1_Deinit(LDD_TDeviceData *DeviceDataPtr)
{
  WDog1_TDeviceData *DeviceDataPrv = (WDog1_TDeviceData *)DeviceDataPtr;

  (void)DeviceDataPrv;
  /* Unregistration of the device structure */
  PE_LDD_UnregisterDeviceStructure(PE_LDD_COMPONENT_WDog1_ID);
  /* Deallocation of the device structure */
  /* {MQX RTOS Adapter} Driver memory deallocation: RTOS function call is defined by MQX RTOS Adapter property */
  _mem_free(DeviceDataPrv);
}
コード例 #27
0
ファイル: flash_ftfl.c プロジェクト: jewlenchow/MQX_3.8.1
/*FUNCTION*-------------------------------------------------------------------
*
* Function Name    : ftfl_flash_deinit
* Returned Value   : none
* Comments         :
*   Release flash specific information.
*
*END*-----------------------------------------------------------------------*/
void ftfl_flash_deinit
(
    /* [IN] Device instance */
    IO_FLASHX_STRUCT_PTR dev_ptr
)
{
    FTFL_FLASH_INTERNAL_STRUCT_PTR dev_spec_ptr = (FTFL_FLASH_INTERNAL_STRUCT_PTR) dev_ptr->DEVICE_SPECIFIC_DATA;

    /* de-allocate the ram function buffer */
    if(dev_spec_ptr->flash_execute_code_ptr)
    {
        _mem_free(dev_spec_ptr->flash_execute_code_ptr);
    }
    dev_spec_ptr->flash_execute_code_ptr = NULL;

    /* de-allocate the device specific structure */
    _mem_free(dev_spec_ptr);

    dev_ptr->DEVICE_SPECIFIC_DATA = NULL;
}
コード例 #28
0
ファイル: spi.c プロジェクト: BillyZhangZ/wifi
/*FUNCTION****************************************************************
*
* Function Name    : _io_spi_close
* Returned Value   : MQX error code
* Comments         :
*    This routine closes the SPI I/O channel.
*
*END**********************************************************************/
static _mqx_int _io_spi_close
    (
        /* [IN] The file handle for the device being closed */
        MQX_FILE_PTR         fd_ptr
    )
{
    _io_spi_flush(fd_ptr, 0);
    _mem_free(fd_ptr->DEV_DATA_PTR);

    return MQX_OK;
}
コード例 #29
0
ファイル: rtcspcb.c プロジェクト: Wangwenxue/FutureMove-T-box
static void RTCSPCB_free_internal
   (
      PCB_PTR   inpcb
         /* [IN] packet to free */
   )
{ 
   RTCSPCB_PTR rtcs_pcb = (RTCSPCB_PTR)inpcb->PRIVATE;

   /* Can't free this PCB until all duplicates are freed */
   if (RTCS_sem_trywait(&rtcs_pcb->DUPCOUNT) == RTCS_OK) {
      PCBLOG(("\nPCB: Free_internal: delaying %p", rtcs_pcb));
      return;
   } 

   /* If this PCB is a duplicate, decrement the original's refcount */
   if (rtcs_pcb->DUPPTR) {
      PCBLOG(("\nPCB: Free_internal: about to free %p", rtcs_pcb->DUPPTR));
      RTCSPCB_free(rtcs_pcb->DUPPTR);
      rtcs_pcb->DUPPTR = NULL;
   } 

   /* If this PCB has been forked, don't forget the link layer's PCB */
   if (rtcs_pcb->PCB_ORIG) {
      PCB_free(rtcs_pcb->PCB_ORIG);
      rtcs_pcb->PCB_ORIG = NULL;
   } 

   /* handle the FREE_FRAG_FIELD */
   if (rtcs_pcb->FREE_FRAG_BITFIELD) {
      uint32_t  i;
      for (i = 0; i < RTCSPCB_FRAG_MAX; i++) {
         if (rtcs_pcb->FREE_FRAG_BITFIELD & (1 << i)) {
            _mem_free(rtcs_pcb->PCBPTR->FRAG[i].FRAGMENT);
         } 
      } 
      rtcs_pcb->FREE_FRAG_BITFIELD = 0;
   } 

   if (rtcs_pcb->PCB_FREE) {
      inpcb->FREE    = rtcs_pcb->PCB_FREE;
      inpcb->PRIVATE = rtcs_pcb->PCB_PRIVATE;
      inpcb->FRAG[0] = rtcs_pcb->PCB_BUFFER;
      PCBLOG(("\nPCB: Free_internal: PCB is %p", inpcb));
      PCB_free(inpcb);
   } 

   if (rtcs_pcb->UDP_REQUEST) {
      RTCS_cmd_complete(rtcs_pcb->UDP_REQUEST, RTCS_OK);
      rtcs_pcb->UDP_REQUEST = NULL;
   } 

   RTCS_part_free(rtcs_pcb);

} 
コード例 #30
0
/*FUNCTION*-------------------------------------------------------------
*
* Function Name   : freeaddrinfo
* Returned Value  : void
* Comments        : Free address info.
*
*END*-----------------------------------------------------------------*/
void freeaddrinfo	(
						struct addrinfo *ai
					) 
{
	struct addrinfo *ai_next;

	while (ai != NULL) 
	{
		ai_next = ai->ai_next;
		if (ai->ai_addr != NULL)
		{
			_mem_free(ai->ai_addr);
		}
		if (ai->ai_canonname)
		{
			_mem_free(ai->ai_canonname);
		}
		_mem_free(ai);
		ai = ai_next;
	}
}