* updated firefox (133.0.3 -> 134.0.2)
[t2sde.git] / package / boot / grub2 / applesetos.patch
blob21a06477f0e5f6d2845e78b49fccb849d2d27ef4
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/grub2/applesetos.patch
3 # Copyright (C) 2017 - 2024 The T2 SDE Project
4 #
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
7 #
8 # This patch file is dual-licensed. It is available under the license the
9 # patched project is licensed under, as long as it is an OpenSource license
10 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
11 # of the GNU General Public License version 2 as used by the T2 SDE.
12 # --- T2-COPYRIGHT-NOTE-END ---
14 The EFI on current macbooks configures hardware differently depending
15 on wether it is booting Mac OS X or a different os, for example
16 disabling the internal GPU completely on some models.
18 Mac OS X identifies itself using a custom EFI protocol.
20 This adds a command that fakes the os identification, making all
21 hardware accessible.
23 ---
24 grub-core/Makefile.core.def | 6 +++
25 grub-core/commands/efi/applesetos.c | 82 +++++++++++++++++++++++++++++++++++++
26 2 files changed, 88 insertions(+)
27 create mode 100644 grub-core/commands/efi/applesetos.c
29 diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
30 index 42443bc..dc9c4de 100644
31 --- a/grub-core/Makefile.core.def
32 +++ b/grub-core/Makefile.core.def
33 @@ -742,6 +742,12 @@ module = {
36 module = {
37 + name = applesetos;
38 + common = commands/efi/applesetos.c;
39 + enable = efi;
40 +};
42 +module = {
43 name = blocklist;
44 common = commands/blocklist.c;
46 diff --git a/grub-core/commands/efi/applesetos.c
47 b/grub-core/commands/efi/applesetos.c
48 new file mode 100644
49 index 0000000..9464307
50 --- /dev/null
51 +++ b/grub-core/commands/efi/applesetos.c
52 @@ -0,0 +1,82 @@
53 +/* applesetos.c - Pretend to be Mac OS X. */
54 +/*
55 + * GRUB -- GRand Unified Bootloader
56 + * Copyright (C) 2013 Free Software Foundation, Inc.
57 + *
58 + * GRUB is free software: you can redistribute it and/or modify
59 + * it under the terms of the GNU General Public License as published by
60 + * the Free Software Foundation, either version 3 of the License, or
61 + * (at your option) any later version.
62 + *
63 + * GRUB is distributed in the hope that it will be useful,
64 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
65 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66 + * GNU General Public License for more details.
67 + *
68 + * You should have received a copy of the GNU General Public License
69 + * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
70 + */
71 +#include <grub/efi/api.h>
72 +#include <grub/efi/efi.h>
73 +#include <grub/command.h>
74 +/* For NULL. */
75 +#include <grub/mm.h>
77 +GRUB_MOD_LICENSE ("GPLv3+");
79 +#define GRUB_EFI_APPLE_SET_OS_PROTOCOL_GUID \
80 + { 0xc5c5da95, 0x7d5c, 0x45e6, \
81 + { 0xb2, 0xf1, 0x3f, 0xd5, 0x2b, 0xb1, 0x00, 0x77 } \
82 + }
84 +struct grub_efi_apple_set_os_interface
86 + grub_efi_uint64_t version;
87 + void (*set_os_version) (const grub_efi_char8_t *os_version);
88 + void (*set_os_vendor) (const grub_efi_char8_t *os_vendor);
89 +};
90 +typedef struct grub_efi_apple_set_os_interface grub_efi_apple_set_os_interface_t;
92 +static const grub_efi_char8_t apple_os_version[] = "macOS-ish";
93 +static const grub_efi_char8_t apple_os_vendor[] = "Apple Inc.";
95 +static grub_err_t
96 +grub_cmd_apple_set_os (grub_command_t cmd __attribute__ ((unused)),
97 + int argc __attribute__ ((unused)),
98 + char **args __attribute__ ((unused)))
100 + grub_guid_t apple_set_os_guid = GRUB_EFI_APPLE_SET_OS_PROTOCOL_GUID;
101 + grub_efi_apple_set_os_interface_t *set_os;
102 + set_os = grub_efi_locate_protocol (&apple_set_os_guid, 0);
103 + if (!set_os) {
104 + return grub_error (GRUB_ERR_FILE_NOT_FOUND,
105 + "Could not locate the apple set os protocol.");
108 + if (set_os->version != 0)
110 + const grub_efi_char8_t* os_version = argc > 0 ? (const grub_efi_char8_t*)args[0] : apple_os_version;
111 + const grub_efi_char8_t* os_vendor = argc > 1 ? (const grub_efi_char8_t*)args[1] : apple_os_vendor;
113 + set_os->set_os_version(os_version);
114 + grub_printf("Set os version to %s\n", os_version);
116 + set_os->set_os_vendor(os_vendor);
117 + grub_printf("Set os vendor to %s\n", os_vendor);
120 + return 0;
123 +static grub_command_t cmd;
125 +GRUB_MOD_INIT(applesetos)
127 + cmd = grub_register_command ("apple_set_os", grub_cmd_apple_set_os, NULL,
128 + "Register as Apple Inc. Mac OS X 10.9.");
131 +GRUB_MOD_FINI(applesetos)
133 + grub_unregister_command (cmd);
136 1.8.5.2