Raspberrypi3系统调用 - 传递64位参数

时间:2018-02-28 18:40:20

标签: assembly linux-kernel arm system-calls raspberry-pi3

我在github.com/raspberrypi/linux的内核中为我的raspberrypi3创建了一个系统调用,并且应用了RT补丁。

在玩游戏时,我注意到我无法通过64位参数。我创建了一个使用syscall()函数进行测试的用户应用程序。

这是我的系统调用:

asmlinkage long sys_testCall(const char __user* buf, unsigned long long testVal)
{
    unsigned long long val1 = 1000;
    unsigned long long val2 = 68719476735;
    unsigned long long retVal = 0;

    retVal = val1 + val1;
    printk("sum 1000 = %llu\n", retVal);

    retVal = val2 + val2;
    printk("sum Fs = %llu\n", retVal);

    printk("DEBUG: Entering %s %d \n", __FUNCTION__, __LINE__);
    printk("DEBUG: Buff: %s\n", buf);
    printk("DEBUG: testVal: %llu\n", testVal);
    printk("DEBUG: testVal: %llx\n", testVal);

    return 0;
}

这是我的用户应用:

#include <stdio.h>
#include <linux/kernel.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>

// arm-linux-gnueabihf-gcc -o sysTest userSyscallTest.c

void main(int argc, char *argv[])
{
    int val = strtol(argv[1], NULL, 10);

    unsigned long long testVal = 100;
    char *mess = "MyMessage";

    printf("SYSCALL TEST: %d\n", val);
    if (397 == val)
    {
        long int test_call_ret = syscall(val, mess, testVal);
    }
    else
    {
        long int syscallRet = syscall(val);
    }
}

我在目标上编译并执行./sysTest 397 ......我得到:

SYSCALL TEST: 397[  595.650294] sum 1000 = 2000

[  595.654537] sum Fs = 137438953470
[  595.658007] DEBUG: Entering sys_testCall 53
[  595.662279] DEBUG: Buff: MyMessage
[  595.665682] DEBUG: testVal: 9137185598140841984
[  595.670214] DEBUG: testVal: 7ecdcde400000000

我不确定如何解释&#34;数学&#34;处理64位值而系统调用则不处理。我假设这两个条件都是从一些寄存器加载,移动,交换等处理的。但是,我不确定这些细节。 我目前正在寻找...

当我继续搜索我的代码时,我想我也会问这里。

思想?

0 个答案:

没有答案
相关问题