Part 1
요약·해설
Sequential block 대기, release message, tx/rx block 수와 양쪽 devicetree swap 규칙을 설명합니다.
Dynamic shared blocks
ICMsg references
Multiple
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
384B159099F5DBB396628E2248FFCF6C63E467628DEEBB824B60A0389A515589
.. _ipc_service_backend_icbmsg:
ICMsg with dynamically allocated buffers backend
################################################
This backend is built on top of the :ref:`ipc_service_backend_icmsg`.
Data transferred over this backend travels in dynamically allocated buffers on shared memory.
The ICMsg just sends references to the buffers.
It also supports multiple endpoints.
This architecture allows for overcoming some common problems with other backends (mostly related to multithread access and zero-copy).
This backend provides an alternative with no significant limitations.
Overview
========
The shared memory is divided into two parts.
One is reserved for the ICMsg and the other contains equal-sized blocks.
The number of blocks is configured in the devicetree.
The data sending process is following:
* The sender allocates one or more blocks.
If there are not enough sequential blocks, it waits using the timeout provided in the parameter that also includes K_FOREVER and K_NO_WAIT.
* The allocated blocks are filled with data.
For the zero-copy case, this is done by the caller, otherwise, it is copied automatically.
During this time other threads are not blocked in any way as long as there are enough free blocks for them.
They can allocate, send data and receive data.
* A message containing the block index is sent over ICMsg to the receiver.
The size of the ICMsg queue is large enough to hold messages for all blocks, so it will never overflow.
* The receiver can hold the data as long as desired.
Again, other threads are not blocked as long as there are enough free blocks for them.
* When data is no longer needed, the backend sends a release message over ICMsg.
* When the backend receives this message, it deallocates all blocks.
It is done internally by the backend and it is invisible to the caller.
Configuration
=============
The backend is configured using Kconfig and devicetree.
When configuring the backend, do the following:
* Define two memory regions and assign them to ``tx-region`` and ``rx-region`` of an instance.
Ensure that the memory regions used for data exchange are unique (not overlapping any other region) and accessible by both domains (or CPUs).
* Define the number of allocable blocks for each region with ``tx-blocks`` and ``rx-blocks``.
* Define MBOX devices for sending a signal that informs the other domain (or CPU) of the written data.
Ensure that the other domain (or CPU) can receive the signal.
See the following configuration example for one of the instances:
.. code-block:: devicetree
reserved-memory {
tx: memory@20070000 {
reg = <0x20070000 0x0800>;
};
rx: memory@20078000 {
reg = <0x20078000 0x0800>;
};
};
ipc {
ipc0: ipc0 {
compatible = "zephyr,ipc-icbmsg";
tx-region = <&tx>;
rx-region = <&rx>;
tx-blocks = <16>;
rx-blocks = <32>;
mboxes = <&mbox 0>, <&mbox 1>;
mbox-names = "tx", "rx";
status = "okay";
};
};
You must provide a similar configuration for the other side of the communication (domain or CPU).
Swap the MBOX channels, memory regions (``tx-region`` and ``rx-region``), and block count (``tx-blocks`` and ``rx-blocks``).
Samples
=======
* :ref:`ipc_multi_endpoint_sample`
Part 3
한국어 전문 번역
이 backend는 ICMsg backend 위에 구현됩니다. 전송 data는 shared memory에서 동적으로 할당한 buffer에 들어가며, ICMsg는 buffer reference만 전달합니다. Endpoint 여러 개도 지원합니다.
이 architecture는 다른 backend에서 흔히 생기는 multithread access와 zero-copy 관련 문제를 피합니다. 눈에 띄는 제약 없이 사용할 수 있는 대안 backend입니다.
Overview
Shared memory는 두 부분으로 나뉩니다. 한 부분은 ICMsg가 사용하고, 다른 부분은 크기가 같은 block들로 구성됩니다. Block 개수는 devicetree에서 정합니다.
Data 전송 과정은 다음과 같습니다.
- Sender가 block 하나 이상을 할당합니다. 연속된 free block이 충분하지 않으면 parameter로 받은 timeout 동안 기다립니다.
K_FOREVER와K_NO_WAIT도 사용할 수 있습니다. - 할당한 block을 data로 채웁니다. Zero-copy에서는 caller가 직접 쓰고, 그렇지 않으면 backend가 자동으로 복사합니다. 다른 thread는 필요한 free block이 남아 있는 한 전혀 block되지 않고 block을 할당하거나 data를 보내고 받을 수 있습니다.
- Block index를 담은 message를 ICMsg로 receiver에게 보냅니다. ICMsg queue는 모든 block의 message를 담을 만큼 크므로 overflow하지 않습니다.
- Receiver는 원하는 시간만큼 data를 보유할 수 있습니다. 이때도 free block이 충분하면 다른 thread는 block되지 않습니다.
- Data가 더 이상 필요하지 않으면 backend가 ICMsg로 release message를 보냅니다.
- 상대 backend가 release message를 받으면 연결된 block을 모두 deallocate합니다. 이 과정은 backend 내부에서 수행되며 caller에게 보이지 않습니다.
Configuration
Backend는 Kconfig와 devicetree로 구성합니다.
- Memory region 두 개를 정의해 instance의
tx-region과rx-region에 지정합니다. Data exchange region은 다른 region과 겹치지 않아야 하고 양쪽 domain 또는 CPU가 모두 접근할 수 있어야 합니다. - 각 region에서 할당할 수 있는 block 수를
tx-blocks와rx-blocks로 지정합니다. - 상대 domain 또는 CPU에 data가 기록됐음을 알릴 MBOX device를 정의합니다. 상대편이 해당 signal을 받을 수 있어야 합니다.
한쪽 instance의 configuration 예는 다음과 같습니다.
reserved-memory {
tx: memory@20070000 {
reg = <0x20070000 0x0800>;
};
rx: memory@20078000 {
reg = <0x20078000 0x0800>;
};
};
ipc {
ipc0: ipc0 {
compatible = "zephyr,ipc-icbmsg";
tx-region = <&tx>;
rx-region = <&rx>;
tx-blocks = <16>;
rx-blocks = <32>;
mboxes = <&mbox 0>, <&mbox 1>;
mbox-names = "tx", "rx";
status = "okay";
};
};
통신 반대편 domain 또는 CPU에도 비슷한 configuration을 제공해야 합니다. 이때 MBOX channel, tx-region과 rx-region, tx-blocks와 rx-blocks의 방향을 서로 바꿉니다.
Samples
여러 endpoint를 사용하는 예는 ipc_multi_endpoint_sample에서 확인할 수 있습니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.