我有一个旧的电视盒,它是基于Amlogic S905X ARM64 SoC的,它是一款Tanix TX5,最初在其上运行安卓系统。我不喜欢被排除在硬件的潜力之外,所以我密切关注了Armbian项目的进展,最近我安装了版本5.67,它基于Ubuntu,运行在Linux 4.19.6上。
一切都工作的很好,有工作驱动的以太网,wifi,蓝牙等,但不幸的是没有包括内核驱动程序支持集成的mali450图形处理器。hdmi输出确实有效,但是Xorg正在fbdev上运行,屏幕更新非常缓慢,视频在全屏上无法观看。我不太清楚这是什么故事,但显然是非理性的,他们目前版本的司机自己。但是,通过访问他们的FTP站点,我找到了一个用于内核驱动程序( http://openlinux.amlogic.com:8000/download/ARM/gpu/gpu-2016-08-18-fe6d7b1d1b.tar.gz )的旧源代码树。它已经过时了,但我已经在将它移植到当前内核方面取得了一些进展,到目前为止,大多数情况下都很容易修复。现在我可以编译大约一半的源文件了。
我应该澄清我不是linux开发人员,我甚至不是C开发人员.我敢说,我知道的足够危险,而且我很有动力。不过,我的日常交易是C#,所以我或多或少知道我在做什么。
目前我遇到的问题是使用马里/linux/马里_osk_timers.c。这是原始代码:
/*
* Copyright (C) 2010-2014, 2016 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
*
* A copy of the licence is included with the program, and can also be obtained from Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* @file mali_osk_timers.c
* Implementation of the OS abstraction layer for the kernel device driver
*/
#include <linux/timer.h>
#include <linux/slab.h>
#include "mali_osk.h"
#include "mali_kernel_common.h"
struct _mali_osk_timer_t_struct {
struct timer_list timer;
};
typedef void (*timer_timeout_function_t)(unsigned long);
_mali_osk_timer_t *_mali_osk_timer_init(void)
{
_mali_osk_timer_t *t = (_mali_osk_timer_t *)kmalloc(sizeof(_mali_osk_timer_t), GFP_KERNEL);
if (NULL != t) init_timer(&t->timer);
return t;
}
void _mali_osk_timer_add(_mali_osk_timer_t *tim, unsigned long ticks_to_expire)
{
MALI_DEBUG_ASSERT_POINTER(tim);
tim->timer.expires = jiffies + ticks_to_expire;
add_timer(&(tim->timer));
}
void _mali_osk_timer_mod(_mali_osk_timer_t *tim, unsigned long ticks_to_expire)
{
MALI_DEBUG_ASSERT_POINTER(tim);
mod_timer(&(tim->timer), jiffies + ticks_to_expire);
}
void _mali_osk_timer_del(_mali_osk_timer_t *tim)
{
MALI_DEBUG_ASSERT_POINTER(tim);
del_timer_sync(&(tim->timer));
}
void _mali_osk_timer_del_async(_mali_osk_timer_t *tim)
{
MALI_DEBUG_ASSERT_POINTER(tim);
del_timer(&(tim->timer));
}
mali_bool _mali_osk_timer_pending(_mali_osk_timer_t *tim)
{
MALI_DEBUG_ASSERT_POINTER(tim);
return 1 == timer_pending(&(tim->timer));
}
void _mali_osk_timer_setcallback(_mali_osk_timer_t *tim, _mali_osk_timer_callback_t callback, void *data)
{
MALI_DEBUG_ASSERT_POINTER(tim);
tim->timer.data = (unsigned long)data;
tim->timer.function = (timer_timeout_function_t)callback;
}
void _mali_osk_timer_term(_mali_osk_timer_t *tim)
{
MALI_DEBUG_ASSERT_POINTER(tim);
kfree(tim);
}这里的主要问题是,这段代码通过一个很久以前就不推荐使用的接口使用计时器,并在4.15中从内核中完全删除。我能够查找如何移植这段代码,并管理了几乎整个文件,但最后我还不太熟悉C语法和指针使用规则,不知道如何实现。主要问题是_mali_osk_timer_setcallback()函数。我不太确定如何修改它,同时也保留相同的函数签名。
编辑
下面是当前代码和编译器的当前输出:
/*
* Copyright (C) 2010-2014, 2016 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
*
* A copy of the licence is included with the program, and can also be obtained from Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* @file mali_osk_timers.c
* Implementation of the OS abstraction layer for the kernel device driver
*/
#include <linux/timer.h>
#include <linux/slab.h>
#include "mali_osk.h"
#include "mali_kernel_common.h"
#define MALI_TIMER_FLAGS 0
struct _mali_osk_timer_t_struct {
struct timer_list timer;
void (*ticked)(unsigned long data);
};
static void tick_trampoline(struct timer_list *t) {
typedef struct _mali_osk_timer_t_struct Tldr;
Tldr *m = container_of(t, Tldr, timer);
m->ticked(t->data);
}
typedef void (*timer_timeout_function_t)(unsigned long);
_mali_osk_timer_t *_mali_osk_timer_init(void)
{
_mali_osk_timer_t *t = (_mali_osk_timer_t *)kmalloc(sizeof(_mali_osk_timer_t), GFP_KERNEL);
if (NULL != t) timer_setup(&(t->timer), tick_trampoline, MALI_TIMER_FLAGS);
return t;
}
void _mali_osk_timer_add(_mali_osk_timer_t *tim, unsigned long ticks_to_expire)
{
MALI_DEBUG_ASSERT_POINTER(tim);
tim->timer.expires = jiffies + ticks_to_expire;
add_timer(&(tim->timer));
}
void _mali_osk_timer_mod(_mali_osk_timer_t *tim, unsigned long ticks_to_expire)
{
MALI_DEBUG_ASSERT_POINTER(tim);
mod_timer(&(tim->timer), jiffies + ticks_to_expire);
}
void _mali_osk_timer_del(_mali_osk_timer_t *tim)
{
MALI_DEBUG_ASSERT_POINTER(tim);
del_timer_sync(&(tim->timer));
}
void _mali_osk_timer_del_async(_mali_osk_timer_t *tim)
{
MALI_DEBUG_ASSERT_POINTER(tim);
del_timer(&(tim->timer));
}
mali_bool _mali_osk_timer_pending(_mali_osk_timer_t *tim)
{
MALI_DEBUG_ASSERT_POINTER(tim);
return 1 == timer_pending(&(tim->timer));
}
void _mali_osk_timer_setcallback(_mali_osk_timer_t *tim, _mali_osk_timer_callback_t callback, void *data)
{
MALI_DEBUG_ASSERT_POINTER(tim);
&(tim->timer).data = (unsigned long)data;
tim->ticked = (timer_timeout_function_t)callback; /* Note no cast */
timer_setup(&(tim->timer), tick_trampoline, MALI_TIMER_FLAGS);
}
void _mali_osk_timer_term(_mali_osk_timer_t *tim)
{
MALI_DEBUG_ASSERT_POINTER(tim);
kfree(tim);
}_
hugo@tx5:/media/hugo/7d79c22a-4ac8-4fcb-ae1c-3310a851a73d/gpu-2016-08-18-fe6d7b1d1b/mali$ sudo KDIR=../../kernel/Amlogic_s905-kernel USING_UMP=0 BUILD=release make
make ARCH=arm64 -C ../../kernel/Amlogic_s905-kernel M=/media/hugo/7d79c22a-4ac8-4fcb-ae1c-3310a851a73d/gpu-2016-08-18-fe6d7b1d1b/mali modules
make[1]: Entering directory '/media/hugo/7d79c22a-4ac8-4fcb-ae1c-3310a851a73d/kernel/Amlogic_s905-kernel'
WARNING: Symbol version dump ./Module.symvers
is missing; modules will have no dependencies and modversions.
CC [M] /media/hugo/7d79c22a-4ac8-4fcb-ae1c-3310a851a73d/gpu-2016-08-18-fe6d7b1d1b/mali/linux/mali_osk_timers.o
/media/hugo/7d79c22a-4ac8-4fcb-ae1c-3310a851a73d/gpu-2016-08-18-fe6d7b1d1b/mali/linux/mali_osk_timers.c: In function ‘tick_trampoline’:
/media/hugo/7d79c22a-4ac8-4fcb-ae1c-3310a851a73d/gpu-2016-08-18-fe6d7b1d1b/mali/linux/mali_osk_timers.c:31:17: error: ‘struct timer_list’ has no member named ‘data’
m->ticked(t->data);
^~
/media/hugo/7d79c22a-4ac8-4fcb-ae1c-3310a851a73d/gpu-2016-08-18-fe6d7b1d1b/mali/linux/mali_osk_timers.c: In function ‘_mali_osk_timer_setcallback’:
/media/hugo/7d79c22a-4ac8-4fcb-ae1c-3310a851a73d/gpu-2016-08-18-fe6d7b1d1b/mali/linux/mali_osk_timers.c:77:18: error: ‘struct timer_list’ has no member named ‘data’
&(tim->timer).data = (unsigned long)data;
^
/media/hugo/7d79c22a-4ac8-4fcb-ae1c-3310a851a73d/gpu-2016-08-18-fe6d7b1d1b/mali/linux/mali_osk_timers.c: At top level:
cc1: warning: unrecognized command line option ‘-Wno-data-time’
scripts/Makefile.build:305: recipe for target '/media/hugo/7d79c22a-4ac8-4fcb-ae1c-3310a851a73d/gpu-2016-08-18-fe6d7b1d1b/mali/linux/mali_osk_timers.o' failed
make[2]: *** [/media/hugo/7d79c22a-4ac8-4fcb-ae1c-3310a851a73d/gpu-2016-08-18-fe6d7b1d1b/mali/linux/mali_osk_timers.o] Error 1
Makefile:1517: recipe for target '_module_/media/hugo/7d79c22a-4ac8-4fcb-ae1c-3310a851a73d/gpu-2016-08-18-fe6d7b1d1b/mali' failed
make[1]: *** [_module_/media/hugo/7d79c22a-4ac8-4fcb-ae1c-3310a851a73d/gpu-2016-08-18-fe6d7b1d1b/mali] Error 2
make[1]: Leaving directory '/media/hugo/7d79c22a-4ac8-4fcb-ae1c-3310a851a73d/kernel/Amlogic_s905-kernel'
Makefile:192: recipe for target 'all' failed
make: *** [all] Error 2发布于 2018-12-16 23:49:57
新的计时器接口喘息,将上下文值留在计时器结构中,然后传递指向该结构的指针。其思想是数据的使用将消失,因为常用的成语是数据是指向包含timer_list结构的结构的指针。
由于您可能希望最小化对马里的更改,这里概述的更改应该会有所帮助;它只是插入了一个小的协议转换函数,以使其看起来像旧的方式。
struct _mali_osk_timer_t_struct {
struct timer_list timer;
unsigned long data;
void (*ticked)(unsigned long data); /* Add this */
};
#define MALI_TIMER_FLAGS 0 /* NB: choose the right bits for this! */
/* This function converts between the “new” and “old” notifications */
static void tick_trampoline(struct timer *t) {
typedef struct _mali_osk_timer_t_struct Tldr;
Tldr *m = container_of(t, Tldr, timer);
m->ticked(m->data);
}
/* change this one: */
void _mali_osk_timer_setcallback(_mali_osk_timer_t *tim, _mali_osk_timer_callback_t callback, void *data)
{
MALI_DEBUG_ASSERT_POINTER(tim);
tim->data = (unsigned long)data;
tim->ticked = callback; /* Note no cast */
timer_setup(&tim->ticked, tick_trampoline, MALI_TIMER_FLAGS);
}“No cast”是请求让类型系统完成它的工作。
https://stackoverflow.com/questions/53801738
复制相似问题