AnsweredAssumed Answered

MQXUG; I/O drivers "not covered in this book", help understanding _io_fopen

Question asked by Carl Norman on Feb 19, 2009
Latest reply on Mar 5, 2009 by Carl Norman

Copied from the MQXUG: 

--- 

2.10I/O drivers
I/O drivers are an optional component at the BSP level. They consist of formatted I/O
drivers are not described in this book.

2.10.1Formatted I/O
MQX provides a library of formatted I/O functions that is the API to the I/O subsystem.
2.10.2I/O subsystem
You can dynamically install I/O device drivers, after which any task can open them.

 

---

 

copied from the http://www.freescale.com/webapp/sps/site/overview.jsp?code=MQXRTOS

 

  • Code Reuse – Freescale MQX RTOS provides a framework with a simple API to build and organize the features across Freescale’s broad portfolio of embedded processors.
  • Intuitive API – Writing code for Freescale MQX RTOS is straight forward with a complete API and available reference documentation.

 

Not sure about anyone else, but I thought this meant that there was documentation to support the above statments?

If its not described in 'this book' where is it?

Is there some document we are am missing that covers all the I/O control, drivers, API functions, how it all works?

Is the only way to learn the inner workings of MQX to read/reverse engineer the source code? 

 

As an example, the I2C example uses fopen (_io_fopen), once we start tracing everything back, you end up needing to understand the kernel (first thing fopen does is _get_kernel_data, then starts using queues controlled via the kernel). Is there some details exactly how MQX handles everything on the back end? 

 

 

Can someone clarifiy what this section of code is doing and more importantly why...?

 

//--------------------------

First things to happen inside _io_fopen function:

... 

   _lwsem_wait((LWSEM_STRUCT_PTR)&kernel_data->IO_LWSEM);
   dev_ptr = (IO_DEVICE_STRUCT_PTR)((pointer)kernel_data->IO_DEVICES.NEXT);
   while (dev_ptr != (pointer)&kernel_data->IO_DEVICES.NEXT) {
      dev_name_ptr = dev_ptr->IDENTIFIER;
      tmp_ptr      = (char _PTR_)open_type_ptr;
      while (*tmp_ptr && *dev_name_ptr && (*tmp_ptr == *dev_name_ptr))
      {
         ++tmp_ptr;
         ++dev_name_ptr;
      } /* Endwhile */
      if (*dev_name_ptr == '\0') {
         /* Match */
         break;
      } /* Endif */
      dev_ptr = (IO_DEVICE_STRUCT_PTR)((pointer)dev_ptr->QUEUE_ELEMENT.NEXT);
   } /* Endwhile */

   _lwsem_post((LWSEM_STRUCT_PTR)&kernel_data->IO_LWSEM);
  
   if (dev_ptr == (pointer)&kernel_data->IO_DEVICES.NEXT) {
      return(NULL)

 

///// 

 

 While were at it, it would be great to have something (should really be in the MQXRM) on all the ioctl options, how to use them, how to create your own...

Message Edited by CarlFST60L on 2009-02-19 04:03 AM
Message Edited by CarlFST60L on 2009-02-19 04:57 AM

Outcomes