Android Ril
Android Ril
The RIL part of Android is mainly divided into two parts: RILJ and RILC. RILJ runs in
the java part of framework->telephony, and RILC runs in the native part of the HAL
layer. In the era of android1.0-7.0, the RIL layer architecture is shown in the following
figure:
The interaction between RILJ and RILC is based on the local Socket. RILJ and RILC
use the Socket connection of the rild port for message interaction and processing;
between RILC and Modem, the AT command is sent and executed through the Socket
port of qemud, and the Modem is completed. Operation control and query request, and
the processing of messages actively reported by the Modem.
In the era of Android 8.0+, Google introduced HIDL to replace the socket
communication method between the framework and the HAL layer. So in the era of
Android 8.0+, the RIL layer architecture is shown in the following figure:
QMI RIL
We know that the mobile phone has a multi-core architecture, the main core
application processor runs the android operating system, the modem processor is
responsible for the radio frequency and protocol part, and some other socs are
responsible for special audio, radio frequency, and display processing.
copyright
Foreword:
Qualcomm MSM Interface, used for the interaction between AP and BP side, popular
saying is to let equipment terminal TE (can be mobile phone, PDA, computer)
Operate the AMSS system on the Qualcomm BP side, such as calling functions, reading
data, and setting NV items in it.
The core of QMI is called QMI Framework (QMI Framework), and its main functions
include the following 3 points:
1. Connect MSM module and equipment terminal to provide an orthogonal control and
data channel. There are two definitions of message usage in QMI, one is
QMIControl Message, the other is QMI DataMessage, which supports the concurrency of
these two messages and will not interfere with each other and cause errors.
2. List a series of enumerated logical devices and provide them for connection. The QMI
mechanism is similar to a server mechanism, with a corresponding client side
And services side, corresponding to QMI control point and service. When AP sends a
request to BP, AP acts as a client, when AP
When receiving the response from the BP side, the AP serves as the services side. QMI
includes a series of QMI Services, such as nas, voice, wds, etc.,
These different services are equivalent to different logical devices and are called by
different apps.
3. QMI has corresponding messages and message protocols, and the equipment
terminal accesses AMSS through these messages. For different qmi messages,
The message length is different, you can define the message length yourself. Different
qmi messages have the same message format.
The figure above is a software structure diagram of QMIFramework.
It can be seen from the figure that the upper control point packs the corresponding type
of QMI message or transmits the data to be sent to the AP through the framework of
other operating systems
The logic device of the bottom layer on the side, and finally the logic device is
transmitted to the AMSS on the BP side through the inline bus interface. You can find in
the code to send from the control point
This is a function for the control point to send a synchronization message to the BP side.
The parameters include the type of QMI_Service, the name of the message in the
Service,
The initial address and length of the request message, and the corresponding initial
address and length are returned. There are also many types of inline buses between the
logic device and the BP side:
USB, SDIO, shared memory, wireless protocol 802.11 can be used as a bus to connect
AP and BP. The MSM platform we are developing now uses
Connection channels, including MSM platform with integrated modem and MDM with
independent modem.
At present, there are four types of logical devices supported by QMI: telephone system,
audio, Bluetooth, and GPS.
It can be seen from the figure that in the entire QMI architecture, the interaction
between TE and MSM on the software is mainly completed through the QMUX layer.
1. One service can correspond to multiple control points, and one control point can only
correspond to one service.
2. The relationship between control points and services is like the relationship between
client and server in the C/S model.
3. If a program uses several QMI services, then it must build a control point for each
service.
It can be seen that QMI is not a simple one-to-one transmission communication method,
but a service can receive messages from several control points at the same time.
copyright
What is QMI?
Qualcom Message Interface Qualcom Message Interface
In 2009, QMI replaced RPC (Remote Procedure Call), the scope of QMI began to expand,
radio interface layer (RILs) began to transition to QMI, and defined the necessary
support; the bottom layer was replaced by more robust communication (IPC router
transmission), through sharing The memory mode (SMD) is available between on-chip
SOCs.
Qualcomm platforms are currently asymmetric multi-core, the most important ones are
AP and Modem. How do two processors communicate? We treat AP and Modem as two
hosts. The problem becomes very simple. The TCP/IP protocol is not a very successful
inter-process cross-host communication method. Qualcomm did not adopt this
approach, but borrowed from the TCP/IP framework design. Its framework is like this,
kernel mode: realizes the link layer based on shared memory (SMD) and extends the
protocol domain; user mode encapsulates an interface similar to the socket function for
use in user mode. The QMI I described is the API interface used by the user mode. These
interfaces are very similar to sockets. As long as you have experience in socket
programming, it will be easy to understand.
Support multiple servers to run concurrently, and each server corresponds to multiple
clients;
QMI architecture
Messages
Request message —— A request message is sent from the client to the server and
processed by the server.
Message ID
Message length
Clients
1. Any internal or external client application that wants to use QMI
Services
1. Any internal application service program that wants to use QMI
Common Libraries
1. Provide functions for client (QCCI) and service (QCSI)
2. Common API is applicable to all platforms/transmissions
3. Package transport and platform-specific changes to share client/service code
4. Provide encoding/decoding support for each service message
Transports
QMUX
IPC Router
QMI IDL
The QMI interface is written in Interface Definition Language (IDL), and the IDL compiler
automatically generates files .c and .h
Encoding/decoding library
1. The library is independent and decoupled from the automatically generated files
2. The meta information of the encoded/decoded message will be generated as Service_Object in
.c
3. During service/client startup, meta information will be registered to QCSI/QCCI for message
encoding/decoding
4. Client/service can send/receive messages using QCCI/QCSI API
QMI message encoding standard
1. Do not use floating-point data, but use Q16 type fixed points, that is, provide a fixed-
point implementation of 16-bit 2-bit complement integer part and 16-bit decimal part.
2. Naming Convention
1. In order to keep all message implementations consistent, the service side needs a fixed
unique prefix
2. The structure ends with _type
3. Enumeration ends with _enum
4. The request message ends with _req_msg, and the type ends with _REQ
5. The message response ends with _resp_msg, and the type ends with _RESP
6. Indicates that the message ends with _ind_msg, and the type ends with _IND
QMI QCCI
QCCI is a set of API collections for the client to receive information from the server or
send messages to the server.
2. When the service arrives, the signal will be set, and the notification callback function
will be called to the client's message about the service arrival;
3. The QMI client resolves the service address after receiving the service arrival
notification;
4. The QMI client initializes the client handle of the service, and the address of the
service is resolved in step 3. Then, this client handle is used to exchange QMI messages
with related QMI services;
5. When the client handle is initialized, an error callback function will be registered with
the client handle. This error callback is used to receive any notification about service
restart or subsystem restart;
6. At this time, the QMI client can release the notifier handle to avoid any resource
leakage;
8. When all related QMI message communication is completed, the QMI client releases
the client handle.
1. qmi_client_recv_raw_msg_async_cb
2. qmi_client_recv_msg_async_cb
3. qmi_client_ind_cb
Connection APIs
1. qmi_client_notifier_init
2. qmi_client_init
3. qmi_client_get_service_list
Message sending APIs
1. qmi_client_send_raw_msg_sync
2. qmi_client_send_msg_sync
3. qmi_client_delete_async_txn
Release connection APIs
1. qmi_client_release
Encode and decode APIs
1. qmi_client_message_encode
2. qmi_client_message_decode
QMI QCSI
QCSI is used to receive client requests and respond to them. In addition, it is also used
to send indication messages and encode/decode messages. This message is sent by the
server.
Request message —— A request message is sent from the client to the server and
processed by the server.
1. qmi_csi_connect
2. qmi_csi_disconnect
3. qmi_csi_process_req
Registration APIs
1. qmi_csi_register
2. qmi_csi_unregister
Message sending APIs
1. qmi_csi_send_resp
2. qmi_csi_send_ind
3. qmi_csi_send_broadcast_ind
Event handling APIs
1. qmi_csi_handle_event
QMI SERVER
This api is built on top of the QCSI framework
Its main purpose is to facilitate the client to implement the server with less workload
The framework allows users to write object-based servers and extend core server
objects. The core server object provides common functions that every service needs
1. qmi_csi_connect
2. qmi_csi_disconnect
3. qmi_csi_process_req
Constructor/Destructor APIs
1. qmi_core_server_new
2. qmi_core_server_delete
Registration APIs
1. qmi_core_server_register
2. qmi_core_server_unregister
3. qmi_core_server_register_client
4. qmi_core_server_unregister_client
Message Dispatch APIs
1. qmi_core_server_dispatch_msg
2. qmi_core_server_send_ind
3. qmi_core_server_send_resp
QMUX
QMI Multiplexing Protocol (QMUX): QMI multiplexing protocol
After the message is transmitted from the control point to the QMI interface through a
socket-like thread, QMI is responsible for encapsulating the data, adding the header of
the QMUX message, and sending it to the QMUX layer.
Then pass the QMUX layer to the shared memory to the BP side.
1. I/FType: After QMI encapsulates the control point data and sends it to QMUX, the added
message header is one byte in length, and the value is usually 0x01, indicating that this
message is a QMUX message. If it has other values, it is another message.
2. Length: The length of the QMUX message, excluding I/F Type.
3. ControlFlags: Control bits, indicating the direction of message transmission. The length is 1
byte, only the 7th bit is a flag bit, and the other bits are 0. Bit7=1 indicates that the QMUX
message is sent by the server, and bit7=0 is sent by the control point.
4. Clien ID: The identification of the control point, which needs to be assigned on both the control
point and the server. When the value of the Client ID of the message sent on the server is
0xFF, it means that the message is a broadcast message, which is actively sent by the server
and searched by all control points. To.
QMUX SDU and TLV structure:
In the entire control channel message, the message identification header I/F Type and
the QMUX message header are sent out. The data transmission is completed in the
QMUXSDU. The data in the QMUX SDU needs to support the Type Length Value (TLV)
format.