first and last commit
This commit is contained in:
commit
1bf4efd552
2612 files changed
+636500
No files matched your search
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple Computer, Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple Computer, Inc.
|
||||
*/
|
||||
#ifndef __SYS_BOOT_H
|
||||
#define __SYS_BOOT_H
|
||||
|
||||
#include <compiler.h>
|
||||
#include <lib/image.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* boot routines */
|
||||
enum boot_target {
|
||||
BOOT_UNKNOWN = 0,
|
||||
BOOT_HALT,
|
||||
BOOT_IBOOT,
|
||||
BOOT_DARWIN, // Darwin restore / boot
|
||||
BOOT_DARWIN_RESTORE, // resume from RAM
|
||||
BOOT_DIAGS,
|
||||
BOOT_TSYS,
|
||||
BOOT_SECUREROM,
|
||||
BOOT_MONITOR,
|
||||
BOOT_DALI,
|
||||
};
|
||||
|
||||
/* boot devices */
|
||||
enum boot_device {
|
||||
BOOT_DEVICE_NOR = 0,
|
||||
BOOT_DEVICE_SPI,
|
||||
BOOT_DEVICE_NAND,
|
||||
BOOT_DEVICE_NVME,
|
||||
BOOT_DEVICE_USBDFU,
|
||||
BOOT_DEVICE_TBTDFU,
|
||||
BOOT_DEVICE_XMODEM,
|
||||
};
|
||||
|
||||
/* boot flags */
|
||||
#define BOOT_FLAG_TEST_MODE (1 << 0)
|
||||
|
||||
void prepare_and_jump(enum boot_target, void *ptr, void *arg) __noreturn;
|
||||
|
||||
/* routines to boot various systems */
|
||||
void find_boot_images(void);
|
||||
int boot_diagnostics(void);
|
||||
int boot_tsys(void);
|
||||
int boot_iboot(void);
|
||||
int mount_bootfs(void);
|
||||
int mount_bootfs_from_device(const char *device);
|
||||
|
||||
int mount_and_boot_system(void);
|
||||
int mount_and_upgrade_system(void);
|
||||
int boot_upgrade_system(void);
|
||||
int restore_system(void);
|
||||
|
||||
#if WITH_BOOT_STAGE
|
||||
int boot_check_stage(void);
|
||||
int boot_set_stage(uint8_t boot_stage);
|
||||
void boot_check_panic(void);
|
||||
int boot_clear_error_count(void);
|
||||
int boot_error_count(uint32_t *boot_fail_count, uint32_t *panic_fail_count);
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple Computer, Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple Computer, Inc.
|
||||
*/
|
||||
#ifndef __SYS_CALLOUT_H
|
||||
#define __SYS_CALLOUT_H
|
||||
|
||||
#include <list.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct callout;
|
||||
typedef void (*callout_func)(struct callout *, void *);
|
||||
|
||||
struct callout {
|
||||
struct list_node list;
|
||||
|
||||
/* scheduled time */
|
||||
uint64_t sched_ticks;
|
||||
utime_t delay;
|
||||
|
||||
/* callback and args */
|
||||
callout_func callback;
|
||||
void *arg;
|
||||
};
|
||||
|
||||
void callout_enqueue(struct callout *, utime_t delay, callout_func, void *arg);
|
||||
int callout_dequeue(struct callout *);
|
||||
int callout_reset(struct callout *, utime_t newdelay); // newdelay = 0 to reuse old delay
|
||||
void callout_reset_deadline(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2014-2015 Apple Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple, Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple, Inc.
|
||||
*/
|
||||
#ifndef __SYS_HASH_H
|
||||
#define __SYS_HASH_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#if WITH_SHA2_384
|
||||
#if !WITH_CORECRYPTO && !HOST_TEST
|
||||
#error "WITH_SHA2_384 requires WITH_CORECRYPTO"
|
||||
#endif
|
||||
|
||||
#include <corecrypto/ccsha2.h>
|
||||
|
||||
#define HASH_OUTPUT_SIZE CCSHA384_OUTPUT_SIZE // bytes
|
||||
|
||||
#else // Assume SHA1
|
||||
|
||||
#include <drivers/sha1.h>
|
||||
|
||||
#define HASH_OUTPUT_SIZE CCSHA1_OUTPUT_SIZE // bytes
|
||||
|
||||
#endif
|
||||
|
||||
void hash_calculate(const void *in_ptr, size_t in_len, void *out_ptr, size_t out_len);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple Computer, Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple Computer, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Linker sets.
|
||||
*/
|
||||
|
||||
#ifndef __LINKER_SET_H__
|
||||
#define __LINKER_SET_H__
|
||||
|
||||
#include <compiler.h>
|
||||
|
||||
/*
|
||||
* Macro evil to generate the awkward Mach-O section specifier format.
|
||||
*
|
||||
* These macros should never be used outside this file.
|
||||
*
|
||||
* The end result is a line of the form
|
||||
*
|
||||
* void const *__set_<_set>_sym_<_sym> __attribute ((section("__Data,<_set>"))) = (void *)&<_sym>
|
||||
*/
|
||||
#ifndef __linux__
|
||||
# define __LS_VA_STRINGIFY(_x...) #_x
|
||||
# define __LS_VA_STRCONCAT(_x,_y) __LS_VA_STRINGIFY(_x,_y)
|
||||
# define __PUT_IN_SECTION(_seg, _sec) __attribute__ ((section(__LS_VA_STRCONCAT(_seg,_sec))))
|
||||
#else
|
||||
# define __PUT_IN_SECTION(_seg, _sec) __attribute__ ((section (#_sec)))
|
||||
#endif
|
||||
#define __LINKER_MAKE_SET(_set,_sym) \
|
||||
void const *__set_##_set##_sym_##_sym \
|
||||
__PUT_IN_SECTION(__TEXT,_set) \
|
||||
__attribute__ ((used)) \
|
||||
= (void *) &_sym
|
||||
|
||||
// The address sanitizer's metadata results in the size of each global being
|
||||
// bloated by a factor of 8
|
||||
#if !__has_feature(address_sanitizer)
|
||||
#define __LINKER_SET_STRIDE (1)
|
||||
#else
|
||||
#define __LINKER_SET_STRIDE (8)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Public macros.
|
||||
*/
|
||||
|
||||
#define LINKER_SET_ENTRY(_set,_sym) __LINKER_MAKE_SET(_set,_sym)
|
||||
|
||||
#define LINKER_SET_BEGIN(_set) __section_start(__TEXT, _set)
|
||||
#define LINKER_SET_LIMIT(_set) __section_end(__TEXT, _set)
|
||||
|
||||
|
||||
#define LINKER_SET_FOREACH(_pvar, _set) \
|
||||
for (_pvar = LINKER_SET_BEGIN(_set); \
|
||||
_pvar < LINKER_SET_LIMIT(_set); \
|
||||
_pvar += __LINKER_SET_STRIDE)
|
||||
|
||||
#define LINKER_SET_ITEM(_set, _i) LINKER_SET_BEGIN(_set)[_i]
|
||||
|
||||
#endif /* __LINKER_SET_H__ */
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2008 Apple Inc. All rights reserved.
|
||||
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple Computer, Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple Computer, Inc.
|
||||
*/
|
||||
#ifndef __SYS_MENU_H
|
||||
#define __SYS_MENU_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/security.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct cmd_arg {
|
||||
int n;
|
||||
size_t u;
|
||||
size_t h;
|
||||
bool b;
|
||||
char *str;
|
||||
};
|
||||
|
||||
typedef int (*cmd_func)(int argc, struct cmd_arg *args);
|
||||
|
||||
struct cmd_menu_item {
|
||||
const char *cmd;
|
||||
cmd_func func;
|
||||
const char *help;
|
||||
void *meta;
|
||||
};
|
||||
|
||||
extern utime_t gMenuLastActivityTime;
|
||||
extern struct task_event gMenuTaskReadyEvent;
|
||||
|
||||
bool process_command_line(char *line, int *last_command_rval);
|
||||
int menu_task(void *arg);
|
||||
char *menu_prompt(char *new_prompt);
|
||||
|
||||
extern struct bgcolor g_bgcolor;
|
||||
|
||||
/*
|
||||
* New-style linker magic menu command registration.
|
||||
*/
|
||||
#include <sys/linker_set.h>
|
||||
#if WITH_MENU
|
||||
|
||||
#define MENU_COMMAND_PROTOTYPE(_function) \
|
||||
int _function(int argc, struct cmd_arg *args)
|
||||
|
||||
#define MENU_COMMAND_HELPER(_command, _function, _help, _meta) \
|
||||
MENU_COMMAND_PROTOTYPE(_function); \
|
||||
static const struct cmd_menu_item __attribute__((used)) \
|
||||
__menu_entry_##_command = { \
|
||||
#_command, \
|
||||
_function, \
|
||||
_help, \
|
||||
_meta \
|
||||
}; \
|
||||
LINKER_SET_ENTRY(menu, __menu_entry_##_command)
|
||||
|
||||
// MENU_COMMAND always gets you a menu command, but when using
|
||||
// the simple menu (release builds and memory-tight accessories)
|
||||
// don't compile in the help strings
|
||||
#if !WITH_SIMPLE_MENU
|
||||
#define MENU_COMMAND(_c, _f, _h, _m) MENU_COMMAND_HELPER(_c, _f, _h, _m)
|
||||
#else
|
||||
#define MENU_COMMAND(_c, _f, _h, _m) MENU_COMMAND_HELPER(_c, _f, "", _m)
|
||||
#endif
|
||||
|
||||
/* MENU_COMMAND_DEVELOPMENT gets you a menu command in DEVELOPMENT_BUILD and DEBUG_BUILD */
|
||||
#if (DEVELOPMENT_BUILD || DEBUG_BUILD)
|
||||
# define MENU_COMMAND_DEVELOPMENT(_c, _f, _h, _m) MENU_COMMAND(_c, _f, _h, _m)
|
||||
#else
|
||||
# define MENU_COMMAND_DEVELOPMENT(_c, _f, _h, _m) struct _hack
|
||||
#endif
|
||||
|
||||
/* MENU_COMMAND_DEBUG gets you a menu command in DEBUG_BUILD only */
|
||||
#if DEBUG_BUILD
|
||||
# define MENU_COMMAND_DEBUG(_c, _f, _h, _m) MENU_COMMAND(_c, _f, _h, _m)
|
||||
#else
|
||||
# define MENU_COMMAND_DEBUG(_c, _f, _h, _m) struct _hack
|
||||
#endif
|
||||
|
||||
#else
|
||||
/* no WITH_MENU, nop these out and cause the linker to delete everything else */
|
||||
#define MENU_COMMAND(_c, _f, _h, _m) struct _hack
|
||||
#define MENU_COMMAND_DEVELOPMENT(_c, _f, _h, _m) struct _hack
|
||||
#define MENU_COMMAND_DEBUG(_c, _f, _h, _m) struct _hack
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2015 Apple, Inc. All rights reserved.
|
||||
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple, Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple, Inc.
|
||||
*/
|
||||
#ifndef __SYS_SECURITY_H
|
||||
#define __SYS_SECURITY_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define kSecurityModeExUntrust (1 << 4)
|
||||
#define kSecurityModeKDPEnabled (1 << 5)
|
||||
#define kSecurityModeDebugCmd (1 << 8)
|
||||
#define kSecurityModeMemAccess (1 << 16)
|
||||
#define kSecurityModeHWAccess (1 << 17)
|
||||
#define kSecurityModeGIDKeyAccess (1 << 18)
|
||||
#define kSecurityModeUIDKeyAccess (1 << 19)
|
||||
#define kSecurityModeDevCertAccess (1 << 20)
|
||||
#define kSecurityModeProdCertAccess (1 << 21)
|
||||
#define kSecurityOptionClearProduction (1 << 24)
|
||||
#define kSecurityOptionMixNMatchPrevented (1 << 25)
|
||||
#define kSecurityOptionBootManifestHashValid (1 << 26)
|
||||
#define kSecurityOptionLockFuses (1 << 27)
|
||||
#define kSecurityStatusSecureBoot (1 << 28)
|
||||
#define kSecurityStatusSystemTrusted (1 << 29)
|
||||
|
||||
#define kSleepTokenKernelOffset (0x80)
|
||||
#define kSleepTokeniBootOffset (0x90)
|
||||
|
||||
typedef u_int32_t security_mode_t;
|
||||
|
||||
|
||||
#define kSecurityImageInvalid (0)
|
||||
#define kSecurityImageUntrusted (1)
|
||||
#define kSecurityImageTrusted (2)
|
||||
|
||||
typedef u_int32_t security_image_t;
|
||||
|
||||
int security_init(bool clear_memory);
|
||||
bool security_allow_modes(security_mode_t modes);
|
||||
bool security_validate_image(security_image_t image_validity);
|
||||
bool security_allow_memory(const void *address, size_t length);
|
||||
void security_protect_memory(const void *address, size_t length, bool protect);
|
||||
void security_enable_kdp(void);
|
||||
void security_set_untrusted(void);
|
||||
void security_set_production_override(bool override);
|
||||
bool security_get_production_override(void);
|
||||
void security_create_sleep_token(addr_t address);
|
||||
bool security_validate_sleep_token(addr_t address);
|
||||
bool security_get_effective_production_status(bool with_demotion);
|
||||
void security_set_boot_manifest_hash(u_int8_t *boot_manifest_hash);
|
||||
bool security_get_boot_manifest_hash(u_int8_t *boot_manifest_hash, u_int32_t hash_length);
|
||||
void security_set_mix_n_match_prevention_status(bool mix_n_match_enforced);
|
||||
bool security_get_mix_n_match_prevention_status(void);
|
||||
void security_set_lock_fuses(void);
|
||||
bool security_get_lock_fuses(void);
|
||||
bool security_consolidate_environment(void);
|
||||
bool security_restore_environment(void);
|
||||
void security_sidp_seal_rom_manifest(void);
|
||||
void security_sidp_seal_boot_manifest(bool require_unlocked);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2011 Apple Inc. All rights reserved.
|
||||
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple Computer, Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple Computer, Inc.
|
||||
*/
|
||||
#ifndef __SYS_TASK_H
|
||||
#define __SYS_TASK_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <arch/arch_task.h>
|
||||
#include <compiler.h>
|
||||
#include <list.h>
|
||||
#include <sys/callout.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef int (*task_routine)(void *);
|
||||
|
||||
enum task_state {
|
||||
TASK_INITIAL,
|
||||
TASK_READY,
|
||||
TASK_RUNNING,
|
||||
TASK_BLOCKED,
|
||||
TASK_SLEEPING,
|
||||
TASK_FINISHED
|
||||
};
|
||||
|
||||
struct task_wait_queue {
|
||||
struct list_node task_list;
|
||||
};
|
||||
|
||||
#define TASK_MAGIC 'task'
|
||||
#define TASK_MAGIC2 'tsk2'
|
||||
#define TASK_NAME_MAX 15
|
||||
#if defined(__LP64__)
|
||||
#define TASK_STACK_MIN (16384)
|
||||
#else
|
||||
#define TASK_STACK_MIN (512)
|
||||
#endif
|
||||
|
||||
struct task {
|
||||
int magic;
|
||||
|
||||
struct list_node task_list_node;
|
||||
struct list_node queue_node;
|
||||
|
||||
/* track the state of the task (READY, RUNNING, etc) */
|
||||
enum task_state state;
|
||||
|
||||
/* interrupt disable count */
|
||||
int irq_disable_count;
|
||||
|
||||
/* saved registers, stack pointer */
|
||||
struct arch_task arch;
|
||||
|
||||
/* a callout for sleeping */
|
||||
struct callout sleep_callout;
|
||||
|
||||
/* to track other tasks waiting on our completion */
|
||||
struct task_wait_queue return_waiters;
|
||||
int return_code;
|
||||
|
||||
/* starting routine and argument */
|
||||
task_routine routine;
|
||||
void *arg;
|
||||
|
||||
/* stack */
|
||||
void *stack_base;
|
||||
size_t stack_len;
|
||||
|
||||
/* debug name of this task */
|
||||
char name[TASK_NAME_MAX + 1];
|
||||
|
||||
/* unique id of this task */
|
||||
int task_id;
|
||||
|
||||
int magic2;
|
||||
};
|
||||
|
||||
/* statistics */
|
||||
struct idle_statistics {
|
||||
u_int64_t uptime_ticks;
|
||||
u_int64_t deep_idle_ticks;
|
||||
u_int64_t deep_idles;
|
||||
u_int64_t idle_ticks;
|
||||
u_int64_t idles;
|
||||
u_int32_t ticksHz;
|
||||
u_int32_t threshold_us;
|
||||
};
|
||||
|
||||
/* the currently running task */
|
||||
extern struct task *current_task;
|
||||
|
||||
/* initialize the tasking system */
|
||||
void task_init(void);
|
||||
|
||||
/* create a new task */
|
||||
struct task *task_create(const char *name, task_routine routine, void *arg, size_t stack_len);
|
||||
void task_destroy(struct task *);
|
||||
|
||||
/* give up the cpu to another task */
|
||||
void task_yield(void);
|
||||
void task_start(struct task *);
|
||||
void task_exit(int return_code) __noreturn;
|
||||
int task_wait_on(struct task *);
|
||||
void task_block(struct task_wait_queue *);
|
||||
void task_sleep(utime_t delay);
|
||||
struct task *task_get_current_task(void);
|
||||
|
||||
/* wait_queue routines */
|
||||
void wait_queue_init(struct task_wait_queue *);
|
||||
void wait_queue_destroy(struct task_wait_queue *);
|
||||
int wait_queue_wake_all(struct task_wait_queue *);
|
||||
int wait_queue_wake_one(struct task_wait_queue *);
|
||||
|
||||
/* profile the task manager */
|
||||
void task_get_statistics(struct idle_statistics *);
|
||||
|
||||
/* define the application's deep idle policy */
|
||||
void task_set_idle_threshold(u_int32_t us);
|
||||
|
||||
/* events */
|
||||
struct task_event {
|
||||
bool signalled;
|
||||
uint32_t flags;
|
||||
|
||||
struct task_wait_queue wait;
|
||||
};
|
||||
|
||||
#define EVENT_STATIC_INIT(_struct, _initial, _flags) \
|
||||
{ \
|
||||
.signalled = _initial, \
|
||||
.flags = _flags, \
|
||||
.wait = { .task_list = LIST_INITIAL_VALUE(_struct.wait.task_list) } \
|
||||
}
|
||||
|
||||
/*
|
||||
* event_init
|
||||
*
|
||||
* Initialise a task_event structure for use.
|
||||
*/
|
||||
void event_init(struct task_event *, uint32_t flags, bool initial_state);
|
||||
|
||||
#define EVENT_FLAG_AUTO_UNSIGNAL 1
|
||||
|
||||
/*
|
||||
* event_signal
|
||||
*
|
||||
* Signal a task_event, potentially waking one or more tasks waiting on the
|
||||
* event. If the event is marked EVENT_FLAG_AUTO_UNSIGNAL, only one waiting
|
||||
* task will be woken each time the event is
|
||||
* signalled.
|
||||
*/
|
||||
void event_signal(struct task_event *);
|
||||
|
||||
/*
|
||||
* event_unsignal
|
||||
*
|
||||
* Clear the is-signalled state of a task_event. This does not affect the
|
||||
* scheduling state of any tasks that may be waiting on the event.
|
||||
*/
|
||||
void event_unsignal(struct task_event *);
|
||||
|
||||
/*
|
||||
* event_wait
|
||||
* event_wait_timeout
|
||||
*
|
||||
* Wait for a task_event to be signalled. If the event is marked
|
||||
* EVENT_FLAG_AUTO_UNSIGNAL, only one waiting task will be woken each time the
|
||||
* event is signalled.
|
||||
*
|
||||
* If the timeout expires and the task_event is not signalled, event_wait_timeout
|
||||
* returns false.
|
||||
*
|
||||
* If the timeout is zero, event_wait_timeout will return immediately with the current
|
||||
* state of the task_event.
|
||||
*/
|
||||
void event_wait(struct task_event *);
|
||||
bool event_wait_timeout(struct task_event *, utime_t delay);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user