From 4ea7d94ff143b0c9bddcd592b0fc190ad761840b Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Sun, 15 Oct 2023 11:35:19 +0100 Subject: [PATCH] vclog: Also try /dev/vc-mem for DMA copy Signed-off-by: Phil Elwell --- vclog/vclog.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/vclog/vclog.c b/vclog/vclog.c index 3a1aa4f..85e1366 100644 --- a/vclog/vclog.c +++ b/vclog/vclog.c @@ -72,6 +72,8 @@ enum }; #define MAX(x, y) (((x) > (y)) ? (x) : (y)) +#define ARRAY_SIZE(_a) (sizeof(_a)/sizeof(_a[0])) + #define FBIODMACOPY _IOW('z', 0x22, struct fb_dmacopy) #ifdef DEBUG @@ -354,25 +356,28 @@ static bool find_logs(uint32_t *logs_start, uint32_t *logs_size) static bool prepare_vc_mapping(uint32_t vc_start, uint32_t vc_size) { - const char *fb_filename = "/dev/fb0"; + const char *dma_filenames[] = { "/dev/vc-mem", "/dev/fb0" }; const char *mem_filename = "/dev/mem"; + struct fb_dmacopy ioparam; uint32_t id; - int fd; + int err, fd, i; + + ioparam.dst = &id; + ioparam.src = vc_start; + ioparam.length = sizeof(id); - if ((fd = open(fb_filename, O_RDWR | O_SYNC)) >= 0) + for (i = 0; i < (int)ARRAY_SIZE(dma_filenames); i++) { - struct fb_dmacopy ioparam; - int err; - ioparam.dst = &id; - ioparam.src = vc_start; - ioparam.length = sizeof(id); - err = ioctl(fd, FBIODMACOPY, &ioparam); - if (err == 0 && id == LOG_ID) + if ((fd = open(dma_filenames[i], O_RDWR | O_SYNC)) >= 0) { - dma_fd = fd; - goto success; + err = ioctl(fd, FBIODMACOPY, &ioparam); + if (err == 0 && id == LOG_ID) + { + dma_fd = fd; + goto success; + } + close(fd); } - close(fd); } if ((fd = open(mem_filename, O_RDONLY)) >= 0)