Kernel Newbies
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Kernel Newbies Japan

  • Webリソース

  • Mailing List

Wiki bits

  • Site Editors

  • Navigation Menu

  • WikiWall Terms of Service

  • Hosted by WikiWall

Navigation

  • RecentChanges
  • FindPage
  • HelpContents

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment

Revision 2 as of 2007-09-02 09:05:09
KernelNewbiesJP:
  • IoMemoryAccess

このページはWritingPortableDriversセクションの一部です。BR

I/Oメモリアクセス

原文: [http://kernelnewbies.org/IoMemoryAccess IoMemoryAccess]

多くの一般的な組み込みシステムと異なり、LinuxではI/Oメモリに直接アクセスすることはできません。 これはLinuxが動作する多様なプロセッサには、さまざまなメモリの種類とメモリマップが存在するからです。 移植性の高い方法でI/Oメモリにアクセスするために、メモリ領域へアクセスするときはioremap()を呼び出し、 アクセスが終ったらiounmap()を呼び出してください。

ioremap()は次のように定義されています。

void __iomem *ioremap(unsigned long offset, unsigned long size);

この関数には、アクセスしたい領域の開始オフセットとその領域のサイズをバイト単位で渡します。この関数の返却値を メモリ領域として直接読み書きすることはできません。この返却値をデータを読み書きする関数に渡してください。

ioremap()でマップされたメモリを読み書きする関数には、次に示すものがあります。

   1 unsigned char  readb(const volatile void __iomem *addr);  /* read 8 bits */
   2 unsigned short readw(const volatile void __iomem *addr);  /* read 16 bits */
   3 unsigned int   readl(const volatile void __iomem *addr);  /* read 32 bits */
   4 
   5 void writeb (unsigned char  value, volatile void __iomem *addr);  /* write 8 bits */
   6 void writew (unsigned short value, volatile void __iomem *addr);  /* write 16 bits */
   7 void writel (unsigned int   value, volatile void __iomem *addr);  /* write 32 bits */

メモリへのアクセスが終了したら、そのメモリを他の人が使えるようにiounmap()を呼び出してメモリを解放してください。

次に示すコード例は、drivers/hotplug/cpqphp_core.cのCompaq PCIホットプラグドライバからのもので、 PCIデバイスのリソースメモリに適切にアクセスする方法を示しています。

FIXME: ここに良い例をあげてください。ホットプラグの例は良くありません...

  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01