io.h

来自「从网上下载的一个自己编写的简单的操作系统源代码,对底层了解很有好处的」· C头文件 代码 · 共 56 行

H
56
字号
/*
 *  Exp
 *
 *
 *
 *
 */
#ifndef _I386_IO_H_
#define _I386_IO_H_






/*
 *  io
 */
#define outb(port,value) \
__asm__ volatile ("outb %%al,%%dx"::"a" (value),"d" (port))


#define inb(port) ({ \
unsigned char _v; \
__asm__ volatile ("inb %%dx,%%al":"=a" (_v):"d" (port)); \
_v; \
})

#define inw(port) ({ \
ushort _v; \
__asm__ volatile ("inb %%dx,%%ax":"=a" (_v):"d" (port)); \
_v; \
})


#define outb_p(port,value) \
__asm__ volatile ("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; \
})




#endif /*_I386_IO_H_*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?