17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*db92b35aSGary Mills  * Copyright (c) 2011 Gary Mills
24*db92b35aSGary Mills  *
257c478bd9Sstevel@tonic-gate  * Copyright (c) 1999 by Sun Microsystems, Inc.
267c478bd9Sstevel@tonic-gate  * All rights reserved.
277c478bd9Sstevel@tonic-gate  */
297c478bd9Sstevel@tonic-gate #ifndef _PCFS_COMMON_H
307c478bd9Sstevel@tonic-gate #define	_PCFS_COMMON_H
327c478bd9Sstevel@tonic-gate /*
337c478bd9Sstevel@tonic-gate  * Common routines for the pcfs user-level utilities
347c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate #ifdef __cplusplus
377c478bd9Sstevel@tonic-gate extern "C" {
387c478bd9Sstevel@tonic-gate #endif
407c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
417c478bd9Sstevel@tonic-gate #include <sys/types.h>
427c478bd9Sstevel@tonic-gate #include <sys/stat.h>
43*db92b35aSGary Mills #include <sys/sysmacros.h>
447c478bd9Sstevel@tonic-gate #include "pcfs_bpb.h"
46*db92b35aSGary Mills #define	IN_RANGE(n, x, y) (((n) >= (x)) && ((n) <= (y)))
47*db92b35aSGary Mills 
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  *  A macro implementing a ceiling function for integer divides.
507c478bd9Sstevel@tonic-gate  */
517c478bd9Sstevel@tonic-gate #define	idivceil(dvend, dvsor) \
527c478bd9Sstevel@tonic-gate 	((dvend)/(dvsor) + (((dvend)%(dvsor) == 0) ? 0 : 1))
547c478bd9Sstevel@tonic-gate /*
557c478bd9Sstevel@tonic-gate  * These defines should move into a kernel header file eventually
567c478bd9Sstevel@tonic-gate  * and pcfs_mount may want to refuse to mount FAT32's that aren't "clean"
577c478bd9Sstevel@tonic-gate  *
587c478bd9Sstevel@tonic-gate  *	If Windows shuts down properly it sets the fourth bit of the 8th
597c478bd9Sstevel@tonic-gate  *	and final reserved byte at the start of the FAT.
607c478bd9Sstevel@tonic-gate  */
617c478bd9Sstevel@tonic-gate #define	WIN_SHUTDOWN_STATUS_BYTE	7
627c478bd9Sstevel@tonic-gate #define	WIN_SHUTDOWN_BIT_MASK		0x8
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  *  Define some special logical drives we use.
667c478bd9Sstevel@tonic-gate  */
677c478bd9Sstevel@tonic-gate #define	BOOT_PARTITION_DRIVE	99
687c478bd9Sstevel@tonic-gate #define	PRIMARY_DOS_DRIVE	1
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * Function prototypes
727c478bd9Sstevel@tonic-gate  */
737c478bd9Sstevel@tonic-gate extern off64_t findPartitionOffset(int fd, char *ldrive);
747c478bd9Sstevel@tonic-gate extern char *stat_actual_disk(char *diskname, struct stat *info, char **suffix);
757c478bd9Sstevel@tonic-gate extern void header_for_dump(void);
767c478bd9Sstevel@tonic-gate extern void store_16_bits(uchar_t **bp, uint32_t v);
777c478bd9Sstevel@tonic-gate extern void store_32_bits(uchar_t **bp, uint32_t v);
787c478bd9Sstevel@tonic-gate extern void read_16_bits(uchar_t *bp, uint32_t *value);
797c478bd9Sstevel@tonic-gate extern void read_32_bits(uchar_t *bp, uint32_t *value);
807c478bd9Sstevel@tonic-gate extern void missing_arg(char *option);
817c478bd9Sstevel@tonic-gate extern void dump_bytes(uchar_t *b, int n);
827c478bd9Sstevel@tonic-gate extern void bad_arg(char *option);
837c478bd9Sstevel@tonic-gate extern void usage(void);
847c478bd9Sstevel@tonic-gate extern int  yes(void);
867c478bd9Sstevel@tonic-gate /*
877c478bd9Sstevel@tonic-gate  *	The assumption here is that _BIG_ENDIAN implies sparc, and
887c478bd9Sstevel@tonic-gate  *	so in addition to swapping bytes we also have to construct
897c478bd9Sstevel@tonic-gate  *	packed structures by hand to avoid bus errors due to improperly
907c478bd9Sstevel@tonic-gate  *	aligned pointers.
917c478bd9Sstevel@tonic-gate  */
927c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN
937c478bd9Sstevel@tonic-gate extern void swap_pack_grab32bpb(bpb_t *wbpb, struct _boot_sector *bsp);
947c478bd9Sstevel@tonic-gate extern void swap_pack_grabbpb(bpb_t *wbpb, struct _boot_sector *bsp);
957c478bd9Sstevel@tonic-gate #endif	/* _BIG_ENDIAN */
977c478bd9Sstevel@tonic-gate #ifdef __cplusplus
987c478bd9Sstevel@tonic-gate }
997c478bd9Sstevel@tonic-gate #endif
1017c478bd9Sstevel@tonic-gate #endif /* _PCFS_COMMON_H */