f464335da72c78a647c54acd38ed0c29589bf44d
[dragonfly.git] / usr.bin / doscmd / disktab.c
1 /*
2  * Copyright (c) 1992, 1993, 1996
3  *      Berkeley Software Design, Inc.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *      This product includes software developed by Berkeley Software
16  *      Design, Inc.
17  *
18  * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  *      BSDI disktab.c,v 2.2 1996/04/08 19:32:27 bostic Exp
31  *
32  * $FreeBSD: src/usr.bin/doscmd/disktab.c,v 1.1.6.1 2002/04/25 11:04:50 tg Exp $
33  * $DragonFly: src/usr.bin/doscmd/disktab.c,v 1.2 2003/06/17 04:29:25 dillon Exp $
34  */
35
36 /* XXX goaway (requires change to config.c) */
37
38 #include "doscmd.h"
39
40 static struct {
41         int     cylinders;
42         int     heads;
43         int     sectors;
44 } disk_table[] = {
45         {  306,  4, 17 },       /* type 01   10M        */
46         {  615,  4, 17 },       /* type 02   20M        */
47         {  615,  6, 17 },       /* type 03   30M        */
48         {  940,  8, 17 },       /* type 04   62M        */
49         {  940,  6, 17 },       /* type 05   46M        */
50         {  615,  4, 17 },       /* type 06   20M        */
51         {  462,  8, 17 },       /* type 07   30M        */
52         {  733,  5, 17 },       /* type 08   30M        */
53         {  900, 15, 17 },       /* type 09   112M       */
54         {  820,  3, 17 },       /* type 10   20M        */
55         {  855,  5, 17 },       /* type 11   35M        */
56         {  855,  7, 17 },       /* type 12   49M        */
57         {  306,  8, 17 },       /* type 13   20M        */
58         {  733,  7, 17 },       /* type 14   42M        */
59         {  976, 15, 17 },       /* type 15   121M       */
60         {  612,  4, 17 },       /* type 16   20M        */
61         {  977,  5, 17 },       /* type 17   40M        */
62         {  977,  7, 17 },       /* type 18   56M        */
63         { 1024,  7, 17 },       /* type 19   59M        */
64         {  733,  5, 17 },       /* type 20   30M        */
65         {  733,  7, 17 },       /* type 21   42M        */
66         {  733,  5, 17 },       /* type 22   30M        */
67         {  306,  4, 17 },       /* type 23   10M        */
68         {  925,  7, 17 },       /* type 24   53M        */
69         {  925,  9, 17 },       /* type 25   69M        */
70         {  754,  7, 17 },       /* type 26   43M        */
71         {  754, 11, 17 },       /* type 27   68M        */
72         {  699,  7, 17 },       /* type 28   40M        */
73         {  823, 10, 17 },       /* type 29   68M        */
74         {  918,  7, 17 },       /* type 30   53M        */
75         { 1024, 11, 17 },       /* type 31   93M        */
76         { 1024, 15, 17 },       /* type 32   127M       */
77         { 1024,  5, 17 },       /* type 33   42M        */
78         {  612,  2, 17 },       /* type 34   10M        */
79         { 1024,  9, 17 },       /* type 35   76M        */
80         { 1024,  8, 17 },       /* type 36   68M        */
81         {  615,  8, 17 },       /* type 37   40M        */
82         {  987,  3, 17 },       /* type 38   24M        */
83         {  987,  7, 17 },       /* type 39   57M        */
84         {  820,  6, 17 },       /* type 40   40M        */
85         {  977,  5, 17 },       /* type 41   40M        */
86         {  981,  5, 17 },       /* type 42   40M        */
87         {  830,  7, 17 },       /* type 43   48M        */
88         {  830, 10, 17 },       /* type 44   68M        */
89         {  917, 15, 17 },       /* type 45   114M       */
90         { 1224, 15, 17 },       /* type 46   152M       */
91 };
92
93 static int ntypes = sizeof(disk_table)/sizeof(disk_table[0]);
94
95 int
96 map_type(int type, int *cyl, int *head, int *sec)
97 {
98     --type;
99     if (type < 0 || type >= ntypes)
100         return(0);
101     *cyl = disk_table[type].cylinders;
102     *head = disk_table[type].heads;
103     *sec = disk_table[type].sectors;
104     return(1);
105 }