{"id":1402,"date":"2012-03-06T22:02:08","date_gmt":"2012-03-06T04:02:08","guid":{"rendered":"http:\/\/peta.okechan.net\/blog\/?p=1402"},"modified":"2012-03-14T11:21:47","modified_gmt":"2012-03-14T02:21:47","slug":"xv6%e3%82%bd%e3%83%bc%e3%82%b9%e3%82%b3%e3%83%bc%e3%83%89%e3%83%aa%e3%83%bc%e3%83%87%e3%82%a3%e3%83%b3%e3%82%b0-%e3%81%9d%e3%81%ae30","status":"publish","type":"post","link":"https:\/\/peta.okechan.net\/blog\/archives\/1402","title":{"rendered":"[xv6 #30] Chapter 2 &#8211; Traps, interrupts, and drivers &#8211; Code: Disk driver"},"content":{"rendered":"<p>\u30c6\u30ad\u30b9\u30c8\u306e39\u301c41\u30da\u30fc\u30b8<\/p>\n<h3>\u672c\u6587<\/h3>\n<p>IDE\u30c7\u30d0\u30a4\u30b9\u306f\u3001PC\u306e\u6a19\u6e96IDE\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306b\u63a5\u7d9a\u3055\u308c\u305f\u30c7\u30a3\u30b9\u30af\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092\u63d0\u4f9b\u3059\u308b\u3002<br \/>\nIDE\u306f\u3001\u4eca\u3068\u306a\u3063\u3066\u306fSCSI\u3084SATA\u306e\u3088\u3046\u306a\u6d41\u884c\u304b\u3089\u306f\u5916\u308c\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u304c\u3001\u305d\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u306f\u5358\u7d14\u3067\u3001\u500b\u5225\u306e\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u306e\u8a73\u7d30\u306b\u7acb\u3061\u5165\u308b\u5fc5\u8981\u306a\u304f\u30c9\u30e9\u30a4\u30d0\u5168\u4f53\u306e\u69cb\u7bc9\u306b\u96c6\u4e2d\u3055\u305b\u3066\u304f\u308c\u308b\u3002<\/p>\n<p>\u30c7\u30a3\u30b9\u30af\u30c9\u30e9\u30a4\u30d0\u306f\u3001\u30d0\u30c3\u30d5\u30a1\u3068\u547c\u3070\u308c\u308b\u30c7\u30fc\u30bf\u306e\u69cb\u9020\u4f53\uff08buf\u69cb\u9020\u4f53\uff09\u3068\u3057\u3066\u30c7\u30a3\u30b9\u30af\u306e\u30bb\u30af\u30bf\u3092\u8868\u73fe\u3059\u308b\u3002<br \/>\n\u3069\u306e\u30d0\u30c3\u30d5\u30a1\u3082\u3001\u500b\u5225\u306e\u30c7\u30a3\u30b9\u30af\u30c7\u30d0\u30a4\u30b9\u4e0a\u306e\u4e00\u3064\u306e\u30bb\u30af\u30bf\u306e\u5185\u5bb9\u3092\u8868\u3059\u3002<br \/>\ndev\u30d5\u30a3\u30fc\u30eb\u30c9\u3068sector\u30d5\u30a3\u30fc\u30eb\u30c9\u306f\u3001\u305d\u308c\u305e\u308c\u30c7\u30d0\u30a4\u30b9\u756a\u53f7\u3068\u30bb\u30af\u30bf\u756a\u53f7\u3092\u8868\u3057\u3001data\u30d5\u30a3\u30fc\u30eb\u30c9\u306f\u30c7\u30a3\u30b9\u30af\u306e\u30bb\u30af\u30bf\u306e\u5185\u5bb9\u306e\u30e1\u30e2\u30ea\u4e0a\u306e\u30b3\u30d4\u30fc\u3067\u3042\u308b\u3002<\/p>\n<p>buf.h<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">struct buf {\n  int flags;\n  uint dev;\n  uint sector;\n  struct buf *prev; \/\/ LRU cache list\n  struct buf *next;\n  struct buf *qnext; \/\/ disk queue\n  uchar data&#x5B;512];\n};\n#define B_BUSY  0x1  \/\/ buffer is locked by some process\n#define B_VALID 0x2  \/\/ buffer has been read from disk\n#define B_DIRTY 0x4  \/\/ buffer needs to be written to disk<\/pre>\n<p>flags\u30d5\u30a3\u30fc\u30eb\u30c9\u306f\u3001\u30e1\u30e2\u30ea\u3068\u30c7\u30a3\u30b9\u30af\u306e\u95a2\u9023\u3092\u8ffd\u8de1\u3059\u308b\u305f\u3081\u306b\u3042\u308b\u3002<br \/>\nB_VALID\u30d5\u30e9\u30b0\u306f\u3001\u30c7\u30fc\u30bf\u304c\u8aad\u307f\u8fbc\u307e\u308c\u305f\u3053\u3068\u3092\u610f\u5473\u3057\u3001B_DIRTY\u30d5\u30e9\u30b0\u306f\u30c7\u30fc\u30bf\u3092\u30c7\u30a3\u30b9\u30af\u3078\u66f8\u304d\u3060\u3059\u5fc5\u8981\u304c\u3042\u308b\u4e8b\u3092\u610f\u5473\u3059\u308b\u3002<br \/>\nB_BUSY\u30d5\u30e9\u30b0\u306f\u30ed\u30c3\u30af\u306e\u305f\u3081\u306e\u30d5\u30e9\u30b0\u3067\u3042\u308a\u3001\u305d\u306e\u30d0\u30c3\u30d5\u30a1\u3092\u3069\u3053\u304b\u306e\u30d7\u30ed\u30bb\u30b9\u304c\u4f7f\u3063\u3066\u3044\u3066\u305d\u306e\u4ed6\u306e\u30d7\u30ed\u30bb\u30b9\u306f\u4f7f\u3046\u3079\u304d\u3067\u306f\u306a\u3044\u4e8b\u3092\u6307\u3057\u793a\u3059\u3002<br \/>\n\u30d0\u30c3\u30d5\u30a1\u306bB_BUSY\u30d5\u30e9\u30b0\u304c\u30bb\u30c3\u30c8\u3055\u308c\u305f\u3068\u304d\u3001\u6211\u3005\u306f\u300c\u305d\u306e\u30d0\u30c3\u30d5\u30a1\u306f\u30ed\u30c3\u30af\u3055\u308c\u3044\u308b\u300d\u3068\u8a00\u3046\u3002<\/p>\n<p>\u30ab\u30fc\u30cd\u30eb\u306f\u3001\u8d77\u52d5\u6642\u306bmain\u95a2\u6570\u304b\u3089ideinit\u95a2\u6570\u3092\u547c\u3076\u3053\u3068\u306b\u3088\u3063\u3066\u30c7\u30a3\u30b9\u30af\u30c9\u30e9\u30a4\u30d0\u3092\u521d\u671f\u5316\u3059\u308b\u3002<br \/>\nideinit\u95a2\u6570\u306f\u3001picenable\u95a2\u6570\u3068ioapicenable\u95a2\u6570\u3092\u547c\u3073\u3001IDE_IRQ\u5272\u308a\u8fbc\u307f\u3092\u6709\u52b9\u306b\u3059\u308b\u3002<br \/>\npicenable\u95a2\u6570\u306f\u3001\u30e6\u30cb\u30d7\u30ed\u30bb\u30c3\u30b5\u4e0a\u3067\u5272\u308a\u8fbc\u307f\u3092\u6709\u52b9\u306b\u3059\u308b\u3002<br \/>\nioapicenable\u95a2\u6570\u306f\u3001\u30de\u30eb\u30c1\u30d7\u30ed\u30bb\u30c3\u30b5\u4e0a\u3067\u5272\u308a\u8fbc\u307f\u3092\u6709\u52b9\u306b\u3059\u308b\u304c\u3001\u6700\u5f8c\u306eCPU\uff08ncpu-1\uff09\u306b\u3064\u3044\u3066\u306e\u307f\u3067\u3042\u308b\u3002<br \/>\n\u3064\u307e\u308a\u30d7\u30ed\u30bb\u30c3\u30b5\u304c2\u3064\u3042\u308b\u30b7\u30b9\u30c6\u30e0\u3067\u306f\u3001CPU 1\u304c\u30c7\u30a3\u30b9\u30af\u5272\u308a\u8fbc\u307f\u3092\u5236\u5fa1\u3059\u308b\u3002<\/p>\n<p>ide.c\u306eideinit\u95a2\u6570<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">void\nideinit(void)\n{\n  int i;\n\n  initlock(&amp;idelock, &quot;ide&quot;);\n  picenable(IRQ_IDE);\n  ioapicenable(IRQ_IDE, ncpu - 1);\n  idewait(0);\n  \n  \/\/ Check if disk 1 is present\n  outb(0x1f6, 0xe0 | (1&lt;&lt;4));\n  for(i=0; i&lt;1000; i++){\n    if(inb(0x1f7) != 0){\n      havedisk1 = 1;\n      break;\n    }\n  }\n  \n  \/\/ Switch back to disk 0.\n  outb(0x1f6, 0xe0 | (0&lt;&lt;4));\n}&amp;#91;\/sourcecode&amp;#93;\n\n\u6b21\u306b\u3001ideinit\u95a2\u6570\u306f\u3001\u30c7\u30a3\u30b9\u30af\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u3092\u63a2\u308b\u3002\n\u305d\u308c\u306fidewait\u95a2\u6570\u306e\u547c\u3073\u51fa\u3057\u306b\u3088\u308a\u306f\u3058\u307e\u308a\u3001\u30c7\u30a3\u30b9\u30af\u304c\u30b3\u30de\u30f3\u30c9\u3092\u53d7\u3051\u4ed8\u3051\u308c\u308b\u72b6\u614b\u306b\u306a\u308b\u307e\u3067\u5f85\u3064\u3002\nPC\u306e\u30de\u30b6\u30fc\u30dc\u30fc\u30c9\u306f\u3001I\/O\u30dd\u30fc\u30c80x1f7\u3067\u30c7\u30a3\u30b9\u30af\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u306e\u72b6\u614b\u30d3\u30c3\u30c8\u3092\u63d0\u4f9b\u3059\u308b\u3002\nidewait\u95a2\u6570\u306f\u3001\u30d3\u30b8\u30fc\u30d3\u30c3\u30c8\uff08IDE_BSY\uff09\u304c\u30af\u30ea\u30a2\u3055\u308c\u6e96\u5099\u5b8c\u4e86\u30d3\u30c3\u30c8\uff08IDE_DRDY\uff09\u304c\u30bb\u30c3\u30c8\u3055\u308c\u308b\u307e\u3067\u3001\u305d\u306e\u72b6\u614b\u30d3\u30c3\u30c8\u3092\u30dd\u30fc\u30ea\u30f3\u30b0\u3059\u308b\u3002\n\nide.c\u306eidewait\u95a2\u6570\n&amp;#91;sourcecode language=&quot;c&quot;&amp;#93;\/\/ Wait for IDE disk to become ready.\nstatic int\nidewait(int checkerr)\n{\n  int r;\n\n  while(((r = inb(0x1f7)) &amp; (IDE_BSY|IDE_DRDY)) != IDE_DRDY) \n    ;\n  if(checkerr &amp;&amp; (r &amp; (IDE_DF|IDE_ERR)) != 0)\n    return -1;\n  return 0;\n}&amp;#91;\/sourcecode&amp;#93;\n\n\u305d\u308c\u304c\u7d42\u308f\u308c\u3070\u3001\u30c7\u30a3\u30b9\u30af\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306f\u6e96\u5099\u5b8c\u4e86\u3068\u306a\u308a\u3001ideinit\u306f\u305d\u3053\u304b\u3089\u63d0\u4f9b\u3055\u308c\u308b\u591a\u304f\u306e\u30c7\u30a3\u30b9\u30af\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u308b\u3002\nideinit\u306f\u30c7\u30a3\u30b9\u30af0\u304c\u3042\u308b\u3068\u4eee\u5b9a\u3059\u308b\uff08\u306a\u305c\u306a\u3089\u30d6\u30fc\u30c8\u30ed\u30fc\u30c0\u3068\u30ab\u30fc\u30cd\u30eb\u306e\u4e21\u65b9\u306f\u30c7\u30a3\u30b9\u30af0\u304b\u3089\u8aad\u307f\u8fbc\u307e\u308c\u3066\u308b\u306e\u3067\uff09\u304c\u3001\u30c7\u30a3\u30b9\u30af1\u304c\u3042\u308b\u304b\u3069\u3046\u304b\u306f\u30c1\u30a7\u30c3\u30af\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002\nideinit\u306f\u3001\u30c7\u30a3\u30b9\u30af1\u3092\u9078\u629e\u3059\u308b\u305f\u3081\u306bI\/O\u30dd\u30fc\u30c80x1f6\u3078\u66f8\u304d\u8fbc\u307f\u3001\u305d\u3057\u3066\u30c7\u30a3\u30b9\u30af\u306e\u72b6\u614b\u30d3\u30c3\u30c8\u304c\u6e96\u5099\u5b8c\u4e86\u72b6\u614b\u3092\u8868\u3059\u3088\u3046\u306b\u306a\u308b\u307e\u3067\u5f85\u3064\u3002\n\u3082\u3057\u305d\u3046\u3067\u306a\u3051\u308c\u3070\u3001ideinit\u306f\u3001\u305d\u306e\u30c7\u30a3\u30b9\u30af\u306f\u306a\u3044\u3068\u3044\u3046\u4e8b\u306b\u3059\u308b\u3002\n\nideinit\u306e\u5f8c\u3001\u30d0\u30c3\u30d5\u30a1\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u304ciderw\u95a2\u6570\u3092\u547c\u3076\u307e\u3067\u3001\u30c7\u30a3\u30b9\u30af\u306f\u4f7f\u7528\u3055\u308c\u306a\u3044\u3002\niderw\u95a2\u6570\u306f\u3001\u30d5\u30e9\u30b0\u306b\u3088\u3063\u3066\u30ed\u30c3\u30af\u72b6\u614b\u3068\u306a\u3063\u3066\u3044\u308b\u30d0\u30c3\u30d5\u30a1\u3092\u66f4\u65b0\u3059\u308b\u3002\n\u3082\u3057B_DIRTY\u304c\u30bb\u30c3\u30c8\u3055\u308c\u3066\u3044\u308c\u3070\u3001iderw\u306f\u305d\u306e\u30d0\u30c3\u30d5\u30a1\u306e\u5185\u5bb9\u3092\u30c7\u30a3\u30b9\u30af\u3078\u66f8\u304d\u8fbc\u3080\u3002\n\u3082\u3057B_VALID\u304c\u30bb\u30c3\u30c8\u3055\u308c\u3066\u3044\u306a\u3051\u308c\u3070\u3001iderw\u306f\u30c7\u30a3\u30b9\u30af\u304b\u3089\u30d0\u30c3\u30d5\u30a1\u3078\u8aad\u307f\u8fbc\u3080\u3002\n\nide.c\u306eiderw\u95a2\u6570\n&amp;#91;sourcecode language=&quot;c&quot;&amp;#93;\/\/ Sync buf with disk. \n\/\/ If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID.\n\/\/ Else if B_VALID is not set, read buf from disk, set B_VALID.\nvoid\niderw(struct buf *b)\n{\n  struct buf **pp;\n\n  if(!(b-&gt;flags &amp; B_BUSY))\n    panic(&quot;iderw: buf not busy&quot;);\n  if((b-&gt;flags &amp; (B_VALID|B_DIRTY)) == B_VALID)\n    panic(&quot;iderw: nothing to do&quot;);\n  if(b-&gt;dev != 0 &amp;&amp; !havedisk1)\n    panic(&quot;iderw: ide disk 1 not present&quot;);\n\n  acquire(&amp;idelock);  \/\/ DOC:acquire-lock\n\n  \/\/ Append b to idequeue.\n  b-&gt;qnext = 0;\n  for(pp=&amp;idequeue; *pp; pp=&amp;(*pp)-&gt;qnext)  \/\/ DOC:insert-queue\n    ;\n  *pp = b;\n  \n  \/\/ Start disk if necessary.\n  if(idequeue == b)\n    idestart(b);\n  \n  \/\/ Wait for request to finish.\n  \/\/ Assuming will not sleep too long: ignore proc-&gt;killed.\n  while((b-&gt;flags &amp; (B_VALID|B_DIRTY)) != B_VALID){\n    sleep(b, &amp;idelock);\n  }\n\n  release(&amp;idelock);\n}<\/pre>\n<p>\u30c7\u30a3\u30b9\u30af\u306e\u30a2\u30af\u30bb\u30b9\u306b\u306f\u3001\u5178\u578b\u7684\u306b\u306f\u30df\u30ea\u79d2\u5358\u4f4d\u306e\u6642\u9593\u304c\u304b\u304b\u308b\u3002<br \/>\n\u305d\u308c\u306f\u30d7\u30ed\u30bb\u30c3\u30b5\u306b\u3068\u3063\u3066\u306f\u9577\u3044\u6642\u9593\u3067\u3042\u308b\u3002<br \/>\n\u30d6\u30fc\u30c8\u30ed\u30fc\u30c0\u306f\u3001\u8aad\u307f\u8fbc\u307f\u30b3\u30de\u30f3\u30c9\u3092\u30c7\u30a3\u30b9\u30af\u306b\u767a\u884c\u3057\u3001\u305d\u3057\u3066\u30c7\u30fc\u30bf\u304c\u6e96\u5099\u51fa\u6765\u308b\u307e\u3067\u72b6\u614b\u30d3\u30c3\u30c8\u3092\u7e70\u308a\u8fd4\u3057\u8aad\u3080\u3002<br \/>\n\u3053\u306e\u30dd\u30fc\u30ea\u30f3\u30b0\u3082\u3057\u304f\u306f\u30d3\u30b8\u30fc\u30a6\u30a7\u30a4\u30c8\u306f\u3001\u4ed6\u306b\u3082\u3063\u3068\u3044\u3044\u65b9\u6cd5\u3092\u6301\u305f\u306a\u3044\u30d6\u30fc\u30c8\u30ed\u30fc\u30c0\u3067\u306f\u4ed5\u65b9\u304c\u306a\u3044\u3002<br \/>\n\u4e00\u65b9OS\u8d77\u52d5\u5f8c\u3067\u306f\u3001\u5225\u306e\u30d7\u30ed\u30bb\u30b9\u3092\u5b9f\u884c\u3057\u3001\u305d\u306e\u30d7\u30ed\u30bb\u30b9\u3067\u30c7\u30a3\u30b9\u30af\u64cd\u4f5c\u304c\u5b8c\u4e86\u3057\u305f\u3068\u304d\u306b\u5272\u308a\u8fbc\u307f\u3092\u53d7\u3051\u3066\u5236\u5fa1\u3059\u308b\u3068\u3044\u3046\u3001\u3088\u308a\u52b9\u7387\u7684\u306a\u65b9\u6cd5\u304c\u4f7f\u3048\u308b\u3002<br \/>\niderw\u306f\u5f8c\u8005\u306e\u624b\u6cd5\u3092\u63a1\u7528\u3057\u3066\u3044\u3066\u3001\u30ad\u30e5\u30fc\u3067\u672a\u5b9f\u884c\u306e\u30c7\u30a3\u30b9\u30af\u3078\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30ea\u30b9\u30c8\u3092\u4fdd\u6301\u3057\u3001\u5404\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u7d42\u308f\u3063\u305f\u3068\u304d\u306b\u3001\u305d\u308c\u3092\u63a2\u3059\u305f\u3081\u306b\u5272\u308a\u8fbc\u307f\u3092\u4f7f\u3046\u3002<br \/>\niderw\u304c\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30ad\u30e5\u30fc\u3092\u7ba1\u7406\u3059\u308b\u3068\u306f\u3044\u3048\u3001\u30b7\u30f3\u30d7\u30eb\u306aIDE\u30c7\u30a3\u30b9\u30af\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306f\u3001\u4e00\u5ea6\u306b\u4e00\u3064\u306e\u64cd\u4f5c\u3057\u304b\u5236\u5fa1\u3067\u304d\u306a\u3044\u3002<br \/>\n\u30c7\u30a3\u30b9\u30af\u30c9\u30e9\u30a4\u30d0\u306f\u3001\u30c7\u30a3\u30b9\u30af\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u3078\u30ad\u30e5\u30fc\u306e\u4e00\u756a\u524d\u306b\u3042\u308b\u30d0\u30c3\u30d5\u30a1\u3092\u9001\u308b\u3068\u3044\u3046\u4e00\u5b9a\u306e\u4ed5\u4e8b\u3092\u7ba1\u7406\u3059\u308b\u3002<br \/>\n\u4ed6\u306f\u3001\u30c7\u30a3\u30b9\u30af\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u306e\u4ed5\u4e8b\u3092\u5358\u7d14\u306b\u5f85\u3064\u3060\u3051\u3067\u3042\u308b\u3002<\/p>\n<p>iderw\u306f\u3001\u30ad\u30e5\u30fc\u306e\u6700\u5f8c\u306b\u30d0\u30c3\u30d5\u30a1b\u3092\u8ffd\u52a0\u3059\u308b\u3002\uff08Append b to idequeue.\u3068\u30b3\u30e1\u30f3\u30c8\u304c\u4ed8\u3044\u3066\u308b\u90e8\u5206\uff09<br \/>\n\u3082\u3057\u305d\u306e\u30d0\u30c3\u30d5\u30a1\u304c\u30ad\u30e5\u30fc\u306e\u4e00\u756a\u524d\u306a\u3089\u3001iderw\u306fidestart\u95a2\u6570\u3092\u4f7f\u3063\u3066\u30c7\u30a3\u30b9\u30af\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u3078\u305d\u308c\u3092\u9001\u4fe1\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002<br \/>\n\u305d\u3046\u3058\u3083\u306a\u3051\u308c\u3070\u3001\u30d0\u30c3\u30d5\u30a1\u306f\u4e00\u5ea6\u958b\u59cb\u3055\u308c\u3001\u305d\u306e\u524d\u306b\u3042\u308b\u30d0\u30c3\u30d5\u30a1\u306b\u3088\u3063\u3066\u51e6\u7406\u3055\u308c\u308b\u3002<br \/>\n\uff08\u3053\u3053\u6587\u7ae0\u304c\u5206\u304b\u308a\u3065\u3089\u3044\u3051\u3069\u3001\u7279\u5b9a\u306e\u30d0\u30c3\u30d5\u30a1\u306b\u95a2\u3059\u308b\u30c7\u30a3\u30b9\u30af\u64cd\u4f5c\u304c\u5b8c\u4e86\u3057\u305f\u3068\u304d\u306b\u5b9f\u884c\u3055\u308c\u308bideintr\uff08\u5f8c\u3067\u8aac\u660e\uff09\u5185\u3067\u3001\u30ad\u30e5\u30fc\u304c\u7a7a\u3058\u3083\u306a\u3051\u308c\u3070\u7d9a\u3051\u3066\u305d\u306e\u5f8c\u306e\u30d0\u30c3\u30d5\u30a1\u3092\u51e6\u7406\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u307f\u305f\u3044\u3002\uff09<\/p>\n<p>ide.c\u306eidestart\u95a2\u6570<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/ Start the request for b.  Caller must hold idelock.\nstatic void\nidestart(struct buf *b)\n{\n  if(b == 0)\n    panic(&quot;idestart&quot;);\n\n  idewait(0);\n  outb(0x3f6, 0);  \/\/ generate interrupt\n  outb(0x1f2, 1);  \/\/ number of sectors\n  outb(0x1f3, b-&gt;sector &amp; 0xff);\n  outb(0x1f4, (b-&gt;sector &gt;&gt; 8) &amp; 0xff);\n  outb(0x1f5, (b-&gt;sector &gt;&gt; 16) &amp; 0xff);\n  outb(0x1f6, 0xe0 | ((b-&gt;dev&amp;1)&lt;&lt;4) | ((b-&gt;sector&gt;&gt;24)&amp;0x0f));\n  if(b-&gt;flags &amp; B_DIRTY){\n    outb(0x1f7, IDE_CMD_WRITE);\n    outsl(0x1f0, b-&gt;data, 512\/4);\n  } else {\n    outb(0x1f7, IDE_CMD_READ);\n  }\n}<\/pre>\n<p>idestart\u95a2\u6570\u306f\u3001\u30d0\u30c3\u30d5\u30a1\u306e\u30c7\u30d0\u30a4\u30b9\u3068\u30bb\u30af\u30bf\u306e\u305f\u3081\u306e\u8aad\u307f\u8fbc\u307f\u30fb\u66f8\u304d\u8fbc\u307f\u3069\u3061\u3089\u3082\u767a\u884c\u3059\u308b\u3002<br \/>\n\u8aad\u307f\u8fbc\u307f\u304b\u66f8\u304d\u8fbc\u307f\u304b\u306f\u30d5\u30e9\u30b0\u3067\u898b\u5206\u3051\u308b\u3002<br \/>\n\u3082\u3057\u64cd\u4f5c\u304c\u66f8\u304d\u8fbc\u307f\u306a\u3089\u3001idestart\u306f\u3053\u306e\u6642\u70b9\u3067\u30c7\u30fc\u30bf\u3092\u4f9b\u7d66\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u305a\uff08outsl(0x1f0, b->data, 512\/4); \u306e\u3068\u3053\u308d\uff09\u3001\u305d\u3057\u3066\u5272\u308a\u8fbc\u307f\u306f\u30c7\u30fc\u30bf\u304c\u30c7\u30a3\u30b9\u30af\u306b\u66f8\u304d\u8fbc\u307e\u308c\u305f\u3053\u3068\u3092\u793a\u3059\u3002<br \/>\n\u3082\u3057\u64cd\u4f5c\u304c\u8aad\u307f\u8fbc\u307f\u306a\u3089\u3001\u5272\u308a\u8fbc\u307f\u306f\u30c7\u30fc\u30bf\u304c\u6e96\u5099\u5b8c\u4e86\u3067\u3042\u308b\u3053\u3068\u3092\u793a\u3057\u3001\u305d\u3057\u3066\u5272\u308a\u8fbc\u307f\u30cf\u30f3\u30c9\u30e9\u306f\u305d\u308c\u3092\u8aad\u307f\u8fbc\u3080\u3002<br \/>\niderw\u306fIDE\u30c7\u30d0\u30a4\u30b9\u306b\u3064\u3044\u3066\u306e\u8a73\u7d30\u306a\u77e5\u8b58\u3092\u6301\u3061\u3001\u6b63\u3057\u3044\u30dd\u30fc\u30c8\u306b\u6b63\u3057\u3044\u5024\u3092\u66f8\u304d\u8fbc\u3080\u3053\u3068\u306b\u6ce8\u610f\u3002<br \/>\n\u3082\u3057\u3001\u4e00\u9023\u306eoutb\u547d\u4ee4\u306b\u9593\u9055\u3044\u304c\u3042\u3063\u305f\u3089\u3001IDE\u306f\u6211\u3005\u304c\u3084\u3063\u3066\u6b32\u3057\u3044\u3053\u3068\u3068\u306f\u9055\u3046\u4f55\u304b\u3092\u884c\u3046\u3060\u308d\u3046\u3002<br \/>\n\u305d\u308c\u3089\u306e\u8a73\u7d30\u3092\u6b63\u3057\u304f\u77e5\u308b\u3053\u3068\u306f\u3001\u30c7\u30d0\u30a4\u30b9\u30c9\u30e9\u30a4\u30d0\u3092\u66f8\u304f\u3053\u3068\u304c\u306a\u305c\u30c1\u30e3\u30ec\u30f3\u30b8\u30f3\u30b0\u3067\u3042\u308b\u304b\u306e\u4e00\u3064\u306e\u7406\u7531\u3067\u3042\u308b\u3002<\/p>\n<p>\u30ad\u30e5\u30fc\u3078\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u8ffd\u52a0\u3057\u305f\u3089\u3001\u3082\u3057\u5fc5\u8981\u306a\u3089\u305d\u306e\u30ad\u30e5\u30fc\u306f\u958b\u59cb\u3055\u308c\u308b\u3002<br \/>\n\u305d\u3057\u3066iderw\u306f\u7d50\u679c\u3092\u5f85\u3064\u3002<br \/>\n\u4e0a\u3067\u8aac\u660e\u3057\u305f\u3088\u3046\u306b\u3001\u30dd\u30fc\u30ea\u30f3\u30b0\u306fCPU\u306e\u4f7f\u3044\u65b9\u3068\u3057\u3066\u306f\u975e\u52b9\u7387\u3067\u3042\u308b\u3002<br \/>\n\u305d\u306e\u4ee3\u308f\u308a\u3001iderw\u306f\u3001\u64cd\u4f5c\u306e\u5b8c\u4e86\u3092\u793a\u3059\u30d5\u30e9\u30b0\u304c\u5272\u308a\u8fbc\u307f\u30cf\u30f3\u30c9\u30e9\u306b\u3088\u3063\u3066\u30d0\u30c3\u30d5\u30a1\u306b\u8a18\u9332\u3055\u308c\u308b\u307e\u3067\u3001sleep\u95a2\u6570\u3067\u5f85\u3064\u3002<br \/>\n\u3053\u306e\u30d7\u30ed\u30bb\u30b9\u304c\u30b9\u30ea\u30fc\u30d7\u3057\u3066\u308b\u9593\u3001xv6\u306fCPU\u306b\u4ed5\u4e8b\u3092\u3055\u305b\u308b\u305f\u3081\u306b\u4ed6\u306e\u30d7\u30ed\u30bb\u30b9\u3092\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u3059\u308b\u3060\u308d\u3046\u3002<\/p>\n<p>\u6700\u7d42\u7684\u306b\u3001\u30c7\u30a3\u30b9\u30af\u306f\u64cd\u4f5c\u3092\u5b8c\u4e86\u3057\u5272\u308a\u8fbc\u307f\u3092\u767a\u751f\u3055\u305b\u308b\u3002<br \/>\ntrap\u95a2\u6570\u306f\u3001\u305d\u306e\u5272\u308a\u8fbc\u307f\u3092\u5236\u5fa1\u3055\u305b\u308b\u305f\u3081\u306bideintr\u95a2\u6570\u3092\u547c\u3076\u3002<br \/>\nideintr\u95a2\u6570\u306f\u3001\u3069\u306e\u64cd\u4f5c\u304c\u8d77\u304d\u305f\u306e\u304b\u77e5\u308b\u305f\u3081\u306b\u30ad\u30e5\u30fc\u306e\u6700\u521d\u306e\u30d0\u30c3\u30d5\u30a1\u3092\u8abf\u3079\u308b\u3002<br \/>\n\u3082\u3057\u3001\u30d0\u30c3\u30d5\u30a1\u304c\u8aad\u307f\u5b8c\u4e86\u3067\u30c7\u30a3\u30b9\u30af\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u304c\u30c7\u30fc\u30bf\u3092\u6e96\u5099\u3057\u3066\u5f85\u3063\u3066\u308b\u306a\u3089\u3001ideintr\u306f\u3001insl\u3092\u4f7f\u3063\u3066\u30d0\u30c3\u30d5\u30a1\u3078\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3080\u3002<br \/>\nideintr\u306f\u3001B_VALID\u3092\u30bb\u30c3\u30c8\u3057\u3001B_DIRTY\u3092\u30af\u30ea\u30a2\u3057\u3001\u30d0\u30c3\u30d5\u30a1\u4e0a\u3067\u5bdd\u3066\u3044\u308b\u3069\u3053\u304b\u306e\u30d7\u30ed\u30bb\u30b9\u3092\u8d77\u3053\u3059\u3002<br \/>\n\uff08Wake process waiting for this buf\u306e\u30b3\u30e1\u30f3\u30c8\u306e\u90e8\u5206\uff09<br \/>\n\u3053\u308c\u3067\u30d0\u30c3\u30d5\u30a1\u304c\u6e96\u5099\u51fa\u6765\u305f\u3053\u3068\u306b\u306a\u308b\u3002<br \/>\n\u6700\u5f8c\u306bideintr\u306f\u3001\u6b21\u306b\u5f85\u3063\u3066\u308b\u30d0\u30c3\u30d5\u30a1\u3092\u30c7\u30a3\u30b9\u30af\u3078\u9001\u3089\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002<\/p>\n<p>trap.c\u306etrap\u95a2\u6570\u306e\u30c7\u30a3\u30b9\u30af\u5272\u308a\u8fbc\u307f\u306e\u51e6\u7406\u306e\u90e8\u5206<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">  case T_IRQ0 + IRQ_IDE:\n    ideintr();\n    lapiceoi();\n    break;<\/pre>\n<p>ide.c\u306eideintr\u95a2\u6570<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/ Interrupt handler.\nvoid\nideintr(void)\n{\n  struct buf *b;\n\n  \/\/ Take first buffer off queue.\n  acquire(&amp;idelock);\n  if((b = idequeue) == 0){\n    release(&amp;idelock);\n    \/\/ cprintf(&quot;spurious IDE interrupt\\n&quot;);\n    return;\n  }\n  idequeue = b-&gt;qnext;\n\n  \/\/ Read data if needed.\n  if(!(b-&gt;flags &amp; B_DIRTY) &amp;&amp; idewait(1) &gt;= 0)\n    insl(0x1f0, b-&gt;data, 512\/4);\n  \n  \/\/ Wake process waiting for this buf.\n  b-&gt;flags |= B_VALID;\n  b-&gt;flags &amp;= ~B_DIRTY;\n  wakeup(b);\n  \n  \/\/ Start disk on next buf in queue.\n  if(idequeue != 0)\n    idestart(idequeue);\n\n  release(&amp;idelock);\n}<\/pre>\n<h3>\u611f\u60f3<\/h3>\n<p>\u30c7\u30a3\u30b9\u30af\u30c9\u30e9\u30a4\u30d0\u306e\u5b9f\u88c5\u3067\u3059\u3002<\/p>\n<p>\u30ad\u30e5\u30fc\u304c\u7a7a\u306e\u3068\u304d\u306b\u8ffd\u52a0\u3055\u308c\u305f\u5834\u5408\u3057\u304bidestart\u3057\u306a\u3044\u3068\u8aac\u660e\u304c\u3042\u3063\u3066\uff08\u30b3\u30fc\u30c9\u3082\u305d\u3046\u306a\u3063\u3066\u308b\uff09\u3001\u30ad\u30e5\u30fc\u304c\u7a7a\u3058\u3083\u306a\u3044\u3068\u304d\u306b\u8ffd\u52a0\u3055\u308c\u305f\u30ea\u30af\u30a8\u30b9\u30c8\u306f\u3069\u3046\u306a\u308b\u306e\u3088\u3001\u3068\u6700\u521d\u6df7\u4e71\u3057\u307e\u3057\u305f\u304c\u3001\u5272\u308a\u8fbc\u307f\u30cf\u30f3\u30c9\u30e9\u5074\u3067\u828b\u3065\u308b\u5f0f\u306b\u30ad\u30e5\u30fc\u3092\u6b21\u3005\u3068\u51e6\u7406\u3057\u3066\u3044\u304f\uff081\u30d0\u30c3\u30d5\u30a1\u3054\u3068\u306b\u5272\u308a\u8fbc\u307f\u304c\u767a\u751f\uff09\u3088\u3046\u306b\u306a\u3063\u3066\u3066\u7d0d\u5f97\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u5b9f\u969b\u306eOS\u3067\u306f\u3001\u30ad\u30e5\u30fc\u3092\u9ad8\u6a5f\u80fd\u5316\u3057\u3066\u3001\u4f8b\u3048\u3070\u51fa\u6765\u308b\u3060\u3051\u30bb\u30af\u30bf\u304c\u9023\u7d9a\u3059\u308b\u3088\u3046\u306b\u30d0\u30c3\u30d5\u30a1\u3092\u4e26\u3073\u304b\u3048\u305f\u308a\u3001\u96fb\u6e90\u306e\u30d6\u30c1\u5207\u308a\u3067\u306a\u308b\u3079\u304f\u30c7\u30fc\u30bf\u304c\u5931\u308f\u308c\u306a\u3044\u3088\u3046\u306a\u5de5\u592b\u304c\u3042\u3063\u305f\u308a\u3059\u308b\u3093\u3058\u3083\u306a\u304b\u308d\u3046\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30c6\u30ad\u30b9\u30c8\u306e39\u301c41\u30da\u30fc\u30b8<\/p>\n<h3>\u672c\u6587<\/h3>\n<p>IDE\u30c7\u30d0\u30a4\u30b9\u306f\u3001PC\u306e\u6a19\u6e96IDE\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306b\u63a5\u7d9a\u3055\u308c\u305f\u30c7\u30a3\u30b9\u30af\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092\u63d0\u4f9b\u3059\u308b\u3002<br \/>\nIDE\u306f\u3001\u4eca\u3068\u306a\u3063\u3066\u306fSCSI\u3084SATA\u306e\u3088\u3046\u306a\u6d41\u884c\u304b\u3089\u306f\u5916\u308c\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u304c\u3001\u305d\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u306f\u5358\u7d14\u3067\u3001\u500b\u5225\u306e\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u306e\u8a73\u7d30\u306b\u7acb\u3061\u5165\u308b\u5fc5\u8981\u306a\u304f\u30c9\u30e9\u30a4\u30d0\u5168\u4f53\u306e\u69cb\u7bc9\u306b\u96c6\u4e2d\u3055\u305b\u3066\u304f\u308c\u308b\u3002<\/p>\n<p>\u30c7\u30a3\u30b9\u30af\u30c9\u30e9\u30a4\u30d0\u306f\u3001\u30d0\u30c3\u30d5\u30a1\u3068\u547c\u3070\u308c\u308b\u30c7\u30fc\u30bf\u306e\u69cb\u9020\u4f53\uff08buf\u69cb\u9020\u4f53\uff09\u3068\u3057\u3066\u30c7\u30a3\u30b9\u30af\u306e\u30bb\u30af\u30bf\u3092\u8868\u73fe\u3059\u308b\u3002<br \/>\n\u3069\u306e\u30d0\u30c3\u30d5\u30a1\u3082\u3001\u500b\u5225\u306e\u30c7\u30a3\u30b9\u30af\u30c7\u30d0\u30a4\u30b9\u4e0a\u306e\u4e00\u3064\u306e\u30bb\u30af\u30bf\u306e\u5185\u5bb9\u3092\u8868\u3059\u3002<br \/>\ndev\u30d5\u30a3\u30fc\u30eb\u30c9\u3068sector\u30d5\u30a3\u30fc\u30eb\u30c9\u306f\u3001\u305d\u308c\u305e\u308c\u30c7\u30d0\u30a4\u30b9\u756a\u53f7\u3068\u30bb\u30af\u30bf\u756a\u53f7\u3092\u8868\u3057\u3001data\u30d5\u30a3\u30fc\u30eb\u30c9\u306f\u30c7\u30a3\u30b9\u30af\u306e\u30bb\u30af\u30bf\u306e\u5185\u5bb9\u306e\u30e1\u30e2\u30ea\u4e0a\u306e\u30b3\u30d4\u30fc\u3067\u3042\u308b\u3002<\/p>\n<p>buf.h<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">struct buf {\n  int flags;\n  uint dev;\n  uint sector;\n  struct buf *prev; \/\/ LRU cache list\n  struct buf *next;\n  struct buf *qnext; \/\/ disk queue\n  uchar data&#x5B;512];\n};\n#define B_BUSY  0x1  \/\/ buffer is locked by some process\n#define B_VALID 0x2  \/\/ buffer has been read from disk\n#define B_DIRTY 0x4  \/\/ buffer needs to be written to disk<\/pre>\n<p>flags\u30d5\u30a3\u30fc\u30eb\u30c9\u306f\u3001\u30e1\u30e2\u30ea\u3068\u30c7\u30a3\u30b9\u30af\u306e\u95a2\u9023\u3092\u8ffd\u8de1\u3059\u308b\u305f\u3081\u306b\u3042\u308b\u3002<br \/>\nB_VALID\u30d5\u30e9\u30b0\u306f\u3001\u30c7\u30fc\u30bf\u304c\u8aad\u307f\u8fbc\u307e\u308c\u305f\u3053\u3068\u3092\u610f\u5473\u3057\u3001B_DIRTY\u30d5\u30e9\u30b0\u306f\u30c7\u30fc\u30bf\u3092\u30c7\u30a3\u30b9\u30af\u3078\u66f8\u304d\u3060\u3059\u5fc5\u8981\u304c\u3042\u308b\u4e8b\u3092\u610f\u5473\u3059\u308b\u3002<br \/>\nB_BUSY\u30d5\u30e9\u30b0\u306f\u30ed\u30c3\u30af\u306e\u305f\u3081\u306e\u30d5\u30e9\u30b0\u3067\u3042\u308a\u3001\u305d\u306e\u30d0\u30c3\u30d5\u30a1\u3092\u3069\u3053\u304b\u306e\u30d7\u30ed\u30bb\u30b9\u304c\u4f7f\u3063\u3066\u3044\u3066\u305d\u306e\u4ed6\u306e\u30d7\u30ed\u30bb\u30b9\u306f\u4f7f\u3046\u3079\u304d\u3067\u306f\u306a\u3044\u4e8b\u3092\u6307\u3057\u793a\u3059\u3002<br \/>\n\u30d0\u30c3\u30d5\u30a1\u306bB_BUSY\u30d5\u30e9\u30b0\u304c\u30bb\u30c3\u30c8\u3055\u308c\u305f\u3068\u304d\u3001\u6211\u3005\u306f\u300c\u305d\u306e\u30d0\u30c3\u30d5\u30a1\u306f\u30ed\u30c3\u30af\u3055\u308c\u3044\u308b\u300d\u3068\u8a00\u3046\u3002<\/p>\n<p>\u30ab\u30fc\u30cd\u30eb\u306f\u3001\u8d77\u52d5\u6642\u306bmain\u95a2\u6570\u304b\u3089ideinit\u95a2\u6570\u3092\u547c\u3076\u3053\u3068\u306b\u3088\u3063\u3066\u30c7\u30a3\u30b9\u30af\u30c9\u30e9\u30a4\u30d0\u3092\u521d\u671f\u5316\u3059\u308b\u3002<br \/>\nideinit\u95a2\u6570\u306f\u3001picenable\u95a2\u6570\u3068ioapicenable\u95a2\u6570\u3092\u547c\u3073\u3001IDE_IRQ\u5272\u308a\u8fbc\u307f\u3092\u6709\u52b9\u306b\u3059\u308b\u3002<br \/>\npicenable\u95a2\u6570\u306f\u3001\u30e6\u30cb\u30d7\u30ed\u30bb\u30c3\u30b5\u4e0a\u3067\u5272\u308a\u8fbc\u307f\u3092\u6709\u52b9\u306b\u3059\u308b\u3002<br \/>\nioapicenable\u95a2\u6570\u306f\u3001\u30de\u30eb\u30c1\u30d7\u30ed\u30bb\u30c3\u30b5\u4e0a\u3067\u5272\u308a\u8fbc\u307f\u3092\u6709\u52b9\u306b\u3059\u308b\u304c\u3001\u6700\u5f8c\u306eCPU\uff08ncpu-1\uff09\u306b\u3064\u3044\u3066\u306e\u307f\u3067\u3042\u308b\u3002<br \/>\n\u3064\u307e\u308a\u30d7\u30ed\u30bb\u30c3\u30b5\u304c2\u3064\u3042\u308b\u30b7\u30b9\u30c6\u30e0\u3067\u306f\u3001CPU 1\u304c\u30c7\u30a3\u30b9\u30af\u5272\u308a\u8fbc\u307f\u3092\u5236\u5fa1\u3059\u308b\u3002<\/p>\n<p>ide.c\u306eideinit\u95a2\u6570<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">void\nideinit(void)\n{\n  int i;\n\n  initlock(&amp;idelock, &quot;ide&quot;);\n  picenable(IRQ_IDE);\n  ioapicenable(IRQ_IDE, ncpu - 1);\n  idewait(0);\n  \n  \/\/ Check if disk 1 is present\n  outb(0x1f6, 0xe0 | (1&lt;&lt;4));\n  for(i=0; i&lt;1000; i++){\n    if(inb(0x1f7) != 0){\n      havedisk1 = 1;\n      break;\n    }\n  }\n  \n  \/\/ Switch back to disk 0.\n  outb(0x1f6, 0xe0 | (0&lt;&lt;4));\n}&amp;#91;\/sourcecode&amp;#93;\n\n\u6b21\u306b\u3001ideinit\u95a2\u6570\u306f\u3001\u30c7\u30a3\u30b9\u30af\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u3092\u63a2\u308b\u3002\n\u305d\u308c\u306fidewait\u95a2\u6570\u306e\u547c\u3073\u51fa\u3057\u306b\u3088\u308a\u306f\u3058\u307e\u308a\u3001\u30c7\u30a3\u30b9\u30af\u304c\u30b3\u30de\u30f3\u30c9\u3092\u53d7\u3051\u4ed8\u3051\u308c\u308b\u72b6\u614b\u306b\u306a\u308b\u307e\u3067\u5f85\u3064\u3002\nPC\u306e\u30de\u30b6\u30fc\u30dc\u30fc\u30c9\u306f\u3001I\/O\u30dd\u30fc\u30c80x1f7\u3067\u30c7\u30a3\u30b9\u30af\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u306e\u72b6\u614b\u30d3\u30c3\u30c8\u3092\u63d0\u4f9b\u3059\u308b\u3002\nidewait\u95a2\u6570\u306f\u3001\u30d3\u30b8\u30fc\u30d3\u30c3\u30c8\uff08IDE_BSY\uff09\u304c\u30af\u30ea\u30a2\u3055\u308c\u6e96\u5099\u5b8c\u4e86\u30d3\u30c3\u30c8\uff08IDE_DRDY\uff09\u304c\u30bb\u30c3\u30c8\u3055\u308c\u308b\u307e\u3067\u3001\u305d\u306e\u72b6\u614b\u30d3\u30c3\u30c8\u3092\u30dd\u30fc\u30ea\u30f3\u30b0\u3059\u308b\u3002\n\nide.c\u306eidewait\u95a2\u6570\n&amp;#91;sourcecode language=&quot;c&quot;&amp;#93;\/\/ Wait for IDE disk to become ready.\nstatic int\nidewait(int checkerr)\n{\n  int r;\n\n  while(((r = inb(0x1f7)) &amp; (IDE_BSY|IDE_DRDY)) != IDE_DRDY) \n    ;\n  if(checkerr &amp;&amp; (r &amp; (IDE_DF|IDE_ERR)) != 0)\n    return -1;\n  return 0;\n}&amp;#91;\/sourcecode&amp;#93;\n\n\u305d\u308c\u304c\u7d42\u308f\u308c\u3070\u3001\u30c7\u30a3\u30b9\u30af\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306f\u6e96\u5099\u5b8c\u4e86\u3068\u306a\u308a\u3001ideinit\u306f\u305d\u3053\u304b\u3089\u63d0\u4f9b\u3055\u308c\u308b\u591a\u304f\u306e\u30c7\u30a3\u30b9\u30af\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u308b\u3002\nideinit\u306f\u30c7\u30a3\u30b9\u30af0\u304c\u3042\u308b\u3068\u4eee\u5b9a\u3059\u308b\uff08\u306a\u305c\u306a\u3089\u30d6\u30fc\u30c8\u30ed\u30fc\u30c0\u3068\u30ab\u30fc\u30cd\u30eb\u306e\u4e21\u65b9\u306f\u30c7\u30a3\u30b9\u30af0\u304b\u3089\u8aad\u307f\u8fbc\u307e\u308c\u3066\u308b\u306e\u3067\uff09\u304c\u3001\u30c7\u30a3\u30b9\u30af1\u304c\u3042\u308b\u304b\u3069\u3046\u304b\u306f\u30c1\u30a7\u30c3\u30af\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002\nideinit\u306f\u3001\u30c7\u30a3\u30b9\u30af1\u3092\u9078\u629e\u3059\u308b\u305f\u3081\u306bI\/O\u30dd\u30fc\u30c80x1f6\u3078\u66f8\u304d\u8fbc\u307f\u3001\u305d\u3057\u3066\u30c7\u30a3\u30b9\u30af\u306e\u72b6\u614b\u30d3\u30c3\u30c8\u304c\u6e96\u5099\u5b8c\u4e86\u72b6\u614b\u3092\u8868\u3059\u3088\u3046\u306b\u306a\u308b\u307e\u3067\u5f85\u3064\u3002\n\u3082\u3057\u305d\u3046\u3067\u306a\u3051\u308c\u3070\u3001ideinit\u306f\u3001\u305d\u306e\u30c7\u30a3\u30b9\u30af\u306f\u306a\u3044\u3068\u3044\u3046\u4e8b\u306b\u3059\u308b\u3002\n\nideinit\u306e\u5f8c\u3001\u30d0\u30c3\u30d5\u30a1\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u304ciderw\u95a2\u6570\u3092\u547c\u3076\u307e\u3067\u3001\u30c7\u30a3\u30b9\u30af\u306f\u4f7f\u7528\u3055\u308c\u306a\u3044\u3002\niderw\u95a2\u6570\u306f\u3001\u30d5\u30e9\u30b0\u306b\u3088\u3063\u3066\u30ed\u30c3\u30af\u72b6\u614b\u3068\u306a\u3063\u3066\u3044\u308b\u30d0\u30c3\u30d5\u30a1\u3092\u66f4\u65b0\u3059\u308b\u3002\n\u3082\u3057B_DIRTY\u304c\u30bb\u30c3\u30c8\u3055\u308c\u3066\u3044\u308c\u3070\u3001iderw\u306f\u305d\u306e\u30d0\u30c3\u30d5\u30a1\u306e\u5185\u5bb9\u3092\u30c7\u30a3\u30b9\u30af\u3078\u66f8\u304d\u8fbc\u3080\u3002\n\u3082\u3057B_VALID\u304c\u30bb\u30c3\u30c8\u3055\u308c\u3066\u3044\u306a\u3051\u308c\u3070\u3001iderw\u306f\u30c7\u30a3\u30b9\u30af\u304b\u3089\u30d0\u30c3\u30d5\u30a1\u3078\u8aad\u307f\u8fbc\u3080\u3002\n\nide.c\u306eiderw\u95a2\u6570\n&amp;#91;sourcecode language=&quot;c&quot;&amp;#93;\/\/ Sync buf with disk. \n\/\/ If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID.\n\/\/ Else if B_VALID is not set, read buf from disk, set B_VALID.\nvoid\niderw(struct buf *b)\n{\n  struct buf **pp;\n\n  if(!(b-&gt;flags &amp; B_BUSY))\n    panic(&quot;iderw: buf not busy&quot;);\n  if((b-&gt;flags &amp; (B_VALID|B_DIRTY)) == B_VALID)\n    panic(&quot;iderw: nothing to do&quot;);\n  if(b-&gt;dev != 0 &amp;&amp; !havedisk1)\n    panic(&quot;iderw: ide disk 1 not present&quot;);\n\n  acquire(&amp;idelock);  \/\/ DOC:acquire-lock\n\n  \/\/ Append b to idequeue.\n  b-&gt;qnext = 0;\n  for(pp=&amp;idequeue; *pp; pp=&amp;(*pp)-&gt;qnext)  \/\/ DOC:insert-queue\n    ;\n  *pp = b;\n  \n  \/\/ Start disk if necessary.\n  if(idequeue == b)\n    idestart(b);\n  \n  \/\/ Wait for request to finish.\n  \/\/ Assuming will not sleep too long: ignore proc-&gt;killed.\n  while((b-&gt;flags &amp; (B_VALID|B_DIRTY)) != B_VALID){\n    sleep(b, &amp;idelock);\n  }\n\n  release(&amp;idelock);\n}<\/pre>\n<p>\u30c7\u30a3\u30b9\u30af\u306e\u30a2\u30af\u30bb\u30b9\u306b\u306f\u3001\u5178\u578b\u7684\u306b\u306f\u30df\u30ea\u79d2\u5358\u4f4d\u306e\u6642\u9593\u304c\u304b\u304b\u308b\u3002<br \/>\n\u305d\u308c\u306f\u30d7\u30ed\u30bb\u30c3\u30b5\u306b\u3068\u3063\u3066\u306f\u9577\u3044\u6642\u9593\u3067\u3042\u308b\u3002<br \/>\n\u30d6\u30fc\u30c8\u30ed\u30fc\u30c0\u306f\u3001\u8aad\u307f\u8fbc\u307f\u30b3\u30de\u30f3\u30c9\u3092\u30c7\u30a3\u30b9\u30af\u306b\u767a\u884c\u3057\u3001\u305d\u3057\u3066\u30c7\u30fc\u30bf\u304c\u6e96\u5099\u51fa\u6765\u308b\u307e\u3067\u72b6\u614b\u30d3\u30c3\u30c8\u3092\u7e70\u308a\u8fd4\u3057\u8aad\u3080\u3002<br \/>\n\u3053\u306e\u30dd\u30fc\u30ea\u30f3\u30b0\u3082\u3057\u304f\u306f\u30d3\u30b8\u30fc\u30a6\u30a7\u30a4\u30c8\u306f\u3001\u4ed6\u306b\u3082\u3063\u3068\u3044\u3044\u65b9\u6cd5\u3092\u6301\u305f\u306a\u3044\u30d6\u30fc\u30c8\u30ed\u30fc\u30c0\u3067\u306f\u4ed5\u65b9\u304c\u306a\u3044\u3002<br \/>\n\u4e00\u65b9OS\u8d77\u52d5\u5f8c\u3067\u306f\u3001\u5225\u306e\u30d7\u30ed\u30bb\u30b9\u3092\u5b9f\u884c\u3057\u3001\u305d\u306e\u30d7\u30ed\u30bb\u30b9\u3067\u30c7\u30a3\u30b9\u30af\u64cd\u4f5c\u304c\u5b8c\u4e86\u3057\u305f\u3068\u304d\u306b\u5272\u308a\u8fbc\u307f\u3092\u53d7\u3051\u3066\u5236\u5fa1\u3059\u308b\u3068\u3044\u3046\u3001\u3088\u308a\u52b9\u7387\u7684\u306a\u65b9\u6cd5\u304c\u4f7f\u3048\u308b\u3002<br \/>\niderw\u306f\u5f8c\u8005\u306e\u624b\u6cd5\u3092\u63a1\u7528\u3057\u3066\u3044\u3066\u3001\u30ad\u30e5\u30fc\u3067\u672a\u5b9f\u884c\u306e\u30c7\u30a3\u30b9\u30af\u3078\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30ea\u30b9\u30c8\u3092\u4fdd\u6301\u3057\u3001\u5404\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u7d42\u308f\u3063\u305f\u3068\u304d\u306b\u3001\u305d\u308c\u3092\u63a2\u3059\u305f\u3081\u306b\u5272\u308a\u8fbc\u307f\u3092\u4f7f\u3046\u3002<br \/>\niderw\u304c\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30ad\u30e5\u30fc\u3092\u7ba1\u7406\u3059\u308b\u3068\u306f\u3044\u3048\u3001\u30b7\u30f3\u30d7\u30eb\u306aIDE\u30c7\u30a3\u30b9\u30af\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306f\u3001\u4e00\u5ea6\u306b\u4e00\u3064\u306e\u64cd\u4f5c\u3057\u304b\u5236\u5fa1\u3067\u304d\u306a\u3044\u3002<br \/>\n\u30c7\u30a3\u30b9\u30af\u30c9\u30e9\u30a4\u30d0\u306f\u3001\u30c7\u30a3\u30b9\u30af\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u3078\u30ad\u30e5\u30fc\u306e\u4e00\u756a\u524d\u306b\u3042\u308b\u30d0\u30c3\u30d5\u30a1\u3092\u9001\u308b\u3068\u3044\u3046\u4e00\u5b9a\u306e\u4ed5\u4e8b\u3092\u7ba1\u7406\u3059\u308b\u3002<br \/>\n\u4ed6\u306f\u3001\u30c7\u30a3\u30b9\u30af\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u306e\u4ed5\u4e8b\u3092\u5358\u7d14\u306b\u5f85\u3064\u3060\u3051\u3067\u3042\u308b\u3002<\/p>\n<p>iderw\u306f\u3001\u30ad\u30e5\u30fc\u306e\u6700\u5f8c\u306b\u30d0\u30c3\u30d5\u30a1b\u3092\u8ffd\u52a0\u3059\u308b\u3002\uff08Append b to idequeue.\u3068\u30b3\u30e1\u30f3\u30c8\u304c\u4ed8\u3044\u3066\u308b\u90e8\u5206\uff09<br \/>\n\u3082\u3057\u305d\u306e\u30d0\u30c3\u30d5\u30a1\u304c\u30ad\u30e5\u30fc\u306e\u4e00\u756a\u524d\u306a\u3089\u3001iderw\u306fidestart\u95a2\u6570\u3092\u4f7f\u3063\u3066\u30c7\u30a3\u30b9\u30af\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u3078\u305d\u308c\u3092\u9001\u4fe1\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002<br \/>\n\u305d\u3046\u3058\u3083\u306a\u3051\u308c\u3070\u3001\u30d0\u30c3\u30d5\u30a1\u306f\u4e00\u5ea6\u958b\u59cb\u3055\u308c\u3001\u305d\u306e\u524d\u306b\u3042\u308b\u30d0\u30c3\u30d5\u30a1\u306b\u3088\u3063\u3066\u51e6\u7406\u3055\u308c\u308b\u3002<br \/>\n\uff08\u3053\u3053\u6587\u7ae0\u304c\u5206\u304b\u308a\u3065\u3089\u3044\u3051\u3069\u3001\u7279\u5b9a\u306e\u30d0\u30c3\u30d5\u30a1\u306b\u95a2\u3059\u308b\u30c7\u30a3\u30b9\u30af\u64cd\u4f5c\u304c\u5b8c\u4e86\u3057\u305f\u3068\u304d\u306b\u5b9f\u884c\u3055\u308c\u308bideintr\uff08\u5f8c\u3067\u8aac\u660e\uff09\u5185\u3067\u3001\u30ad\u30e5\u30fc\u304c\u7a7a\u3058\u3083\u306a\u3051\u308c\u3070\u7d9a\u3051\u3066\u305d\u306e\u5f8c\u306e\u30d0\u30c3\u30d5\u30a1\u3092\u51e6\u7406\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u307f\u305f\u3044\u3002\uff09<\/p>\n<p>ide.c\u306eidestart\u95a2\u6570<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/ Start the request for b.  Caller must hold idelock.\nstatic void\nidestart(struct buf *b)\n{\n  if(b == 0)\n    panic(&quot;idestart&quot;);\n\n  idewait(0);\n  outb(0x3f6, 0);  \/\/ generate interrupt\n  outb(0x1f2, 1);  \/\/ number of sectors\n  outb(0x1f3, b-&gt;sector &amp; 0xff);\n  outb(0x1f4, (b-&gt;sector &gt;&gt; 8) &amp; 0xff);\n  outb(0x1f5, (b-&gt;sector &gt;&gt; 16) &amp; 0xff);\n  outb(0x1f6, 0xe0 | ((b-&gt;dev&amp;1)&lt;&lt;4) | ((b-&gt;sector&gt;&gt;24)&amp;0x0f));\n  if(b-&gt;flags &amp; B_DIRTY){\n    outb(0x1f7, IDE_CMD_WRITE);\n    outsl(0x1f0, b-&gt;data, 512\/4);\n  } else {\n    outb(0x1f7, IDE_CMD_READ);\n  }\n}<\/pre>\n<p>idestart\u95a2\u6570\u306f\u3001\u30d0\u30c3\u30d5\u30a1\u306e\u30c7\u30d0\u30a4\u30b9\u3068\u30bb\u30af\u30bf\u306e\u305f\u3081\u306e\u8aad\u307f\u8fbc\u307f\u30fb\u66f8\u304d\u8fbc\u307f\u3069\u3061\u3089\u3082\u767a\u884c\u3059\u308b\u3002<br \/>\n\u8aad\u307f\u8fbc\u307f\u304b\u66f8\u304d\u8fbc\u307f\u304b\u306f\u30d5\u30e9\u30b0\u3067\u898b\u5206\u3051\u308b\u3002<br \/>\n\u3082\u3057\u64cd\u4f5c\u304c\u66f8\u304d\u8fbc\u307f\u306a\u3089\u3001idestart\u306f\u3053\u306e\u6642\u70b9\u3067\u30c7\u30fc\u30bf\u3092\u4f9b\u7d66\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u305a\uff08outsl(0x1f0, b->data, 512\/4); \u306e\u3068\u3053\u308d\uff09\u3001\u305d\u3057\u3066\u5272\u308a\u8fbc\u307f\u306f\u30c7\u30fc\u30bf\u304c\u30c7\u30a3\u30b9\u30af\u306b\u66f8\u304d\u8fbc\u307e\u308c\u305f\u3053\u3068\u3092\u793a\u3059\u3002<br \/>\n\u3082\u3057\u64cd\u4f5c\u304c\u8aad\u307f\u8fbc\u307f\u306a\u3089\u3001\u5272\u308a\u8fbc\u307f\u306f\u30c7\u30fc\u30bf\u304c\u6e96\u5099\u5b8c\u4e86\u3067\u3042\u308b\u3053\u3068\u3092\u793a\u3057\u3001\u305d\u3057\u3066\u5272\u308a\u8fbc\u307f\u30cf\u30f3\u30c9\u30e9\u306f\u305d\u308c\u3092\u8aad\u307f\u8fbc\u3080\u3002<br \/>\niderw\u306fIDE\u30c7\u30d0\u30a4\u30b9\u306b\u3064\u3044\u3066\u306e\u8a73\u7d30\u306a\u77e5\u8b58\u3092\u6301\u3061\u3001\u6b63\u3057\u3044\u30dd\u30fc\u30c8\u306b\u6b63\u3057\u3044\u5024\u3092\u66f8\u304d\u8fbc\u3080\u3053\u3068\u306b\u6ce8\u610f\u3002<br \/>\n\u3082\u3057\u3001\u4e00\u9023\u306eoutb\u547d\u4ee4\u306b\u9593\u9055\u3044\u304c\u3042\u3063\u305f\u3089\u3001IDE\u306f\u6211\u3005\u304c\u3084\u3063\u3066\u6b32\u3057\u3044\u3053\u3068\u3068\u306f\u9055\u3046\u4f55\u304b\u3092\u884c\u3046\u3060\u308d\u3046\u3002<br \/>\n\u305d\u308c\u3089\u306e\u8a73\u7d30\u3092\u6b63\u3057\u304f\u77e5\u308b\u3053\u3068\u306f\u3001\u30c7\u30d0\u30a4\u30b9\u30c9\u30e9\u30a4\u30d0\u3092\u66f8\u304f\u3053\u3068\u304c\u306a\u305c\u30c1\u30e3\u30ec\u30f3\u30b8\u30f3\u30b0\u3067\u3042\u308b\u304b\u306e\u4e00\u3064\u306e\u7406\u7531\u3067\u3042\u308b\u3002<\/p>\n<p>\u30ad\u30e5\u30fc\u3078\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u8ffd\u52a0\u3057\u305f\u3089\u3001\u3082\u3057\u5fc5\u8981\u306a\u3089\u305d\u306e\u30ad\u30e5\u30fc\u306f\u958b\u59cb\u3055\u308c\u308b\u3002<br \/>\n\u305d\u3057\u3066iderw\u306f\u7d50\u679c\u3092\u5f85\u3064\u3002<br \/>\n\u4e0a\u3067\u8aac\u660e\u3057\u305f\u3088\u3046\u306b\u3001\u30dd\u30fc\u30ea\u30f3\u30b0\u306fCPU\u306e\u4f7f\u3044\u65b9\u3068\u3057\u3066\u306f\u975e\u52b9\u7387\u3067\u3042\u308b\u3002<br \/>\n\u305d\u306e\u4ee3\u308f\u308a\u3001iderw\u306f\u3001\u64cd\u4f5c\u306e\u5b8c\u4e86\u3092\u793a\u3059\u30d5\u30e9\u30b0\u304c\u5272\u308a\u8fbc\u307f\u30cf\u30f3\u30c9\u30e9\u306b\u3088\u3063\u3066\u30d0\u30c3\u30d5\u30a1\u306b\u8a18\u9332\u3055\u308c\u308b\u307e\u3067\u3001sleep\u95a2\u6570\u3067\u5f85\u3064\u3002<br \/>\n\u3053\u306e\u30d7\u30ed\u30bb\u30b9\u304c\u30b9\u30ea\u30fc\u30d7\u3057\u3066\u308b\u9593\u3001xv6\u306fCPU\u306b\u4ed5\u4e8b\u3092\u3055\u305b\u308b\u305f\u3081\u306b\u4ed6\u306e\u30d7\u30ed\u30bb\u30b9\u3092\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u3059\u308b\u3060\u308d\u3046\u3002<\/p>\n<p>\u6700\u7d42\u7684\u306b\u3001\u30c7\u30a3\u30b9\u30af\u306f\u64cd\u4f5c\u3092\u5b8c\u4e86\u3057\u5272\u308a\u8fbc\u307f\u3092\u767a\u751f\u3055\u305b\u308b\u3002<br \/>\ntrap\u95a2\u6570\u306f\u3001\u305d\u306e\u5272\u308a\u8fbc\u307f\u3092\u5236\u5fa1\u3055\u305b\u308b\u305f\u3081\u306bideintr\u95a2\u6570\u3092\u547c\u3076\u3002<br \/>\nideintr\u95a2\u6570\u306f\u3001\u3069\u306e\u64cd\u4f5c\u304c\u8d77\u304d\u305f\u306e\u304b\u77e5\u308b\u305f\u3081\u306b\u30ad\u30e5\u30fc\u306e\u6700\u521d\u306e\u30d0\u30c3\u30d5\u30a1\u3092\u8abf\u3079\u308b\u3002<br \/>\n\u3082\u3057\u3001\u30d0\u30c3\u30d5\u30a1\u304c\u8aad\u307f\u5b8c\u4e86\u3067\u30c7\u30a3\u30b9\u30af\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u304c\u30c7\u30fc\u30bf\u3092\u6e96\u5099\u3057\u3066\u5f85\u3063\u3066\u308b\u306a\u3089\u3001ideintr\u306f\u3001insl\u3092\u4f7f\u3063\u3066\u30d0\u30c3\u30d5\u30a1\u3078\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3080\u3002<br \/>\nideintr\u306f\u3001B_VALID\u3092\u30bb\u30c3\u30c8\u3057\u3001B_DIRTY\u3092\u30af\u30ea\u30a2\u3057\u3001\u30d0\u30c3\u30d5\u30a1\u4e0a\u3067\u5bdd\u3066\u3044\u308b\u3069\u3053\u304b\u306e\u30d7\u30ed\u30bb\u30b9\u3092\u8d77\u3053\u3059\u3002<br \/>\n\uff08Wake process waiting for this buf\u306e\u30b3\u30e1\u30f3\u30c8\u306e\u90e8\u5206\uff09<br \/>\n\u3053\u308c\u3067\u30d0\u30c3\u30d5\u30a1\u304c\u6e96\u5099\u51fa\u6765\u305f\u3053\u3068\u306b\u306a\u308b\u3002<br \/>\n\u6700\u5f8c\u306bideintr\u306f\u3001\u6b21\u306b\u5f85\u3063\u3066\u308b\u30d0\u30c3\u30d5\u30a1\u3092\u30c7\u30a3\u30b9\u30af\u3078\u9001\u3089\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002<\/p>\n<p>trap.c\u306etrap\u95a2\u6570\u306e\u30c7\u30a3\u30b9\u30af\u5272\u308a\u8fbc\u307f\u306e\u51e6\u7406\u306e\u90e8\u5206<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">  case T_IRQ0 + IRQ_IDE:\n    ideintr();\n    lapiceoi();\n    break;<\/pre>\n<p>ide.c\u306eideintr\u95a2\u6570<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/ Interrupt handler.\nvoid\nideintr(void)\n{\n  struct buf *b;\n\n  \/\/ Take first buffer off queue.\n  acquire(&amp;idelock);\n  if((b = idequeue) == 0){\n    release(&amp;idelock);\n    \/\/ cprintf(&quot;spurious IDE interrupt\\n&quot;);\n    return;\n  }\n  idequeue = b-&gt;qnext;\n\n  \/\/ Read data if needed.\n  if(!(b-&gt;flags &amp; B_DIRTY) &amp;&amp; idewait(1) &gt;= 0)\n    insl(0x1f0, b-&gt;data, 512\/4);\n  \n  \/\/ Wake process waiting for this buf.\n  b-&gt;flags |= B_VALID;\n  b-&gt;flags &amp;= ~B_DIRTY;\n  wakeup(b);\n  \n  \/\/ Start disk on next buf in queue.\n  if(idequeue != 0)\n    idestart(idequeue);\n\n  release(&amp;idelock);\n}<\/pre>\n<h3>\u611f\u60f3<\/h3>\n<p>\u30c7\u30a3\u30b9\u30af\u30c9\u30e9\u30a4\u30d0\u306e\u5b9f\u88c5\u3067\u3059\u3002<\/p>\n<p>\u30ad\u30e5\u30fc\u304c\u7a7a\u306e\u3068\u304d\u306b\u8ffd\u52a0\u3055\u308c\u305f\u5834\u5408\u3057\u304bidestart\u3057\u306a\u3044\u3068\u8aac\u660e\u304c\u3042\u3063\u3066\uff08\u30b3\u30fc\u30c9\u3082\u305d\u3046\u306a\u3063\u3066\u308b\uff09\u3001\u30ad\u30e5\u30fc\u304c\u7a7a\u3058\u3083\u306a\u3044\u3068\u304d\u306b\u8ffd\u52a0\u3055\u308c\u305f\u30ea\u30af\u30a8\u30b9\u30c8\u306f\u3069\u3046\u306a\u308b\u306e\u3088\u3001\u3068\u6700\u521d\u6df7\u4e71\u3057\u307e\u3057\u305f\u304c\u3001\u5272\u308a\u8fbc\u307f\u30cf\u30f3\u30c9\u30e9\u5074\u3067\u828b\u3065\u308b\u5f0f\u306b\u30ad\u30e5\u30fc\u3092\u6b21\u3005\u3068\u51e6\u7406\u3057\u3066\u3044\u304f\uff081\u30d0\u30c3\u30d5\u30a1\u3054\u3068\u306b\u5272\u308a\u8fbc\u307f\u304c\u767a\u751f\uff09\u3088\u3046\u306b\u306a\u3063\u3066\u3066\u7d0d\u5f97\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u5b9f\u969b\u306eOS\u3067\u306f\u3001\u30ad\u30e5\u30fc\u3092\u9ad8\u6a5f\u80fd\u5316\u3057\u3066\u3001\u4f8b\u3048\u3070\u51fa\u6765\u308b\u3060\u3051\u30bb\u30af\u30bf\u304c\u9023\u7d9a\u3059\u308b\u3088\u3046\u306b\u30d0\u30c3\u30d5\u30a1\u3092\u4e26\u3073\u304b\u3048\u305f\u308a\u3001\u96fb\u6e90\u306e\u30d6\u30c1\u5207\u308a\u3067\u306a\u308b\u3079\u304f\u30c7\u30fc\u30bf\u304c\u5931\u308f\u308c\u306a\u3044\u3088\u3046\u306a\u5de5\u592b\u304c\u3042\u3063\u305f\u308a\u3059\u308b\u3093\u3058\u3083\u306a\u304b\u308d\u3046\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[405],"class_list":["post-1402","post","type-post","status-publish","format-standard","hentry","category-tech","tag-xv6"],"_links":{"self":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts\/1402","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/comments?post=1402"}],"version-history":[{"count":0,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts\/1402\/revisions"}],"wp:attachment":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/media?parent=1402"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/categories?post=1402"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/tags?post=1402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}