Hello friends,
When we look into syslink codes. We often find there are multipule files having the same function. Which one is used in what scenario? e.g. how to differetiate usr and knl on QNX HLOS side.
Thanks,
Fuquan
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello friends,
When we look into syslink codes. We often find there are multipule files having the same function. Which one is used in what scenario? e.g. how to differetiate usr and knl on QNX HLOS side.
Thanks,
Fuquan
Fortune,
It is unfortunate we have so many files with similar names and implementations. In general, an application runs in user-mode and calls an IPC API, such as MessageQ_put(). But this function is actually implemented in the driver. So, the usr/MessageQ.c is a stub function used to invoke the same function in the driver, which is implemented in knl/MessageQ.c. Typically, the usr folder is for user-mode stub functions and the knl folder is for the driver implementation.
Depending on which HLOS you are running (Linux vs. QNX) the path from user-mode to driver will be different. This is where the Linux and Qnx folders come into play. They provide the HLOS specific details. The code in usr and knl is mostly reused on both.
For example, on Linux you would have the following:
MessageQ_put - syslink/ipc/usr/MessageQ.c
MessageQDrv_ioctl - syslink/ipc/usr/Linux/MessageQDrv.c
ioctl - part of Linux system library
MessageQDrv_ioctl - syslink/ipc/knl/Linux/MessageQDrv.c
MessageQ_put - syslink/ipc/knl/MessagQ.c
For QNX, you would replace the Linux folders with Qnx.
MessageQ_put - syslink/ipc/usr/MessageQ.c
MessageQDrv_ioctl - syslink/ipc/usr/Qnx/MessageQDrv.c
devctl - part of Qnx system library
syslink_messageq_devctl - syslink/ipc/knl/Qnx/messageq_devctl.c
syslink_messageq_put
MessageQ_put - syslink/ipc/knl/MessagQ.c
In addition to this, on QNX only, there were a few module which were moved from driver mode to user mode. This was an effort to reduce latency in the function calls. These include GateHWSpinlock, GateMP, GatePeterson, and Ipc. You will find these new implementations in the hlos folder.
syslink/ipc/hlos/GateHWSpinlock_qnx.c
syslink/ipc/hlos/GateMP_qnx.c
syslink/ipc/hlos/GatePeterson_qnx.c
syslink/ipc/hlos/Ipc_qnx.c
These files replace the equivalent files above. You will have to study the build files and observe the build process to verify which files is actually used when building the user-mode library or the driver. Unfortunately, this effort on QNX was never completed, so you will find some duplicate code and work-in-progress. This effort was never started for Linux.
~Ramsey