]> git.lizzy.rs Git - plan9front.git/blob - sys/man/3/arch
mothra: add keyboard command a to collapse/expand navigation boxes
[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/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 .B /dev/msr
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 and DEC Alpha machines.
19 .PP
20 Reads from
21 .I cputype
22 recover the processor type and clock rate in MHz.
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 .IR 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 .PP
126 Reads and writes to
127 .I msr
128 go to the P4/P6/Core/Core2/AMD64 MSRs.
129 .SH EXAMPLE
130 The following code reads from an x86 byte I/O port.
131 .IP
132 .EX
133 uchar
134 inportb(unsigned port)
135 {
136     uchar data;
137
138     if(iobfd == -1)
139         iobfd = open("#P/iob", ORDWR);
140
141     seek(iobfd, port, 0);
142     if(read(iobfd, &data, sizeof(data)) != sizeof(data))
143         sysfatal("inportb(0x%4.4ux): %r", port);
144     return data;
145 }
146 .EE
147 .SH SOURCE
148 .B /sys/src/9/pc/devarch.c