[
  {
    "path": ".gitignore",
    "content": "*.so \napple_set_os.o\napple_set_os.efi\n"
  },
  {
    "path": "Dockerfile",
    "content": "FROM debian:stretch\n\nWORKDIR /build\n\nRUN apt-get update && apt-get install -y \\\n  build-essential \\\n  gnu-efi\n\nCMD make clean && make\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015 Bruno Bierbaumer\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n"
  },
  {
    "path": "Makefile",
    "content": "ARCH\t= x86_64\n\nTARGET\t= apple_set_os.efi\nFORMAT \t= efi-app-$(ARCH)\n\nINC\t\t= /usr/include/efi\nCFLAGS\t= -I$(INC) -I$(INC)/$(ARCH) \\\n\t\t -DGNU_EFI_USE_MS_ABI -fPIC -fshort-wchar -ffreestanding \\\n\t\t -fno-stack-protector -maccumulate-outgoing-args \\\n\t\t -Wall -D$(ARCH) -Werror -m64 -mno-red-zone\n\nLDFLAGS\t= -T /usr/lib/elf_$(ARCH)_efi.lds -Bsymbolic -shared -nostdlib -znocombreloc \\\n\t\t  /usr/lib/crt0-efi-$(ARCH).o\n\n%.efi: %.so\n\tobjcopy -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \\\n\t\t-j .rela -j .reloc -S --target=$(FORMAT) $^ $@\n\n%.so: %.o\n\t$(LD) $(LDFLAGS) -o $@ $^ $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) \\\n\t/usr/lib/libgnuefi.a\n\nall: $(TARGET)\n\nclean:\n\trm -f $(TARGET) *.so apple_set_os.o\n"
  },
  {
    "path": "README.md",
    "content": "# apple_set_os.efi\nTiny EFI program for unlocking the Intel IGD on the Macbook Pro 11,3 for Linux and Windows.  \nIt has been made to be easily chainloaded by unmodified EFI bootloader like Grub, rEFInd etc.\n\nThe Macbook Pro 11,3 model's EFI is switching off the Intel GPU if you boot anything but Mac OS X.  \nSo a little trick by faking the OS identifiction is required to make all hardware accessible.\n\nAll credits belong to [Andreas Heider](https://github.com/ah-) who originally discovered this hack:  \nhttps://lists.gnu.org/archive/html/grub-devel/2013-12/msg00442.html\n\n## Usage:\nCopy the apple_set_os.efi binary (download it from [releases](https://github.com/0xbb/apple_set_os.efi/releases)) to EFI System Partition (ESP) :\n```\nmkdir /boot/efi/EFI/custom\ncp apple_set_os.efi /boot/efi/EFI/custom\n```\n[rEFInd](http://www.rodsbooks.com/refind/) should automatically show a new icon for apple_set_os.efi.\n\nGrub can be configured to start apple_set_os.efi automatically by adding the following lines to  ``/etc/grub.d/40_custom``:\n```\nsearch --no-floppy --set=root --label EFI\nchainloader (${root})/EFI/custom/apple_set_os.efi\nboot\n```\n\n## Build:\nTested on Debian Jessie 8.0:\n```\napt-get install gnu-efi\ngit clone https://github.com/0xbb/apple_set_os.efi\ncd apple_set_os.efi\nmake\n```\n## Build via docker\n```bash\ndocker build -t apple_set_os . && docker run --rm -it -v $(pwd):/build apple_set_os\n```\n\n\n"
  },
  {
    "path": "apple_set_os.c",
    "content": "// Copyright (c) 2015 Bruno Bierbaumer\n\n#include <efibind.h>\n#include <efidef.h>\n#include <efidevp.h>\n#include <eficon.h>\n#include <efiprot.h>\n#include <efiapi.h>\n#include <efierr.h>\n\n#define APPLE_SET_OS_VENDOR  \"Apple Inc.\"\n#define APPLE_SET_OS_VERSION \"Mac OS X 10.9\"\n\nstatic EFI_GUID APPLE_SET_OS_GUID = { 0xc5c5da95, 0x7d5c, 0x45e6, { 0xb2, 0xf1, 0x3f, 0xd5, 0x2b, 0xb1, 0x00, 0x77 }};\n\ntypedef struct efi_apple_set_os_interface {\n\tUINT64 version;\n\tEFI_STATUS (EFIAPI *set_os_version) (IN CHAR8 *version);\n\tEFI_STATUS (EFIAPI *set_os_vendor) (IN CHAR8 *vendor);\n} efi_apple_set_os_interface;\n\nEFI_STATUS\nefi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systemTable)\n{\n\tSIMPLE_TEXT_OUTPUT_INTERFACE *conOut = systemTable->ConOut;\n\tconOut->OutputString(conOut, L\"apple_set_os started\\r\\n\");\n\n\tefi_apple_set_os_interface *set_os = NULL;\n\n\tEFI_STATUS status  = systemTable->BootServices->LocateProtocol(&APPLE_SET_OS_GUID, NULL, (VOID**) &set_os);\n\tif(EFI_ERROR(status) || set_os == NULL) {\n\t\tconOut->OutputString(conOut, L\"Could not locate the apple set os protocol.\\r\\n\");\n\t\treturn status;\n\t}\n\n\tif(set_os->version != 0){\n\t\tstatus = set_os->set_os_version((CHAR8 *) APPLE_SET_OS_VERSION);\n\t\tif(EFI_ERROR(status)){\n\t\t\tconOut->OutputString(conOut, L\"Could not set version.\\r\\n\");\n\t\t\treturn status;\n\t\t}\n\t\tconOut->OutputString(conOut, L\"Set os version to \" APPLE_SET_OS_VERSION  \".\\r\\n\");\n\t}\n\n\tstatus = set_os->set_os_vendor((CHAR8 *) APPLE_SET_OS_VENDOR);\n\tif(EFI_ERROR(status)){\n\t\tconOut->OutputString(conOut, L\"Could not set vendor.\\r\\n\");\n\t\treturn status;\n\t}\n\tconOut->OutputString(conOut, L\"Set os vendor to \" APPLE_SET_OS_VENDOR  \".\\r\\n\");\n\n\treturn EFI_SUCCESS;\n}\n"
  }
]