source: trunk/minix/man/man4/controller.4@ 12

Last change on this file since 12 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 13.4 KB
Line 
1.TH CONTROLLER 4
2.SH NAME
3controller, disk, tape, at, bios, esdi, aha1540, ncr810, dosfile, fatfile \- controllers, disks and tapes
4.SH DESCRIPTION
5.de SP
6.if t .sp 0.4
7.if n .sp
8..
9The
10.BI c n *
11family of devices refer to drivers that control disks, disk like devices,
12and tapes. MINIX 3 contains a number of drivers for several different
13controllers. These controllers can have disks, cdroms and tapes attached to
14them. Boot Monitor variables specify which drivers are activated using
15the variables
16.BR c0 ,
17.BR c1 ,
18etc. The names of the devices in
19.BR /dev
20that correspond with the driver for controller 0 are all named beginning
21with
22.BR c0 .
23.PP
24For each controller, the minor device numbers are organized as follows:
25.PP
26.RS
27.nf
28.ta +\w'122-127nnmm'u +\w'd0p0s0nnmm'u +\w'disk 0, part 0, subpart 0nnmm'u
29.ft B
30minor device what? obsolete
31.ft P
320 d0 disk 0 hd0
331 d0p0 disk 0, partition 0 hd1
342 d0p1 disk 0, partition 1 hd2
353 d0p2 disk 0, partition 2 hd3
364 d0p3 disk 0, partition 3 hd4
375 d1 disk 1 hd5
386 d1p0 disk 1, partition 0 hd6
397 d1p1 disk 1, partition 1 hd7
408 d1p2 disk 1, partition 2 hd8
419 d1p3 disk 1, partition 3 hd9
42\&... ...
4339 d7p3 disk 7, partition 3 hd39
44.SP
4564 t0n tape 0, non-rewinding
4665 t0 tape 0, rewind on close
4766 t1n tape 1, non-rewinding
4867 t1 tape 1, rewind on close
49\&... ...
5078 t7n tape 7, non-rewinding
5179 t7 tape 7, rewind on close
52.SP
53120 r0 raw access device 0
54121 r1 raw access device 1
55\&... ...
56127 r7 raw access device 7
57.SP
58128 d0p0s0 disk 0, part 0, subpart 0 hd1a
59129 d0p0s1 disk 0, part 0, subpart 1 hd1b
60130 d0p0s2 disk 0, part 0, subpart 2 hd1c
61131 d0p0s3 disk 0, part 0, subpart 3 hd1d
62132 d0p1s0 disk 0, part 1, subpart 0 hd2a
63\&... ...
64144 d1p0s0 disk 1, part 0, subpart 0 hd6a
65\&... ...
66255 d7p3s3 disk 7, part 3, subpart 3 hd39d
67.fi
68.RE
69.PP
70The device names in
71.B /dev
72also name the controller, of course, so the usual place for the MINIX 3
73root device, the first subpartition of the second partition of disk 0 on
74controller 0 is
75.BR /dev/c0d0p1s0 .
76Note that everything is numbered from 0! The first controller is controller
770, the first disk is disk 0, etc. So the second partition is
78.BR p1 .
79.PP
80The fourth column in the table above shows the disk devices names that were
81used by previous versions of MINIX 3 for what is now controller 0. These
82devices are no longer present in
83.BR /dev .
84.SS Disks
85Most disks are arrays of 512 byte sectors. The disk devices are normally
86block devices, which means they are block buffered by the MINIX 3 file system
87cache using 1024 byte blocks. The FS cache allows I/O at any byte offset,
88and takes care of cutting and pasting incomplete blocks together. If one
89creates a character device for a disk device, then I/O must be in multiples
90of the disk block size.
91.PP
92For each disk there is a device that covers the entire disk, these are named
93.BR c0d0 ,
94.BR c0d1 ,
95etc, up to
96.B c0d7
97for controller 0. If a partition table is placed in the first sector of the
98disk, then the disk is subdivided into regions named partitions. Up to four
99partitions may be defined, named
100.BR c0d0p0
101to
102.BR c0d0p3
103for disk 0 on controller 0. To make things interesting you can also place a
104partition table in the first sector of a MINIX 3 partition, which divides the
105partition into up to four subpartitions. Normally MINIX 3 is installed into a
106single partition, with the root, swap and /usr file systems in subpartitions.
107.PP
108If a partition is an extended partition then it contains a linked list of
109partition tables each of which may specify a logical partition. Up to four
110of these logical partitions are presented by the driver as subpartitions of
111the extended partition.
112.PP
113A sector containing a partition table starts with 446 bytes of boot code,
114followed by four partition table entries of 16 bytes each, and ends with
115the magic number 0xAA55 (little endian, so first 0x55 then 0xAA.) Partition
116table information is defined in <ibm/partition.h>:
117.PP
118.nf
119.ta +2n +29n +37n
120/* Description of entry in the partition table. */
121
122struct part_entry {
123 unsigned char bootind; /* boot indicator 0/ACTIVE_FLAG */
124 unsigned char start_head; /* head value for first sector */
125 unsigned char start_sec; /* sector value + high 2 cyl bits */
126 unsigned char start_cyl; /* low 8 cylinder bits */
127 unsigned char sysind; /* system indicator */
128 unsigned char last_head; /* h/s/c for the last sector */
129 unsigned char last_sec;
130 unsigned char last_cyl;
131 unsigned long lowsec; /* logical first sector */
132 unsigned long size; /* size of partition in sectors */
133};
134
135.ta +24n +7n +37n
136#define ACTIVE_FLAG 0x80 /* value for active in bootind field */
137#define NR_PARTITIONS 4 /* number of entries in table */
138#define PART_TABLE_OFF 0x1BE /* offset of table in boot sector */
139
140/* Partition types (sysind). */
141#define NO_PART 0x00 /* unused entry */
142#define MINIX_PART 0x81 /* MINIX 3 partition type */
143.fi
144.PP
145The cylinder numbers are encoded in a very strange way, bits 8 and 9 are
146in the high two bits of the sector number. The sector numbers count from 1,
147not 0! More useful are the lowsec and size fields however, they simply give
148the location of the partition as an absolute sector offset and length within
149the drive.
150.PP
151The partition table entry defined above is specific to IBM type disks. The
152device drivers use another partition entry structure to pass information on
153a partition. This is what <minix/partition.h> looks like:
154.sp
155.nf
156.ta +2n +25n
157struct partition {
158 u64_t base; /* byte offset to the partition start */
159 u64_t size; /* number of bytes in the partition */
160 unsigned cylinders; /* disk geometry for partitioning */
161 unsigned heads;
162 unsigned sectors;
163};
164.fi
165.PP
166The base and size fields are the byte offset and length of a partition.
167The geometry of the disk is also given for the benefit of
168partition table editors. This information can be obtained from an open disk
169device with the call:
170.sp
171.RS
172.ft B
173ioctl(\fIfd\fP, DIOCGETP, &\fIentry\fP);
174.ft R
175.RE
176.sp
177One can change the placement of the device to the lowsec and size fields of
178.I entry
179by using the
180.B DIOCSETP
181call instead. Only the base and size fields are used for
182.BR DIOCSETP .
183.PP
184The partition tables when read from disk by the driver are checked and
185truncated to fit within the primary partition or drive. The first sector
186is normally left free for the partition table.
187.PP
188The partition tables are read when the in-use count (opens and mounts)
189changes from 0 to 1. So an idle disk is automatically repartitioned on the
190next access. This means that DIOCSETP only has effect if the disk is in
191use.
192.SS "Disk-like devices"
193Devices like a CD-ROM are treated as read-only disks, and can be accessed
194using disk devices. A CD-ROM usually has a block size of 2048 bytes, but
195the driver knows this, and allows one to read at any byte offset by reading
196what isn't needed into a scratch buffer.
197.SS Tapes
198There are two kinds of tape devices: Non-rewinding, and rewind-on-close.
199The non-rewinding devices treat the tape as a series of files. The
200rewind-on-close devices look at the tape as a single file, and when you close
201such a device the tape is told to rewind.
202See
203.BR mt (1),
204and
205.BR mtio (4)
206for a description of the commands that may be sent to the tape, either from
207the command prompt or from a program.
208.PP
209There are two kinds of tape drives: Fixed and variable block size tape
210drives. Examples of the first kind are cartridge
211tapes, with a fixed 512 bytes block size. An Exabyte tape drive has a
212variable block size, with a minimum of 1 byte and a maximum of 245760 bytes
213(see the documentation of such devices.)
214The maximum is truncated to 32767 bytes for Minix-86 and 61440 bytes for
215Minix-vmd, because the driver can't move more bytes in a single request.
216.PP
217A read or write to a fixed block size tape must be a precise multiple of the
218block size, any other count gives results in an I/O error. A read from a
219variable block sized tape must be large enough to accept the block that is
220read, otherwise an I/O error will be returned. A write can be any size
221above the minimum, creating a block of that size. If the write count is
222larger than the maximum block size then more blocks are written until the
223count becomes zero. The last block must be larger than the minimum of
224course. (This minimum is often as small as 1 byte, as for the Exabyte.)
225.PP
226The
227.B mt blksize
228command may be used to select a fixed block size for a variable block sized
229tape. This will speed up I/O considerably for small block sizes. (Some
230systems can only use fixed mode and will write an Exabyte tape with 1024
231byte blocks, which read very slow in variable mode.)
232.PP
233A tape is a sequence of blocks and filemarks. A tape may be opened and
234blocks may be read from it upto a filemark, after that all further reads
235return 0. After the tape is closed and reopened one can read the blocks
236following the filemark if using a non-rewinding device. This makes the tape
237look like a sequence of files.
238.PP
239If a tape has been written to or opened in write-only mode, then a filemark
240is written if the tape is closed or if a space command is issued. No extra
241filemark is written if the drive is instructed to write filemarks.
242.SS "Raw Access Devices"
243Under Minix-vmd one can use the raw access devices to program a SCSI
244device entirely from user mode. The disk and tape devices probe for devices
245when opened, start disks and load tapes, but the raw access devices do
246nothing at all. Given an open file descriptor to any SCSI character device
247(not just the raw access devices) one can use the following ioctl:
248.PP
249.RS
250ioctl(fd, SCIOCCMD, &scsicmd)
251.RE
252.PP
253The structure whose address is passed as the third argument is defined
254in <sys/scsi.h> as follows:
255.PP
256.RS
257.nf
258struct scsicmd {
259 void *cmd;
260 size_t cmdlen;
261 void *buf;
262 size_t buflen;
263 void *sense;
264 size_t senselen;
265 int dir;
266};
267.fi
268.RE
269.PP
270.B Cmd
271and
272.B cmdlen
273hold the address and length of an object holding a Group 0 or Group 1
274SCSI command. The next two fields describe a buffer of at most 8 kilobytes
275used in the data in or out phase.
276.B Dir
277is 0 if data is to be read from the device, 1 if data is written to the
278device. If the ioctl succeeds then 0 is returned, otherwise -1 with
279.B errno
280set to
281.B EIO
282and the request sense info returned in the buffer described by the sense and
283senselen fields. If the sense key is zero on error then a host adapter
284error occurred, this means that the device is most likely turned off or not
285present.
286.SH DRIVERS
287By setting the Boot variables
288.BR c0
289to
290.BR c3
291under MINIX 3, or
292.BR c0
293to
294.BR c4
295under Minix-vmd one attaches a set of disk and tape devices to a driver.
296See
297.BR boot (8)
298for a list of boot variables that configure each of these drivers.
299The following drivers are available:
300.SS at
301The standard IBM/AT disk driver that also supports IDE disks. This is the
302default driver for controller 0 on AT class machines. (Most PCs are in that
303class.)
304.SS bios
305A disk driver that uses BIOS calls to do disk I/O. This is the default
306driver on anything but an AT. (Old XTs and PS/2s.) On an XT this is the
307best driver you can use, but on any other machine this driver may be
308somewhat slow, because the system has to switch out of protected mode to
309make a BIOS call. On a fast enough machine with a high enough setting of
310DMA_SECTORS (see
311.BR config (8))
312it works well enough.
313.SS esdi
314A hard disk driver for use on some PS/2 models.
315.SS "xt \fR(MINIX 3 only)"
316A hard disk driver for IBM/XT type hard disks. Useful for old 286 based
317machines that have such a disk. On XTs you are better off with the
318.B bios
319driver.
320.SS aha1540
321A SCSI driver for the Adaptec 1540 host adapter family, which includes the
3221540, 1540A, 1540B, 1540C, 1540CF, 1640, and 1740. Also supported is the
323compatible BusLogic 545.
324.SS ncr810
325This will eventually become a Symbios 810 SCSI driver. (Formerly owned by
326NCR.) KJB has read the docs on this card three times, but has still done
327nothing, the lazy bum.
328.SS dosfile
329The "DOS file as disk" driver that is used when MINIX 3 is running
330under DOS. It treats a large DOS file as a MINIX 3 disk. Only primary
331partitions are supported, there are no subpartitions. This is the default
332driver when MINIX 3 is started under DOS.
333.SS fatfile
334Uses a large file on a FAT file system as a disk. It needs one of the other
335disk drivers to do the actual I/O. This driver only knows how to interpret
336a FAT file system to find the file to use. With a fast native disk driver
337this driver is much faster than the
338.B dosfile
339driver.
340.SH FILES
341.TP 25
342/dev/c*d*
343Disks devices.
344.TP
345/dev/c*d*p*
346Partitions.
347.TP
348/dev/c*d*p*s*
349Subpartitions.
350.TP
351/dev/c*t*n, /dev/c*t*
352Tapes.
353.TP
354/dev/c*r*
355Raw access devices.
356.SH "SEE ALSO"
357.BR dd (1),
358.BR mt (1),
359.BR eject (1),
360.BR ioctl (2),
361.BR int64 (3),
362.BR mtio (4),
363.BR boot (8),
364.BR config (8),
365.BR monitor (8),
366.BR part (8),
367.BR repartition (8).
368.SH BUGS
369The subpartitioning is incompatible with the MS-DOS method of extended
370partitions. The latter does not map well to the sparse minor device number
371space.
372.PP
373The primary partition table is sorted by lowsec like MS-DOS does, subpartition
374tables are not. Just think about what happens when you delete a partition in
375the MS-DOS scheme.
376.PP
377Don't move a partition that is mounted or kept open by some process. The
378file system may write cached blocks to the new location.
379.PP
380The BIOS driver is not slow at all on a buffered disk.
381.PP
382Some IDE disks send an interrupt when they spin down under hardware power
383management. The driver acknowledges the interrupt as it is supposed to do by
384reading the status register. The disk then spins up again... You have to
385disable the spin down in the computer setup to fix the problem.
386.SH AUTHOR
387Kees J. Bot (kjb@cs.vu.nl)
Note: See TracBrowser for help on using the repository browser.