mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-10 09:40:53 +01:00
Merge branch 'master' of https://github.com/CloverHackyColor/CloverBootloader
This commit is contained in:
commit
7d21f54ad6
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@
|
||||
# dump NVRAM for UEFI Clover with EmuVariable or Legacy Clover
|
||||
#
|
||||
# Script version info
|
||||
gScriptVersion=1.16.6
|
||||
gScriptVersion=1.16.7
|
||||
#================================= GLOBAL VARS ==================================
|
||||
#
|
||||
# The script expects '0.5' but non-US localizations use '0,5' so we export
|
||||
@ -44,7 +44,7 @@ fi
|
||||
# Variables
|
||||
#
|
||||
gNVRAMf=nvram.plist
|
||||
gNVRAMbuf=$(nvram -x -p)
|
||||
gNVRAMbuf=$(nvram2 -x -p)
|
||||
gNVRAMLogPath="${CLOVER_LOG_LOCATION}/rc.shutdown.log"
|
||||
gDisk=($(ls /dev/disk? |grep -i -o "disk[0-9]"))
|
||||
gESPList=""
|
||||
|
@ -601,11 +601,13 @@ fi
|
||||
# ditto --noextattr --noqtn ${SYMROOT}/utils/clover-genconfig ${PKG_BUILD_DIR}/${choiceId}/Root/Private/tmp/usr/local/bin/
|
||||
ditto --noextattr --noqtn ${SYMROOT}/utils/partutil ${PKG_BUILD_DIR}/${choiceId}/Root/Private/tmp/usr/local/bin/
|
||||
# ditto --noextattr --noqtn ${SYMROOT}/utils/espfinder ${PKG_BUILD_DIR}/${choiceId}/Root/Private/tmp/usr/local/bin/
|
||||
ditto --noextattr --noqtn ${SYMROOT}/utils/nvram2 ${PKG_BUILD_DIR}/${choiceId}/Root/Private/tmp/usr/local/bin/
|
||||
fixperms "${PKG_BUILD_DIR}/${choiceId}/Root/"
|
||||
#chmod 755 "${PKG_BUILD_DIR}/${choiceId}"/Root/Private/tmp/usr/local/bin/{bdmesg,clover-genconfig,partutil,espfinder}
|
||||
# chmod 755 "${PKG_BUILD_DIR}/${choiceId}"/Root/Private/tmp/usr/local/bin/{bdmesg,partutil}
|
||||
chmod 755 "${PKG_BUILD_DIR}/${choiceId}"/Root/Private/tmp/usr/local/bin/partutil
|
||||
chmod 755 "${PKG_BUILD_DIR}/${choiceId}"/Root/usr/local/bin/bdmesg
|
||||
chmod 755 "${PKG_BUILD_DIR}/${choiceId}"/Root/usr/local/bin/nvram2
|
||||
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
|
||||
packageUtilsRefId=$packageRefId
|
||||
buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
|
||||
|
@ -3,6 +3,6 @@ include $(CURDIR)/Make.rules
|
||||
#fdisk440 out
|
||||
#clover-genconfig temporary out
|
||||
#espfinder out
|
||||
SUBDIRS = boot1-install partutil bdmesg
|
||||
SUBDIRS = boot1-install partutil bdmesg nvram
|
||||
|
||||
all: all-recursive
|
||||
|
26
CloverPackage/utils/nvram/Makefile
Normal file
26
CloverPackage/utils/nvram/Makefile
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
PROGRAM = nvram2
|
||||
|
||||
SRCROOT := $(abspath $(CURDIR)/..)
|
||||
SYMROOT := $(abspath $(CURDIR)/../../sym)
|
||||
OBJROOT := $(SYMROOT)/build/$(PROGRAM)
|
||||
INSTALL_DIR_NAME=utils
|
||||
UTILSDIR= $(SYMROOT)/$(INSTALL_DIR_NAME)
|
||||
|
||||
|
||||
SRC := $(wildcard $(PROGRAM)/*.c)
|
||||
PROG := $(addprefix $(UTILSDIR)/, $(PROGRAM))
|
||||
|
||||
all: $(PROG)
|
||||
|
||||
$(PROG): $(SRC)
|
||||
@echo "\t[CXX] $(PROGRAM)"
|
||||
@cc -o $(PROGRAM) $(PROGRAM).c -framework CoreFoundation -framework IOKit -Wall >/dev/null
|
||||
@mv $(PROGRAM) $(UTILSDIR)
|
||||
|
||||
install-local: $(PROG)
|
||||
@sudo install -d -g 0 -o 0 /usr/local/bin
|
||||
@sudo install -psv -g 0 -o 0 $(PROG) /usr/local/bin
|
||||
|
||||
clean-local:
|
||||
@rm -rf $(OBJROOT) *~
|
558
CloverPackage/utils/nvram/assumes.h
Normal file
558
CloverPackage/utils/nvram/assumes.h
Normal file
@ -0,0 +1,558 @@
|
||||
/* Copyright (c) 2012, 2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __OS_ASSUMES_H__
|
||||
#define __OS_ASSUMES_H__
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <stdalign.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <Availability.h>
|
||||
#include <TargetConditionals.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
//#include <_simple.h>
|
||||
#include <errno.h>
|
||||
//#include <os/base_private.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if __GNUC__
|
||||
#define os_constant(x) __builtin_constant_p((x))
|
||||
#define os_hardware_trap() __asm__ __volatile__ (""); __builtin_trap()
|
||||
#define __OS_COMPILETIME_ASSERT__(e) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wvla\"") \
|
||||
char __compile_time_assert__[(e) ? 1 : -1]; \
|
||||
(void)__compile_time_assert__; \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
#else /* __GNUC__ */
|
||||
#define os_constant(x) ((long)0)
|
||||
#define os_hardware_trap() abort()
|
||||
#define __OS_COMPILETIME_ASSERT__(e) (e)
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#pragma mark os_crash
|
||||
|
||||
/*
|
||||
* os_crash() is like os_hardware_trap(), except you get to pass in a crash
|
||||
* message, and it can be redirected to a callback function using
|
||||
* os_set_crash_callback()
|
||||
*/
|
||||
|
||||
#define __os_crash_simple(msg) \
|
||||
({ \
|
||||
_os_crash(msg); \
|
||||
os_hardware_trap(); \
|
||||
})
|
||||
|
||||
#if defined(OS_CRASH_ENABLE_EXPERIMENTAL_LIBTRACE)
|
||||
#include <os/log_private.h>
|
||||
|
||||
#define __os_crash_fmt(...) \
|
||||
({ \
|
||||
const size_t size = os_log_pack_size(__VA_ARGS__); \
|
||||
uint8_t buf[size] __attribute__((aligned(alignof(os_log_pack_s)))); \
|
||||
os_log_pack_t pack = (os_log_pack_t)&buf; \
|
||||
os_log_pack_fill(pack, size, errno, __VA_ARGS__); \
|
||||
_os_crash_fmt(pack, size); \
|
||||
os_hardware_trap(); \
|
||||
})
|
||||
|
||||
#define __os_crash_N(msg) __os_crash_simple(msg)
|
||||
#define __os_crash_Y(...) __os_crash_fmt(__VA_ARGS__)
|
||||
|
||||
// Returns Y if >1 argument, N if just one argument.
|
||||
#define __thirty_second_argument(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, \
|
||||
_12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, \
|
||||
_26, _27, _28, _29, _30, _31, _32, ...) _32
|
||||
#define __has_more_than_one_argument(...) __thirty_second_argument(__VA_ARGS__, \
|
||||
Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, \
|
||||
Y, Y, Y, Y, Y, Y, Y, N, EXTRA)
|
||||
|
||||
#define __os_crash_invoke(variant, ...) \
|
||||
OS_CONCAT(__os_crash_, variant)(__VA_ARGS__)
|
||||
|
||||
#define os_crash(...) \
|
||||
__os_crash_invoke(__has_more_than_one_argument(__VA_ARGS__), __VA_ARGS__)
|
||||
|
||||
OS_COLD
|
||||
extern void
|
||||
_os_crash_fmt(os_log_pack_t, size_t);
|
||||
|
||||
/*!
|
||||
* @function os_assert_sprintf
|
||||
* A routine to assert the result of a call to snprintf(3) or vsnprintf(3).
|
||||
*
|
||||
* @param ret
|
||||
* The return value from {v}snprintf(3).
|
||||
*
|
||||
* @param buff_size
|
||||
* The size of the buffer given to {v}snprintf(3).
|
||||
*
|
||||
* @discussion
|
||||
* If ret is less than zero or greater than size, the routine will abort the
|
||||
* caller with a message indicating the nature of the failure in the Application
|
||||
* Specific Information section of the resulting crash log.
|
||||
*
|
||||
* This routine is useful for printing paths that are expected to succeed with a
|
||||
* statically-sized buffer.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
OS_ALWAYS_INLINE OS_COLD
|
||||
static inline void
|
||||
os_assert_sprintf(int ret, size_t buff_size)
|
||||
{
|
||||
if (ret < 0) {
|
||||
os_crash("error printing buffer: %s", strerror(errno));
|
||||
}
|
||||
|
||||
if ((size_t)ret > buff_size) {
|
||||
os_crash("buffer too small: needed = %d, actual = %lu",
|
||||
ret, buff_size);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @function os_assert_asprintf
|
||||
* A routine to assert the result of a call to {v}asprintf(3).
|
||||
*
|
||||
* @param ret
|
||||
* The return value from {v}asnprintf(3).
|
||||
*
|
||||
* @discussion
|
||||
* If ret is less than zero, the routine will abort the caller with a message
|
||||
* indicating the nature of the failure in the Application Specific Information
|
||||
* section of the resulting crash log.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.15.2), ios(13.3), tvos(13.3), watchos(6.1.1))
|
||||
OS_ALWAYS_INLINE OS_COLD
|
||||
static inline void
|
||||
os_assert_asprintf(int ret)
|
||||
{
|
||||
if (ret < 0) {
|
||||
os_crash("error printing buffer: %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @function os_assert_malloc
|
||||
* A routine to assert the result of allocations which may fail.
|
||||
*
|
||||
* @param desc
|
||||
* A string describing the object whose allocation was attempted.
|
||||
*
|
||||
* @param p
|
||||
* The result of a call to malloc(3), calloc(3), et al.
|
||||
*
|
||||
* @param alloc_size
|
||||
* The size of the attempted allocation.
|
||||
*
|
||||
* @discussion
|
||||
* If {@link p} is NULL, the routine will abort the caller with a message
|
||||
* indicating the nature of the failure in the Application Specific Information
|
||||
* section of the resulting crash log.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
OS_ALWAYS_INLINE
|
||||
static inline void
|
||||
os_assert_malloc(const char *desc, const void *const p, size_t alloc_size)
|
||||
{
|
||||
if (!p) {
|
||||
os_crash("allocation failed: obj = %s, size = %lu, error = %s",
|
||||
desc, alloc_size, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @function os_assert_mach
|
||||
* A routine to assert the result of a Mach kernel routine.
|
||||
*
|
||||
* @param op
|
||||
* A human-readable description of the operation.
|
||||
*
|
||||
* @param kr
|
||||
* The return code.
|
||||
*
|
||||
* @discsussion
|
||||
* If {@link kr} is non-zero, this routine will abort the caller with a message
|
||||
* indicating the nature of the failure in the Application Specific Information
|
||||
* section of the resulting crash log.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
OS_EXPORT OS_NONNULL1 OS_COLD
|
||||
void
|
||||
os_assert_mach(const char *op, kern_return_t kr);
|
||||
|
||||
#define os_assert_mach(op, kr) ({ \
|
||||
kern_return_t __kr = (kr); \
|
||||
if (os_unlikely(__kr != KERN_SUCCESS)) os_assert_mach(op, kr); \
|
||||
})
|
||||
|
||||
/*!
|
||||
* @function os_assert_mach_port_status
|
||||
* A routine to assert the status of a Mach port.
|
||||
*
|
||||
* @param desc
|
||||
* A human-readable description of the port's purpose.
|
||||
*
|
||||
* @param p
|
||||
* The port.
|
||||
*
|
||||
* @param expected
|
||||
* A pointer to a mach_port_status_t describing the expected attributes of the
|
||||
* port. If no particular value is expected for a given field in the structure,
|
||||
* a sentinel value may be provided for each expected field to indicate that its
|
||||
* check should be elided. The sentival values are:
|
||||
*
|
||||
* mps_pset => UINT32_MAX
|
||||
* mps_seqno => UINT32_MAX
|
||||
* mps_mscount => UINT32_MAX
|
||||
* mps_qlimit => UINT32_MAX
|
||||
* mps_msgcount => UINT32_MAX
|
||||
* mps_sorights => UINT32_MAX
|
||||
* mps_srights => INT32_MAX
|
||||
* mps_pdrequest => INT32_MAX
|
||||
* mps_nsrequest => INT32_MAX
|
||||
* mps_flags => 0
|
||||
*
|
||||
* @discussion
|
||||
* If there are any mismatches in the expected and actual status of the port,
|
||||
* the implementation will abort the caller. If status cannot be obtained for
|
||||
* the given port, the implementation will abort the caller.
|
||||
*/
|
||||
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
|
||||
OS_EXPORT
|
||||
void
|
||||
os_assert_mach_port_status(const char *desc, mach_port_t p,
|
||||
mach_port_status_t *expected);
|
||||
|
||||
#else // OS_CRASH_ENABLE_EXPERIMENTAL_LIBTRACE
|
||||
|
||||
#define os_crash(msg) __os_crash_simple(msg)
|
||||
|
||||
#endif // OS_CRASH_ENABLE_EXPERIMENTAL_LIBTRACE
|
||||
|
||||
/*
|
||||
* An executable can register a callback to be made upon a crash using the
|
||||
* os_set_crash_callback function. If a crash callback is not set, the symbol
|
||||
* `os_crash_function` will be called in the main binary, if it exists.
|
||||
*/
|
||||
|
||||
typedef void (*os_crash_callback_t) (const char *);
|
||||
|
||||
/* private: use accessors below */
|
||||
extern os_crash_callback_t _os_crash_callback;
|
||||
|
||||
static inline os_crash_callback_t
|
||||
os_get_crash_callback() {
|
||||
return _os_crash_callback;
|
||||
}
|
||||
|
||||
static inline void
|
||||
os_set_crash_callback(os_crash_callback_t callback) {
|
||||
_os_crash_callback = callback;
|
||||
}
|
||||
|
||||
#pragma mark os_assert
|
||||
|
||||
#if defined(OS_CRASH_ENABLE_EXPERIMENTAL_LIBTRACE)
|
||||
|
||||
#define _os_assert_crash(value, expression) ({ \
|
||||
os_crash("assertion failure: \"" expression "\" -> %lld", value); \
|
||||
})
|
||||
|
||||
#define _os_assert_crash_errno(value, expression) ({ \
|
||||
os_crash("assertion failure: \"" expression "\" -> %{errno}d", value); \
|
||||
})
|
||||
|
||||
#else // OS_CRASH_ENABLE_EXPERIMENTAL_LIBTRACE
|
||||
|
||||
#define _os_assert_crash(e, ...) ({ \
|
||||
char *_fail_message = _os_assert_log(e); \
|
||||
os_crash(_fail_message); \
|
||||
free(_fail_message); \
|
||||
})
|
||||
|
||||
#define _os_assert_crash_errno(...) _os_assert_crash(__VA_ARGS__)
|
||||
|
||||
#endif // OS_CRASH_ENABLE_EXPERIMENTAL_LIBTRACE
|
||||
|
||||
#define __os_assert(e) __extension__({ \
|
||||
__typeof__(e) _e = (e); \
|
||||
if (os_unlikely(!_e)) { \
|
||||
if (os_constant(e)) { __OS_COMPILETIME_ASSERT__((e)); } \
|
||||
_os_assert_crash((uint64_t)(uintptr_t)_e, #e); \
|
||||
} \
|
||||
})
|
||||
|
||||
#define __os_assert_zero(e) __extension__({ \
|
||||
__typeof__(e) _e = (e); \
|
||||
if (os_unlikely(_e)) { \
|
||||
if (os_constant(e)) { __OS_COMPILETIME_ASSERT__(!(e)); } \
|
||||
_os_assert_crash((uint64_t)(uintptr_t)_e, #e); \
|
||||
} \
|
||||
})
|
||||
|
||||
/*
|
||||
* This variant is for use with old-style POSIX APIs that return -1 on failure
|
||||
* and set errno. If the return code is -1, the value logged will be as though
|
||||
* os_assert_zero(errno) was used. It encapsulates the following pattern:
|
||||
*
|
||||
* int tubes[2];
|
||||
* if (pipe(tubes) == -1) {
|
||||
* (void)os_assert_zero(errno);
|
||||
* }
|
||||
*/
|
||||
#define __posix_assert_zero(e) __extension__({ \
|
||||
__typeof__(e) _e = (e); \
|
||||
if (os_unlikely(_e == (__typeof__(e))-1)) { \
|
||||
_os_assert_crash_errno(errno, #e); \
|
||||
} \
|
||||
})
|
||||
|
||||
#if defined(OS_CRASH_ENABLE_EXPERIMENTAL_LIBTRACE)
|
||||
|
||||
#define __os_assert_msg(e, fmt, ...) __extension__({ \
|
||||
__typeof__(e) _e = (e); \
|
||||
if (os_unlikely(!_e)) { \
|
||||
os_crash("assertion failure: " fmt, ##__VA_ARGS__); \
|
||||
} \
|
||||
})
|
||||
|
||||
#define __os_assert_zero_msg(e, fmt, ...) __extension__({ \
|
||||
__typeof__(e) _e = (e); \
|
||||
if (os_unlikely(_e)) { \
|
||||
os_crash("assertion failure (%lld): " fmt, value, ##__VA_ARGS__); \
|
||||
} \
|
||||
})
|
||||
|
||||
#define __posix_assert_zero_msg(e, fmt, ...) __extension__({ \
|
||||
__typeof__(e) _e = (e); \
|
||||
if (os_unlikely(_e == (__typeof__(e))-1)) { \
|
||||
os_crash("assertion failure (%{errno}d): " fmt, errno, ##__VA_ARGS__); \
|
||||
} \
|
||||
})
|
||||
|
||||
#define __os_assert_N(e) __os_assert(e)
|
||||
#define __os_assert_Y(...) __os_assert_msg(__VA_ARGS__)
|
||||
#define __os_assert_zero_N(e) __os_assert_zero(e)
|
||||
#define __os_assert_zero_Y(...) __os_assert_zero_msg(__VA_ARGS__)
|
||||
#define __posix_assert_zero_N(e) __posix_assert_zero(e)
|
||||
#define __posix_assert_zero_Y(...) __posix_assert_zero_msg(__VA_ARGS__)
|
||||
|
||||
#define __os_assert_invoke(function, variant, ...) \
|
||||
OS_CONCAT(function, variant)(__VA_ARGS__)
|
||||
|
||||
#define os_assert(...) \
|
||||
__os_assert_invoke(__os_assert_, \
|
||||
__has_more_than_one_argument(__VA_ARGS__), __VA_ARGS__)
|
||||
#define os_assert_zero(...) \
|
||||
__os_assert_invoke(__os_assert_zero_, \
|
||||
__has_more_than_one_argument(__VA_ARGS__), __VA_ARGS__)
|
||||
#define posix_assert_zero(...) \
|
||||
__os_assert_invoke(__posix_assert_zero_, \
|
||||
__has_more_than_one_argument(__VA_ARGS__), __VA_ARGS__)
|
||||
|
||||
#else // OS_CRASH_ENABLE_EXPERIMENTAL_LIBTRACE
|
||||
|
||||
#define os_assert(e) __os_assert(e)
|
||||
#define os_assert_zero(e) __os_assert_zero(e)
|
||||
#define posix_assert_zero(e) __posix_assert_zero(e)
|
||||
|
||||
#endif
|
||||
|
||||
#pragma mark os_assumes
|
||||
|
||||
|
||||
#define os_assumes(e) __extension__({ \
|
||||
__typeof__(e) _e = os_fastpath(e); \
|
||||
if (!_e) { \
|
||||
if (os_constant(e)) { \
|
||||
__OS_COMPILETIME_ASSERT__(e); \
|
||||
} \
|
||||
_os_assumes_log((uint64_t)(uintptr_t)_e); \
|
||||
} \
|
||||
_e; \
|
||||
})
|
||||
|
||||
#define os_assumes_zero(e) __extension__({ \
|
||||
__typeof__(e) _e = os_slowpath(e); \
|
||||
if (_e) { \
|
||||
if (os_constant(e)) { \
|
||||
__OS_COMPILETIME_ASSERT__(!(e)); \
|
||||
} \
|
||||
_os_assumes_log((uint64_t)(uintptr_t)_e); \
|
||||
} \
|
||||
_e; \
|
||||
})
|
||||
|
||||
#define posix_assumes_zero(e) __extension__({ \
|
||||
__typeof__(e) _e = os_slowpath(e); \
|
||||
if (_e == (__typeof__(e))-1) { \
|
||||
_os_assumes_log((uint64_t)(uintptr_t)errno); \
|
||||
} \
|
||||
_e; \
|
||||
})
|
||||
|
||||
#pragma mark assumes redirection
|
||||
|
||||
/* This is useful for clients who wish for the messages generated by assumes()
|
||||
* failures to go somewhere other than (or in addition to) the system log. If
|
||||
* you don't wish for the message to be logged to the system log, then return
|
||||
* true (to indicate that the message has been handled). If you want the default
|
||||
* behavior, return false.
|
||||
*/
|
||||
typedef bool (*os_redirect_t)(const char *);
|
||||
struct _os_redirect_assumes_s {
|
||||
os_redirect_t redirect;
|
||||
};
|
||||
|
||||
#define OS_ASSUMES_REDIRECT_SEG "__DATA"
|
||||
#define OS_ASSUMES_REDIRECT_SECT "__os_assumes_log"
|
||||
|
||||
#define os_redirect_assumes(func) \
|
||||
__attribute__((__used__)) \
|
||||
__attribute__((__section__(OS_ASSUMES_REDIRECT_SEG "," OS_ASSUMES_REDIRECT_SECT))) \
|
||||
static struct _os_redirect_assumes_s _os_redirect_##func = { \
|
||||
.redirect = &func, \
|
||||
};
|
||||
|
||||
#pragma mark _ctx variants
|
||||
|
||||
/*
|
||||
* These are for defining your own assumes()-like wrapper calls so that you can
|
||||
* log additional information, such as the about-PID, sender, etc. They're
|
||||
* generally not useful for direct inclusion in your code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The asl_message argument is a _SIMPLE_STRING that, when given to _simple_asl_send(), will
|
||||
* direct the message to the MessageTracer diagnostic messages store rather than
|
||||
* the default system log store.
|
||||
*/
|
||||
typedef bool (*os_log_callout_t)(_SIMPLE_STRING asl_message, void *ctx, const char *);
|
||||
|
||||
|
||||
#define os_assumes_ctx(f, ctx, e) __extension__({ \
|
||||
__typeof__(e) _e = os_fastpath(e); \
|
||||
if (!_e) { \
|
||||
if (os_constant(e)) { \
|
||||
__OS_COMPILETIME_ASSERT__(e); \
|
||||
} \
|
||||
_os_assumes_log_ctx(f, ctx, (uintptr_t)_e); \
|
||||
} \
|
||||
_e; \
|
||||
})
|
||||
|
||||
#define os_assumes_zero_ctx(f, ctx, e) __extension__({ \
|
||||
__typeof__(e) _e = os_slowpath(e); \
|
||||
if (_e) { \
|
||||
if (os_constant(e)) { \
|
||||
__OS_COMPILETIME_ASSERT__(!(e)); \
|
||||
} \
|
||||
_os_assumes_log_ctx((f), (ctx), (uintptr_t)_e); \
|
||||
} \
|
||||
_e; \
|
||||
})
|
||||
|
||||
#define posix_assumes_zero_ctx(f, ctx, e) __extension__({ \
|
||||
__typeof__(e) _e = os_slowpath(e); \
|
||||
if (_e == (__typeof__(e))-1) { \
|
||||
_os_assumes_log_ctx((f), (ctx), (uintptr_t)errno); \
|
||||
} \
|
||||
_e; \
|
||||
})
|
||||
|
||||
#define os_assert_ctx(f, ctx, e) __extension__({ \
|
||||
__typeof__(e) _e = os_fastpath(e); \
|
||||
if (!_e) { \
|
||||
if (os_constant(e)) { \
|
||||
__OS_COMPILETIME_ASSERT__(e); \
|
||||
} \
|
||||
\
|
||||
char *_fail_message = _os_assert_log_ctx((f), (ctx), (uint64_t)(uintptr_t)_e); \
|
||||
os_crash(_fail_message); \
|
||||
free(_fail_message); \
|
||||
} \
|
||||
})
|
||||
|
||||
#define os_assert_zero_ctx(f, ctx, e) __extension__({ \
|
||||
__typeof__(e) _e = os_slowpath(e); \
|
||||
if (_e) { \
|
||||
if (os_constant(e)) { \
|
||||
__OS_COMPILETIME_ASSERT__(!(e)); \
|
||||
} \
|
||||
\
|
||||
char *_fail_message = _os_assert_log_ctx((f), (ctx), (uint64_t)(uintptr_t)_e); \
|
||||
os_crash(_fail_message); \
|
||||
free(_fail_message); \
|
||||
} \
|
||||
})
|
||||
|
||||
#define posix_assert_zero_ctx(f, ctx, e) __extension__({ \
|
||||
__typeof__(e) _e = os_slowpath(e); \
|
||||
if (_e == (__typeof__(e))-1) { \
|
||||
char *_fail_message = _os_assert_log_ctx((f), (ctx), (uint64_t)(uintptr_t)errno); \
|
||||
os_crash(_fail_message); \
|
||||
free(_fail_message); \
|
||||
} \
|
||||
})
|
||||
|
||||
#pragma mark internal symbols
|
||||
|
||||
__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0)
|
||||
OS_COLD OS_NOT_TAIL_CALLED
|
||||
extern void
|
||||
_os_crash(const char *);
|
||||
|
||||
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_6_0)
|
||||
OS_COLD OS_NOT_TAIL_CALLED
|
||||
extern void
|
||||
_os_assumes_log(uint64_t code);
|
||||
|
||||
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_6_0)
|
||||
OS_COLD OS_NOT_TAIL_CALLED
|
||||
extern char *
|
||||
_os_assert_log(uint64_t code);
|
||||
|
||||
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_6_0)
|
||||
OS_COLD OS_NOT_TAIL_CALLED
|
||||
extern void
|
||||
_os_assumes_log_ctx(os_log_callout_t callout, void *ctx, uint64_t code);
|
||||
|
||||
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_6_0)
|
||||
OS_COLD OS_NOT_TAIL_CALLED
|
||||
extern char *
|
||||
_os_assert_log_ctx(os_log_callout_t callout, void *ctx, uint64_t code);
|
||||
|
||||
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_6_0)
|
||||
extern void
|
||||
_os_avoid_tail_call(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __OS_ASSUMES_H__ */
|
1306
CloverPackage/utils/nvram/nvram2.c
Normal file
1306
CloverPackage/utils/nvram/nvram2.c
Normal file
File diff suppressed because it is too large
Load Diff
20
README.md
20
README.md
@ -28,15 +28,11 @@ Bootloader for macOS, Windows and Linux in UEFI and in legacy mode
|
||||
|
||||
# Building from Source
|
||||
|
||||
`mkdir -p $HOME/src && cd $HOME/src`
|
||||
|
||||
`git clone -q https://github.com/CloverHackyColor/CloverBootloader`
|
||||
|
||||
`cd CloverBootloader && git submodule update --init --recursive`
|
||||
|
||||
`cd OpenCorePkg && git checkout master && git pull`
|
||||
|
||||
`cd ..`
|
||||
|
||||
`./buildme`
|
||||
#
|
||||
```bash
|
||||
mkdir -p $HOME/src && cd $HOME/src
|
||||
git clone -q https://github.com/CloverHackyColor/CloverBootloader
|
||||
cd CloverBootloader && git submodule update --init --recursive
|
||||
cd OpenCorePkg && git checkout master && git pull
|
||||
cd ..
|
||||
./buildme
|
||||
```
|
||||
|
26
hebuild.sh
26
hebuild.sh
@ -21,6 +21,8 @@ declare -r DRIVERS_LEGACY="BIOS" # same in buildpkg.sh/makeiso
|
||||
declare -r DRIVERS_UEFI="UEFI" # same in buildpkg.sh/makeiso
|
||||
declare -r DRIVERS_OFF="off" # same in buildpkg.sh/makeiso
|
||||
|
||||
startBuildEpoch=$(date -u "+%s")
|
||||
|
||||
if [[ "$SYSNAME" == Linux ]]; then
|
||||
declare -r NUMBER_OF_CPUS=$(nproc)
|
||||
else
|
||||
@ -882,16 +884,6 @@ MainPostBuildScript() {
|
||||
echo "Generating BootSectors"
|
||||
local BOOTHFS="$CLOVERROOT"/BootHFS
|
||||
DESTDIR="$CLOVER_PKG_DIR"/BootSectors make -C $BOOTHFS
|
||||
echo "Done!"
|
||||
stopBuildEpoch=$(date -u "+%s")
|
||||
buildTime=$(expr $stopBuildEpoch - $startBuildEpoch)
|
||||
if [[ $buildTime -gt 59 ]]; then
|
||||
timeToBuild=$(printf "%dm%ds" $((buildTime/60%60)) $((buildTime%60)))
|
||||
else
|
||||
timeToBuild=$(printf "%ds" $((buildTime)))
|
||||
fi
|
||||
|
||||
printf -- "\n* %s %s %s\n" "Clover build process took " "$timeToBuild" " to complete..."
|
||||
|
||||
}
|
||||
|
||||
@ -925,3 +917,17 @@ fi
|
||||
# End: #
|
||||
#
|
||||
# vi: set expandtab ts=4 sw=4 sts=4: #
|
||||
|
||||
echo "Done!"
|
||||
stopBuildEpoch=$(date -u "+%s")
|
||||
buildTime=$(expr $stopBuildEpoch - $startBuildEpoch)
|
||||
if [[ $buildTime -ge 3600 ]]; then
|
||||
timeToBuild=$(printf "%dh%dm%ds" $((buildTime/3600)) $((buildTime/60%60)) $((buildTime%60)))
|
||||
elif [[ $buildTime -gt 59 ]]; then
|
||||
timeToBuild=$(printf "%dm%ds" $((buildTime/60%60)) $((buildTime%60)))
|
||||
else
|
||||
timeToBuild=$(printf "%ds" $((buildTime)))
|
||||
fi
|
||||
|
||||
printf -- "\n* %s %s %s\n" "Clover build process took " "$timeToBuild" " to complete..."
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
#./ebuild.sh -gcc53 -fr --no-lto --ia32 -D NO_GRUB_DRIVERS_EMBEDDED
|
||||
./ebuild.sh -gcc53 -fr -n 5 -mc --no-usb -D NO_GRUB_DRIVERS_EMBEDDED
|
||||
./ebuild.sh -gcc53 -fr -n 5 -D NO_GRUB_DRIVERS_EMBEDDED
|
||||
./ebuild.sh -gcc131 -fr -n 5 -mc --no-usb -D NO_GRUB_DRIVERS_EMBEDDED
|
||||
./ebuild.sh -gcc131 -fr -n 5 -D NO_GRUB_DRIVERS_EMBEDDED
|
||||
cd CloverPackage
|
||||
#./makepkg
|
||||
./makeiso
|
||||
|
@ -194,6 +194,7 @@ public:
|
||||
XBool KPPanicNoKextDump = XBool();
|
||||
XBool _KPAppleIntelCPUPM = XBool();
|
||||
XBool KPAppleRTC = XBool();
|
||||
XBool BlockSkywalk = XBool();
|
||||
XBool EightApple = XBool();
|
||||
XBool KPDELLSMBIOS = XBool(); // Dell SMBIOS patch
|
||||
UINT32 FakeCPUID = UINT32();
|
||||
@ -220,6 +221,7 @@ public:
|
||||
if ( !(_KPAppleIntelCPUPM == other._KPAppleIntelCPUPM ) ) return false;
|
||||
if ( !(KPAppleRTC == other.KPAppleRTC ) ) return false;
|
||||
if ( !(EightApple == other.EightApple ) ) return false;
|
||||
if ( !(BlockSkywalk == other.BlockSkywalk ) ) return false;
|
||||
if ( !(KPDELLSMBIOS == other.KPDELLSMBIOS ) ) return false;
|
||||
if ( !(FakeCPUID == other.FakeCPUID ) ) return false;
|
||||
if ( !(KPATIConnectorsController == other.KPATIConnectorsController ) ) return false;
|
||||
@ -240,6 +242,7 @@ public:
|
||||
KPPanicNoKextDump = other.dgetKPPanicNoKextDump();
|
||||
_KPAppleIntelCPUPM = other.dget_KPAppleIntelCPUPM();
|
||||
KPAppleRTC = other.dgetKPAppleRTC();
|
||||
BlockSkywalk = other.dgetBlockSkywalk();
|
||||
EightApple = other.dgetEightApple();
|
||||
KPDELLSMBIOS = other.dgetKPDELLSMBIOS();
|
||||
FakeCPUID = other.dgetFakeCPUID();
|
||||
|
@ -243,6 +243,7 @@ public:
|
||||
XmlBool PanicNoKextDump = XmlBool();
|
||||
XmlBool AppleIntelCPUPM = XmlBool();
|
||||
XmlBool AppleRTC = XmlBool();
|
||||
XmlBool BlockSkywalk = XmlBool();
|
||||
XmlBool EightApple = XmlBool();
|
||||
XmlBool DellSMBIOSPatch = XmlBool();
|
||||
XmlUInt32 FakeCPUID = XmlUInt32();
|
||||
@ -254,7 +255,7 @@ public:
|
||||
XmlArray<KernelAndKextPatches_KernelToPatch_Class> KernelToPatch = XmlArray<KernelAndKextPatches_KernelToPatch_Class>();
|
||||
XmlArray<KernelAndKextPatches_BootPatch_Class> BootPatches = XmlArray<KernelAndKextPatches_BootPatch_Class>();
|
||||
|
||||
XmlDictField m_fields[17] = {
|
||||
XmlDictField m_fields[18] = {
|
||||
{"Debug", Debug},
|
||||
{"KernelLapic", KernelLapic},
|
||||
{"KernelXCPM", KernelXCPM},
|
||||
@ -262,6 +263,7 @@ public:
|
||||
{"PanicNoKextDump", PanicNoKextDump},
|
||||
{"AppleIntelCPUPM", AppleIntelCPUPM},
|
||||
{"AppleRTC", AppleRTC},
|
||||
{"BlockSkywalk", BlockSkywalk},
|
||||
{"EightApple", EightApple},
|
||||
{"DellSMBIOSPatch", DellSMBIOSPatch},
|
||||
{"FakeCPUID", FakeCPUID},
|
||||
@ -313,6 +315,7 @@ public:
|
||||
XBool dgetKPPanicNoKextDump() const { return PanicNoKextDump.isDefined() ? PanicNoKextDump.value() : XBool(false); };
|
||||
XBool dget_KPAppleIntelCPUPM() const { return AppleIntelCPUPM.isDefined() ? AppleIntelCPUPM.value() : XBool(false); };
|
||||
XBool dgetKPAppleRTC() const { return AppleRTC.isDefined() ? AppleRTC.value() : XBool(true); };
|
||||
XBool dgetBlockSkywalk() const { return BlockSkywalk.isDefined() ? BlockSkywalk.value() : XBool(true); };
|
||||
XBool dgetEightApple() const { return EightApple.isDefined() ? EightApple.value() : XBool(false); };
|
||||
XBool dgetKPDELLSMBIOS() const { return DellSMBIOSPatch.isDefined() ? DellSMBIOSPatch.value() : XBool(false); };
|
||||
uint32_t dgetFakeCPUID() const { return FakeCPUID.isDefined() ? FakeCPUID.value() : 0; };
|
||||
|
@ -1137,24 +1137,25 @@ void LOADER_ENTRY::StartLoader()
|
||||
DBG("assign executable as '%s'\n", mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->ExecutablePath.Value);
|
||||
|
||||
}
|
||||
if (gSettings.KernelAndKextPatches.BlockSkywalk) {
|
||||
mOpenCoreConfiguration.Kernel.Block.Count = 1;
|
||||
mOpenCoreConfiguration.Kernel.Block.AllocCount = 1;
|
||||
mOpenCoreConfiguration.Kernel.Block.ValueSize = sizeof(__typeof_am__(**mOpenCoreConfiguration.Kernel.Block.Values));
|
||||
valuesSize = mOpenCoreConfiguration.Kernel.Block.AllocCount*sizeof(*mOpenCoreConfiguration.Kernel.Block.Values);
|
||||
mOpenCoreConfiguration.Kernel.Block.Values = (OC_KERNEL_BLOCK_ENTRY**)malloc(valuesSize);
|
||||
|
||||
mOpenCoreConfiguration.Kernel.Block.Count = 1;
|
||||
mOpenCoreConfiguration.Kernel.Block.AllocCount = 1;
|
||||
mOpenCoreConfiguration.Kernel.Block.ValueSize = sizeof(__typeof_am__(**mOpenCoreConfiguration.Kernel.Block.Values));
|
||||
valuesSize = mOpenCoreConfiguration.Kernel.Block.AllocCount*sizeof(*mOpenCoreConfiguration.Kernel.Block.Values);
|
||||
mOpenCoreConfiguration.Kernel.Block.Values = (OC_KERNEL_BLOCK_ENTRY**)malloc(valuesSize);
|
||||
|
||||
memset(mOpenCoreConfiguration.Kernel.Block.Values, 0, valuesSize);
|
||||
|
||||
mOpenCoreConfiguration.Kernel.Block.Values[0] = (__typeof_am__(*mOpenCoreConfiguration.Kernel.Block.Values))malloc(mOpenCoreConfiguration.Kernel.Block.ValueSize);
|
||||
memset(mOpenCoreConfiguration.Kernel.Block.Values[0], 0, mOpenCoreConfiguration.Kernel.Block.ValueSize);
|
||||
mOpenCoreConfiguration.Kernel.Block.Values[0]->Enabled = 1;
|
||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->Arch, OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Scheme.KernelArch));
|
||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->Comment, "");
|
||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->MaxKernel, "");
|
||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->MinKernel, "");
|
||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->Identifier, "com.apple.iokit.IOSkywalkFamily");
|
||||
memset(mOpenCoreConfiguration.Kernel.Block.Values, 0, valuesSize);
|
||||
|
||||
mOpenCoreConfiguration.Kernel.Block.Values[0] = (__typeof_am__(*mOpenCoreConfiguration.Kernel.Block.Values))malloc(mOpenCoreConfiguration.Kernel.Block.ValueSize);
|
||||
memset(mOpenCoreConfiguration.Kernel.Block.Values[0], 0, mOpenCoreConfiguration.Kernel.Block.ValueSize);
|
||||
mOpenCoreConfiguration.Kernel.Block.Values[0]->Enabled = 1;
|
||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->Arch, OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Scheme.KernelArch));
|
||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->Comment, "");
|
||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->MaxKernel, "");
|
||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->MinKernel, "23");
|
||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->Identifier, "com.apple.iokit.IOSkywalkFamily");
|
||||
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->Strategy, "Exclude");
|
||||
}
|
||||
#endif
|
||||
|
||||
mOpenCoreConfiguration.Uefi.Output.ProvideConsoleGop = gSettings.GUI.ProvideConsoleGop;
|
||||
|
Loading…
Reference in New Issue
Block a user