1/*
2 * Copyright (c) 2001-2007 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24/*
25 *  bless_private.h
26 *  bless
27 *
28 *  Created by Shantonu Sen <ssen@apple.com> on Wed Feb 28 2002.
29 *  Copyright (c) 2002-2007 Apple Inc. All Rights Reserved.
30 *
31 *  $Id: bless_private.h,v 1.22 2006/05/31 22:30:26 ssen Exp $
32 *
33 */
34
35#ifndef _BLESS_PRIVATE_H_
36#define _BLESS_PRIVATE_H_
37
38#include <sys/types.h>
39#include <sys/mount.h>
40#include <sys/cdefs.h>
41#include <TargetConditionals.h>
42#include <AvailabilityMacros.h>
43
44#include "bless.h"
45
46#define kBootBlocksSize 1024
47#define kBootBlockTradOSSig 0x4c4b
48
49#ifndef BLESS_EMBEDDED
50#if defined(TARGET_OS_EMBEDDED) && TARGET_OS_EMBEDDED
51#define BLESS_EMBEDDED 1
52#else
53#define BLESS_EMBEDDED 0
54#endif
55#endif
56
57#if BLESS_EMBEDDED
58
59#define USE_DISKARBITRATION		0
60#define USE_CORETEXT			0
61#define USE_COREGRAPHICS		0
62#define USE_MEDIAKIT			0
63#define SUPPORT_RAID			0
64#define	SUPPORT_APPLE_PARTITION_MAP	0
65#define SUPPORT_CSM_LEGACY_BOOT 0
66
67#else
68
69#define USE_DISKARBITRATION		1
70#if defined(MAC_OS_X_VERSION_10_5) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
71#define USE_CORETEXT			1
72#else
73#define USE_CORETEXT			0
74#endif
75#define USE_COREGRAPHICS		1
76#define USE_MEDIAKIT			1
77#define SUPPORT_RAID			1
78#define	SUPPORT_APPLE_PARTITION_MAP	1
79#define SUPPORT_CSM_LEGACY_BOOT 1
80
81#endif
82
83#if DISABLE_DISK_ARBITRATION
84#undef  USE_DISKARBITRATION
85#define USE_DISKARBITRATION		0
86#endif
87
88/*
89 * Internal support for EFI routines shared between tool & library.
90 */
91int setefidevice(BLContextPtr context, const char * bsdname, int bootNext,
92                 int bootLegacy, const char *legacyHint,
93				 const char *optionalData, bool shortForm);
94int setefifilepath(BLContextPtr context, const char * path, int bootNext,
95                                   const char *optionalData, bool shortForm);
96int setefinetworkpath(BLContextPtr context, CFStringRef booterXML,
97                      CFStringRef kernelXML, CFStringRef mkextXML,
98					  CFStringRef kernelcacheXML, int bootNext);
99int efinvramcleanup(BLContextPtr context);
100int setit(BLContextPtr context, mach_port_t masterPort, const char *bootvar,
101		  CFStringRef xmlstring);
102int _forwardNVRAM(BLContextPtr context, CFStringRef from, CFStringRef to);
103
104
105/* Calculate a shift-1-left & add checksum of all
106 * 32-bit words
107 */
108uint32_t BLBlockChecksum(const void *buf , uint32_t length);
109
110/*
111 * write the CFData to a file
112 */
113int BLCopyFileFromCFData(BLContextPtr context, const CFDataRef data,
114	     				 const char * dest, int shouldPreallocate);
115
116/*
117 * convert to a char * description
118 */
119char *BLGetCStringDescription(CFTypeRef typeRef);
120
121/*
122 * check if the context is null. if not, check if the log function is null
123 */
124int contextprintf(BLContextPtr context, int loglevel, char const *fmt, ...) __printflike(3, 4);;
125
126/*
127 * stringify the OSType into the caller-provided buffer
128 */
129char * blostype2string(uint32_t type, char buf[5]);
130
131// statfs wrapper that works in single user mode,
132// where the mount table hasn't been updated with the
133// proper dev node
134int blsustatfs(const char *path, struct statfs *buf);
135
136// Open raw DVD data and search for the first UEFI boot image; returns false if no for any reason,
137// including if the given disk is not even a DVD, or if no ElTorito header, or if no boot image
138// pointed to by the ElTorito structures. If you get false you should assume the disk to be anything
139// else worthy of consideration, such as even a MacOSX disc. If you get true then output fields
140// give info that, when converted to XML form and put in the IOReg->NVRAM, will command EFI to boot it.
141bool isDVDWithElToritoWithUEFIBootableOS (BLContextPtr inContext, const char* inDevBSD, int* outBootEntry, int* outPartitionStart, int* outPartitionSize);
142
143#endif // _BLESS_PRIVATE_H_
144