4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
33 * Definitions for Label types: L_TYPE_SOLORIS is the default Sun label
34 * a.k.a VTOC. L_TYPE_EFI is the EFI label type.
36 #define L_TYPE_SOLARIS 0
40 #define UINT_MAX64 0xffffffffffffffffULL
44 #define UINT_MAX32 0xffffffffU
47 #if !defined(_EXTVTOC)
48 #define _EXTVTOC /* extented vtoc (struct extvtoc) format is used */
52 * This file contains global definitions and declarations. It is intended
53 * to be included by everyone.
60 #include <sys/types.h>
61 #include <sys/param.h>
62 #include <sys/isa_defs.h>
64 #include <sys/dklabel.h>
68 #include "hardware_structs.h"
72 #include <sys/dktp/fdisk.h>
73 #include <sys/fcntl.h>
77 * These declarations are global state variables.
79 struct disk_info
*disk_list
; /* list of found disks */
80 struct ctlr_info
*ctlr_list
; /* list of found ctlrs */
81 char cur_menu
; /* current menu level */
82 char last_menu
; /* last menu level */
83 char option_msg
; /* extended message options */
84 char diag_msg
; /* extended diagnostic msgs */
85 char option_s
; /* silent mode option */
86 char *option_f
; /* input redirect option */
87 char *option_l
; /* log file option */
88 FILE *log_file
; /* log file pointer */
89 char *option_d
; /* forced disk option */
90 char *option_t
; /* forced disk type option */
91 char *option_p
; /* forced partition table option */
92 char *option_x
; /* data file redirection option */
93 FILE *data_file
; /* data file pointer */
94 char *file_name
; /* current data file name */
95 /* for useful error messages */
96 int expert_mode
; /* enable for expert mode */
98 int need_newline
; /* for correctly formatted output */
99 int dev_expert
; /* enable for developer mode */
103 * These declarations are used for quick access to information about
104 * the disk being worked on.
106 int cur_file
; /* file descriptor for current disk */
107 int cur_flags
; /* flags for current disk */
108 int cur_label
; /* current label type */
109 uint_t cur_blksz
; /* currect disk block size */
110 struct disk_info
*cur_disk
; /* current disk */
111 struct disk_type
*cur_dtype
; /* current dtype */
112 struct ctlr_info
*cur_ctlr
; /* current ctlr */
113 struct ctlr_type
*cur_ctype
; /* current ctype */
114 struct ctlr_ops
*cur_ops
; /* current ctlr's ops vector */
115 struct partition_info
*cur_parts
; /* current disk's partitioning */
116 struct defect_list cur_list
; /* current disk's defect list */
117 void *cur_buf
; /* current disk's I/O buffer */
118 void *pattern_buf
; /* current disk's pattern buffer */
119 uint_t pcyl
; /* # physical cyls */
120 uint_t ncyl
; /* # data cyls */
121 uint_t acyl
; /* # alt cyls */
122 uint_t nhead
; /* # heads */
123 uint_t phead
; /* # physical heads */
124 uint_t nsect
; /* # data sects/track */
125 uint_t psect
; /* # physical sects/track */
126 uint_t apc
; /* # alternates/cyl */
127 uint_t solaris_offset
; /* Solaris offset, this value is zero */
128 /* for non-fdisk machines. */
129 int prot_type
; /* protection type to format disk */
131 #if defined(_SUNOS_VTOC_16)
132 uint_t bcyl
; /* # other cyls */
133 #endif /* defined(_SUNOS_VTOC_16) */
135 struct mboot boot_sec
; /* fdisk partition info */
136 uint_t xstart
; /* solaris partition start */
137 char x86_devname
[MAXNAMELEN
]; /* saved device name for fdisk */
138 /* information accesses */
139 struct mctlr_list
*controlp
; /* master controller list ptr */
143 * These defines are used to manipulate the physical characteristics of
146 #define sectors(h) ((h) == nhead - 1 ? nsect - apc : nsect)
147 #define spc() (nhead * nsect - apc)
148 #define chs2bn(c, h, s) (((diskaddr_t)(c) * spc() + (h) * nsect + (s)))
149 #define bn2c(bn) (uint_t)((diskaddr_t)(bn) / spc())
150 #define bn2h(bn) (uint_t)(((diskaddr_t)(bn) % spc()) / nsect)
151 #define bn2s(bn) (uint_t)(((diskaddr_t)(bn) % spc()) % nsect)
152 #define datasects() (ncyl * spc())
153 #define totalsects() ((ncyl + acyl) * spc())
154 #define physsects() (pcyl * spc())
157 * Macro to convert a device number into a partition number
159 #define PARTITION(dev) (minor(dev) & 0x07)
162 * These values define flags for the current disk (cur_flags).
164 #define DISK_FORMATTED 0x01 /* disk is formatted */
165 #define LABEL_DIRTY 0x02 /* label has been scribbled */
168 * These flags are for the controller type flags field.
170 #define CF_NONE 0x0000 /* NO FLAGS */
171 #define CF_BLABEL 0x0001 /* backup labels in funny place */
172 #define CF_DEFECTS 0x0002 /* disk has manuf. defect list */
173 #define CF_APC 0x0004 /* ctlr uses alternates per cyl */
174 #define CF_SMD_DEFS 0x0008 /* ctlr does smd defect handling */
176 #define CF_SCSI 0x0040 /* ctlr is for SCSI disks */
177 #define CF_EMBEDDED 0x0080 /* ctlr is for embedded SCSI disks */
179 #define CF_IPI 0x0100 /* ctlr is for IPI disks */
180 #define CF_WLIST 0x0200 /* ctlt handles working list */
181 #define CF_NOFORMAT 0x0400 /* Manufacture formatting only */
183 * This flag has been introduced only for SPARC ATA. Which has been approved
184 * at that time with the agreement in the next fix it will be removed and the
185 * format will be revamped with controller Ops structure not to have
186 * any operation to be NULL. As it makes things more modular.
188 * This flag is also used for PCMCIA pcata driver.
189 * The flag prevents reading or writing a defect list on the disk
190 * testing and console error reporting still work normally.
191 * This is appropriate for the PCMCIA disks which often have MS/DOS filesystems
192 * and have not allocated any space for alternate cylinders to keep
193 * the bab block lists.
195 #define CF_NOWLIST 0x0800 /* Ctlr doesnot handle working list */
199 * Do not require confirmation to extract defect lists on SCSI
200 * and IPI drives, since this operation is instantaneous
202 #define CF_CONFIRM (CF_SCSI|CF_IPI)
205 * Macros to make life easier
207 #define SMD (cur_ctype->ctype_flags & CF_SMD_DEFS)
208 #define SCSI (cur_ctype->ctype_flags & CF_SCSI)
209 #define EMBEDDED_SCSI ((cur_ctype->ctype_flags & (CF_SCSI|CF_EMBEDDED)) == \
210 (CF_SCSI|CF_EMBEDDED))
213 * These flags are for the disk type flags field.
215 #define DT_NEED_SPEFS 0x01 /* specifics fields are uninitialized */
218 * These defines are used to access the ctlr specific
219 * disk type fields (based on ctlr flags).
221 #define dtype_bps dtype_specifics[0] /* bytes/sector */
222 #define dtype_dr_type dtype_specifics[1] /* drive type */
223 #define dtype_dr_type_data dtype_specifics[2] /* drive type in data file */
226 * These flags are for the disk info flags field.
228 #define DSK_LABEL 0x01 /* disk is currently labelled */
229 #define DSK_LABEL_DIRTY 0x02 /* disk auto-sensed, but not */
231 #define DSK_AUTO_CONFIG 0x04 /* disk was auto-configured */
232 #define DSK_RESERVED 0x08 /* disk is reserved by other host */
233 #define DSK_UNAVAILABLE 0x10 /* disk not available, could be */
234 /* currently formatting */
237 * These flags are used to control disk command execution.
239 #define F_NORMAL 0x00 /* normal operation */
240 #define F_SILENT 0x01 /* no error msgs at all */
241 #define F_ALLERRS 0x02 /* return any error, not just fatal */
242 #define F_RQENABLE 0x04 /* no error msgs at all */
245 * Directional parameter for the op_rdwr controller op.
251 * These defines are the mode parameter for the checksum routines.
253 #define CK_CHECKSUM 0 /* check checksum */
254 #define CK_MAKESUM 1 /* generate checksum */
257 * This is the base character for partition identifiers
259 #define PARTITION_BASE '0'
262 * Base pathname for devfs names to be stripped from physical name.
264 #define DEVFS_PREFIX "/devices"
267 * Protection type by SCSI-3
269 #define PROT_TYPE_0 0
270 #define PROT_TYPE_1 1
271 #define PROT_TYPE_2 2
272 #define PROT_TYPE_3 3
273 #define NUM_PROT_TYPE 4
276 * Function prototypes ... Both for ANSI and non-ANSI C compilers
280 int copy_solaris_part(struct ipart
*);
281 int good_fdisk(void);
282 int fdisk_physical_name(char *);
286 int copy_solaris_part();
288 int fdisk_physical_name();
290 #endif /* __STDC__ */
296 #endif /* _GLOBAL_H */