1
0

arch 3.2 KB

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