Thursday, 25 July 2013

GSOC : Rules for updating legacy code in RTEMS BSPS

The legacy API employed by RTEMS bsps consists of methods defined in libbsp/shared/src/rq-legacy.c . The prototypes for these functions are written in cpukit/include/rtems/irq.h
Following are the rules/recommendations that must be followed while updating legacy code from RTEMS BSPs. They are:

  • The replacement of legacy methods should happen like this:

BSP_get_current_rtems_irq_handler()      → Obsolete

BSP_install_rtems_irq_handler()        → rtem_interrupt_handler_install()

BSP_install_rtems_shared_irq_handler() → rtems_interrupt_handler_install()

BSP_remove_rtems_irq_handler()            → rtems_interrupt_handler_remove()

BSP_rtems_irq_mngt_set()                      → bsp_interrupt_initialize()

BSP_rtems_irq_mngt_get()                     → Obsolete

  • All uses of rtems_irq_connect_data type and other data types from legacy API should be removed and replaced with suitable data types if required.

rtems_irq_connect_data  → Use components of this data type individually

rtems_irq_number           →  rtems_vector_number

rtems_irq_hdl_param      →  void *

rtems_irq_hdl      →  void *

  • Remove functions if they’re defined but not used, or if they’re empty.
  • Insert prototypes for non-global functions( having no declarations in a header file) in order to remove any compiler warnings.
  • Make functions static if they’re only used in that specific file.
  • Obtain status of install() & remove() functions in a rtems_status_code status and check it’s value with an assert().
  • While using install() method from the new API, the on() function needs to be called if it’s defined, and it’s not empty.
  • While using remove() method from the new API, the off() function needs to be called before, if it’s defined, and it’s not empty.
  • The implementation of is_enabled/is_on() helper from previous structure should be removed if it’s not used already.
  • Inserting a declaration of a global function in the same file is a bad hack.

Tuesday, 16 July 2013

GSOC Update 2

This blog post covers the progress for my RTEMS GSOC Project Unified APIs from 5th July till now( roughly the next 10 days, since my last GSOC post ). The task for removing legacy support completely from different BSPs is on, and in full swing.

As of now, major work has been done on ARM BSPs which include csb336, csb337, edb7312, gumstix, rtl22xx & gba. I've been asked to set the nds BSP aside for a while, since it uses custom internal methods defined for that BSP, but having the same name as the Legacy API. I'm right now working on pc386 & a couple more in powerpc. Links to accepted commits can be seen here

As a high school and a college student now, I've always been fascinated by Facebook and it's culture. Their core philosophy goes by the words "Move Fast and Break Things". The meaning behind this slogan is not to cause havoc, but instead to encourage engineers to build more things and learn faster. The idea is that if you never break anything, you’re probably not moving fast enough. Hence, you're not learning.

Although I deeply understand this quote, and feel motivated by it, I seem to be taking the above lines a bit literally while working on my GSOC Project. I feel a need to move fast with my work, sending patches in an accelerated sequence again & again until I've corrected them and they're accepted. During this process, Joel & Sebastian seem to be always behind me pointing me towards the things that I've actually broken along my way, instead of improving them. I've been asked to move forward carefully reminding me to check my work for quality, rather than quantity, and I appreciate this suggestion.

What I would like to summarize with this post is that, I'm maybe breaking more stuff at a time, rather than fixing it, but I'm definitely fulfilling the most important aspect of this above philosophy. That is, I am learning. And I am improving my work, along with maintaining my speed.

Friday, 5 July 2013

GSOC Update 1

This blog post follows the progress of my GSOC Project - Unified APIs for the first 15 days of the coding period. According to my proposal, the main task for my project included identifying and implementing a unified pattern of file usage and header installation among various BSPs in the RTEMS tree.

During my discussion with Joel Sherrill(my Mentor), we identified an important sub-task that needed to be done first. This was removing legacy support from the BSPs. The legacy code is defined in the file libbsp/shared/src/irq-legacy.c , which include the following deprecated methods :

  • int BSP_get_current_rtems_irq_handler(rtems_irq_connect_data *cd)
  • int BSP_install_rtems_irq_handler(const rtems_irq_connect_data *cd)
  • int BSP_install_rtems_shared_irq_handler(const rtems_irq_connect_data *cd)
  • int BSP_remove_rtems_irq_handler(const rtems_irq_connect_data *cd)
  • int BSP_rtems_irq_mngt_set(rtems_irq_global_settings *config)
  • int BSP_rtems_irq_mngt_get(rtems_irq_global_settings **config)
These methods need to be updated with functions from the new generic framework present in libbsp/shared/src/irq-generic.c , written by Sebastian Huber. I've submitted patches for arm-csb336 and arm-csb337 for now. But I'll increase this list shortly.

Since being new to RTEMS, I've been committing a few minor mistakes while submitting the patches. But Sebastian, Joel and Gedare have been very helpful. Being experienced developers themselves, I really appreciate their support  in pointing out and correcting those mistakes.