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.h 26 * bless 27 * 28 * Created by Shantonu Sen <ssen@apple.com> on Wed Feb 21 2002. 29 * Copyright (c) 2002-2007 Apple Inc. All Rights Reserved. 30 * 31 * $Id: bless.h,v 1.79 2006/07/19 00:15:38 ssen Exp $ 32 * 33 */ 34 35#ifndef _BLESS_H_ 36#define _BLESS_H_ 37 38#include <CoreFoundation/CoreFoundation.h> 39#include <IOKit/IOKitLib.h> 40 41#include <sys/types.h> 42#include <stdint.h> 43#include <stdbool.h> 44#include <sys/cdefs.h> 45 46__BEGIN_DECLS 47 48/*! 49 * @header Bless Library 50 * @discussion Common functions for setting on-disk and Open Firmware-base 51 * bootability options 52 */ 53 54/***** Structs *****/ 55 56/*! 57 * @struct BLContext 58 * @abstract Bless Library Context 59 * @discussion Each thread of a multi-threaded program should 60 * have their own bless context, which is the first argument 61 * to all functions in the Bless Library. Only one function 62 * should be performed with a given context at the same time, 63 * although multiple functions can be called simultaneously if 64 * they are provided unique contexts. All bless functions can 65 * be called with a null context, or a non-null context with 66 * a null <b>logstring</b> member. a null <b>logrefcon</b> 67 * may or may not be allowed depending on the user-defined 68 * <b>logstring</b> function. 69 * @field version version of BLContext in use by client. Currently 70 * 0 71 * @field logstring function used for messages from the library. It 72 * will be called with <b>logrefcon</b> and a log level, which 73 * can be used to tailor the output 74 * @field logrefcon arbitrary data passed to <b>logrefcon</b> 75 */ 76typedef struct { 77 int32_t version; 78 int32_t (*logstring)(void *refcon, int32_t level, char const *string); 79 void *logrefcon; 80} BLContext, *BLContextPtr; 81 82/*! 83 * @define kBLLogLevelNormal 84 * @discussion Normal output indicating status 85 */ 86#define kBLLogLevelNormal 0x00000001 87 88/*! 89 * @define kBLLogLevelVerbose 90 * @discussion Verbose output for greater feedback 91 */ 92#define kBLLogLevelVerbose 0x00000002 93 94/*! 95 * @define kBLLogLevelError 96 * @discussion Error output for warnings and unexpected conditions 97 */ 98#define kBLLogLevelError 0x00000004 99 100/***** Constants *****/ 101 102/*! 103 * @define kBL_PATH_PPC_BOOTBLOCKDATA 104 * @discussion Boot blocks for Darwin PPC on HFS/HFS+ partitions 105 */ 106#define kBL_PATH_PPC_BOOTBLOCKDATA "/usr/share/misc/bootblockdata" 107 108/*! 109 * @define kBL_PATH_PPC_CDBOOTDATA 110 * @discussion Fake System file for an HFS+ wrapper to repatch OF 111 */ 112#define kBL_PATH_PPC_CDBOOTDATA "/usr/share/misc/cdblockdata" 113 114/*! 115 * @define kBL_PATH_PPC_HDBOOTDATA 116 * @discussion Fake System file for an HFS+ volume to repatch OF 117 */ 118#define kBL_PATH_PPC_HDBOOTDATA "/usr/share/misc/hdblockdata" 119 120/*! 121 * @define kBL_PATH_PPC_BOOTX_XCOFF 122 * @discussion XCOFF format Secondary loader for Old World 123 */ 124#define kBL_PATH_PPC_BOOTX_XCOFF "/usr/standalone/ppc/bootx.xcoff" 125 126/*! 127 * @define kBL_PATH_PPC_BOOTX_BOOTINFO 128 * @discussion bootinfo format Secondary loader for New World 129 */ 130#define kBL_PATH_PPC_BOOTX_BOOTINFO "/usr/standalone/ppc/bootx.bootinfo" 131 132/*! 133 * @define kBL_PATH_CORESERVICES 134 * @discussion Default blessed system folder for Mac OS X 135 */ 136#define kBL_PATH_CORESERVICES "/System/Library/CoreServices" 137 138/*! 139 * @define kBL_PATH_I386_BOOT0 140 * @discussion MBR boot code 141 */ 142#define kBL_PATH_I386_BOOT0 "/usr/standalone/i386/boot0" 143 144/*! 145 * @define kBL_PATH_I386_BOOT1HFS 146 * @discussion partition boot record boot code for HFS+ 147 */ 148#define kBL_PATH_I386_BOOT1HFS "/usr/standalone/i386/boot1h" 149 150/*! 151 * @define kBL_PATH_I386_BOOT1UFS 152 * @discussion partition boot record boot code for UFS 153 */ 154#define kBL_PATH_I386_BOOT1UFS "/usr/standalone/i386/boot1u" 155 156/*! 157 * @define kBL_PATH_I386_BOOT2 158 * @discussion Second stage loader for Darwin x86 on BIOS-based systems 159 */ 160#define kBL_PATH_I386_BOOT2 "/usr/standalone/i386/boot" 161 162/*! 163 * @define kBL_PATH_I386_BOOT_EFI 164 * @discussion Booter for Darwin x86 on EFI-based systems 165 */ 166#define kBL_PATH_I386_BOOT_EFI "/usr/standalone/i386/boot.efi" 167 168/*! 169 * @define kBL_PATH_I386_BOOT2_CONFIG_PLIST 170 * @discussion Second stage loader config file for Darwin x86 171 */ 172#define kBL_PATH_I386_BOOT2_CONFIG_PLIST "/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" 173 174 175/*! 176 * @define kBL_OSTYPE_PPC_TYPE_BOOTX 177 * @discussion HFS+ type for Secondary loader for New World 178 */ 179#define kBL_OSTYPE_PPC_TYPE_BOOTX 'tbxi' 180 181/*! 182 * @define kBL_OSTYPE_PPC_TYPE_OFLABEL 183 * @discussion HFS+ type for OpenFirmware volume label 184 */ 185#define kBL_OSTYPE_PPC_TYPE_OFLABEL 'tbxj' 186 187 188/*! 189* @define kBL_OSTYPE_PPC_TYPE_OFLABEL_PLACEHOLDER 190 * @discussion Placeholder for OpenFirmware volume label 191 */ 192#define kBL_OSTYPE_PPC_TYPE_OFLABEL_PLACEHOLDER 'xxxx' 193 194/*! 195 * @define kBL_OSTYPE_PPC_CREATOR_CHRP 196 * @discussion HFS+ creator for all OF support files 197 */ 198#define kBL_OSTYPE_PPC_CREATOR_CHRP 'chrp' 199 200/***** Enumerations *****/ 201 202typedef enum { 203 204 kBLPartitionType_None = 0x00000001, 205 206 kBLPartitionType_MBR = 0x00000002, 207 208 kBLPartitionType_APM = 0x00000004, 209 210 kBLPartitionType_GPT = 0x00000008 211 212} BLPartitionType; 213 214typedef enum { 215 216 kBLBootRootRole_Unknown = 0x00000001, 217 218 kBLBootRootRole_None = 0x00000002, 219 220 kBLBootRootRole_AuxiliaryPartition = 0x00000004, 221 222 kBLBootRootRole_MemberPartition = 0x00000008, 223 224 kBLBootRootRole_BootRootDevice = 0x00000010, 225 226} BLBootRootRole; 227 228typedef enum { 229 230 kBLPreBootEnvType_Unknown = 0x00000001, 231 232 kBLPreBootEnvType_OpenFirmware = 0x00000002, 233 234 kBLPreBootEnvType_BIOS = 0x00000004, 235 236 kBLPreBootEnvType_EFI = 0x00000008, 237 238 kBLPreBootEnvType_iBoot = 0x00000010, 239 240} BLPreBootEnvType; 241 242typedef enum { 243 244 kBLNetBootProtocol_Unknown = 0x00000001, 245 246 kBLNetBootProtocol_BSDP = 0x00000002, 247 248 kBLNetBootProtocol_PXE = 0x00000004 249 250} BLNetBootProtocolType; 251 252 253enum { 254 kBitmapScale_1x = 1, 255 kBitmapScale_2x = 2 256}; 257 258/***** FinderInfo *****/ 259 260/*! 261 * @function BLCreateVolumeInformationDictionary 262 * @abstract Gather bootability information on a volume 263 * @discussion Return information on the volume at <b>mount</b>, 264 * including blessed folder IDs and paths, UUID, 265 * and return it as a CFDictionary 266 * @param context Bless Library context 267 * @param mount mountpoint of volume to gather information on 268 * @param outDict result dictionary 269 */ 270int BLCreateVolumeInformationDictionary(BLContextPtr context, 271 const char * mountpoint, 272 CFDictionaryRef *outDict); 273 274/*! 275 * @function BLGetFinderFlag 276 * @abstract Fetch Finder flags for a file/directory 277 * @discussion Get the value of the flag <b>flag</b>, as defined 278 * <CoreServices/.../CarbonCore/Finder.h>, for the file 279 * or directory <b>path</b> 280 * @param context Bless Library context 281 * @param path a file or directory 282 * @param flag bitmask of flag to be fetched 283 * @param retval value of <b>flag</b> for <b>path</b>. 284 */ 285int BLGetFinderFlag(BLContextPtr context, 286 const char * path, 287 uint16_t flag, 288 int *retval); 289/*! 290 * @function BLSetFinderFlag 291 * @abstract Set Finder flags for a file/directory 292 * @discussion Set the value of the flag <b>flag</b>, as defined 293 * <CoreServices/.../CarbonCore/Finder.h>, for the file 294 * or directory <b>path</b> 295 * @param context Bless Library context 296 * @param path a file or directory 297 * @param flag bitmask of flag to be set 298 * @param setval value of <b>flag</b> for <b>path</b>. 299 */ 300int BLSetFinderFlag(BLContextPtr context, 301 const char * path, 302 uint16_t flag, 303 int setval); 304 305/*! 306 * @function BLGetVolumeFinderInfo 307 * @abstract Get Finder info words for a volume 308 * @discussion Get the Finder info words for a volume, 309 * which specifies the dirIDs of blessed system 310 * folders for Open Firmware to set 311 * @param context Bless Library context 312 * @param mountpoint mountpoint of volume 313 * @param words array of at least length 8 314 * (directory IDs in host endianness) 315 */ 316int BLGetVolumeFinderInfo(BLContextPtr context, 317 const char * mountpoint, 318 uint32_t * words); 319 320/*! 321 * @function BLSetVolumeFinderInfo 322 * @abstract Set Finder info words for a volume 323 * @discussion Set the Finder info words for a volume, 324 * which specifies the dirIDs of blessed system 325 * folders for Open Firmware to set 326 * @param context Bless Library context 327 * @param mountpoint mountpoint of volume 328 * @param words array of at least length 6, which will 329 * replace the first 6 words on-disk 330 * (directory IDs in host endianness) 331 */ 332int BLSetVolumeFinderInfo(BLContextPtr context, 333 const char * mountpoint, 334 uint32_t * words); 335 336/*! 337 * @function BLSetTypeAndCreator 338 * @abstract Set the HFS Type and Creator for a file 339 * @discussion Set te HFS Type and Creator for 340 * a file using the OSType's <b>type</b> 341 * and <b>creator</b> 342 * @param context Bless Library context 343 * @param path file to set 344 * @param type OSType with type 345 * @param creator OSType with creator 346 */ 347int BLSetTypeAndCreator(BLContextPtr context, 348 const char * path, 349 uint32_t type, 350 uint32_t creator); 351 352/***** HFS *****/ 353 354/*! 355 * @function BLBlessDir 356 * @abstract Bless the volume 357 * @discussion Bless the volume, using <b>dirX</b> 358 * for <i>finderinfo[5]</i>, <b>dir9</b> 359 * for <i>finderinfo[3]</i>, and selecting one 360 * of them for <i>finderinfo[0]</i> based 361 * on <b>useX</b> 362 * @param context Bless Library context 363 * @param mountpoint mountpoint of volume 364 * @param dirX directory ID of Mac OS X 365 * <i>/System/Library/CoreServices</i> 366 * folder 367 * @param dir9 directory ID of Mac OS 9 368 * <i>/System Folder</i> folder 369 * @param useX preferentially use <b>dirX</b> 370 * for <i>finderinfo[0]</i>, which is 371 * the only thing Open Firmware uses for 372 * loading the secondary loader 373 */ 374 375int BLBlessDir(BLContextPtr context, 376 const char * mountpoint, 377 uint32_t dirX, 378 uint32_t dir9, 379 int useX); 380 381/*! 382 * @function BLGetFileID 383 * @abstract Get the file ID for a file 384 * @discussion Get the file ID for a file, 385 * relative to the volume its on 386 * @param context Bless Library context 387 * @param path path to file 388 * @param folderID file ID of <b>path</b> 389 */ 390int BLGetFileID(BLContextPtr context, 391 const char * path, 392 uint32_t *folderID); 393 394/*! 395 * @function BLIsMountHFS 396 * @abstract Test if the volume is HFS/HFS+ 397 * @discussion Perform a statfs(2) on the 398 * the volume at <b>mountpoint</b> and 399 * report whether it is an HFS/HFS+ volume 400 * @param context Bless Library context 401 * @param mountpt Mountpoint of volume 402 * @param isHFS is the mount hfs? 403 */ 404int BLIsMountHFS(BLContextPtr context, 405 const char * mountpt, 406 int *isHFS); 407 408/*! 409 * @function BLLookupFileIDOnMount 410 * @abstract Get path of file with ID <b>fileID</b> 411 * on <b>mount</b> 412 * @discussion Use volfs to do reverse-resolution of 413 * <b>fileID</b> on <b>mount</b> to a full path 414 * @param context Bless Library context 415 * @param mount Mountpoint of volume 416 * @param fileID file ID to look up 417 * @param out resulting path (up to MAXPATHLEN characeters will be written) 418 */ 419int BLLookupFileIDOnMount(BLContextPtr context, 420 const char * mountpoint, 421 uint32_t fileID, 422 char * out); 423 424 425/*! 426 * @function BLGetDiskSectorsForFile 427 * @abstract Determine the on-disk location of a file 428 * @discussion Get the HFS/HFS+ extents for the 429 * file <b>path</b>, and translate it to 512-byte 430 * sector start/length pairs, relative to the beginning 431 * of the partition. 432 * @param context Bless Library context 433 * @param path path to file 434 * @param extents array to hold start/length pairs for disk extents 435 * @param device filled in with the device the extent information applies to 436 * @param length of buffer provided for device parameter 437 */ 438 439int BLGetDiskSectorsForFile(BLContextPtr context, 440 const char * path, 441 off_t extents[8][2], 442 char * device, 443 int deviceLen); 444 445/***** Misc *****/ 446 447 448/*! 449 * @function BLCreateFile 450 * @abstract Create a new file with contents of old one 451 * @discussion Copy <b>source</b> to <b>dest</b>/<b>file</b>, 452 * with the new file being contiguously allocated. 453 * Optionally, write the data into the resource fork 454 * of the destination 455 * @param context Bless Library context 456 * @param data source data 457 * @param file destination file 458 * @param setImmutable mark new file with "uchg" flag 459 * @param type an OSType representing the type of the new file 460 * @param creator an OSType representing the creator of the new file 461 */ 462int BLCreateFile(BLContextPtr context, 463 const CFDataRef data, 464 const char * file, 465 int setImmutable, 466 uint32_t type, 467 uint32_t creator); 468 469/*! 470 * @function BLGetCommonMountPoint 471 * @abstract Get the volume that both paths reside on 472 * @discussion Determine the mountpoint command 473 * to both paths 474 * @param context Bless Library context 475 * @param f1 First path 476 * @param f2 Second path 477 * @param mountp Resulting mount path 478 */ 479int BLGetCommonMountPoint(BLContextPtr context, 480 const char * f1, 481 const char * f2, 482 char * mountp); 483 484/*! 485 * @function BLGetParentDevice 486 * @abstract Get the parent of a leaf device 487 * @discussion Get the parent whole device for 488 * a leaf device, and return which slice this is 489 * @param context Bless Library context 490 * @param partitionDev partition to use 491 * @param parentDev parent partition of <b>partitionDev</b> 492 * @param partitionNum which partition of <b>parentDev</b> 493 * is <b>partitionDev</b> 494 */ 495int BLGetParentDevice(BLContextPtr context, 496 const char * partitionDev, 497 char * parentDev, 498 uint32_t *partitionNum); 499 500/*! 501* @function BLGetParentDeviceAndPartitionType 502 * @abstract Get the parent and type of a leaf device 503 * @discussion Get the parent whole device for 504 * a leaf device, and return which slice this is. Als 505 * what type of container it is 506 * @param context Bless Library context 507 * @param partitionDev partition to use 508 * @param parentDev parent partition of <b>partitionDev</b> 509 * @param partitionNum which partition of <b>parentDev</b> 510 * is <b>partitionDev</b> 511 * @param pmapType the partition type 512 */ 513int BLGetParentDeviceAndPartitionType(BLContextPtr context, 514 const char * partitionDev, 515 char * parentDev, 516 uint32_t *partitionNum, 517 BLPartitionType *pmapType); 518 519 520/*! 521 * @function BLIsNewWorld 522 * @abstract Is the machine a New World machine 523 * @discussion Get the hardware type of the 524 * current machine. Deprecated, since it 525 * only applies to OpenFirmware-based systems 526 * @param context Bless Library context 527 */ 528int BLIsNewWorld(BLContextPtr context); 529 530/*! 531 * @function BLGenerateOFLabel 532 * @abstract Generate a bitmap label 533 * @discussion Use CoreGraphics to render 534 * a bitmap for an OF label 535 * @param context Bless Library context 536 * @param label UTF-8 encoded text to use 537 * @param data bitmap data 538 */ 539int BLGenerateOFLabel(BLContextPtr context, 540 const char * label, 541 CFDataRef *data) DEPRECATED_ATTRIBUTE ; 542 543/*! 544 * @function BLGenerateLabelData 545 * @abstract Generate a bitmap label from the given string 546 * @discussion Use CoreGraphics to render 547 * a bitmap for a label suitable for display 548 * by the firmware picker. 549 * @param context Bless Library context 550 * @param label UTF-8 encoded text to use 551 * @param scale How big the bitmap should be. kBitmapScale_1x for standard, kBitmapScale_2x for HiDPI 552 * @param data bitmap data returned to caller; must be released by caller. 553 */ 554int BLGenerateLabelData(BLContextPtr context, const char *label, int scale, CFDataRef *data); 555 556 557 558/*! 559 * @function BLSetOFLabelForDevice 560 * @abstract Set the OpenFirmware label for an 561 * unmounted volume 562 * @discussion Use MediaKit to analyze an HFS+ 563 * volume header and catalog to find the OF 564 * label, and if it exists write the new data. 565 * If an existing label is not present, or if 566 * the on-disk allocated extent is too small, 567 * return an error 568 * @param context Bless Library context 569 * @param device an HFS+ (wrapped or not) device node 570 * @param label a correctly formatted OF label, 571 * as returned by BLGenerateOFLabel 572 */ 573int BLSetOFLabelForDevice(BLContextPtr context, 574 const char * device, 575 const CFDataRef label) DEPRECATED_ATTRIBUTE ; 576 577 578 579/*! 580 * @function BLSetDiskLabelForDevice 581 * @abstract Set the disk label (displayed by the firmware picker) 582 * for an unmounted volume 583 * @discussion Use MediaKit to analyze an HFS+ 584 * volume header and catalog to find the disk 585 * label, and if it exists write the new data. 586 * If an existing label is not present, or if 587 * the on-disk allocated extent is too small, 588 * return an error 589 * @param context Bless Library context 590 * @param device an HFS+ (wrapped or not) device node 591 * @param label a correctly formatted disk label, 592 * @param scale how big the bitmap should be. kBitmapScale_1x for standard, kBitmapScale_2x for HiDPI 593 * as returned by BLGenerateLabelData 594 */ 595int BLSetDiskLabelForDevice(BLContextPtr context, 596 const char *device, 597 const CFDataRef label, 598 int scale); 599 600 601 602/*! 603 * @function BLLoadFile 604 * @abstract Load the contents of a file into a CFDataRef 605 * @discussion use URLAccess to load <b>src</b> into 606 * a newly allocated CFDataRef. Caller must release 607 * it. 608 * @param context Bless Library context 609 * @param src path to source 610 * @param useRsrcFork whether to copy data from resource fork 611 * @param data pointer to new data 612 */ 613int BLLoadFile(BLContextPtr context, 614 const char * src, 615 int useRsrcFork, 616 CFDataRef* data); 617 618/*! 619 @function 620 @abstract Determine pre-boot environment 621 @discussion Determine the pre-boot environment type in 622 order to set the active boot partition, which requires 623 communicating information to the pre-boot environment, either 624 directly via nvram, or indirectly via on-disk files/locations. 625 * @param context Bless Library context 626 * @param pbType type of environment 627 * @result 0 on success 628*/ 629 630int BLGetPreBootEnvironmentType(BLContextPtr context, 631 BLPreBootEnvType *pbType); 632 633 634/***** OpenFirmware *****/ 635 636/*! 637 * @function BLIsOpenFirmwarePresent 638 * @abstract Does the host use Open Firmware 639 * @discussion Attempts to access the IODeviceTree 640 * plane to see if Open Firmware is present 641 * @param context Bless Library context 642 */ 643int BLIsOpenFirmwarePresent(BLContextPtr context); 644 645/*! 646 * @function BLGetOpenFirmwareBootDevice 647 * @abstract Determine the <i>boot-device</i> 648 * string for a partition 649 * @discussion Determine the OF path to 650 * boot from a partition. If the partition 651 * is not HFS+, point to the secondary loader 652 * partition 653 * @param context Bless Library context 654 * @param mntfrm partition device to use 655 * @param ofstring resulting OF string 656 */ 657int BLGetOpenFirmwareBootDevice(BLContextPtr context, 658 const char * mntfrm, 659 char * ofstring); 660 661/*! 662 * @function BLGetOpenFirmwareBootDeviceForMountPoint 663 * @abstract Determine to <i>boot-device</i> 664 * string for a mountpoint 665 * @discussion Determine the OF path to 666 * boot from a partition. If the partition 667 * is not HFS+, point to the secondary loader 668 * partition 669 * @param context Bless Library context 670 * @param mountpoint mountpoint to use 671 * @param ofstring resulting OF string 672 */ 673int BLGetOpenFirmwareBootDeviceForMountPoint(BLContextPtr context, 674 const char * mountpoint, 675 char * ofstring); 676 677int BLGetOpenFirmwareBootDeviceForNetworkPath(BLContextPtr context, 678 const char *interface, 679 const char *host, 680 const char *path, 681 char * ofstring); 682 683/*! 684 * @function BLSetOpenFirmwareBootDevice 685 * @abstract Set OF <i>boot-device</i> 686 * to boot from a device 687 * @discussion Set the OF path to 688 * boot from a partition. If the partition 689 * is not HFS+, point to the secondary loader 690 * partition 691 * @param context Bless Library context 692 * @param mntfrm device to use 693 */ 694int BLSetOpenFirmwareBootDevice(BLContextPtr context, 695 const char * mntfrm); 696 697/*! 698 * @function BLSetOpenFirmwareBootDevice 699 * @abstract Set OF <i>boot-device</i> 700 * to boot from a mountpoint 701 * @discussion Set the OF path to 702 * boot from a partition. If the partition 703 * is not HFS+, point to the secondary loader 704 * partition 705 * @param context Bless Library context 706 * @param mountpoint mountpoint to use 707 */ 708int BLSetOpenFirmwareBootDeviceForMountPoint(BLContextPtr context, 709 const char * mountpoint); 710 711 712/*! 713 * @function BLGetDeviceForOpenFirmwarePath 714 * @abstract Convert an OF string to a mountpoint 715 * @discussion Determine which mountpoint corresponds 716 * to an OF <b>boot-device</b> string 717 * @param context Bless Library context 718 * @param ofstring OF string 719 * @param mntfrm resulting mountpoint 720 */ 721int BLGetDeviceForOpenFirmwarePath(BLContextPtr context, 722 const char * ofstring, 723 char * mntfrm) DEPRECATED_ATTRIBUTE; 724 725 726int BLCopyOpenFirmwareNVRAMVariableAsString(BLContextPtr context, 727 CFStringRef name, 728 CFStringRef *value); 729 730/* RAID info */ 731int BLGetRAIDBootDataForDevice(BLContextPtr context, const char * device, 732 CFTypeRef *bootData); 733int BLUpdateRAIDBooters(BLContextPtr context, const char * device, 734 CFTypeRef bootData, 735 CFDataRef bootxData, CFDataRef labelData); 736 737typedef struct { 738 uint32_t version; 739 uint32_t reqType; 740 uint32_t reqCreator; 741 uint32_t reqParentDir; 742 char * reqFilename; 743 744 CFDataRef payloadData; 745 746 uint32_t postType; 747 uint32_t postCreator; 748 749 uint8_t foundFile; 750 uint8_t updatedFile; 751 752} BLUpdateBooterFileSpec; 753 754int BLUpdateBooter(BLContextPtr context, const char * device, 755 BLUpdateBooterFileSpec *specs, 756 int32_t specCount); 757 758int BLGetIOServiceForDeviceName(BLContextPtr context, const char * devName, 759 io_service_t *service); 760 761int BLDeviceNeedsBooter(BLContextPtr context, const char * device, 762 int32_t *needsBooter, 763 int32_t *isBooter, 764 io_service_t *booterPartition); 765 766// if want to netboot but don't know what interface to use, 767// use this function. name ifname must be > IF_NAMESIZE 768int BLGetPreferredNetworkInterface(BLContextPtr context, 769 char *ifname); 770 771bool BLIsValidNetworkInterface(BLContextPtr context, 772 const char *ifname); 773 774// optionalData is optional 775int BLCreateEFIXMLRepresentationForPath(BLContextPtr context, 776 const char *path, 777 const char *optionalData, 778 CFStringRef *xmlString, 779 bool shortForm); 780 781int BLCreateEFIXMLRepresentationForDevice(BLContextPtr context, 782 const char *bsdName, 783 const char *optionalData, 784 CFStringRef *xmlString, 785 bool shortForm); 786 787int BLCreateEFIXMLRepresentationForLegacyDevice(BLContextPtr context, 788 const char *bsdName, 789 CFStringRef *xmlString); 790 791int BLCreateEFIXMLRepresentationForElToritoEntry(BLContextPtr context, 792 const char *bsdName, 793 int bootEntry, 794 int partitionStart, 795 int partitionSize, 796 CFStringRef *xmlString); 797 798int BLCreateEFIXMLRepresentationForNetworkPath(BLContextPtr context, 799 BLNetBootProtocolType protocol, 800 const char *interface, 801 const char *host, 802 const char *path, 803 const char *optionalData, 804 CFStringRef *xmlString); 805 806// interface must point to a buffer at least IF_NAMESIZE chars long. 807// host must point to a buffer at least NS_MAXDNAME chars long. 808int BLInterpretEFIXMLRepresentationAsNetworkPath(BLContextPtr context, 809 CFStringRef xmlString, 810 BLNetBootProtocolType *protocol, 811 char *interface, 812 char *host, 813 char *path); 814 815int BLInterpretEFIXMLRepresentationAsDevice(BLContextPtr context, 816 CFStringRef xmlString, 817 char *bsdName, 818 int bsdNameLen); 819 820int BLInterpretEFIXMLRepresentationAsLegacyDevice(BLContextPtr context, 821 CFStringRef xmlString, 822 char *bsdName, 823 int bsdNameLen); 824 825int BLCopyEFINVRAMVariableAsString(BLContextPtr context, 826 CFStringRef name, 827 CFStringRef *value); 828 829int BLValidateXMLBootOption(BLContextPtr context, 830 CFStringRef xmlName, 831 CFStringRef binaryName); 832 833kern_return_t BLSetEFIBootDevice(BLContextPtr context, char *bsdName); 834kern_return_t BLSetEFIBootDeviceOnce(BLContextPtr context, char *bsdName); 835kern_return_t BLSetEFIBootFileOnce(BLContextPtr context, char *path); 836 837bool BLSupportsLegacyMode(BLContextPtr context); 838 839bool BLIsEFIRecoveryAccessibleDevice(BLContextPtr context, CFStringRef bsdName); 840 841 842// filter out bad boot-args 843int BLPreserveBootArgs(BLContextPtr context, 844 const char *input, 845 char *output, 846 int outputLen); 847 848#define kBLDataPartitionsKey CFSTR("Data Partitions") 849#define kBLAuxiliaryPartitionsKey CFSTR("Auxiliary Partitions") 850#define kBLSystemPartitionsKey CFSTR("System Partitions") 851 852int BLCreateBooterInformationDictionary(BLContextPtr context, const char * bsdName, 853 CFDictionaryRef *outDict); 854 855__END_DECLS 856 857#endif // _BLESS_H_ 858