linux之上C内嵌汇编并转换虚拟/物理地址

来源:互联网 发布:高清摄像头录像软件 编辑:程序博客网 时间:2024/06/05 08:09
#include <linux/gpio.h>             //gpio管教设置
#include <mach/regs-gpio.h>             //gpio设置功能#include <asm/io.h>#include <linux/kthread.h>#include <linux/module.h>#define GPFDAT (unsigned long)ioremap(0x56000054,4)#ifndef SLEEP_MILLI_SEC#define SLEEP_MILLI_SEC(nMilliSec)\do { \long timeout = (nMilliSec) * HZ / 1000; \while(timeout > 0) \{ \timeout = schedule_timeout(timeout); \} \}while(0);#endifstatic int MyPrintk(void *data){    long int led_addr;    long int val0 = 0;    long int val1 = 1;        led_addr = GPFDAT;    printk("%s,addrs changed !\n",mydata);    printk("%s,leds OFF\n",mydata);        while(!kthread_should_stop())        {            __asm__ __volatile__ (                    "str   %1, [%0]\n\t"                    "nop\n\t"                    :                    :"r" (led_addr), "r" (val0)//                    :                );            __asm__ __volatile__ (                    "str   %1, [%0]\n\t"                    "nop\n\t"                    :                    :"r" (led_addr), "r" (val1)//                    :                );        }    kfree(mydata);    return 0;}



原创粉丝点击