linux源代码剖析之include-asm
include-asm
汇编
io.h
#define outb(value,port)
asm (“outb %%al,%%dx”::“a” (value),“d” (port))
#define inb(port) ({
unsigned char _v;
asm volatile (“inb %%dx,%%al”:"=a" (_v):“d” (port));
_v;
})
#define outb_p(value,port)
asm (“outb %%al,%%dx\n”
“\tjmp 1f\n”
“1:\tjmp 1f\n”
“1:”::“a” (value),“d” (port))
#define inb_p(port) ({
unsigned char _v;
asm volatile (“inb %%dx,%%al\n”
“\tjmp 1f\n”
“1:\tjmp 1f\n”
“1:”:"=a" (_v):“d” (port));
_v;
})
memory.h
/*
- NOTE!!! memcpy(dest,src,n) assumes ds=es=normal data segment. This
- goes for all kernel functions (ds=es=kernel space, fs=local data,
- gs=null), as well as for all well-behaving user programs (ds=es=
- user data space). This is NOT a bug, as any user program that changes
- es deserves to die if it isn’t careful.
*/
#define memcpy(dest,src,n) ({
void * _res = dest;
asm (“cld;rep;movsb”
::“D” ((long)(_res)),“S” ((long)(src)),“c” ((long) (n))
:“di”,“si”,“cx”);
_res;
})
segment.h
extern inline unsigned char get_fs_byte(const char * addr)
{
unsigned register char _v;
__asm__ ("movb %%fs:%1,%0":"=r" (_v):"m" (*addr));
return _v;
}
extern inline unsigned short get_fs_word(const unsigned short *addr)
{
unsigned short _v;
__asm__ ("movw %%fs:%1,%0":"=r" (_v):"m" (*addr));
return _v;
}
extern inline unsigned long get_fs_long(const unsigned long *addr)
{
unsigned long _v;
__asm__ ("movl %%fs:%1,%0":"=r" (_v):"m" (*addr)); \
return _v;
}
extern inline void put_fs_byte(char val,char *addr)
{
asm (“movb %0,%%fs:%1”::“r” (val),“m” (*addr));
}
extern inline void put_fs_word(short val,short * addr)
{
asm (“movw %0,%%fs:%1”::“r” (val),“m” (*addr));
}
extern inline void put_fs_long(unsigned long val,unsigned long * addr)
{
asm (“movl %0,%%fs:%1”::“r” (val),“m” (*addr));
}
system.h
#define move_to_user_mode()
asm (“movl %%esp,%%eax\n\t”
“pushl $0x17\n\t”
“pushl %%eax\n\t”
“pushfl\n\t”
“pushl $0x0f\n\t”
“pushl $1f\n\t”
“iret\n”
“1:\tmovl $0x17,%%eax\n\t”
“movw %%ax,%%ds\n\t”
“movw %%ax,%%es\n\t”
“movw %%ax,%%fs\n\t”
“movw %%ax,%%gs”
:::“ax”)
#define sti() asm (“sti”:
linux源代码剖析之include-asm相关推荐
- linux源代码剖析之kernel
kernel asm.s /* asm.s contains the low-level code for most hardware faults. page_exception is handle ...
- linux源代码剖析之三fs
fs bitmap.c /* bitmap.c contains the code that handles the inode and block bitmaps */ #include <s ...
- linux源码0.11解析pdf,linux0.11 赵炯的Linux源代码剖析中的带中文注释的源代码 - 下载 - 搜珍网...
linux内核0.11注释版/boot/bootsect.s linux内核0.11注释版/boot/head.s linux内核0.11注释版/boot/setup.s linux内核0.11注释版 ...
- linux源代码剖析之lib
lib _exit.c #define LIBRARY #include <unistd.h> volatile void _exit(int exit_code) { asm(" ...
- linux源代码剖析之一
boot fs include include-asm include-linux include-sys init kernel lib mm tools Makefile
- linux源代码剖析之二boot
"boot" boot.s | | boot.s | | boot.s is loaded at 0x7c00 by the bios-startup routines, and ...
- linux源代码分析视频教程,linux源代码分析方法谈
Linux的最大的好处之一就是它的源码公开.同时,公开的核心源码也吸引着无数的电脑爱好者和程序员:他们把解读和分析Linux的核心源码作为自己的最大兴趣,把修改Linux源码和改造Linux系统作为自 ...
- linux文件系统dentry_NFS 文件系统源代码剖析
NFS 文件系统概述 NFS(Network File System,网络文件系统)是一种基于网络的文件系统.它可以将远端服务器文件系统的目录挂载到本地文件系统的目录上,允许用户或者应用程序像访问本地 ...
- linux内核 noreturn,读《ARM Linux 内核源代码剖析》.......第13章 setup_processor()
setup_processor首先是查找保存相应处理器信息的结构体,然后根据结构体里的值,对处理器相关的各种变量进行设置. setup_processor static void __init set ...
最新文章
- linux c/c++ 判断是否为中文(不包括中文符号,非正则)
- DIP第二章习题解答
- SQL 2005 收缩事务日志文件
- Parity Game CodeForces - 298C
- 【转载】数据库操作:添加、插入、更新语句
- [渝粤教育] 广东-国家-开放大学 21秋期末考试建筑工程概预算10326k2
- java实现蛇蛇大作战_蛇蛇大作战3D旋涡版
- springcloud工作笔记106---eureka实现服务监控_监控服务下线_服务注册_服务续约_判断注册中心可用_监控eurekaserver启动
- 机器学习基础(十六)—— bootstrap
- UML类图(Class Diagram)中类与类之间的关系及表示方式
- python image 转成字节_Python 办公自动化之 Excel(下)
- 拓端tecdat|R语言多元逐步回归模型分析房价和葡萄酒价格:选择最合适的预测变量
- Android速度仪表盘,速度评级小车动画(模仿电脑版360宽带测速器)
- PHY之MDIO解析
- python3 url 获取域名ip
- Mac新手必备技巧之如何关闭Mac屏幕亮度自动调节功能
- 计算房租收入比(1)- scrapy 爬取网上租房信息
- 数据结构与算法Python版-第六周作业
- 列主元消去法例题详解_列主元消去法
- 区分java的三大版本:JavaSE、JavaME、JavaEE
热门文章
- Ubuntu下The program 'python' can be found in the following packages:
- ubuntu16.04源码编译安装nginx1.16.2
- 使用doc下的copy命令复制文件时,注意文件分割符
- 在Windows系统下安装RabbitMQ
- 异常检测-基于孤立森林算法Isolation-based Anomaly Detection-1-论文学习
- sql无效字符 执行sql语句报错解决方案
- 通过swagger下载的文件乱码解决方法,求解
- BeyondCompare3 提示许可证密钥已被撤销解决方法
- Jenkins连接git时出现“Failed to connect to repository : Command ... HEAD“ returned status code 128:”的问题解决
- 地图点击区域高亮 vue_这个Excel技巧很强大,鼠标点击即高亮显示数据区域