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