W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
本章介紹下列與硬件管理相關(guān)的符號(hào):
#include <linux/kernel.h>
void barrier(void)
這個(gè)"軟件"內(nèi)存屏蔽要求編譯器對(duì)待所有內(nèi)存是跨這個(gè)指令而非易失的.
#include <asm/system.h>
void rmb(void);
void read_barrier_depends(void);
void wmb(void);
void mb(void);
硬件內(nèi)存屏障. 它們請(qǐng)求 CPU(和編譯器)來檢查所有的跨這個(gè)指令的內(nèi)存讀, 寫, 或都有.
#include <asm/io.h>
unsigned inb(unsigned port);
void outb(unsigned char byte, unsigned port);
unsigned inw(unsigned port);
void outw(unsigned short word, unsigned port);
unsigned inl(unsigned port);
void outl(unsigned doubleword, unsigned port);
用來讀和寫 I/O 端口的函數(shù). 它們還可以被用戶空間程序調(diào)用, 如果它們有正當(dāng)?shù)臋?quán)限來存取端口.
unsigned inb_p(unsigned port);
如果在一次 I/O 操作后需要一個(gè)小延時(shí), 你可以使用在前一項(xiàng)中介紹的這些函數(shù)的 6 個(gè)暫停對(duì)應(yīng)部分; 這些暫停函數(shù)有以 _p 結(jié)尾的名子.
void insb(unsigned port, void *addr, unsigned long count);
void outsb(unsigned port, void *addr, unsigned long count);
void insw(unsigned port, void *addr, unsigned long count);
void outsw(unsigned port, void *addr, unsigned long count);
void insl(unsigned port, void *addr, unsigned long count);
void outsl(unsigned port, void *addr, unsigned long count);
這些"字串函數(shù)"被優(yōu)化為傳送數(shù)據(jù)從一個(gè)輸入端口到一個(gè)內(nèi)存區(qū), 或者其他的方式. 這些傳送通過讀或?qū)懙酵欢丝?count 次來完成.
#include <linux/ioport.h>
struct resource *request_region(unsigned long start, unsigned long len, char *name);
void release_region(unsigned long start, unsigned long len);
int check_region(unsigned long start, unsigned long len);
I/O 端口的資源分配器. 這個(gè)檢查函數(shù)成功返回 0 并且在錯(cuò)誤時(shí)小于 0.
struct resource *request_mem_region(unsigned long start, unsigned long len, char *name);
void release_mem_region(unsigned long start, unsigned long len);
int check_mem_region(unsigned long start, unsigned long len);
為內(nèi)存區(qū)處理資源分配的函數(shù)
#include <asm/io.h>
void *ioremap(unsigned long phys_addr, unsigned long size);
void *ioremap_nocache(unsigned long phys_addr, unsigned long size);
void iounmap(void *virt_addr);
ioremap 重映射一個(gè)物理地址范圍到處理器的虛擬地址空間, 使它對(duì)內(nèi)核可用. iounmap 釋放映射當(dāng)不再需要它時(shí).
#include <asm/io.h>
unsigned int ioread8(void *addr);
unsigned int ioread16(void *addr);
unsigned int ioread32(void *addr);
void iowrite8(u8 value, void *addr);
void iowrite16(u16 value, void *addr);
void iowrite32(u32 value, void *addr);
用來使用 I/O 內(nèi)存的存取者函數(shù).
void ioread8_rep(void *addr, void *buf, unsigned long count);
void ioread16_rep(void *addr, void *buf, unsigned long count);
void ioread32_rep(void *addr, void *buf, unsigned long count);
void iowrite8_rep(void *addr, const void *buf, unsigned long count);
void iowrite16_rep(void *addr, const void *buf, unsigned long count);
void iowrite32_rep(void *addr, const void *buf, unsigned long count);
I/O 內(nèi)存原語(yǔ)的"重復(fù)"版本.
unsigned readb(address);
unsigned readw(address);
unsigned readl(address);
void writeb(unsigned value, address);
void writew(unsigned value, address);
void writel(unsigned value, address);
memset_io(address, value, count);
memcpy_fromio(dest, source, nbytes);
memcpy_toio(dest, source, nbytes);
舊的, 類型不安全的存取 I/O 內(nèi)存的函數(shù).
void *ioport_map(unsigned long port, unsigned int count);
void ioport_unmap(void *addr);
一個(gè)想對(duì)待 I/O 端口如同它們是 I/O 內(nèi)存的驅(qū)動(dòng)作者, 可以傳遞它們的端口給 ioport_map. 這個(gè)映射應(yīng)當(dāng)在不需要的時(shí)候恢復(fù)( 使用 ioport_unmap )
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: