Structure of PBMaster
From PBMasterWiki
[edit] Drivers
The current driver design is divided into three groups of modules:
- The core module - (pbmcore) - is the main driver implementing basic functions like data structure, chip related defines, UART stack implementation, bit/byte stack implementation and the most important part, the Profibus DP implementation. The implementation of Profibus covers Finite State Machines of a Master station, Profibus DP Frame Analyzer and UART Bit/Byte Analyzer. In the future, an abstract layer for simulation of Slave stations will be added. The module is platform and hardware independent and by itself does nothing but offers functions to other chip drivers. This allows use of several chip drivers simultaneously without any code redundancy.
- Chip drivers - (pbm_950pci, pbm_8250, ..) - implement operations with real hardware like chip initialization, read, write etc. The chip module, upon loading, registers to the core module these basic operations and provides hardware and system dependent support for things such as resource allocation or interrupt registration. The remaining actions are controlled by the core module through the state machine.
- User space interface module - (pbm_fdl) - this module implements an interface between user applications and the FDL layer in the kernel space. Currently, the module is a character device but in the future a socket module may be developed to allow communication using sockets technique.
An applications writes its request to, and reads responses from, the device. This data is passed to the core module and then is addressed correctly to an appropriate chip device. Regardless of whether the user chooses to communicate using a file or a socket, the API between an application and a kernel is unified, as well as the API between an interface module and the core module.
libpbm +--------+ +--------+ +--------+
! User 1 ! ! User 2 ! ! User 3 !
(USER SPACE) +--------+ +--------+ +--+ +---+
-------------------------------------------------+ +--------------+ +----
-------------------------------------------------+ +--------------+ +----
(KERNEL SPACE) ! ! ! !
+-------------------------+ +-----+ +--------------+ +----+
(MODULE NAME) ! UART DEVICE SHARED DATA ! ! /dev/pbmaster0,pbmaster1,.. !
+-------------------------+ +-----------------------------+
pbm_fdl ! +---------------------+ ! { pbm_fdl_open()
! ! Queue of Responses ! ! +---{ pbm_fdl_close()
! +------+ +-------+ ! !+--{ pbm_fdl_read()
! ! ! ^ ! ! vv { pbm_fdl_write()
---------------+--------+ ! ! +---------+--------------+ +---------------
! ! v ! ! !
! +------+ +-------+ !
! ! Low/High Priority ! !
! ! Queue of Requests ! !
! +---------------------+ ! +-------------------+
! +-------------------+ ! ! !
pbmcore ! ! Profibus related ! ! ! FDL State Machine !
! ! functions ! ! ! !
! +-------------------+ ! +-------------------+
! +---------------------+ !
! ! Mode Configuration ! !
! ! (master,analyzer,..)! !
! +---------------------+ !
! +-------------------+ !
! ! Buffer functions ! !
! +-------------------+ ! +---- init()
! +-----------+ ! !+--- read(), write()
! ! RX Queue ! ! !!+-- timeout()
! +--+ +--+ ! !!! ....
! ! ! ^ ! ! vvv
---------------+---------+ ! ! +---------+--------------+ +---------------
! ! v ! ! !
! +--+ +--+ !
! ! TX Queue ! !
! +-----------+ !
! +-------------------+ !
! ! Interrupt Service ! !
! ! Routines ! !
! +-------------------+ !
! +-----------------+ ! +-----------------------+
pbm_8250 ! ! Chip Operations ! ! ! !
! +-----------------+ ! ! Device I/O Operations !
pbm_950pci ! ! read() ! ! ! !
! ! write() ! ! +-----------------------+
! ! tx_ready() ! !
! ! rx_ready() ! !
! ! wait() ! !
! ! init() ! !
! ! ... ! !
! +-----------------+ !
+-------------------------+
--------------------------+ +------------+ +---------------------------
+---+---+---+ +--+---+---+
! UART 8250 ! ! OX16C950 !
+---+---+---+ +--+---+---+
--------------------------+ +------------+ +---------------------------
PROFIBUS NETWORK
---------------------------------------------------------------------------


