-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmsgboxkill.c
More file actions
49 lines (43 loc) · 1.27 KB
/
msgboxkill.c
File metadata and controls
49 lines (43 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include "rpmsg.h"
/*
// The ioctl number, replace with exact value from your kernel (may vary, typically defined in rpmsg_chrdev.h)
#define RPMSG_CREATE_EPT_IOCTL 0x4020b009
struct rpmsg_endpoint_info {
char name[32];
uint32_t src_addr;
uint32_t dst_addr;
};
*/
int main() {
int ctrlfd, rpmsgfd;
struct rpmsg_endpoint_info ept_info;
ssize_t len;
char rx_buf[512];
char tx_buf[512] = "Hello DSP from Linux!";
// Fill endpoint info (customize src/dst addresses as needed!)
memset(&ept_info, 0, sizeof(ept_info));
strncpy(ept_info.name, "msgbox-channel", sizeof(ept_info.name));
// Example addresses. Match these to those used in DSP firmware and dts 'msgbox' node.
ept_info.src_addr = 0x01;
ept_info.dst_addr = 0x02;
// Open the control device
ctrlfd = open("/dev/rpmsg_ctrl0", O_RDWR);
if (ctrlfd < 0) {
perror("open /dev/rpmsg_ctrl0");
return 1;
}
// Issue the ioctl to destroy the endpoint
if (ioctl(ctrlfd, RPMSG_DESTROY_EPT_IOCTL) < 0) {
perror("ioctl RPMSG_DESTROY_EPT_IOCTL");
close(ctrlfd);
return 1;
}
close(ctrlfd);
}