Full Code of 0xbb/apple_set_os.efi for AI

master 5712c5bf5352 cached
6 files
4.9 KB
1.6k tokens
2 symbols
1 requests
Download .txt
Repository: 0xbb/apple_set_os.efi
Branch: master
Commit: 5712c5bf5352
Files: 6
Total size: 4.9 KB

Directory structure:
gitextract_en31dnqg/

├── .gitignore
├── Dockerfile
├── LICENSE
├── Makefile
├── README.md
└── apple_set_os.c

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
*.so 
apple_set_os.o
apple_set_os.efi


================================================
FILE: Dockerfile
================================================
FROM debian:stretch

WORKDIR /build

RUN apt-get update && apt-get install -y \
  build-essential \
  gnu-efi

CMD make clean && make


================================================
FILE: LICENSE
================================================
The MIT License (MIT)

Copyright (c) 2015 Bruno Bierbaumer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



================================================
FILE: Makefile
================================================
ARCH	= x86_64

TARGET	= apple_set_os.efi
FORMAT 	= efi-app-$(ARCH)

INC		= /usr/include/efi
CFLAGS	= -I$(INC) -I$(INC)/$(ARCH) \
		 -DGNU_EFI_USE_MS_ABI -fPIC -fshort-wchar -ffreestanding \
		 -fno-stack-protector -maccumulate-outgoing-args \
		 -Wall -D$(ARCH) -Werror -m64 -mno-red-zone

LDFLAGS	= -T /usr/lib/elf_$(ARCH)_efi.lds -Bsymbolic -shared -nostdlib -znocombreloc \
		  /usr/lib/crt0-efi-$(ARCH).o

%.efi: %.so
	objcopy -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
		-j .rela -j .reloc -S --target=$(FORMAT) $^ $@

%.so: %.o
	$(LD) $(LDFLAGS) -o $@ $^ $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) \
	/usr/lib/libgnuefi.a

all: $(TARGET)

clean:
	rm -f $(TARGET) *.so apple_set_os.o


================================================
FILE: README.md
================================================
# apple_set_os.efi
Tiny EFI program for unlocking the Intel IGD on the Macbook Pro 11,3 for Linux and Windows.  
It has been made to be easily chainloaded by unmodified EFI bootloader like Grub, rEFInd etc.

The Macbook Pro 11,3 model's EFI is switching off the Intel GPU if you boot anything but Mac OS X.  
So a little trick by faking the OS identifiction is required to make all hardware accessible.

All credits belong to [Andreas Heider](https://github.com/ah-) who originally discovered this hack:  
https://lists.gnu.org/archive/html/grub-devel/2013-12/msg00442.html

## Usage:
Copy the apple_set_os.efi binary (download it from [releases](https://github.com/0xbb/apple_set_os.efi/releases)) to EFI System Partition (ESP) :
```
mkdir /boot/efi/EFI/custom
cp apple_set_os.efi /boot/efi/EFI/custom
```
[rEFInd](http://www.rodsbooks.com/refind/) should automatically show a new icon for apple_set_os.efi.

Grub can be configured to start apple_set_os.efi automatically by adding the following lines to  ``/etc/grub.d/40_custom``:
```
search --no-floppy --set=root --label EFI
chainloader (${root})/EFI/custom/apple_set_os.efi
boot
```

## Build:
Tested on Debian Jessie 8.0:
```
apt-get install gnu-efi
git clone https://github.com/0xbb/apple_set_os.efi
cd apple_set_os.efi
make
```
## Build via docker
```bash
docker build -t apple_set_os . && docker run --rm -it -v $(pwd):/build apple_set_os
```




================================================
FILE: apple_set_os.c
================================================
// Copyright (c) 2015 Bruno Bierbaumer

#include <efibind.h>
#include <efidef.h>
#include <efidevp.h>
#include <eficon.h>
#include <efiprot.h>
#include <efiapi.h>
#include <efierr.h>

#define APPLE_SET_OS_VENDOR  "Apple Inc."
#define APPLE_SET_OS_VERSION "Mac OS X 10.9"

static EFI_GUID APPLE_SET_OS_GUID = { 0xc5c5da95, 0x7d5c, 0x45e6, { 0xb2, 0xf1, 0x3f, 0xd5, 0x2b, 0xb1, 0x00, 0x77 }};

typedef struct efi_apple_set_os_interface {
	UINT64 version;
	EFI_STATUS (EFIAPI *set_os_version) (IN CHAR8 *version);
	EFI_STATUS (EFIAPI *set_os_vendor) (IN CHAR8 *vendor);
} efi_apple_set_os_interface;

EFI_STATUS
efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systemTable)
{
	SIMPLE_TEXT_OUTPUT_INTERFACE *conOut = systemTable->ConOut;
	conOut->OutputString(conOut, L"apple_set_os started\r\n");

	efi_apple_set_os_interface *set_os = NULL;

	EFI_STATUS status  = systemTable->BootServices->LocateProtocol(&APPLE_SET_OS_GUID, NULL, (VOID**) &set_os);
	if(EFI_ERROR(status) || set_os == NULL) {
		conOut->OutputString(conOut, L"Could not locate the apple set os protocol.\r\n");
		return status;
	}

	if(set_os->version != 0){
		status = set_os->set_os_version((CHAR8 *) APPLE_SET_OS_VERSION);
		if(EFI_ERROR(status)){
			conOut->OutputString(conOut, L"Could not set version.\r\n");
			return status;
		}
		conOut->OutputString(conOut, L"Set os version to " APPLE_SET_OS_VERSION  ".\r\n");
	}

	status = set_os->set_os_vendor((CHAR8 *) APPLE_SET_OS_VENDOR);
	if(EFI_ERROR(status)){
		conOut->OutputString(conOut, L"Could not set vendor.\r\n");
		return status;
	}
	conOut->OutputString(conOut, L"Set os vendor to " APPLE_SET_OS_VENDOR  ".\r\n");

	return EFI_SUCCESS;
}
Download .txt
gitextract_en31dnqg/

├── .gitignore
├── Dockerfile
├── LICENSE
├── Makefile
├── README.md
└── apple_set_os.c
Download .txt
SYMBOL INDEX (2 symbols across 1 files)

FILE: apple_set_os.c
  type efi_apple_set_os_interface (line 16) | typedef struct efi_apple_set_os_interface {
  function EFI_STATUS (line 22) | EFI_STATUS
Condensed preview — 6 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (6K chars).
[
  {
    "path": ".gitignore",
    "chars": 38,
    "preview": "*.so \napple_set_os.o\napple_set_os.efi\n"
  },
  {
    "path": "Dockerfile",
    "chars": 134,
    "preview": "FROM debian:stretch\n\nWORKDIR /build\n\nRUN apt-get update && apt-get install -y \\\n  build-essential \\\n  gnu-efi\n\nCMD make "
  },
  {
    "path": "LICENSE",
    "chars": 1084,
    "preview": "The MIT License (MIT)\n\nCopyright (c) 2015 Bruno Bierbaumer\n\nPermission is hereby granted, free of charge, to any person "
  },
  {
    "path": "Makefile",
    "chars": 713,
    "preview": "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)/$"
  },
  {
    "path": "README.md",
    "chars": 1405,
    "preview": "# apple_set_os.efi\nTiny EFI program for unlocking the Intel IGD on the Macbook Pro 11,3 for Linux and Windows.  \nIt has "
  },
  {
    "path": "apple_set_os.c",
    "chars": 1663,
    "preview": "// Copyright (c) 2015 Bruno Bierbaumer\n\n#include <efibind.h>\n#include <efidef.h>\n#include <efidevp.h>\n#include <eficon.h"
  }
]

About this extraction

This page contains the full source code of the 0xbb/apple_set_os.efi GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 6 files (4.9 KB), approximately 1.6k tokens, and a symbol index with 2 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!