Advertisement
Guest User

Untitled

a guest
Jan 29th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. ---
  2. grub-core/Makefile.core.def | 6 +++
  3. grub-core/commands/efi/applesetos.c | 82 +++++++++++++++++++++++++++++++++++++
  4. 2 files changed, 88 insertions(+)
  5. create mode 100644 grub-core/commands/efi/applesetos.c
  6.  
  7. diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
  8. index 42443bc..dc9c4de 100644
  9. --- a/grub-core/Makefile.core.def
  10. +++ b/grub-core/Makefile.core.def
  11. @@ -742,6 +742,12 @@ module = {
  12. };
  13.  
  14. module = {
  15. + name = applesetos;
  16. + common = commands/efi/applesetos.c;
  17. + enable = efi;
  18. +};
  19. +
  20. +module = {
  21. name = blocklist;
  22. common = commands/blocklist.c;
  23. };
  24. diff --git a/grub-core/commands/efi/applesetos.c
  25. b/grub-core/commands/efi/applesetos.c
  26. new file mode 100644
  27. index 0000000..9464307
  28. --- /dev/null
  29. +++ b/grub-core/commands/efi/applesetos.c
  30. @@ -0,0 +1,82 @@
  31. +/* applesetos.c - Pretend to be Mac OS X. */
  32. +/*
  33. + * GRUB -- GRand Unified Bootloader
  34. + * Copyright (C) 2013 Free Software Foundation, Inc.
  35. + *
  36. + * GRUB is free software: you can redistribute it and/or modify
  37. + * it under the terms of the GNU General Public License as published by
  38. + * the Free Software Foundation, either version 3 of the License, or
  39. + * (at your option) any later version.
  40. + *
  41. + * GRUB is distributed in the hope that it will be useful,
  42. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  43. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  44. + * GNU General Public License for more details.
  45. + *
  46. + * You should have received a copy of the GNU General Public License
  47. + * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  48. + */
  49. +#include <grub/efi/api.h>
  50. +#include <grub/efi/efi.h>
  51. +#include <grub/command.h>
  52. +/* For NULL. */
  53. +#include <grub/mm.h>
  54. +
  55. +GRUB_MOD_LICENSE ("GPLv3+");
  56. +
  57. +#define GRUB_EFI_APPLE_SET_OS_PROTOCOL_GUID \
  58. + { 0xc5c5da95, 0x7d5c, 0x45e6, \
  59. + { 0xb2, 0xf1, 0x3f, 0xd5, 0x2b, 0xb1, 0x00, 0x77 } \
  60. + }
  61. +
  62. +struct grub_efi_apple_set_os_interface
  63. +{
  64. + grub_efi_uint64_t version;
  65. + void (*set_os_version) (const grub_efi_char8_t *os_version);
  66. + void (*set_os_vendor) (const grub_efi_char8_t *os_vendor);
  67. +};
  68. +typedef struct grub_efi_apple_set_os_interface grub_efi_apple_set_os_interface_t;
  69. +
  70. +static const grub_efi_char8_t apple_os_version[] = "Mac OS X 10.9";
  71. +static const grub_efi_char8_t apple_os_vendor[] = "Apple Inc.";
  72. +
  73. +static grub_err_t
  74. +grub_cmd_apple_set_os (grub_command_t cmd __attribute__ ((unused)),
  75. + int argc __attribute__ ((unused)),
  76. + char **args __attribute__ ((unused)))
  77. +{
  78. + grub_efi_guid_t apple_set_os_guid = GRUB_EFI_APPLE_SET_OS_PROTOCOL_GUID;
  79. + grub_efi_apple_set_os_interface_t *set_os;
  80. + set_os = grub_efi_locate_protocol (&apple_set_os_guid, 0);
  81. + if (!set_os) {
  82. + return grub_error (GRUB_ERR_FILE_NOT_FOUND,
  83. + "Could not locate the apple set os protocol.");
  84. + }
  85. +
  86. + if (set_os->version != 0)
  87. + {
  88. + efi_call_1 (set_os->set_os_version, apple_os_version);
  89. + grub_printf("Set os version to %s\n", apple_os_version);
  90. + }
  91. +
  92. + if (set_os->version == 2)
  93. + {
  94. + efi_call_1 (set_os->set_os_vendor, apple_os_vendor);
  95. + grub_printf("Set os vendor to %s\n", apple_os_vendor);
  96. + }
  97. +
  98. + return 0;
  99. +}
  100. +
  101. +static grub_command_t cmd;
  102. +
  103. +GRUB_MOD_INIT(applesetos)
  104. +{
  105. + cmd = grub_register_command ("apple_set_os", grub_cmd_apple_set_os, NULL,
  106. + "Register as Apple Inc. Mac OS X 10.9.");
  107. +}
  108. +
  109. +GRUB_MOD_FINI(applesetos)
  110. +{
  111. + grub_unregister_command (cmd);
  112. +}
  113. --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement