usbinst.c 2.33 KB
/*HEADER******************************************************************
**************************************************************************
*** 
*** Copyright (c) 2001-2002 ARC International.
*** All rights reserved                                          
***                                                              
*** This software embodies materials and concepts which are      
*** confidential to ARC International and is made
*** available solely pursuant to the terms of a written license   
*** agreement with ARC International             
***
*** File: usbinst.c
***
*** Comments:      
***   This file contains the function to install the low-level driver functions
***                                                               
**************************************************************************
*END*********************************************************************/

#include "mqx.h"
#include "bsp.h"
#include "usbprv.h"

/*FUNCTION*-------------------------------------------------------------
*
*  Function Name  : _usb_driver_install
*  Returned Value : None
*  Comments       :
*        Installs the device
*END*-----------------------------------------------------------------*/
uint_8 _usb_driver_install
   (
      /* [IN] device number */
      uint_32  device_number,
            
      /* [IN] address if the callback functions structure */
      pointer  callback_struct_ptr
   )
{ /* Body */
   pointer callback_struct_table_ptr;
   
   callback_struct_table_ptr = _mqx_get_io_component_handle(IO_USB_COMPONENT);
   
   if (!callback_struct_table_ptr) {
      callback_struct_table_ptr = 
         USB_memalloc(BSP_MAX_USB_DRIVERS*
            sizeof(USB_CALLBACK_FUNCTIONS_STRUCT));
      
      if (!callback_struct_table_ptr) {
         return USBERR_DRIVER_INSTALL_FAILED;
      } /* Endif */
      
      USB_memzero((uchar_ptr)callback_struct_table_ptr, 
         sizeof(callback_struct_table_ptr));
      
      _mqx_set_io_component_handle(IO_USB_COMPONENT, 
         callback_struct_table_ptr);
   } /* Endif */

   *((USB_CALLBACK_FUNCTIONS_STRUCT_PTR)\
      (((USB_CALLBACK_FUNCTIONS_STRUCT_PTR)callback_struct_table_ptr) + 
      device_number)) = 
      *((USB_CALLBACK_FUNCTIONS_STRUCT_PTR)callback_struct_ptr);

} /* EndBody */

/* EOF */