]> git.saurik.com Git - apple/xnu.git/blame - bsd/dev/disk.h
xnu-344.tar.gz
[apple/xnu.git] / bsd / dev / disk.h
CommitLineData
1c79356b 1/*
9bccf70c 2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
1c79356b
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/* @(#)disk.h 1.0 08/29/87 (c) 1987 NeXT */
23
1c79356b
A
24#ifndef _BSD_DEV_DISK_
25#define _BSD_DEV_DISK_
9bccf70c
A
26#ifndef _SYS_DISK_H_
27#define _SYS_DISK_H_
1c79356b 28
9bccf70c 29#include <sys/appleapiopts.h>
1c79356b
A
30#include <mach/machine/vm_types.h>
31#include <mach/machine/boolean.h>
32#include <sys/types.h>
33#include <sys/ioctl.h>
34#include <sys/time.h>
35#include <dev/disk_label.h>
36
9bccf70c
A
37/*
38 * USE <sys/disk.h> INSTEAD (NOTE: DKIOCGETBLOCKCOUNT -> DKIOCGETBLOCKCOUNT32)
39 */
40
41#ifdef __APPLE_API_OBSOLETE
42
1c79356b
A
43#define DR_CMDSIZE 32
44#define DR_ERRSIZE 32
45
46struct disk_req {
47 int dr_bcount; /* byte count for data transfers */
48 caddr_t dr_addr; /* memory addr for data transfers */
49 struct timeval dr_exec_time; /* execution time of operation */
50
51 /*
52 * interpretation of cmdblk and errblk is driver specific.
53 */
54 char dr_cmdblk[DR_CMDSIZE];
55 char dr_errblk[DR_ERRSIZE];
56};
57
58struct sdc_wire {
59 vm_offset_t start, end;
60 boolean_t new_pageable;
61};
62
63
64#define BAD_BLK_OFF 4 /* offset of bad blk tbl from label */
65#define NBAD_BLK (12 * 1024 / sizeof (int))
66
67struct bad_block { /* bad block table, sized to be 12KB */
68 int bad_blk[NBAD_BLK];
69};
70
71/*
72 * sector bitmap states (2 bits per sector)
73 */
74#define SB_UNTESTED 0 /* must be zero */
75#define SB_BAD 1
76#define SB_WRITTEN 2
77#define SB_ERASED 3
78
79struct drive_info { /* info about drive hardware */
80 char di_name[MAXDNMLEN]; /* drive type name */
81 int di_label_blkno[NLABELS];/* label loc'ns in DEVICE SECTORS */
82 int di_devblklen; /* device sector size */
83 int di_maxbcount; /* max bytes per transfer request */
84};
85
86#define DS_STATSIZE 32
87
88struct disk_stats {
89 int s_ecccnt; /* avg ECC corrections per sector */
90 int s_maxecc; /* max ECC corrections observed */
91
92 /*
93 * interpretation of s_stats is driver specific
94 */
95 char s_stats[DS_STATSIZE];
96};
97
98struct drive_location {
99 char location[ 128 ];
100};
101
102#define DKIOCGLABEL _IOR('d', 0,struct disk_label) /* read label */
103#define DKIOCSLABEL _IOW('d', 1,struct disk_label) /* write label */
104#define DKIOCGBITMAP _IO('d', 2) /* read bitmap */
105#define DKIOCSBITMAP _IO('d', 3) /* write bitmap */
106#define DKIOCREQ _IOWR('d', 4, struct disk_req) /* cmd request */
107#define DKIOCINFO _IOR('d', 5, struct drive_info) /* get drive info */
108#define DKIOCZSTATS _IO('d',7) /* zero statistics */
109#define DKIOCGSTATS _IO('d', 8) /* get statistics */
110#define DKIOCRESET _IO('d', 9) /* reset disk */
111#define DKIOCGFLAGS _IOR('d', 11, int) /* get driver flags */
112#define DKIOCSFLAGS _IOW('d', 12, int) /* set driver flags */
113#define DKIOCSDCWIRE _IOW('d', 14, struct sdc_wire) /* sdc wire memory */
114#define DKIOCSDCLOCK _IO('d', 15) /* sdc lock */
115#define DKIOCSDCUNLOCK _IO('d', 16) /* sdc unlock */
116#define DKIOCGFREEVOL _IOR('d', 17, int) /* get free volume # */
117#define DKIOCGBBT _IO('d', 18) /* read bad blk tbl */
118#define DKIOCSBBT _IO('d', 19) /* write bad blk tbl */
119#define DKIOCMNOTIFY _IOW('d', 20, int) /* message on insert */
120#define DKIOCEJECT _IO('d', 21) /* eject disk */
121#define DKIOCPANELPRT _IOW('d', 22, int) /* register Panel */
122 /* Request port */
123#define DKIOCSFORMAT _IOW('d', 23, int) /* set 'Formatted' flag */
124#define DKIOCGFORMAT _IOR('d', 23, int) /* get 'Formatted' flag */
125#define DKIOCBLKSIZE _IOR('d', 24, int) /* device sector size */
126#define DKIOCNUMBLKS _IOR('d', 25, int) /* number of sectors */
127#define DKIOCCHECKINSERT _IO('d',26) /* manually poll removable */
128 /* media drive */
129#define DKIOCCANCELAUTOMOUNT _IOW('d',27, dev_t) /* cancel automount request */
130#define DKIOCGLOCATION _IOR('d',28, struct drive_location) /* arch dependent location descrip */
131#define DKIOCSETBLOCKSIZE _IOW('d', 24, int) /* set media's preferred sector size */
132#define DKIOCGETBLOCKSIZE DKIOCBLKSIZE /* get media's preferred sector size */
9bccf70c
A
133#define DKIOCGETBLOCKCOUNT32 DKIOCNUMBLKS /* get media's sector count */
134#define DKIOCGETBLOCKCOUNT64 _IOR('d', 25, u_int64_t) /* get media's sector count */
1c79356b
A
135#define DKIOCGETLOCATION DKIOCGLOCATION /* get media's location description */
136#define DKIOCISFORMATTED DKIOCGFORMAT /* is media formatted? */
137#define DKIOCISWRITABLE _IOR('d', 29, int) /* is media writable? */
1c79356b 138
0b4e3aa0
A
139#define DKIOCGETMAXBLOCKCOUNTREAD _IOR('d', 64, u_int64_t) /* get device's maximum block count for read requests */
140#define DKIOCGETMAXBLOCKCOUNTWRITE _IOR('d', 65, u_int64_t) /* get device's maximum block count for write requests */
141#define DKIOCGETMAXSEGMENTCOUNTREAD _IOR('d', 66, u_int64_t) /* get device's maximum physical segment count for read buffers */
142#define DKIOCGETMAXSEGMENTCOUNTWRITE _IOR('d', 67, u_int64_t) /* get device's maximum physical segment count for write buffers */
143
9bccf70c
A
144#endif /* __APPLE_API_OBSOLETE */
145
146#endif /* _SYS_DISK_H_ */
0b4e3aa0 147#endif /* _BSD_DEV_DISK_ */