arch 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. .TH ARCH 3
  2. .SH NAME
  3. arch \- architecture-specific information and control
  4. .SH SYNOPSIS
  5. .nf
  6. .B bind -a #P /dev
  7. .sp 0.3v
  8. .B /dev/archctl
  9. .B /dev/cputype
  10. .B /dev/ioalloc
  11. .B /dev/iob
  12. .B /dev/iol
  13. .B /dev/iow
  14. .B /dev/irqalloc
  15. .SH DESCRIPTION
  16. This device presents textual information about PC hardware and allows
  17. user-level control of the I/O ports on x86-class and DEC Alpha machines.
  18. .PP
  19. Reads from
  20. .I cputype
  21. recover the processor type and clock rate in MHz in the first line, followed
  22. by further lines with CPU information values as provided by the processor.
  23. Reads from
  24. .I archctl
  25. yield at least data of this form:
  26. .IP
  27. .EX
  28. cpu AMD64 2201 pge
  29. pge on
  30. coherence mfence
  31. cmpswap cmpswap486
  32. i8253set on
  33. cache default uc
  34. cache 0x0 1073741824 wb
  35. cache 0x3ff00000 1048576 uc
  36. .EE
  37. .LP
  38. Where
  39. .L AMD64
  40. is the processor type,
  41. .L 2201
  42. is the processor speed in MHz,
  43. and
  44. .L pge
  45. is present only if the `page global extension' capability is present;
  46. the next line reflects its setting.
  47. .L coherence
  48. is followed by one of
  49. .LR mb386 ,
  50. .LR mb586 ,
  51. .L mfence
  52. or
  53. .LR nop ,
  54. showing the form of memory barrier used by the kernel.
  55. .L cmpswap
  56. is followed by
  57. .L cmpswap386
  58. or
  59. .LR cmpswap486 ,
  60. reflecting the form of `compare and swap' used by the kernel.
  61. .L i8253set
  62. is a flag, indicating the need to explicitly set
  63. the Intel 8253 or equivalent timer.
  64. There may be lines starting with
  65. .L cache
  66. that reflect the state of memory caching via MTRRs
  67. (memory-type region registers).
  68. The second word on the line is
  69. .L default
  70. or a C-style number which is the base physical address of the region;
  71. the third is a C-style length of the region;
  72. and the fourth is one of
  73. .LR uc
  74. (for uncachable),
  75. .LR wb
  76. (write-back),
  77. .LR wc
  78. (write-combining),
  79. .LR wp
  80. (write-protected),
  81. or
  82. .LR wt
  83. (write-through).
  84. A region may be a subset of another region, and the smaller region
  85. takes precedence.
  86. This may be used to make I/O registers uncachable
  87. in the midst of a write-combining region mostly used
  88. for a video framebuffer, for example.
  89. Control messages may be written to
  90. .I archctl
  91. and use the same syntax as the data read from
  92. .IR archctl .
  93. Known commands include
  94. .LR cache ,
  95. .LR coherence ,
  96. .LR i8253set ,
  97. and
  98. .LR pge .
  99. .
  100. .PP
  101. Reads from
  102. .I ioalloc
  103. return I/O ranges used by each device, one line
  104. per range.
  105. Each line contains three fields separated by white space: first address
  106. in hexadecimal,
  107. last address, name of device.
  108. .PP
  109. Reads from
  110. .I irqalloc
  111. return the enabled interrupts, one line per
  112. interrupt. Each line contains three fields separated by white space:
  113. the trap number, the IRQ it is assigned to, and the name of
  114. the device using it.
  115. .PP
  116. Reads and writes to
  117. .IR iob ,
  118. .IR iow ,
  119. and
  120. .I iol
  121. cause 8-bit wide, 16-bit wide, and 32-bit wide requests to
  122. I/O ports.
  123. The port accessed is determined by the byte offset of the
  124. file descriptor.
  125. .SH EXAMPLE
  126. The following code reads from an x86 byte I/O port.
  127. .IP
  128. .EX
  129. uchar
  130. inportb(unsigned port)
  131. {
  132. uchar data;
  133. if(iobfd == -1)
  134. iobfd = open("#P/iob", ORDWR);
  135. seek(iobfd, port, 0);
  136. if(read(iobfd, &data, sizeof(data)) != sizeof(data))
  137. sysfatal("inportb(0x%4.4ux): %r", port);
  138. return data;
  139. }
  140. .EE
  141. .SH SOURCE
  142. .B /sys/src/9/pc/devarch.c