

Luckily the library is not performing much required functionality, so third-party programs like SnoopSnitch have managed to talk directly to the /dev/diag kernel device without needing to use that non-free library. In userspace on the Linux inside the modem, there is a (unfortunately again non-free) library called libdiag which offers some convenience API for programs to either consume DIAG or to generate/respond to DIAG received from the host/PC.

The Qualcomm Android Linux kernel (usd even on the non-Android devices) implements several related kernel drivers, see Qualcomm_Kernel Furthermore, code in the Linux processor might also want to offer some DIAG information towards the external host/PC. First of all, not only the external host/PC might want to consume DIAG information, but also code on the Linux processor inside the chip. In a multi-processor situation (like the MDM9215/MDM9x07 with their Linux-running Cortex-A5), the situation becomes slightly more complex. In a single-processor Modem (with only a baseband processor) it is rather simple: Some software on the baseband processor implements the DIAG protocol, and responds to any related requests received on the DIAG port. Later, this became a virtual serial port over USB. Initially, this transport was a dedicated serial port/UART. The general idea is that there is some physical transport medium between the chipset/modem and an external PC, and the PC can request certain diagnostic information to be sent via that physical transport. It is not publicly documented, but there are tools from Qualcomm (QPST, QXDM) as well as proprietary third-party tools and some Free Softare projects that implement parts of it. Qualcomm Diag is the qualcomm diagnostics interface built into many Qualcomm based chipsets (or rather their software) for a long time (more than a decade).
