io.h

来自「一个操作系统的源代码」· C头文件 代码 · 共 101 行

H
101
字号
/** io.h ** ** Original Author: Kasper Verdich Lund ** Date: 10/11/99 ** ** Description: ** Low-level fnctions ** ** 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 or 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 ** *********************************************************Apostle OS**/#ifndef __IO_H_#define __IO_H_#include <types.h>/* this code should be rewritten - it's messy  and ugly *//* any better now? */#define io_wait()   inb(0x80)static inline byte inb (word port){  register byte x;  __asm__ __volatile__ (    "inb %%dx,%%al"    : "=a" (x)    : "d" (port));  return (x);}static inline word inw (word port){  register word x;  __asm__ __volatile__ (    "inw %%dx,%%ax"    : "=a" (x)    : "d" (port));  return (x);}static inline dword inl (word port){  register dword x;  __asm__ __volatile__ (    "inl %%dx,%%eax"    : "=a" (x)    : "d" (port));  return (x);}static inline void outb (word port, byte value){  __asm__ __volatile__ (    "outb %%al,%%dx"    : /* no outputs */    : "a" (value), "d" (port));}static inline void outw (word port, word value){  __asm__ __volatile__ (    "outw %%ax,%%dx"    : /* no outputs*/    : "a" (value), "d" (port));}static inline void outl (word port, dword value){  __asm__ __volatile__ (    "outl %%eax,%%dx"    : /* no outputs */    : "a" (value), "d" (port));}static inline void repinsw (port, buffer, count){  __asm__ __volatile__ (    "rep; insw"    : /* no outputs */    : "d" (port), "D" (buffer), "c" (count)    : "eax", "ecx", "edx", "edi");}#endif /* __IO_H_ */

⌨️ 快捷键说明

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