linux下运行pl,PS如何在linux下访问PL的寄存器
devmem2了解一下,源码随便一搜便有。
这里贴出来,方便你使用。/*
* devmem2.c: Simple program to read/write from/to any location in memory.
*
* Copyright (C) 2000, Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
*
*
* This software has been developed for the LART computing board
* (http://www.lart.tudelft.nl/). The development has been sponsored by
* the Mobile MultiMedia Communications (http://www.mmc.tudelft.nl/)
* and Ubiquitous Communications (http://www.ubicom.tudelft.nl/)
* projects.
*
* The author can be reached at:
*
* Jan-Derk Bakker
* Information and Communication Theory Group
* Faculty of Information Technology and Systems
* Delft University of Technology
* P.O. Box 5031
* 2600 GA Delft
* The Netherlands
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", \
__LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)
#define MAP_SIZE 4096UL
#define MAP_MASK (MAP_SIZE - 1)
int main(int argc, char **argv) {
int fd;
void *map_base, *virt_addr;
unsigned long read_result, writeval;
off_t target;
int access_type = 'w';
if(argc < 2) {
fprintf(stderr, "\nUsage:\t%s { address } [ type [ data ] ]\n"
"\taddress : memory address to act upon\n"
"\ttype : access operation type : [b]yte, [h]alfword, [w]ord\n"
"\tdata : data to be written\n\n",
argv[0]);
exit(1);
}
target = strtoul(argv[1], 0, 0);
if(argc > 2)
access_type = tolower(argv[2][0]);
if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) FATAL;
printf("/dev/mem opened.\n");
fflush(stdout);
/* Map one page */
map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, target & ~MAP_MASK);
if(map_base == (void *) -1) FATAL;
printf("Memory mapped at address %p.\n", map_base);
fflush(stdout);
virt_addr = map_base + (target & MAP_MASK);
switch(access_type) {
case 'b':
read_result = *((unsigned char *) virt_addr);
break;
case 'h':
read_result = *((unsigned short *) virt_addr);
break;
case 'w':
read_result = *((unsigned long *) virt_addr);
break;
default:
fprintf(stderr, "Illegal data type '%c'.\n", access_type);
exit(2);
}
printf("Value at address 0x%X (%p): 0x%X\n", target, virt_addr, read_result);
fflush(stdout);
if(argc > 3) {
writeval = strtoul(argv[3], 0, 0);
switch(access_type) {
case 'b':
*((unsigned char *) virt_addr) = writeval;
read_result = *((unsigned char *) virt_addr);
break;
case 'h':
*((unsigned short *) virt_addr) = writeval;
read_result = *((unsigned short *) virt_addr);
break;
case 'w':
*((unsigned long *) virt_addr) = writeval;
read_result = *((unsigned long *) virt_addr);
break;
}
printf("Written 0x%X; readback 0x%X\n", writeval, read_result);
fflush(stdout);
}
if(munmap(map_base, MAP_SIZE) == -1) FATAL;
close(fd);
return 0;
}
使用:devmem2 { address } [ type [ data ] ]
address : 物理地址
如果是要修改该地址的数据,需要填入下面的参数;如果只是读取,省略即可
type :要访问的数据类型 : [b]yte, [h]alfword, [w]ord
data :想要写入的数据
BestRegards,
HSQ
linux下运行pl,PS如何在linux下访问PL的寄存器相关推荐
- 如何在虚拟机linux下运行程序吗,如何在Linux上运行Windows应用程序?
一些人可能避免在Linux上运行Windows应用程序,但事实上有时候这么做大有帮助. 一些人无法摆脱Windows的最主要原因之一是可用的应用程序.有时候,这些应用程序是老式应用程序,没有开源替代版 ...
- linux如何运行windows游戏,如何在Linux上运行Windows应用程序和游戏 互联网技术圈 互联网技术圈...
在本教程中,我将向您介绍如何在Linux中运行Windows应用程序和游戏.您可能知道,Microsoft Windows使用DirectX来运行游戏.因此,在Windows平台上玩一些需要Direc ...
- Linux下监控磁盘io,如何在Linux下监控磁盘IO?
[51CTO.com快译]iostat用于获取存储设备和分区的I/O统计信息.iostat是sysstat软件包的一部分.使用iostat,你可以监控存储设备(比如硬驱和SSD)以及分区(磁盘分区)的 ...
- linux下开放sftp端口,如何在 Linux 系统中如何更改 SFTP 端口
如何在 Linux 系统中如何更改 SFTP 端口 SFTP(SSH文件传输协议)是一种安全文件协议,用于通过加密连接在两个主机之间传输文件. 它还允许您对远程文件执行各种文件操作并恢复文件传输. S ...
- linux禁止ssh传输文件,如何在Linux下使用scp命令通过ssh安全传输文件
原标题:如何在Linux下使用scp命令通过ssh安全传输文件 在Unix或Linux操作系统上,scp实用程序(secure copy)与更著名的命令cp类似,但用于在安全加密的网络上在主机之间传输 ...
- linux 和android开发环境,如何在linux下配置AndroidStudio开发环境
1.选择linux系统 个人比较推荐国产的UbuntuKylin,目前最新的系统已经更新到16.04了,这个系统集合了原生Ubuntu系统的优点,有具有中国特色,比较适合国人使用.还有一个国产系统比较 ...
- linux 怎么查看go版本,如何在Linux下查看版本信息
Linux下如何查看版本信息, 包括位数.版本信息以及CPU内核信息.CPU具体型号等等,整个CPU信息一目了然. 1.# uname -a (Linux查看版本当前操作系统内核信息) Linux ...
- linux命令行运行c程序,如何在Linux中编写和运行C程序
Linux正在成为开发人员的编程天堂,成为开源和免费操作系统. Turbo C编译器已经是一种编译程序的旧方法,所以让程序员转向Linux以获得新的编程环境. 在本文中,我们将解释如何编写,编译和运行 ...
- linux查看并口设备,如何在LINUX下实现硬件的自动检测(下)
本文是<如何在LINUX下实现硬件的自动检测>一文的下部分,作者将继续向我们讲述如何自动检测另外几种总线类型硬件设备. 5 .USB设备的自动检测 5.1 USB设备检测的一般过程 USB ...
- Linux下运行纯dos软件,在linux下运行dos软件(转)
在linux下运行dos软件(转)[@more@]在linux系统上运行的dosemu软件包使你能在linux环境运行许多dos软件. [安装] DOSEMU处于不断进行修改和升级的过程中.它在不断增 ...
最新文章
- 为 Asp.net 网站新增发送手机短信功能
- altium designer怎么在原理图中批量修改元件封装
- 面试题目集锦--二叉树
- Http 请求处理流程(转)
- Csharp+Asp.net系列教程(四)
- 深入浅出:Microsoft分布式事务处理协调器
- RHCE 学习笔记(16) - KickStart
- html css 深入理解float
- 大数据量表的优化查询
- linux查看共享内存max,浅析Linux的共享内存与tmpfs文件系统
- Spring处理跨域请求
- 不输入密码执行sudo 命令
- rust腐蚀机场蓝卡_rust怎么弄蓝卡和红卡
- 阿里云服务器购买价格表:国内和国外地域云服务器活动报价表
- html easyui怎么实现折叠面板,Easyui 创建折叠面板_EasyUI 教程
- 云旗OS助手火了!可一站式体验统信UOS
- 网络层笔记六、硬件地址与IP地址
- 微信小程序实现动态横向步骤条的两种方式
- PCIe扫盲——PCIe错误源详解(一)
- 为什么公众号总是显示服务器不正常,“该公众号提供的服务出现故障,请稍后再试”问题的处理办法...
热门文章
- 钢模块化结构的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告
- 【电磁兼容】03 高速数字电路的阻抗匹配
- 某空分设备公司薪酬体系设计项目成功案例纪实
- OpenCV Android解决相机旋转90度及全屏问题
- HTML标题处有一个小图片
- arcgis自动完成面怎么用_ArcGIS实践教程(35)ArcGIS/ArcMap面文件的分割
- 广州凯荣都国际大酒店会议室改造工程案例
- 商河AAA企业信用评级申请条件和流程
- Protobuf的直白理解
- Castem制造了世界第一批888个拳形铸件限量版产品,其原型来自于赢得六次世界拳击冠军的传奇人物Manny Pacquiao!