first and last commit
This commit is contained in:
commit
1bf4efd552
2612 files changed
+636500
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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 __AVAILABILITY__
|
||||
#define __AVAILABILITY__
|
||||
|
||||
#define __OSX_AVAILABLE_STARTING(_mac, _iphone)
|
||||
#define __OSX_AVAILABLE_BUT_DEPRECATED(_macIntro, _macDep, _iphoneIntro, _iphoneDep)
|
||||
#define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_macIntro, _macDep, _iphoneIntro, _iphoneDep, _msg)
|
||||
|
||||
#endif // __AVAILABILITY__
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2010 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 __ARCH_H
|
||||
#define __ARCH_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <compiler.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct arch_task;
|
||||
struct task;
|
||||
|
||||
int arch_cpu_init(bool resume);
|
||||
int arch_cpu_init_posttasks(void);
|
||||
int arch_cpu_quiesce(void);
|
||||
|
||||
void arch_halt(void);
|
||||
void arch_spin(void) __attribute__((noreturn));
|
||||
|
||||
u_int32_t arch_get_noncached_address(u_int32_t address);
|
||||
|
||||
u_int32_t arch_enable_ints(void);
|
||||
u_int32_t arch_disable_ints(void);
|
||||
u_int32_t arch_restore_ints(u_int32_t state);
|
||||
|
||||
/*
|
||||
* arch_task_create
|
||||
*
|
||||
* Initialises the architecture-specific fields in the given task
|
||||
* such that it can be switched to and run.
|
||||
*/
|
||||
int arch_task_create(struct task *); // used internally by task_create()
|
||||
|
||||
/*
|
||||
* arch_task_context_switch
|
||||
*
|
||||
* Switches execution from the current task to a new task. This can be used to
|
||||
* save the current state by switching from and to the same task.
|
||||
*/
|
||||
void arch_task_context_switch(struct arch_task *old, struct arch_task *new_task);
|
||||
|
||||
/*
|
||||
* arch_task_context_restore
|
||||
*
|
||||
* Switches execution to a previously saved state.
|
||||
*/
|
||||
void arch_task_context_restore(struct arch_task *restore_context);
|
||||
|
||||
/*
|
||||
* Prints a backtrace for the current execution context.
|
||||
*/
|
||||
void arch_backtrace_current_task(void *stack_base, size_t stack_len);
|
||||
|
||||
/*
|
||||
* Prints a backtrace for the given task.
|
||||
*/
|
||||
void arch_backtrace_task(struct arch_task *arch_task, void *stack_base, size_t stack_len);
|
||||
|
||||
#if WITH_VFP
|
||||
/*
|
||||
* arch_task_fp_enable
|
||||
*
|
||||
* Enable floating point support for the current task.
|
||||
*/
|
||||
bool arch_task_fp_enable(bool enable);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Collects entropy by reading a counter across
|
||||
* an asynchronous boundary. The returned word
|
||||
* will ideally contain at least one bit of entropy.
|
||||
*/
|
||||
u_int32_t arch_get_entropy(volatile u_int32_t *counter_address);
|
||||
|
||||
extern const char *build_banner_string;
|
||||
extern const char *build_style_string;
|
||||
extern const char *build_tag_string;
|
||||
|
||||
extern void _text_start __segment_start_sym(__TEXT);
|
||||
extern void _text_end __segment_end_sym(__TEXT);
|
||||
extern void _data_start __segment_start_sym(__DATA);
|
||||
extern void _data_end __segment_end_sym(__DATA);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2011 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 __ASSERT_H
|
||||
#define __ASSERT_H
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#define assert(x) RELEASE_ASSERT(x)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2009 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 __IOSTREAM_H
|
||||
#define __IOSTREAM_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <lib/libc.h>
|
||||
|
||||
struct ostream
|
||||
{
|
||||
ostream & operator << (const char *str)
|
||||
{
|
||||
printf("%s", str);
|
||||
return(*this);
|
||||
}
|
||||
|
||||
ostream & operator << (char *str)
|
||||
{
|
||||
printf("%s", str);
|
||||
return(*this);
|
||||
}
|
||||
|
||||
ostream & operator << (int x)
|
||||
{
|
||||
printf("%d", x);
|
||||
return(*this);
|
||||
}
|
||||
|
||||
ostream & operator << (unsigned int x)
|
||||
{
|
||||
printf("%u", x);
|
||||
return(*this);
|
||||
}
|
||||
|
||||
ostream & operator << (long long int x)
|
||||
{
|
||||
printf("%lld", x);
|
||||
return(*this);
|
||||
}
|
||||
|
||||
ostream & operator << (unsigned long long int x)
|
||||
{
|
||||
printf("%llu", x);
|
||||
return(*this);
|
||||
}
|
||||
|
||||
ostream & operator << (char ch)
|
||||
{
|
||||
printf("%c", ch);
|
||||
return(*this);
|
||||
}
|
||||
};
|
||||
|
||||
struct istream
|
||||
{
|
||||
istream & operator << (char &ch)
|
||||
{
|
||||
ch = getchar();
|
||||
return(*this);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
extern const char *endl;
|
||||
extern ostream cout;
|
||||
extern ostream cerr;
|
||||
extern istream cin;
|
||||
|
||||
#endif /* __IOSTREAM_H */
|
||||
@@ -0,0 +1,320 @@
|
||||
/*
|
||||
* 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 _CBUFER_H_
|
||||
#define _CBUFER_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys.h>
|
||||
#include <lib/libc.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define CB_ALIGNMENT 64
|
||||
|
||||
typedef struct _CBUFFER {
|
||||
uint8_t * head;
|
||||
uint8_t * tail;
|
||||
size_t size;
|
||||
size_t readableSize;
|
||||
size_t bufferSize;
|
||||
uint8_t * dataStart;
|
||||
uint8_t * dataEnd;
|
||||
} CBUFFER;
|
||||
|
||||
#define cb_fix_high( ptr, pcb ) \
|
||||
if( pcb->ptr >= pcb->dataEnd ) { \
|
||||
pcb->ptr = pcb->dataStart; \
|
||||
}
|
||||
|
||||
#define cb_cs_encap( theCall, retType ) \
|
||||
retType ret; \
|
||||
enter_critical_section(); \
|
||||
ret = theCall; \
|
||||
exit_critical_section(); \
|
||||
return ret
|
||||
|
||||
|
||||
|
||||
static inline bool cb_initialized( CBUFFER * pcb )
|
||||
{
|
||||
return pcb->dataStart?true:false;
|
||||
}
|
||||
|
||||
static inline int cb_create( CBUFFER * pcb, size_t size )
|
||||
{
|
||||
// round up
|
||||
size = (size + CB_ALIGNMENT-1) & ~(CB_ALIGNMENT-1);
|
||||
pcb->dataStart = (uint8_t *)memalign( size, CB_ALIGNMENT );
|
||||
|
||||
pcb->head = pcb->tail = pcb->dataStart;
|
||||
pcb->dataEnd = pcb->dataStart+size;
|
||||
pcb->size = 0;
|
||||
pcb->readableSize = 0;
|
||||
pcb->bufferSize = size;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static inline void cb_reset( CBUFFER * pcb )
|
||||
{
|
||||
enter_critical_section();
|
||||
pcb->head = pcb->tail = pcb->dataStart;
|
||||
pcb->size = 0;
|
||||
pcb->readableSize = 0;
|
||||
pcb->bufferSize = pcb->dataEnd - pcb->dataStart;
|
||||
exit_critical_section();
|
||||
}
|
||||
|
||||
static inline uint32_t cb_size( CBUFFER * pcb)
|
||||
{
|
||||
return pcb->size;
|
||||
}
|
||||
|
||||
static inline uint32_t cb_readable_size( CBUFFER * pcb )
|
||||
{
|
||||
return pcb->readableSize;
|
||||
}
|
||||
|
||||
static inline uint8_t * cb_get_head( CBUFFER * pcb )
|
||||
{
|
||||
return pcb->head;
|
||||
}
|
||||
|
||||
static inline uint32_t cb_free_space( CBUFFER * pcb )
|
||||
{
|
||||
return pcb->bufferSize - cb_size(pcb);
|
||||
}
|
||||
|
||||
static inline uint32_t cb_block_free_space_unsafe( CBUFFER * pcb )
|
||||
{
|
||||
uint32_t freeTotal = cb_free_space(pcb);
|
||||
uint32_t freeTillEnd = pcb->dataEnd-pcb->head;
|
||||
|
||||
return __min( freeTotal, freeTillEnd );
|
||||
}
|
||||
|
||||
|
||||
static inline uint32_t cb_block_free_space( CBUFFER * pcb )
|
||||
{
|
||||
cb_cs_encap( cb_block_free_space_unsafe( pcb ), uint32_t );
|
||||
}
|
||||
|
||||
static inline uint8_t * cb_block_read_ptr_unsafe( CBUFFER * pcb, uint32_t * pamount )
|
||||
{
|
||||
uint8_t * ret = pcb->tail;
|
||||
|
||||
/*printf( "data 0x%08X, head 0x%08X, tail 0x%08X, data end %08X, size %d\n",
|
||||
(uint)pcb->dataStart, (uint)pcb->head, (uint)pcb->tail, (uint)pcb->dataEnd, (uint)cb_size( pcb ) ); */
|
||||
if( pcb->head <= pcb->tail ){
|
||||
// header is past tail, so there is a wrap around
|
||||
*pamount = pcb->dataEnd-pcb->tail;
|
||||
pcb->size -= *pamount;
|
||||
pcb->readableSize -= *pamount;
|
||||
pcb->tail = pcb->dataStart;
|
||||
} else {
|
||||
// we can consume all of it
|
||||
pcb->tail = pcb->head;
|
||||
*pamount = pcb->size;
|
||||
pcb->size = 0;
|
||||
pcb->readableSize = 0;
|
||||
}
|
||||
/*printf( "- data 0x%08X, head 0x%08X, tail 0x%08X, data end %08X, size %d\n",
|
||||
(uint)pcb->dataStart, (uint)pcb->head, (uint)pcb->tail, (uint)pcb->dataEnd, (uint)cb_size( pcb ) ); */
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline uint8_t * cb_block_read_ptr( CBUFFER * pcb, uint32_t * pamount )
|
||||
{
|
||||
cb_cs_encap( cb_block_read_ptr_unsafe( pcb, pamount ), uint8_t * );
|
||||
}
|
||||
|
||||
static inline void cb_pre_skip( CBUFFER * pcb, uint32_t amount )
|
||||
{
|
||||
uint32_t bfs;
|
||||
enter_critical_section();
|
||||
|
||||
pcb->size += amount;
|
||||
|
||||
bfs = pcb->dataEnd-pcb->head;
|
||||
|
||||
if( bfs > amount ){
|
||||
//printf( "a bfs %d, amount %d\n", bfs, amount );
|
||||
pcb->head += amount;
|
||||
} else {
|
||||
//printf( "b bfs %d, amount %d\n", bfs, amount );
|
||||
pcb->head = pcb->dataStart + amount-bfs;
|
||||
}
|
||||
|
||||
exit_critical_section();
|
||||
|
||||
}
|
||||
|
||||
static inline void cb_post_skip( CBUFFER * pcb, uint32_t amount )
|
||||
{
|
||||
|
||||
enter_critical_section();
|
||||
|
||||
|
||||
/*printf( "$ data 0x%08X, head 0x%08X, tail 0x%08X, data end %08X, size %d\n",
|
||||
(uint)pcb->dataStart, (uint)pcb->head, (uint)pcb->tail, (uint)pcb->dataEnd, (uint)cb_size( pcb ) ); */
|
||||
|
||||
// update internal count to reflect the new data now available to read
|
||||
pcb->readableSize += amount;
|
||||
|
||||
|
||||
/*printf( "* data 0x%08X, head 0x%08X, tail 0x%08X, data end %08X, size %d\n",
|
||||
(uint)pcb->dataStart, (uint)pcb->head, (uint)pcb->tail, (uint)pcb->dataEnd, (uint)cb_size( pcb ) ); */
|
||||
|
||||
exit_critical_section();
|
||||
|
||||
}
|
||||
|
||||
static inline int cb_putc_unsafe( CBUFFER * pcb, uint8_t c )
|
||||
{
|
||||
if( cb_free_space( pcb ) ){
|
||||
*pcb->head++ = c;
|
||||
|
||||
cb_fix_high( head, pcb );
|
||||
|
||||
pcb->size++;
|
||||
pcb->readableSize++;
|
||||
return c;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline int cb_putc( CBUFFER * pcb, uint8_t c )
|
||||
{
|
||||
cb_cs_encap( cb_putc_unsafe( pcb, c ), int );
|
||||
}
|
||||
|
||||
static inline int cb_peekc_unsafe( CBUFFER * pcb )
|
||||
{
|
||||
if( cb_size( pcb ) ){
|
||||
return *pcb->tail;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline int cb_peekc( CBUFFER * pcb )
|
||||
{
|
||||
cb_cs_encap( cb_peekc_unsafe( pcb ), int );
|
||||
}
|
||||
|
||||
static inline int cb_getc_unsafe( CBUFFER * pcb )
|
||||
{
|
||||
if( cb_size( pcb ) ){
|
||||
uint8_t ret = *pcb->tail++;
|
||||
|
||||
cb_fix_high( tail, pcb );
|
||||
|
||||
pcb->size--;
|
||||
pcb->readableSize--;
|
||||
|
||||
return ret;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int cb_getc( CBUFFER * pcb )
|
||||
{
|
||||
cb_cs_encap( cb_getc_unsafe( pcb ), int );
|
||||
}
|
||||
|
||||
static inline uint32_t cb_read_unsafe( CBUFFER * pcb, uint8_t * buffer, size_t size )
|
||||
{
|
||||
uint32_t readable = cb_readable_size( pcb );
|
||||
if( readable ){
|
||||
size = __min( size, readable );
|
||||
size_t blockSize = pcb->dataEnd-pcb->tail;
|
||||
|
||||
if( blockSize < size ){
|
||||
// we must copy some part of the data from tail-->dataEnd
|
||||
// and then copy the rest from dataStart
|
||||
memcpy( buffer, pcb->tail, blockSize );
|
||||
buffer += blockSize;
|
||||
|
||||
blockSize = size - blockSize;
|
||||
pcb->tail = pcb->dataStart + blockSize;
|
||||
memcpy( buffer, pcb->dataStart, blockSize );
|
||||
|
||||
} else {
|
||||
// we can copy the entire block from tail
|
||||
memcpy( buffer, pcb->tail, size );
|
||||
|
||||
pcb->tail += size;
|
||||
|
||||
}
|
||||
|
||||
pcb->size -= size;
|
||||
pcb->readableSize -= size;
|
||||
|
||||
return size;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint32_t cb_read( CBUFFER * pcb, uint8_t * buffer, size_t size )
|
||||
{
|
||||
cb_cs_encap( cb_read_unsafe( pcb, buffer, size ), uint32_t );
|
||||
}
|
||||
|
||||
static inline int cb_write_unsafe( CBUFFER * pcb, const uint8_t * buffer, size_t size )
|
||||
{
|
||||
if( cb_free_space( pcb ) ){
|
||||
size = __min( size, pcb->bufferSize-pcb->size );
|
||||
size_t blockSize = pcb->dataEnd-pcb->head;
|
||||
if( blockSize < size ){
|
||||
// must write in blocks from head-->dataEnd
|
||||
// and then from dataStart
|
||||
memcpy( pcb->head, buffer, blockSize );
|
||||
buffer += blockSize;
|
||||
|
||||
blockSize = size - blockSize;
|
||||
pcb->head = pcb->dataStart + blockSize;
|
||||
memcpy( pcb->dataStart, buffer, blockSize );
|
||||
|
||||
} else {
|
||||
memcpy( pcb->head, buffer, size );
|
||||
pcb->head += size;
|
||||
|
||||
}
|
||||
|
||||
pcb->size += size;
|
||||
pcb->readableSize += size;
|
||||
|
||||
return size;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline int cb_write( CBUFFER * pcb, const uint8_t * buffer, size_t size )
|
||||
{
|
||||
cb_cs_encap( cb_write_unsafe( pcb, buffer, size ), int );
|
||||
}
|
||||
|
||||
static inline void cb_free( CBUFFER * pcb )
|
||||
{
|
||||
free( pcb->dataStart );
|
||||
pcb->dataEnd = pcb->dataStart = NULL;
|
||||
}
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (C) 2006,2011 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 __COMPILER_H
|
||||
#define __COMPILER_H
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
#ifndef offsetof
|
||||
# define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
|
||||
#endif
|
||||
#define clz(_x) __builtin_clz(_x)
|
||||
#define ctz(_x) __builtin_ctz(_x)
|
||||
|
||||
#define __max(_x, _y) ({ typeof (_x) _a = (_x); typeof (_y) _b = (_y); _a > _b ? _a : _b; })
|
||||
#define __min(_x, _y) ({ typeof (_x) _a = (_x); typeof (_y) _b = (_y); _a < _b ? _a : _b; })
|
||||
|
||||
#ifndef __unused
|
||||
# define __unused __attribute__((unused))
|
||||
#endif
|
||||
#ifndef __pure
|
||||
# define __pure __attribute__((pure))
|
||||
#endif
|
||||
#ifndef __printflike
|
||||
# define __printflike(__fmt,__varargs) __attribute__((__format__ (__printf__, __fmt, __varargs)))
|
||||
#endif
|
||||
#ifndef __scanflike
|
||||
# define __scanflike(__fmt,__varargs) __attribute__((__format__ (__scanf__, __fmt, __varargs)))
|
||||
#endif
|
||||
|
||||
#ifndef __used
|
||||
# define __used __attribute__((used))
|
||||
#endif
|
||||
#define __packed __attribute__((packed))
|
||||
#define __aligned(x) __attribute__((aligned(x)))
|
||||
#define __noreturn __attribute__((noreturn))
|
||||
#ifndef __always_inline
|
||||
# define __always_inline __attribute__((always_inline))
|
||||
#endif
|
||||
#define __deprecated __attribute__((deprecated))
|
||||
#ifndef __nonnull
|
||||
#define __nonnull(_x) __attribute__((nonnull _x))
|
||||
#endif
|
||||
#define __malloc __attribute__((malloc))
|
||||
#define __warn_unused_result __attribute__((warn_unused_result))
|
||||
#define __return_address(_x) __builtin_return_address(_x)
|
||||
#ifndef __has_feature
|
||||
# define has_feature(x) 0
|
||||
#endif
|
||||
|
||||
#ifndef __has_builtin
|
||||
# define __has_builtin(x) 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Statement expressions for determining the start/end of segments and sections.
|
||||
*
|
||||
* These are uglier than they should be courtesy of
|
||||
* <rdar://problem/9245770> No way to generate new segment/section boundary symbols from C code
|
||||
*/
|
||||
/* these have to be used at function scope due to their use of statement expressions */
|
||||
#ifndef __linux__
|
||||
#define __segment_start(_seg) \
|
||||
({extern void *__seg_start_##_seg __asm("segment$start$" #_seg); &__seg_start_##_seg;})
|
||||
|
||||
#define __segment_end(_seg) \
|
||||
({extern void *__seg_end_##_seg __asm("segment$end$" #_seg); &__seg_end_##_seg;})
|
||||
|
||||
#define __section_start(_seg, _sec) \
|
||||
({extern void *__sec_start_##_seg##_sec __asm("section$start$" #_seg "$" #_sec); &__sec_start_##_seg##_sec;})
|
||||
|
||||
#define __section_end(_seg, _sec) \
|
||||
({extern void *__sec_end_##_seg##_sec __asm("section$end$" #_seg "$" #_sec); &__sec_end_##_seg##_sec;})
|
||||
#else
|
||||
#define __section_start(_seg, _sec) ({extern void *__start_##_sec; &__start_##_sec;})
|
||||
#define __section_end(_seg, _sec) ({extern void *__stop_##_sec; &__stop_##_sec;})
|
||||
#endif
|
||||
|
||||
|
||||
/* these work at global scope, when tagged onto the definition of a variable */
|
||||
#define __segment_start_sym(_seg) __asm("segment$start$" #_seg)
|
||||
#define __segment_end_sym(_seg) __asm("segment$end$" #_seg)
|
||||
#define __section_start_sym(_seg, _sec) __asm("section$start$" #_seg "$" #_sec)
|
||||
#define __section_end_sym(_seg, _sec) __asm("section$end$" #_seg "$" #_sec)
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __COMPILER_H */
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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 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 __DEBUG_H
|
||||
#define __DEBUG_H
|
||||
|
||||
#include <compiler.h>
|
||||
#include <stdio.h>
|
||||
#include <sys.h>
|
||||
|
||||
#ifndef DEBUG_UART_ENABLE_DEFAULT
|
||||
# define DEBUG_UART_ENABLE_DEFAULT 0
|
||||
#endif
|
||||
|
||||
#define DEBUG_SILENT 0
|
||||
#define DEBUG_RELEASE 5
|
||||
#define DEBUG_CRITICAL 10
|
||||
#define DEBUG_INFO 20
|
||||
#define DEBUG_SPEW 30
|
||||
#define DEBUG_NEVER 40
|
||||
|
||||
#ifndef DEBUG_LEVEL
|
||||
# if DEBUG_BUILD
|
||||
# define DEBUG_LEVEL DEBUG_INFO
|
||||
# else
|
||||
# define DEBUG_LEVEL DEBUG_CRITICAL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef OBFUSCATED_LOGGING
|
||||
# if RELEASE_BUILD
|
||||
# define OBFUSCATED_LOGGING 1
|
||||
# else
|
||||
# define OBFUSCATED_LOGGING 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define dprintf(level, x...) \
|
||||
do { \
|
||||
if ((level) <= DEBUG_LEVEL) { \
|
||||
if (OBFUSCATED_LOGGING && (level) > DEBUG_RELEASE) { printf("%llx:%d\n", DEBUG_FILE_HASH, __LINE__); } \
|
||||
else { printf(x); } \
|
||||
} \
|
||||
} while(0)
|
||||
#define dhexdump(level, ptr, len) \
|
||||
do { \
|
||||
if ((level) <= DEBUG_LEVEL) { \
|
||||
if (OBFUSCATED_LOGGING && (level) > DEBUG_RELEASE) { printf("%llx:%d\n", DEBUG_FILE_HASH, __LINE__); } \
|
||||
else { hexdump(ptr, len); } \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define __ASSERT(_x, _str) \
|
||||
do { \
|
||||
if (unlikely(!(_x))) { \
|
||||
panic("ASSERT FAILED at (%s:%d)\n", __FILE__, __LINE__);\
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#if DEBUG_BUILD || ENABLE_RELEASE_ASSERTS || defined(__clang_analyzer__)
|
||||
/* for debug builds, turn all the asserts */
|
||||
# define RELEASE_ASSERT(_x) __ASSERT(_x, #_x)
|
||||
# define ASSERT(_x) __ASSERT(_x, #_x)
|
||||
#else
|
||||
/* for release, development builds */
|
||||
# define RELEASE_ASSERT(_x) __ASSERT(_x, #_x)
|
||||
# define ASSERT(_x) do {if (_x) {}} while(0)
|
||||
#endif
|
||||
|
||||
#define static_assert(assertion, error) _Static_assert(assertion, error)
|
||||
|
||||
#if WITH_SIMULATION_TRACE
|
||||
/*
|
||||
* To enable postmortem analysis of non-debug code being run in simulation, we allow a platform to
|
||||
* define two locations to which we will write trace data; one for location, one for parameters.
|
||||
* This also permits watchpoint debugging using a hardware debugger.
|
||||
*
|
||||
* In both cases, the write to the IP trace register stores the address of the current function.
|
||||
* Following this are either one or two writes to the parameter trace register; the first gives the
|
||||
* source file line containing the trace statement, the second (if present) the parameter.
|
||||
*/
|
||||
#if !defined(SIMULATION_TRACE_IP_REGISTER) || !defined(SIMULATION_TRACE_PARAMETER_REGISTER)
|
||||
# error Must define SIMULATION_TRACE_IP_REGISTER and SIMULATION_TRACE_PARAMETER_REGISTER if WITH_SIMULATION_TRACE is defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Trace our passing a location.
|
||||
*/
|
||||
#define SIMULATION_TRACE() \
|
||||
do { \
|
||||
*(uint32_t *)SIMULATION_TRACE_IP_REGISTER = (uint32_t)__func__; \
|
||||
*(uint32_t *)SIMULATION_TRACE_PARAMETER_REGISTER = (uint32_t)__LINE__; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Trace a location and a parameter at that location.
|
||||
*/
|
||||
#define SIMULATION_TRACE_VALUE(_x) \
|
||||
do { \
|
||||
SIMULATION_TRACE(); \
|
||||
*(uint32_t *)SIMULATION_TRACE_PARAMETER_REGISTER = (uint32_t)(_x); \
|
||||
} while (0)
|
||||
|
||||
#define SIMULATION_TRACE_VALUE2(_x,_y) \
|
||||
do { \
|
||||
SIMULATION_TRACE(); \
|
||||
*(uint32_t *)SIMULATION_TRACE_PARAMETER_REGISTER = (uint32_t)(_x); \
|
||||
*(uint32_t *)SIMULATION_TRACE_PARAMETER_REGISTER = (uint32_t)(_y); \
|
||||
} while (0)
|
||||
|
||||
#endif /* WITH_SIMULATION_TRACE */
|
||||
|
||||
#endif /* __DEBUG_H */
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2012 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 __DRIVERS_AES_H
|
||||
#define __DRIVERS_AES_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define AES_CMD_ENC (0x00000000)
|
||||
#define AES_CMD_DEC (0x00000001)
|
||||
#define AES_CMD_DIR_MASK (0x0000000F)
|
||||
#define AES_CMD_ECB (0x00000000)
|
||||
#define AES_CMD_CBC (0x00000010)
|
||||
#define AES_CMD_MODE_MASK (0x000000F0)
|
||||
|
||||
#define AES_KEY_TYPE_USER (0x00000000)
|
||||
#define AES_KEY_TYPE_UID0 (0x00000100)
|
||||
#define AES_KEY_TYPE_GID0 (0x00000200)
|
||||
#define AES_KEY_TYPE_GID1 (0x00000201)
|
||||
#define AES_KEY_TYPE_MASK (0x00000FFF)
|
||||
|
||||
#define AES_KEY_SIZE_128 (0x00000000)
|
||||
#define AES_KEY_SIZE_192 (0x10000000)
|
||||
#define AES_KEY_SIZE_256 (0x20000000)
|
||||
#define AES_KEY_SIZE_MASK (0xF0000000)
|
||||
|
||||
#define AES_BLOCK_SIZE (16)
|
||||
|
||||
/*
|
||||
* aes_crypto_cmd - provides access to AES functions
|
||||
*
|
||||
* cmd - operation mode: ENC or DEC and EBC or CBC
|
||||
* src - source buffer and destination buffer for in place operations
|
||||
* dst - desination buffer, or NULL for in place operations
|
||||
* len - size in bytes of the operation
|
||||
* opts - key type and size
|
||||
* key - key buffer or NULL for non USER key types
|
||||
* iv - iv buffer or NULL if iv should be all zeros
|
||||
*
|
||||
* AES operations may return an error if the requested operation depends
|
||||
* on hardware resources that are not available.
|
||||
*
|
||||
* Bad arguments passed to AES operations will result in a panic.
|
||||
*/
|
||||
int aes_crypto_cmd(u_int32_t cmd, void *src, void *dst, size_t len, u_int32_t opts, const void *key, void *iv);
|
||||
|
||||
#define aes_cbc_encrypt(src, dst, len, opts, key, iv) \
|
||||
aes_crypto_cmd(AES_CMD_ENC | AES_CMD_CBC, src, dst, len, opts, key, iv)
|
||||
#define aes_cbc_decrypt(src, dst, len, opts, key, iv) \
|
||||
aes_crypto_cmd(AES_CMD_DEC | AES_CMD_CBC, src, dst, len, opts, key, iv)
|
||||
|
||||
/* exported interface from hardware AES driver */
|
||||
int aes_hw_crypto_cmd(u_int32_t cmd, void *src, void *dst, size_t len, u_int32_t opts, const void *key, void *iv);
|
||||
|
||||
/* old AES hardware driver protocol, not for new platforms */
|
||||
enum aes_key_type {
|
||||
AES_KEY_TYPE_REGISTER = 0,
|
||||
AES_KEY_TYPE_GLOBAL,
|
||||
AES_KEY_TYPE_CHIP
|
||||
};
|
||||
|
||||
int AES_CBC_DecryptInPlace(u_int8_t* pAddr, u_int32_t u32Len, u_int32_t keyType, u_int8_t* pKey, u_int8_t* pIv);
|
||||
bool AES_CBC_EncryptInPlace(u_int8_t* pAddr, u_int32_t u32Len, u_int32_t keyType, u_int8_t* pKey, u_int8_t* pIv);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_AES_H */
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2011 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 ANC_BOOT_H
|
||||
#define ANC_BOOT_H
|
||||
|
||||
#define ANC_BOOT_MODE_RESET_ALL_CONTROLLERS 0
|
||||
#define ANC_BOOT_MODE_RESET_ONE_CONTROLLER 1
|
||||
#define ANC_MIN_ALIGNMENT 16
|
||||
|
||||
extern bool anc_reset(int resetMode);
|
||||
extern bool anc_firmware_init(void);
|
||||
extern size_t anc_read_llb(void* data, size_t size);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2012-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 APCIE_INIT_H
|
||||
#define APCIE_INIT_H
|
||||
|
||||
#include <lib/devicetree.h>
|
||||
#include <drivers/pci.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// 10 second timeout when enabling a link
|
||||
#define APCIE_ENABLE_TIMEOUT 10000000
|
||||
|
||||
struct apcie_link_config {
|
||||
uint32_t perst_gpio;
|
||||
uint32_t clkreq_gpio;
|
||||
unsigned int dart_id;
|
||||
utime_t t_perst_delay;
|
||||
utime_t t_boot_to_perst;
|
||||
utime_t t_refclk_to_perst;
|
||||
};
|
||||
|
||||
struct apcie_link_status {
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
void apcie_init(void);
|
||||
void apcie_use_external_refclk(bool use);
|
||||
void apcie_set_s3e_mode(bool reset_on_enable);
|
||||
|
||||
void apcie_config_read_raw(void *dst, uint32_t bdfo, int size);
|
||||
void apcie_config_write_raw(const void *src, uint32_t bdfo, int size);
|
||||
|
||||
bool apcie_enable_link(uint32_t link);
|
||||
void apcie_disable_link(uint32_t link);
|
||||
void apcie_disable_all(void);
|
||||
uint32_t apcie_get_link_enable_count(void);
|
||||
void apcie_setup_root_port_bridge(uint32_t link, struct apcie_link_config *config);
|
||||
void apcie_update_devicetree(DTNode *apcie_node);
|
||||
pci_device_t apcie_get_port_bridge(uint32_t link);
|
||||
void apcie_free_port_bridge(uint32_t link);
|
||||
|
||||
extern struct apcie_link_config platform_apcie_link_configs[];
|
||||
extern struct apcie_link_status apcie_link_statuses[];
|
||||
extern struct apcie_link_config *apcie_link_configs;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef _ASP_INIT_H
|
||||
#define _ASP_INIT_H
|
||||
|
||||
int asp_init(void);
|
||||
int asp_nand_open(void);
|
||||
int asp_set_default_dies_in_parallel(void);
|
||||
int asp_disable_uid(void);
|
||||
|
||||
#endif // _ASP_INIT_H
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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 __DRIVERS_BUTTONS_H
|
||||
#define __DRIVERS_BUTTONS_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
enum buttons {
|
||||
MENU_KEY,
|
||||
VOLUP_KEY,
|
||||
VOLDOWN_KEY,
|
||||
};
|
||||
|
||||
typedef void (*button_callback)(bool state);
|
||||
|
||||
int buttons_init(void);
|
||||
|
||||
/* Callback is executed in interrupt context */
|
||||
void button_callback_register(enum buttons button, button_callback callback);
|
||||
void button_callback_unregister(enum buttons button, button_callback callback);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_BUTTONS_H */
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 __DRIVERS_CHARGER_H
|
||||
#define __DRIVERS_CHARGER_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void charger_early_init(void);
|
||||
void charger_clear_alternate_usb_current_limit(void);
|
||||
bool charger_has_usb(int dock);
|
||||
bool charger_has_firewire(int dock);
|
||||
bool charger_has_external(int dock);
|
||||
bool charger_check_usb_change(int dock, bool expected);
|
||||
void charger_set_charging(int dock, uint32_t input_current_ma, uint32_t *charge_current_ma);
|
||||
void charger_clear_usb_state(void);
|
||||
bool charger_set_usb_brick_detect(int dock, int select);
|
||||
bool charger_charge_done(int dock);
|
||||
bool charger_has_batterypack(int dock);
|
||||
uint32_t charger_get_max_charge_current(int dock);
|
||||
int charger_read_battery_temperature(int *centiCelsiusTemperature);
|
||||
int charger_read_battery_level(uint32_t *milliVolts);
|
||||
int charger_set_gasgauge_interface(bool enabled);
|
||||
void charger_print_status(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_CHARGER_H */
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2011-2012 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 __DRIVERS_CONSISTENT_DEBUG__H
|
||||
#define __DRIVERS_CONSISTENT_DEBUG__H
|
||||
|
||||
|
||||
#include <consistent_debug/consistent_debug_registry.h>
|
||||
#include <consistent_debug/consistent_debug_helper_fns.h>
|
||||
|
||||
// Functions
|
||||
|
||||
// Restores consistent debug state on resume from sleep.
|
||||
int consistent_debug_resume(void);
|
||||
|
||||
// Set up consistent debug region on cold boot.
|
||||
int consistent_debug_init(void);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the location of the Consistent Debug Registry
|
||||
*
|
||||
* @author jdong (1/25/2013)
|
||||
*
|
||||
* @return A pointer to the debug registry if it exists. NULL if
|
||||
* not yet initialized.
|
||||
*/
|
||||
dbg_registry_t* consistent_debug_get_registry(void);
|
||||
|
||||
/**
|
||||
* Attempt to register a header with the supplied information.
|
||||
*
|
||||
* @author jdong (12/10/2012)
|
||||
*
|
||||
* @param hdr: A filled-out header. The debug registry will be
|
||||
* filled in with this information.
|
||||
*
|
||||
* @return dbg_record_header_t*: NULL if unsuccessful.
|
||||
* Otherwise, a pointer to the entry in the debug
|
||||
* registry. It's already filled out, so in the general
|
||||
* case one would just check if it's non-NULL.
|
||||
*/
|
||||
dbg_record_header_t* consistent_debug_register_header(dbg_record_header_t hdr);
|
||||
|
||||
|
||||
/**
|
||||
* Attempt to deregister a consistent debug header. This might
|
||||
* have to be done when handing off from a bootloader to an OS,
|
||||
* or when powering down / resetting a coprocessor. It ensures
|
||||
* that consumers of a debug region are given a chance to clean
|
||||
* up before it is no longer valid.
|
||||
*
|
||||
* Note the return value. One should initially check that a call
|
||||
* returns "0" indicating an entry is valid and has been marked
|
||||
* as being freed. Then, one should poll by calling again with
|
||||
* the same argument until the return value is 1.
|
||||
*
|
||||
* @author jdong (12/14/2012)
|
||||
*
|
||||
* @param hdr A pointer to a debug header returned by
|
||||
* consistent_debug_register_header()
|
||||
*
|
||||
* @return -1: Error has occurred. Most likely the value passed
|
||||
* is not an in-use debug registry header.
|
||||
* 0: Record is marked as being freed -- waiting for
|
||||
* the other end to acknowledge it. Check again later.
|
||||
* 1: Record has been freed and is now unused.
|
||||
*/
|
||||
int consistent_debug_unregister_header(dbg_record_header_t *hdr);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update the AP's Progress Report with the given state and
|
||||
* state argument.
|
||||
*
|
||||
*/
|
||||
void consistent_debug_update_ap_cpr(cp_state_t state, int arg);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) 2011 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 __CSI_H
|
||||
#define __CSI_H
|
||||
|
||||
#include <sys/task.h>
|
||||
#include <sys/boot.h>
|
||||
|
||||
//
|
||||
// Public API
|
||||
//
|
||||
|
||||
typedef enum {
|
||||
CSI_COPROC_ANS = 0,
|
||||
CSI_COPROC_SEP,
|
||||
CSI_COPROC_ISP,
|
||||
CSI_COPROC_SIO,
|
||||
CSI_COPROC_MAX
|
||||
} csi_coproc_t;
|
||||
|
||||
#define IOP_NAME(coproc) \
|
||||
(((coproc)==CSI_COPROC_ANS) ? "ANS" : \
|
||||
(((coproc)==CSI_COPROC_SEP) ? "SEP" : \
|
||||
(((coproc)==CSI_COPROC_ISP) ? "ISP" : \
|
||||
(((coproc)==CSI_COPROC_SIO) ? "SIO" : "???"))))
|
||||
|
||||
#define KFW(coproc) \
|
||||
(((coproc)==CSI_COPROC_ANS) ? KFW_ANS : \
|
||||
(((coproc)==CSI_COPROC_SEP) ? KFW_SEP : \
|
||||
(((coproc)==CSI_COPROC_ISP) ? 0 : \
|
||||
(((coproc)==CSI_COPROC_SIO) ? KFW_SIO : 0))))
|
||||
|
||||
typedef enum {
|
||||
CSI_STATUS_OK = 0,
|
||||
CSI_STATUS_UNSUPPORTED,
|
||||
CSI_STATUS_UNAVAILABLE,
|
||||
CSI_STATUS_ERROR,
|
||||
CSI_STATUS_NO_FIRMWARE,
|
||||
CSI_STATUS_BAD_FIRMWARE,
|
||||
CSI_STATUS_TIMEOUT,
|
||||
CSI_STATUS_PANIC_RECOVER,
|
||||
CSI_STATUS_OUT_OF_RESSOURCES,
|
||||
} csi_status_t;
|
||||
|
||||
#define CSI_STATUS_STR(status) \
|
||||
(((status)==CSI_STATUS_OK) ? "OK" : \
|
||||
(((status)==CSI_STATUS_UNSUPPORTED) ? "UNSUPPORTED" : \
|
||||
(((status)==CSI_STATUS_UNAVAILABLE) ? "UNAVAILABLE" : \
|
||||
(((status)==CSI_STATUS_ERROR) ? "ERROR" : \
|
||||
(((status)==CSI_STATUS_NO_FIRMWARE) ? "NO_FIRMWARE" : \
|
||||
(((status)==CSI_STATUS_BAD_FIRMWARE) ? "BAD_FIRMWARE" : \
|
||||
(((status)==CSI_STATUS_TIMEOUT) ? "TIMEOUT" : "???")))))))
|
||||
|
||||
|
||||
typedef uint64_t msg_payload_t;
|
||||
|
||||
|
||||
csi_status_t csi_init (csi_coproc_t which_coproc);
|
||||
csi_status_t csi_late_init (void);
|
||||
|
||||
csi_status_t csi_quiesce (enum boot_target target);
|
||||
|
||||
csi_status_t csi_register_endpoint (csi_coproc_t which_coproc, uint32_t ep, struct task_event *event, void **csi_token, const char **name);
|
||||
|
||||
void* csi_allocate_shared_memory (void *csi_token, uint32_t capacity);
|
||||
void csi_free_shared_memory (void *sm);
|
||||
|
||||
csi_status_t csi_receive_message (void *csi_token, msg_payload_t *msg_payload);
|
||||
csi_status_t csi_send_message (void *csi_token, msg_payload_t msg_payload);
|
||||
|
||||
//
|
||||
// coprocessor feature and status
|
||||
//
|
||||
|
||||
#define COPROC_FEATURE_NONE (0x0000UL)
|
||||
#define COPROC_FEATURE_SHUTDOWN_IN_PROGRESS (0x0001UL)
|
||||
#define COPROC_FEATURE_PANIC_RECOVERY (0x0002UL)
|
||||
#define COPROC_FEATURE_ALL (0xFFFFFFFFUL)
|
||||
|
||||
typedef uint32_t coproc_feature_t;
|
||||
|
||||
coproc_feature_t csi_get_feature (csi_coproc_t which_coproc);
|
||||
|
||||
static inline bool csi_is_panic_recovery (csi_coproc_t which_coproc)
|
||||
{
|
||||
return (csi_get_feature(which_coproc) & COPROC_FEATURE_PANIC_RECOVERY);
|
||||
}
|
||||
|
||||
static inline bool csi_is_shutdown_in_progress (csi_coproc_t which_coproc)
|
||||
{
|
||||
return (csi_get_feature(which_coproc) & COPROC_FEATURE_SHUTDOWN_IN_PROGRESS);
|
||||
}
|
||||
|
||||
#endif /* !defined(__CSI_H) */
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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 _DART_H
|
||||
#define _DART_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define DART_PAGE_SIZE (4096)
|
||||
|
||||
typedef uint32_t dart_iovm_addr_t;
|
||||
|
||||
void dart_init(unsigned int dart_id);
|
||||
void dart_enable_translation(unsigned int dart_id);
|
||||
void dart_disable_translation(unsigned int dart_id);
|
||||
void dart_map_page_range(unsigned int dart_id, uintptr_t paddr, dart_iovm_addr_t vaddr, uint32_t pages, bool write_protect);
|
||||
void dart_unmap_page_range(unsigned int dart_id, dart_iovm_addr_t vaddr, uint32_t pages);
|
||||
void dart_write_protect_page_range(unsigned int dart_id, dart_iovm_addr_t vaddr, uint32_t pages, bool write_protect);
|
||||
void dart_assert_unmapped(unsigned int dart_id);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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 __DRIVERS_DISPLAY_H
|
||||
#define __DRIVERS_DISPLAY_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <lib/paint.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct display_window {
|
||||
bool active;
|
||||
enum colorspace cs;
|
||||
uint32_t depth;
|
||||
uint32_t pos_x, pos_y;
|
||||
uint32_t width, height;
|
||||
uint32_t stride;
|
||||
struct canvas c;
|
||||
void *ptr; // device specific data
|
||||
};
|
||||
|
||||
#define kGammaChannelBufferSize (72)
|
||||
#define kGammaBufferSize (kGammaChannelBufferSize * 3)
|
||||
|
||||
struct display_gamma_table {
|
||||
uint32_t display_id;
|
||||
uint32_t display_id_mask;
|
||||
uint8_t display_gamma_data[kGammaBufferSize];
|
||||
};
|
||||
typedef struct display_gamma_table display_gamma_table;
|
||||
|
||||
struct syscfg_glcl {
|
||||
uint8_t minor_vers;
|
||||
uint8_t major_vers;
|
||||
uint8_t reserved[2];
|
||||
uint8_t gamma_data[kGammaBufferSize];
|
||||
};
|
||||
|
||||
int display_init(void);
|
||||
int display_quiesce(bool clear_display);
|
||||
void display_clear(void);
|
||||
|
||||
bool display_get_enable(void);
|
||||
void display_set_enable(bool enable, uint32_t *color);
|
||||
bool display_set_rotation(bool rotate180);
|
||||
void display_delay_frames(uint32_t frames);
|
||||
void display_set_background_color(uint32_t color);
|
||||
|
||||
struct display_window *display_create_window(uint32_t x, uint32_t y, uint32_t width, uint32_t height, enum colorspace color);
|
||||
void display_destroy_window(struct display_window *win);
|
||||
void display_move_window(struct display_window *win, uint32_t x, uint32_t y);
|
||||
void display_activate_window(struct display_window *win);
|
||||
void display_deactivate_window(struct display_window *win);
|
||||
void display_set_window_fb(struct display_window *win, void *fb);
|
||||
|
||||
struct display_info {
|
||||
addr_t framebuffer;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t stride;
|
||||
uint32_t depth;
|
||||
};
|
||||
|
||||
/* after the fact get the information about the current display */
|
||||
int display_get_info(struct display_info *info);
|
||||
|
||||
struct display_timing
|
||||
{
|
||||
const char *display_name;
|
||||
|
||||
uint32_t host_clock_id;
|
||||
uint32_t pixel_clock;
|
||||
|
||||
uint32_t dot_pitch;
|
||||
|
||||
uint32_t h_active;
|
||||
uint32_t h_back_porch;
|
||||
uint32_t h_front_porch;
|
||||
uint32_t h_pulse_width;
|
||||
uint32_t v_active;
|
||||
uint32_t v_back_porch;
|
||||
uint32_t v_front_porch;
|
||||
uint32_t v_pulse_width;
|
||||
|
||||
bool neg_vclk;
|
||||
bool neg_hsync;
|
||||
bool neg_vsync;
|
||||
bool neg_vden;
|
||||
|
||||
uint32_t display_depth;
|
||||
uint32_t display_type;
|
||||
void *display_config;
|
||||
};
|
||||
|
||||
#define DISPLAY_TYPE_DUMB (0)
|
||||
#define DISPLAY_TYPE_SMART (1)
|
||||
#define DISPLAY_TYPE_MERLOT (2)
|
||||
#define DISPLAY_TYPE_PINOT (3)
|
||||
#define DISPLAY_TYPE_TMDS (4)
|
||||
#define DISPLAY_TYPE_DP (5)
|
||||
#define DISPLAY_TYPE_EDP (6)
|
||||
#define DISPLAY_TYPE_HDMI (7)
|
||||
#define DISPLAY_TYPE_SUMMIT (8)
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_DISPLAY_H */
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) 2012-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 DRIVERS_DISPLAYAV_H
|
||||
#define DRIVERS_DISPLAYAV_H 1
|
||||
|
||||
|
||||
enum {
|
||||
kDisplayAxisTypeHorizontal,
|
||||
kDisplayAxisTypeVertical,
|
||||
kDisplayAxisCount
|
||||
};
|
||||
|
||||
enum {
|
||||
kDisplayColorSpacesRGB,
|
||||
kDisplayColorSpacesYCbCr422,
|
||||
kDisplayColorSpacesYCbCr444
|
||||
};
|
||||
|
||||
enum {
|
||||
kDisplayColorDynamicRangeFull,
|
||||
kDisplayColorDynamicRangeLimited,
|
||||
kDisplayColorDynamicRangeVESA = kDisplayColorDynamicRangeFull,
|
||||
kDisplayColorDynamicRangeCEA = kDisplayColorDynamicRangeLimited
|
||||
};
|
||||
|
||||
enum {
|
||||
kDisplayColorCoefficientITU601,
|
||||
kDisplayColorCoefficientITU709
|
||||
};
|
||||
|
||||
enum {
|
||||
kDisplayTestModeOff,
|
||||
kDisplayTestModeColorRamp,
|
||||
kDisplayTestModeBlackWhiteVLines,
|
||||
kDisplayTestModeColorSquare,
|
||||
kDisplayTestModeInvalid,
|
||||
kDisplayTestModeColorBar32,
|
||||
kDisplayTestModeColorBar64,
|
||||
kDisplayTestModeWhiteGrayBlackBar32,
|
||||
kDisplayTestModeWhiteGrayBlackBar64,
|
||||
kDisplayTestModeMobileWhiteBar32,
|
||||
kDisplayTestModeMobileWhiteBar64
|
||||
};
|
||||
|
||||
enum {
|
||||
kDisplayColorRGBQuantizationRangeDefault,
|
||||
kDisplayColorRGBQuantizationRangeLimited,
|
||||
kDisplayColorRGBQuantizationRangeFull
|
||||
};
|
||||
|
||||
struct video_color_data {
|
||||
u_int32_t depth;
|
||||
u_int32_t space;
|
||||
u_int32_t range;
|
||||
u_int32_t coefficient;
|
||||
};
|
||||
|
||||
struct video_timing_axis {
|
||||
uint32_t total;
|
||||
uint32_t active;
|
||||
uint32_t sync_width;
|
||||
uint32_t back_porch;
|
||||
uint32_t front_porch;
|
||||
int32_t sync_rate;
|
||||
uint32_t sync_polarity;
|
||||
};
|
||||
|
||||
struct video_timing_data {
|
||||
bool interlaced;
|
||||
struct video_timing_axis axis[kDisplayAxisCount];
|
||||
};
|
||||
|
||||
struct video_link_data {
|
||||
bool mirror_mode;
|
||||
u_int32_t test_mode;
|
||||
struct video_color_data color;
|
||||
struct video_timing_data timing;
|
||||
};
|
||||
|
||||
|
||||
typedef enum {
|
||||
kDisplayInfoFrameTypeReserved = 0x80,
|
||||
kDisplayInfoFrameTypeVendorSpecific = 0x81,
|
||||
kDisplayInfoFrameTypeAVI = 0x82,
|
||||
kDisplayInfoFrameTypeProductDescription = 0x83,
|
||||
kDisplayInfoFrameTypeAudio = 0x84,
|
||||
kDisplayInfoFrameTypeMPEG = 0x85,
|
||||
kDisplayInfoFrameTypeMin = kDisplayInfoFrameTypeReserved,
|
||||
kDisplayInfoFrameTypeMax = kDisplayInfoFrameTypeMPEG,
|
||||
kDisplayInfoFrameTypeCount = 1 + (kDisplayInfoFrameTypeMax - kDisplayInfoFrameTypeMin)
|
||||
} display_infoframe_type;
|
||||
|
||||
struct display_infoframe {
|
||||
display_infoframe_type type;
|
||||
uint8_t version;
|
||||
uint8_t length;
|
||||
uint8_t checksum;
|
||||
uint8_t data[28];
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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 DRIVERS_DISPLAY_PMU_H
|
||||
#define DRIVERS_DISPLAY_PMU_H 1
|
||||
|
||||
#if WITH_HW_CHESTNUT
|
||||
#define DISPLAY_PMU_LDO(n) (((n) + 1) << 2)
|
||||
#endif
|
||||
|
||||
int display_pmu_init(void);
|
||||
int display_pmu_quiesce(void);
|
||||
void display_pmu_update_device_tree(const char *node);
|
||||
|
||||
#endif /* DRIVERS_DISPLAY_PMU_H */
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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 DRIVERS_DISPLAYPORT_H
|
||||
#define DRIVERS_DISPLAYPORT_H 1
|
||||
|
||||
#include <drivers/display.h>
|
||||
#include <drivers/displayAV.h>
|
||||
|
||||
#define kDPMaxLanes 4
|
||||
|
||||
|
||||
enum {
|
||||
kLinkRate000Gbps = 0x0,
|
||||
kLinkRate162Gbps = 0x6,
|
||||
kLinkRate270Gbps = 0xa,
|
||||
kLinkRate324Gbps = 0x0c,
|
||||
kLinkRate540Gbps = 0x14
|
||||
};
|
||||
|
||||
enum {
|
||||
kDPVoltageLevel0,
|
||||
kDPVoltageLevel1,
|
||||
kDPVoltageLevel2,
|
||||
kDPVoltageLevel3,
|
||||
kDPVoltageLevelMin = kDPVoltageLevel0,
|
||||
kDPVoltageLevelMax = kDPVoltageLevel3
|
||||
};
|
||||
|
||||
enum {
|
||||
kDPEQLevel0,
|
||||
kDPEQLevel1,
|
||||
kDPEQLevel2,
|
||||
kDPEQLevel3,
|
||||
kDPEQLevelMin = kDPEQLevel0,
|
||||
kDPEQLevelMax = kDPEQLevel3
|
||||
};
|
||||
|
||||
enum {
|
||||
kDPTrainingPatternNone,
|
||||
kDPTrainingPattern1,
|
||||
kDPTrainingPattern2,
|
||||
kDPTrainingPattern3
|
||||
};
|
||||
|
||||
enum {
|
||||
kDPLaneStatusFlagClockRecoveryDone = (1<<0),
|
||||
kDPLaneStatusFlagsEQDone = (1<<1),
|
||||
kDPLaneStatusFlagsSymbolLocked = (1<<2),
|
||||
kDPLaneStatusFlagsMask = (0x7)
|
||||
};
|
||||
|
||||
enum {
|
||||
kDPAlignmentStatusFlagsDone = (1<<0),
|
||||
kDPAlignmentStatusFlagsDownstreamChanged = (1<<6),
|
||||
kDPAlignmentStatusFlagsLinkUpdated = (1<<7),
|
||||
};
|
||||
|
||||
enum {
|
||||
kDPDownstreamTypeDP,
|
||||
kDPDownstreamTypeVGA,
|
||||
kDPDownstreamTypeDVI,
|
||||
kDPDownstreamTypeHDMI,
|
||||
kDPDownstreamTypeOther,
|
||||
kDPDownstreamTypeCount
|
||||
};
|
||||
|
||||
struct dp_link_training_lane_data {
|
||||
u_int32_t voltage;
|
||||
u_int32_t eq;
|
||||
};
|
||||
|
||||
struct dp_link_train_data {
|
||||
bool enhanced_mode;
|
||||
bool assr;
|
||||
bool downspread;
|
||||
bool fast;
|
||||
u_int32_t lane_count;
|
||||
u_int32_t link_rate;
|
||||
struct dp_link_training_lane_data lane[kDPMaxLanes];
|
||||
};
|
||||
|
||||
|
||||
// controller config flags
|
||||
|
||||
enum {
|
||||
kDPControllerMode_Master = 0,
|
||||
kDPControllerMode_Slave
|
||||
};
|
||||
#define kDPControllerMode_Mask 0xf
|
||||
#define kDPControllerMode_Shift 4
|
||||
|
||||
enum {
|
||||
kDPControllerType_DP = 0,
|
||||
kDPControllerType_EDP
|
||||
};
|
||||
#define kDPControllerType_Mask 0xf
|
||||
#define kDPControllerType_Shift 0
|
||||
|
||||
#include <drivers/display.h>
|
||||
|
||||
// global
|
||||
int displayport_init(dp_t *dp);
|
||||
int displayport_init_with_timing_info(struct display_timing *timing_info);
|
||||
int displayport_set_timings(struct display_timing *timing_info);
|
||||
int displayport_start_video(void);
|
||||
int displayport_enable_alpm(bool enable);
|
||||
bool displayport_video_configured();
|
||||
void displayport_quiesce();
|
||||
|
||||
// eDP support
|
||||
#if WITH_HW_DISPLAY_EDP
|
||||
#define kEDPRawPanelIdLength 16
|
||||
|
||||
int displayport_get_raw_panel_id(u_int8_t *raw_panel_id);
|
||||
#endif // WITH_HW_DISPLAY_EDP
|
||||
|
||||
// controller
|
||||
int dp_controller_start(dp_t *);
|
||||
void dp_controller_stop();
|
||||
int dp_controller_validate_video(struct video_timing_data *data);
|
||||
int dp_controller_read_bytes_dpcd(u_int32_t addr, u_int8_t *data, u_int32_t length);
|
||||
int dp_controller_read_bytes_i2c(u_int32_t device_addr, u_int32_t addr, u_int8_t *data, u_int32_t length);
|
||||
int dp_controller_write_bytes_dpcd(u_int32_t addr, u_int8_t *data, u_int32_t length);
|
||||
int dp_controller_write_bytes_i2c(u_int32_t device_addr, u_int32_t addr, u_int8_t *data, u_int32_t length);
|
||||
int dp_controller_train_link(struct dp_link_train_data *data);
|
||||
int dp_controller_get_adjustment_levels(u_int32_t lane, u_int32_t *voltage_swing, u_int32_t *eq);
|
||||
int dp_controller_set_adjustment_levels(u_int32_t lane, u_int32_t voltage_swing, u_int32_t eq,
|
||||
bool *voltage_max_reached, bool *eq_max_reached);
|
||||
int dp_controller_set_training_pattern(u_int32_t value, bool scramble);
|
||||
int dp_controller_get_training_pattern(u_int32_t *value, bool *scramble);
|
||||
int dp_controller_set_link_rate(u_int32_t link_rate);
|
||||
int dp_controller_get_link_rate(u_int32_t *link_rate);
|
||||
int dp_controller_set_lane_count(uint32_t lane_count);
|
||||
int dp_controller_get_lane_count(uint32_t * lane_count);
|
||||
int dp_controller_set_enhanced_mode(bool mode);
|
||||
int dp_controller_get_enhanced_mode(bool * mode);
|
||||
int dp_controller_set_ASSR(bool mode);
|
||||
int dp_controller_get_ASSR(bool * mode);
|
||||
int dp_controller_set_downspread(bool state);
|
||||
int dp_controller_get_downspread(bool *state);
|
||||
int dp_controller_start_video(struct video_link_data *data);
|
||||
int dp_controller_stop_video();
|
||||
u_int32_t dp_controller_get_max_lane_count();
|
||||
u_int32_t dp_controller_get_max_link_rate();
|
||||
u_int32_t dp_controller_get_min_lane_count();
|
||||
u_int32_t dp_controller_get_min_link_rate();
|
||||
bool dp_controller_get_supports_downspread();
|
||||
bool dp_controller_get_supports_fast_link_training();
|
||||
bool dp_controller_get_supports_alpm();
|
||||
int dp_controller_enable_alpm(bool enable, struct video_link_data *data);
|
||||
|
||||
bool dp_controller_video_configured();
|
||||
bool dp_controller_wait_for_edp_hpd(utime_t *hpd_time);
|
||||
void dp_controller_wait_for_HPD_to_BL(utime_t hpd_time);
|
||||
|
||||
void dp_controller_wait_phy_locked(void);
|
||||
|
||||
// device
|
||||
|
||||
int dp_device_start(bool edp_panel);
|
||||
int dp_device_wait_started(utime_t timeout);
|
||||
void dp_device_stop();
|
||||
int dp_device_get_alignment_status_mask(u_int32_t *mask);
|
||||
int dp_device_get_lane_status_mask(uint32_t lane, uint32_t *mask);
|
||||
int dp_device_get_training_pattern(uint32_t *value, bool *scramble);
|
||||
int dp_device_set_training_pattern(uint32_t value, bool scramble);
|
||||
int dp_device_get_requested_adjustment_levels(uint32_t lane, u_int32_t *voltage, u_int32_t *eq);
|
||||
int dp_device_set_adjustment_levels(uint32_t lane, u_int32_t voltage_swing, u_int32_t eq,
|
||||
bool voltage_max_reached, bool eq_max_reached);
|
||||
int dp_device_get_enhanced_mode(bool * value);
|
||||
int dp_device_set_enhanced_mode(bool value);
|
||||
int dp_device_get_ASSR(bool * value);
|
||||
int dp_device_set_ASSR(bool value);
|
||||
int dp_device_get_downspread(bool * value);
|
||||
int dp_device_set_downspread(bool value);
|
||||
int dp_device_get_lane_count(uint32_t * value);
|
||||
int dp_device_set_lane_count(uint32_t value);
|
||||
int dp_device_get_link_rate(u_int32_t * value);
|
||||
int dp_device_set_link_rate(u_int32_t value);
|
||||
int dp_device_hdcp_enable(bool enable);
|
||||
int dp_device_get_downstream_port_type(int *ret_value);
|
||||
int dp_device_get_raw_panel_id(u_int8_t *raw_panel_id);
|
||||
int dp_device_get_sink_count(uint8_t * value);
|
||||
|
||||
bool dp_device_get_supports_fast_link_training();
|
||||
bool dp_device_get_supports_alpm();
|
||||
int dp_device_enable_alpm(bool enable);
|
||||
bool dp_device_is_alpm_enabled();
|
||||
bool dp_device_get_supports_enhanced_mode();
|
||||
bool dp_device_get_supports_assr();
|
||||
bool dp_device_get_supports_downspread();
|
||||
u_int32_t dp_device_get_revision();
|
||||
u_int32_t dp_device_get_max_lane_count();
|
||||
u_int32_t dp_device_get_max_link_rate();
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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 __DRIVERS_DITHER_H
|
||||
#define __DRIVERS_DITHER_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define DITHER_NONE (0 << 0)
|
||||
#define DITHER_BLUE_NOISE (1 << 0)
|
||||
#define DITHER_SPATIO_TEMPORAL (1 << 1)
|
||||
#define DITHER_ERROR_DIFFUSION (1 << 2)
|
||||
|
||||
#if DITHER_VERSION == 4
|
||||
void dither_init(uint32_t display_width, uint32_t display_height, uint32_t display_depth);
|
||||
#else
|
||||
void dither_init(uint32_t display_depth);
|
||||
#endif
|
||||
void dither_set_enable(bool enable);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_DITHER_H */
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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 __DRIVERS_DMA_H
|
||||
#define __DRIVERS_DMA_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define DMA_CMD_DIR_MEM (0x00000000)
|
||||
#define DMA_CMD_DIR_TX (0x00000001)
|
||||
#define DMA_CMD_DIR_RX (0x00000002)
|
||||
#define DMA_CMD_DIR_MASK (0x00000003)
|
||||
|
||||
void dma_init(void);
|
||||
|
||||
/*
|
||||
* dma_execute_cmd - simple DMA operation
|
||||
*
|
||||
* cmd - operation mode: MEM (MEMORY-MEMORY), TX (MEMORY-DEVICE) or RX (DEVICE-MEMORY)
|
||||
* dma_channel - dma channel number
|
||||
* src - source buffer or fifo
|
||||
* dst - desination buffer or fifo
|
||||
* length - size in bytes of the operation
|
||||
* word_size - size in bytes of each word
|
||||
* burst_size - size in words of each burst
|
||||
*
|
||||
* Returns 0 on success or -1 on failure
|
||||
*/
|
||||
int dma_execute_cmd(u_int32_t cmd, int dma_channel,
|
||||
void *src, void *dst, u_int32_t length,
|
||||
u_int32_t word_size, u_int32_t burst_size);
|
||||
|
||||
|
||||
/*
|
||||
* dma_execute_async - complex async DMA operation
|
||||
*
|
||||
* cmd - operation mode: MEM (MEMORY-MEMORY), TX (MEMORY-DEVICE) or RX (DEVICE-MEMORY)
|
||||
* dma_channel - dma channel number
|
||||
* sgl - memory scatter/gather list
|
||||
* fifo - device fifo address
|
||||
* length - size in bytes of the operation
|
||||
* word_size - size in bytes of each word
|
||||
* burst_size - size in words of each burst
|
||||
* completion - completion callback
|
||||
* completion_arg - argument passed to callback
|
||||
*
|
||||
* Returns 0 on success or -1 on failure
|
||||
*
|
||||
*/
|
||||
|
||||
struct dma_segment {
|
||||
u_int32_t paddr;
|
||||
u_int32_t length;
|
||||
};
|
||||
|
||||
typedef void (* dma_completion_function)(void *);
|
||||
|
||||
int dma_execute_async(u_int32_t cmd, int dma_channel,
|
||||
struct dma_segment *sgl, void *fifo, u_int32_t length,
|
||||
u_int32_t word_size, u_int32_t burst_size,
|
||||
dma_completion_function completion, void *completion_arg);
|
||||
|
||||
void dma_use_int(int dma_channel, bool use);
|
||||
|
||||
bool dma_poll(int dma_channel);
|
||||
|
||||
/*
|
||||
* dma_cancel - cancel DMA operation on a given channel.
|
||||
*
|
||||
* When this returns, the numbered DMA channel is guaranteed to be idle.
|
||||
*/
|
||||
|
||||
void dma_cancel(int dma_channel);
|
||||
|
||||
/*
|
||||
* DMA channel encryption
|
||||
*
|
||||
* A channel is configured to perform AES en/decryption by calling dma_set_aes()
|
||||
* with a dma_aes_config structure. If NULL is passed as an argument, encryption
|
||||
* is disabled for the channel; the en/decryption state is also reset at the completion
|
||||
* or aborting of the transaction.
|
||||
*
|
||||
* The caller is responsible for ensuring the dma_aes_config structure remains valid
|
||||
* for the duration of the operation.
|
||||
*
|
||||
* A constant key is used for a given DMA operation, however the caller may specify
|
||||
* that a transfer should be broken into constant-sized chunks. For each chunk, the
|
||||
* iv_func hook will be invoked with the chunk index (offset from 0 at the start of
|
||||
* the transaction).
|
||||
*
|
||||
*/
|
||||
|
||||
struct dma_aes_config {
|
||||
/* AES configuration */
|
||||
u_int32_t command; /* AES_CMD bits from <drivers/aes.h> */
|
||||
u_int32_t keying; /* AES_KEY bits from <drivers/aes.h> */
|
||||
void *key; /* AES key for AES_KEY_TYPE_USER */
|
||||
|
||||
/* IV generation */
|
||||
u_int32_t chunk_size; /* AES chunk size */
|
||||
void (* iv_func)(void *arg, u_int32_t chunk_index, void *iv_buffer);
|
||||
void *iv_func_arg;
|
||||
};
|
||||
|
||||
int dma_set_aes(int dma_channel, struct dma_aes_config *config);
|
||||
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_DMA_H */
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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 __DRIVERS_DPB_H
|
||||
#define __DRIVERS_DPB_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#if DPB_VERSION < 2
|
||||
void dpb_init(void);
|
||||
#else
|
||||
void dpb_init(uint32_t display_width, uint32_t display_height);
|
||||
#endif
|
||||
void dpb_install_gamma_table(u_int32_t *red_lut, u_int32_t *green_lut, u_int32_t *blue_lut, struct syscfg_wpcl *wpcl);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_DPB_H */
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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 __JEDEC_H
|
||||
#define __JEDEC_H
|
||||
|
||||
/* Based on JEDEC LPDDR2 spec */
|
||||
|
||||
enum {
|
||||
JEDEC_MANUF_ID_RSVD0 = 0,
|
||||
JEDEC_MANUF_ID_SAMSUNG,
|
||||
JEDEC_MANUF_ID_QIMONDA,
|
||||
JEDEC_MANUF_ID_ELPIDA,
|
||||
JEDEC_MANUF_ID_ETRON,
|
||||
JEDEC_MANUF_ID_NANYA,
|
||||
JEDEC_MANUF_ID_HYNIX,
|
||||
JEDEC_MANUF_ID_MOSEL,
|
||||
JEDEC_MANUF_ID_WINBOND,
|
||||
JEDEC_MANUF_ID_ESMT,
|
||||
JEDEC_MANUF_ID_RSVD1,
|
||||
JEDEC_MANUF_ID_SPANSION,
|
||||
JEDEC_MANUF_ID_SST,
|
||||
JEDEC_MANUF_ID_ZMOS,
|
||||
JEDEC_MANUF_ID_INTEL,
|
||||
JEDEC_MANUF_ID_NUMONYX,
|
||||
JEDEC_MANUF_ID_MICRON,
|
||||
JEDEC_MANUF_ID_RSVD2,
|
||||
JEDEC_NUM_MANUF_IDS
|
||||
};
|
||||
|
||||
// LPDDR4 vendor ids
|
||||
#define JEDEC_LPDDR4_MANUF_ID_SAMSUNG JEDEC_MANUF_ID_SAMSUNG
|
||||
#define JEDEC_LPDDR4_MANUF_ID_HYNIX JEDEC_MANUF_ID_HYNIX
|
||||
#define JEDEC_LPDDR4_MANUF_ID_MICRON 0xFF
|
||||
#define JEDEC_LPDDR4_MANUF_ID_ELPIDA JEDEC_LPDDR4_MANUF_ID_MICRON
|
||||
|
||||
enum {
|
||||
JEDEC_TYPE_S4_SDRAM = 0,
|
||||
JEDEC_TYPE_S2_SDRAM
|
||||
};
|
||||
|
||||
enum {
|
||||
JEDEC_IO_WIDTH_32 = 0,
|
||||
JEDEC_IO_WIDTH_16,
|
||||
JEDEC_IO_WIDTH_8
|
||||
};
|
||||
|
||||
enum {
|
||||
JEDEC_DENSITY_64Mb = 0,
|
||||
JEDEC_DENSITY_128Mb,
|
||||
JEDEC_DENSITY_256Mb,
|
||||
JEDEC_DENSITY_512Mb,
|
||||
JEDEC_DENSITY_1Gb,
|
||||
JEDEC_DENSITY_2Gb,
|
||||
JEDEC_DENSITY_4Gb,
|
||||
JEDEC_DENSITY_8Gb,
|
||||
JEDEC_DENSITY_16Gb,
|
||||
JEDEC_DENSITY_32Gb
|
||||
};
|
||||
|
||||
enum {
|
||||
JEDEC_LPDDR4_DENSITY_4Gb = 0,
|
||||
JEDEC_LPDDR4_DENSITY_6Gb,
|
||||
JEDEC_LPDDR4_DENSITY_8Gb,
|
||||
JEDEC_LPDDR4_DENSITY_12Gb,
|
||||
JEDEC_LPDDR4_DENSITY_16Gb,
|
||||
JEDEC_LPDDR4_DENSITY_24Gb,
|
||||
JEDEC_LPDDR4_DENSITY_32Gb
|
||||
};
|
||||
|
||||
|
||||
#define JEDEC_MR8_TYPE_SHIFT (0)
|
||||
#define JEDEC_MR8_TYPE_MASK (0x3)
|
||||
#define JEDEC_MR8_DENSITY_SHIFT (2)
|
||||
#define JEDEC_MR8_DENSITY_MASK (0xF)
|
||||
#define JEDEC_MR8_WIDTH_SHIFT (6)
|
||||
#define JEDEC_MR8_WIDTH_MASK (0x3)
|
||||
|
||||
#endif // __JEDEC_H
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2007 Apple 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 __DRIVERS_EDGEIC_H
|
||||
#define __DRIVERS_EDGEIC_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void edgeic_reset(void);
|
||||
void edgeic_select_edge(u_int32_t vector, bool edge);
|
||||
void edgeic_clear_interrupt(u_int32_t vector);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_EDGEIC_H */
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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 __DRIVERS_ETHERNET_H
|
||||
#define __DRIVERS_ETHERNET_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <lib/net/mbuf.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef struct ethq {
|
||||
int read,write;
|
||||
int numentries;
|
||||
int queue_len;
|
||||
int queue_len_mask;
|
||||
|
||||
mymbuf_t **packets; // pointer to an array of pointers to mbufs
|
||||
} ethqueue_t;
|
||||
|
||||
typedef struct ethdstats {
|
||||
int rxerrors; //Sum of all errors
|
||||
int txerrors; //Sum of all errors
|
||||
int runt; //?
|
||||
int extra; //?
|
||||
int crc; // crc error
|
||||
int dribble; //?
|
||||
int rxmissed;
|
||||
int txcollisions;
|
||||
int rxpktok;
|
||||
int txpktok;
|
||||
int rxbytes;
|
||||
int txbytes;
|
||||
} ethdstats_t;
|
||||
|
||||
|
||||
typedef struct ethpriv
|
||||
{
|
||||
ethdstats_t dstats;
|
||||
ethqueue_t rxqueue;
|
||||
ethqueue_t txqueue;
|
||||
char macaddr[6];
|
||||
} ethstat_t;
|
||||
|
||||
//Function declarations
|
||||
//
|
||||
//eth_init()
|
||||
//NULL on failure, ptr private data otherwise.
|
||||
int eth_init(void);
|
||||
|
||||
int eth_start(ethstat_t *);
|
||||
|
||||
int eth_stop(ethstat_t *);
|
||||
|
||||
ethstat_t *eth_get_handle(void);
|
||||
|
||||
int eth_printstatus(ethstat_t *);
|
||||
|
||||
int eth_getpkt(ethstat_t *,char *buffer,int *len);
|
||||
|
||||
int eth_output_packet(ethstat_t *d, const char *pkt,int len,int flag);
|
||||
|
||||
void eth_setmacaddr(ethstat_t *data, const char macaddr[6]);
|
||||
|
||||
void eth_getmacaddr(ethstat_t *data,char *buf);
|
||||
|
||||
void eth_uninit(ethstat_t *data);
|
||||
|
||||
#if WITH_HW_ETHERNET_SWITCH
|
||||
int eth_switch_init(void);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_ETHERNET_H */
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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 __DRIVERS_FLASH_NAND_H
|
||||
#define __DRIVERS_FLASH_NAND_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int flash_nand_init(void);
|
||||
int flash_nand_id(void);
|
||||
|
||||
#if WITH_HW_BOOTROM_NAND
|
||||
/* page offset into block zero from which the bootblock should be read */
|
||||
#define NAND_BOOTBLOCK_OFFSET 2
|
||||
|
||||
int nand_read_bootblock(u_int8_t interface, u_int8_t cs, void *buffer, size_t *size);
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_FLASH_NAND_H */
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
|
||||
* Copyright (C) 2007-2012 Apple 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 __DRIVERS_FLASH_NOR_H
|
||||
#define __DRIVERS_FLASH_NOR_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <lib/blockdev.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct nor_blockdev {
|
||||
struct blockdev bdev;
|
||||
|
||||
uintptr_t handle;
|
||||
|
||||
int (* readRange)(uintptr_t handle, uint8_t *ptr, uint32_t offset, uint32_t length);
|
||||
int (* writeRange)(uintptr_t handle, const uint8_t *ptr, uint32_t offset, uint32_t length);
|
||||
int (* eraseRange)(uintptr_t handle, uint32_t offset, uint32_t length);
|
||||
};
|
||||
|
||||
/* pass -1 for which_device to use the target-defined default device */
|
||||
int flash_nor_init(int which_device);
|
||||
int flash_nor_register(struct nor_blockdev *nor_bdev, const char *name, uint64_t len, uint32_t block_size);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_FLASH_NOR_H */
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2009 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 __DRIVERS_GASGAUGE_H
|
||||
#define __DRIVERS_GASGAUGE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <drivers/power.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void gasgauge_init(void);
|
||||
void gasgauge_late_init(void);
|
||||
void gasgauge_print_status(void);
|
||||
|
||||
#define GG_NEEDS_PRECHARGE (1<<0)
|
||||
#define GG_NEEDS_RESET (1<<1)
|
||||
#define GG_COMMS_WD (1<<2)
|
||||
|
||||
int gasgauge_needs_precharge(int debug_print_level, bool debug_show_target);
|
||||
void gasgauge_will_shutdown(void);
|
||||
bool gasgauge_full(void);
|
||||
int gasgauge_get_battery_id(u_int8_t *buf, int size);
|
||||
bool gasgauge_check_health(unsigned int vbat_mv);
|
||||
bool gasgauge_read_charge_table(struct power_charge_limits *table, size_t num_elems);
|
||||
|
||||
// gasgauge_read_temperature: returns 0 on success
|
||||
int gasgauge_read_temperature(int *centiCelsiusTemperature);
|
||||
// gasgauge_read_voltage: returns 0 on success
|
||||
int gasgauge_read_voltage(unsigned int *milliVolt);
|
||||
int gasgauge_read_design_capacity(unsigned int *milliAmpHours);
|
||||
int gasgauge_read_soc(unsigned int *soc);
|
||||
int gasgauge_reset_timer(int debug_print_level, unsigned int timeout);
|
||||
|
||||
// Gas Gauge Flags
|
||||
enum {
|
||||
kHDQRegFlagsMaskOTC = (1 << 15),
|
||||
kHDQRegFlagsMaskOTD = (1 << 14),
|
||||
kHDQRegFlagsMaskCHG_INH = (1 << 11),
|
||||
kHDQRegFlagsMaskXCHG = (1 << 10),
|
||||
|
||||
kHDQRegFlagsMaskIMAXOK = (1 << 13), // Aquarius
|
||||
kHDQRegFlagsMaskTC2 = (1 << 11), // 0x800 Aquarius
|
||||
kHDQRegFlagsMaskTC1 = (1 << 10), // 0x400 Aquarius
|
||||
|
||||
kHDQRegFlagsMaskFC = (1 << 9),
|
||||
kHDQRegFlagsMaskCHG = (1 << 8),
|
||||
kHDQRegFlagsMaskCCA_REQ = (1 << 5), // Aquarius
|
||||
kHDQRegFlagsMaskLOWV = (1 << 4), // A4
|
||||
kHDQRegFlagsMaskSOC1 = (1 << 2),
|
||||
kHDQRegFlagsMaskSOCF = (1 << 1),
|
||||
kHDQRegFlagsMaskDSG = (1 << 0),
|
||||
};
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#if (WITH_HW_GASGAUGE && DEBUG_BUILD)
|
||||
// define BATTERY_TRAP_DEBUG for full gas gauge register dump in gasgauge_needs_precharge
|
||||
#define BATTERY_TRAP_DEBUG
|
||||
#endif
|
||||
#endif /* __DRIVERS_GAUGE_H */
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 __DRIVERS_HDC_H
|
||||
#define __DRIVERS_HDC_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <lib/blockdev.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* Generic Device defines */
|
||||
#define HDC_BLOCK_SIZE 512
|
||||
|
||||
#define HDC_CMD_READ 0x01
|
||||
#define HDC_CMD_WRITE 0x02
|
||||
#define HDC_CMD_INT 0x80
|
||||
#define HDC_CMD_MASK 0x7F
|
||||
|
||||
#define HDC_ST_READY 0x0
|
||||
#define HDC_ST_BUSY 0x1
|
||||
#define HDC_ST_DONE 0x2
|
||||
#define HDC_ST_ERROR 0x3
|
||||
|
||||
#define HDC_SET_CMD_CMD(r,c) ((r) | (((c) & 0xff) << 24))
|
||||
#define HDC_SET_CMD_DISK(r,c) ((r) | (((c) & 0xff) << 16))
|
||||
#define HDC_SET_CMD_LEN(r,c) ((r) | (((c) & 0xff) << 0))
|
||||
|
||||
#define HDC_GET_STATUS_ST(r) (((r) >> 24) & 0xff)
|
||||
#define HDC_GET_STATUS_DISK(r) (((r) >> 16) & 0xff)
|
||||
#define HDC_GET_STATUS_CNT(r) (((r) >> 0) & 0xffff)
|
||||
|
||||
|
||||
int hdc_init(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_HDC_H */
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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 DRIVERS_HDMI_H
|
||||
#define DRIVERS_HDMI_H 1
|
||||
|
||||
#include <drivers/displayAV.h>
|
||||
#include <drivers/display.h>
|
||||
|
||||
// Color component limits for limited range color
|
||||
#define kVideoColorLimitedRangeYMin 16 // Also used for RGB
|
||||
#define kVideoColorLimitedRangeYMax 235 // Also used for RGB
|
||||
#define kVideoColorLimitedRangeCMin 16
|
||||
#define kVideoColorLimitedRangeCMax 240
|
||||
|
||||
// Timing Generator Limits (max value + 1)
|
||||
#define kHorizontalTotalLimit 8192u
|
||||
#define kHorizontalActiveLimit 4096u
|
||||
#define kHorizontalBlankLimit 4096u
|
||||
#define kVerticalTotalLimit 2048u
|
||||
#define kVerticalActiveLimit 2048u
|
||||
#define kVerticalBlankLimit 2048u
|
||||
|
||||
#define kPHYReadyPollIntervalMS 10
|
||||
#define kVideoStabilizationIntervalMS 60
|
||||
|
||||
// controller config flags
|
||||
|
||||
enum {
|
||||
kHDMIControllerMode_Master = 0,
|
||||
kHDMIControllerMode_Slave
|
||||
};
|
||||
#define kHDMIControllerMode_Mask 0xf
|
||||
#define kHDMIControllerMode_Shift 4
|
||||
|
||||
enum {
|
||||
kHDMIControllerType_HDMI = 0,
|
||||
};
|
||||
#define kHDMIControllerType_Mask 0xf
|
||||
#define kHDMIControllerType_Shift 0
|
||||
|
||||
enum {
|
||||
kHDMI_tx_mode_None = 0,
|
||||
kHDMI_tx_mode_HDMI = 1,
|
||||
kHDMI_tx_mode_DVI = 2,
|
||||
} TX_Mode;
|
||||
|
||||
struct pixel {
|
||||
uint16_t r; // R or Cr
|
||||
uint16_t g; // G or Y
|
||||
uint16_t b; // B or Cb
|
||||
};
|
||||
|
||||
// global
|
||||
int hdmi_init();
|
||||
int hdmi_init_with_timing_info(struct display_timing *timing_info);
|
||||
int hdmi_set_timings(struct display_timing *timing_info);
|
||||
int hdmi_start_video(void);
|
||||
bool hdmi_video_configured();
|
||||
void hdmi_quiesce();
|
||||
|
||||
// controller
|
||||
int hdmi_controller_start(u_int8_t type, u_int8_t mode);
|
||||
void hdmi_controller_stop();
|
||||
int hdmi_controller_validate_video(struct video_timing_data *data);
|
||||
int hdmi_controller_read_bytes_i2c(u_int32_t device_addr, u_int8_t addr, u_int8_t *data, u_int32_t length);
|
||||
int hdmi_controller_write_bytes_i2c(u_int32_t device_addr, u_int32_t addr, u_int8_t *data, u_int32_t length);
|
||||
int hdmi_controller_start_video(struct video_link_data *data, uint32_t pixel_clock);
|
||||
int hdmi_controller_stop_video();
|
||||
|
||||
uint8_t hdmi_read_reg(uint32_t offset);
|
||||
void hdmi_write_reg(uint32_t offset, uint8_t value);
|
||||
|
||||
bool hdmi_controller_video_configured();
|
||||
|
||||
// device
|
||||
|
||||
int hdmi_device_start();
|
||||
int hdmi_device_wait_started();
|
||||
void hdmi_device_stop();
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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 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 __DRIVERS_IIC_H
|
||||
#define __DRIVERS_IIC_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef enum {
|
||||
IIC_NORMAL = 1,
|
||||
IIC_COMBINED = 2,
|
||||
} iic_fmt_t;
|
||||
|
||||
void iic_init(void);
|
||||
void iic_set_filter(int iic, uint32_t value);
|
||||
void iic_set_frequency(int iic, u_int32_t frequency);
|
||||
int iic_read(int iic, uint8_t address, const void *send_data, size_t send_len, void *data, size_t len, iic_fmt_t fmt);
|
||||
int iic_write(int iic, uint8_t address, const void *data, size_t len);
|
||||
|
||||
bool iic_probe(int iic, uint8_t address);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_IIC_H */
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 __DRIVERS_IIS_H
|
||||
#define __DRIVERS_IIS_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys.h>
|
||||
#include <platform.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void iis_set_master(int iis, bool master);
|
||||
int iis_set_bcpf(int iis, int bcpf);
|
||||
int iis_set_usb(int iis, bool usb);
|
||||
void iis_set_bclk_scaler(int iis, int bclk_scaler);
|
||||
|
||||
void iis_tx(int iis, void *buf, size_t len);
|
||||
|
||||
bool iis_is_done(int iis);
|
||||
bool iis_wait_done(int iis, int ms);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_IIS_H */
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2013 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 IPIPE_H
|
||||
#define IPIPE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct ipipe ipipe_t;
|
||||
|
||||
typedef void (ipipe_tx_callback_t)(void *priv, const uint8_t *packet, uint32_t bytes);
|
||||
|
||||
ipipe_t *ipipe_init(uint32_t max_packet_size, ipipe_tx_callback_t *tx_callback, void *priv);
|
||||
void ipipe_quiesce_and_free(ipipe_t *ipipe);
|
||||
void ipipe_handle_packet(ipipe_t *ipipe, const uint8_t *packet, uint32_t bytes);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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 __DRIVERS_MCU_H
|
||||
#define __DRIVERS_MCU_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int mcu_init(void);
|
||||
int mcu_start_recover(void);
|
||||
int mcu_start_boot(void);
|
||||
int mcu_set_passthrough_mode(bool on);
|
||||
int mcu_send_info_frames(bool on);
|
||||
int mcu_quiesce_uart(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_MCU_H */
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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 __DRIVERS_MIPI_H
|
||||
#define __DRIVERS_MIPI_H
|
||||
|
||||
#include <drivers/display.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int mipi_dsim_init(struct display_timing *timing, enum colorspace color);
|
||||
void mipi_dsim_enable_high_speed(bool enable);
|
||||
void mipi_dsim_enable_video(bool enable);
|
||||
int mipi_dsim_quiesce(void);
|
||||
int mipi_dsim_send_short_command(u_int8_t cmd, u_int8_t data0, u_int8_t data1);
|
||||
int mipi_dsim_send_long_command(u_int8_t cmd, const u_int8_t *data, u_int32_t length);
|
||||
int mipi_dsim_read_short_command(u_int8_t cmd, u_int8_t *data);
|
||||
int mipi_dsim_read_long_command(u_int8_t cmd, u_int8_t *data, u_int32_t *length);
|
||||
|
||||
/* DSIM command types */
|
||||
#define DSIM_TYPE_DSC_WRITE 0x05
|
||||
#define DSIM_TYPE_DSC_READ 0x06
|
||||
#define DSIM_TYPE_GEN_READ_1P 0x14
|
||||
#define DSIM_TYPE_DSC_WRITE_1P 0x15
|
||||
#define DSIM_TYPE_DSC_READ_2P 0x24
|
||||
#define DSIM_TYPE_GEN_LONG_WRITE 0x29
|
||||
#define DSIM_TYPE_GEN_LUT_WRITE 0x39
|
||||
|
||||
/* DSIM response types */
|
||||
#define DSIM_RSP_READ_1B 0x11
|
||||
#define DSIM_RSP_READ_2B 0x12
|
||||
#define DSIM_RSP_LONG_READ 0x1A
|
||||
#define DSIM_RSP_DSC_LONG_READ 0x1C
|
||||
#define DSIM_RSP_DSC_READ_1B 0x21
|
||||
#define DSIM_RSP_DSC_READ_2B 0x22
|
||||
|
||||
/* DSIM commands / registers */
|
||||
#define DSIM_CMD_NOP 0x00
|
||||
#define DSIM_CMD_ENTER_SLEEP 0x10
|
||||
#define DSIM_CMD_EXIT_SLEEP 0x11
|
||||
#define DSIM_CMD_INVERT_OFF 0x20
|
||||
#define DSIM_CMD_INVERT_ON 0x21
|
||||
#define DSIM_CMD_DISPLAY_OFF 0x28
|
||||
#define DSIM_CMD_DISPLAY_ON 0x29
|
||||
#define DSIM_CMD_ADDRESS_MODE 0x36
|
||||
#define DSIM_CMD_DEVICE_ID 0xb1
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* ! __DRIVERS_MIPI_H */
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2011 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 __DRIVERS_MIU_H
|
||||
#define __DRIVERS_MIU_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int mcu_initialize_dram(bool resume);
|
||||
int mcu_suspend_dram(void);
|
||||
void mcu_adjust_performance(void);
|
||||
u_int64_t mcu_get_memory_size(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_MIU_H */
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2009 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 _NAND_BOOT_H
|
||||
#define _NAND_BOOT_H
|
||||
#if WITH_NAND_BOOT
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int nand_boot_init(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* WITH_NAND_BOOT */
|
||||
#endif /* ! _NAND_BOOT_H */
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (C) 2009 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.
|
||||
//
|
||||
|
||||
#include <lib/devicetree.h>
|
||||
|
||||
#ifndef _NAND_DEVICETREE_H_
|
||||
|
||||
// Add required NAND properties to the given device-tree node
|
||||
|
||||
void fillNandConfigProperties(DTNode *node);
|
||||
|
||||
#endif //_NAND_DEVICETREE_H_
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2009 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 _NAND_SYSCFG_H
|
||||
#define _NAND_SYSCFG_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int nand_syscfg_init(NandPartInterface * npi);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* ! _NAND_SYSCFG_H */
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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 DRIVERS_NVME_H
|
||||
#define DRIVERS_NVME_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <drivers/pci.h>
|
||||
#if WITH_DEVICETREE
|
||||
#include <lib/devicetree.h>
|
||||
#endif
|
||||
|
||||
// NVMe for iOS says we can assume IDENTIFY.MDTS >= 8, which translates to 256 blocks
|
||||
#define NVME_BOOT_MAX_TRANSFER_BLOCKS (256)
|
||||
|
||||
#define NVME_NAMESPACE_NAND 1
|
||||
#define NVME_NAMESPACE_FIRMWARE 2
|
||||
#define NVME_NAMESPACE_SYSCFG 3
|
||||
#define NVME_NAMESPACE_NVRAM 5
|
||||
#define NVME_NAMESPACE_EFFACEABLE 6
|
||||
#define NVME_NAMESPACE_PANICLOG 7
|
||||
|
||||
#define NVME_BLOCK_SIZE (1<<12)
|
||||
|
||||
#define NVME_SUCCESS (0)
|
||||
// Error codes from -1 to -4095 are reserved for NVMe errors
|
||||
// - Bits 7:0 get the SC field from the completion
|
||||
// - Bits 11:8 get the SCT field from the completion
|
||||
// - See the NVMe spec for details on errors from -1 to -4095
|
||||
// Error codes from 5000 to 5999 for PCI errors
|
||||
#define NVME_ERR_PROBE_FAILED (-5000)
|
||||
#define NVME_ERR_INVALID_CLASS_CODE (-5001)
|
||||
#define NVME_ERR_INVALID_BAR (-5002)
|
||||
#define NVME_ERR_INVALID_REG (-5003)
|
||||
// Error codes from 6000 to 6999 for controller initialization errors
|
||||
#define NVME_ERR_DISABLE_TIMEOUT (-6000)
|
||||
#define NVME_ERR_ENABLE_TIMEOUT (-6001)
|
||||
#define NVME_ERR_SHUTDOWN_TIMEOUT (-6002)
|
||||
#define NVME_ERR_CFS (-6003)
|
||||
#define NVME_ERR_POLL_REG_TIMEOUT (-6004)
|
||||
#define NVME_ERR_INVALID_DSTRD (-6100)
|
||||
#define NVME_ERR_INVALID_MPSMIN (-6101)
|
||||
#define NVME_ERR_INVALID_MQES (-6102)
|
||||
#define NVME_ERR_INVALID_SQES (-6103)
|
||||
#define NVME_ERR_INVALID_CQES (-6104)
|
||||
#define NVME_ERR_INVALID_DDRREQALIGN (-6150)
|
||||
#define NVME_ERR_INVALID_DDRREQSIZE (-6151)
|
||||
// Error codes from 7000 to 7999 for command processing errors
|
||||
#define NVME_ERR_INVALID_CMPL_SQID (-7001)
|
||||
#define NVME_ERR_INVALID_CMPL_SQHD (-7002)
|
||||
#define NVME_ERR_IO_CMD_TIMEOUT (-7003)
|
||||
#define NVME_ERR_ADMIN_CMD_TIMEOUT (-7004)
|
||||
#define NVME_ERR_CMPL_CID_MISMATCH (-7005)
|
||||
// Error codes from 8000 to 8999 are generic driver errors
|
||||
#define NVME_ERR_NOT_ENABLED (-8000)
|
||||
|
||||
typedef struct nvme_namespace_params_t {
|
||||
bool formatted;
|
||||
uint64_t num_blocks;
|
||||
uint32_t block_size;
|
||||
} nvme_namespace_params_t;
|
||||
|
||||
int nvme_init(int nvme_id, pci_device_t bridge, uint32_t dart_id);
|
||||
void nvme_quiesce(int nvme_id);
|
||||
void nvme_quiesce_all(void);
|
||||
int nvme_read_blocks(int nvme_id, uint32_t nsid, void *ptr, uint32_t block, uint32_t count);
|
||||
int nvme_write_blocks(int nvme_id, uint32_t nsid, const void *ptr, uint32_t block, uint32_t count);
|
||||
int nvme_identify_namespace(int nvme_id, uint32_t nsid, nvme_namespace_params_t *params_out);
|
||||
uint32_t nvme_get_max_transfer_blocks(int nvme_id);
|
||||
int nvme_init_mass_storage(int nvme_id);
|
||||
int nvme_init_mass_storage_panic(int nvme_id);
|
||||
|
||||
#if WITH_DEVICETREE
|
||||
void nvme_update_devicetree (int nvme_id, dt_node_t *node);
|
||||
#endif
|
||||
|
||||
#endif // DRIVERS_NVME_H
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2013 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 Computer, Inc.
|
||||
*/
|
||||
#ifndef __DRIVERS_PCI_PCI_H
|
||||
#define __DRIVERS_PCI_PCI_H
|
||||
|
||||
#include <sys.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef void (*pci_config_read_cb_t)(void *priv, void *dst, uint32_t bdfo, int size);
|
||||
typedef void (*pci_config_write_cb_t)(void *priv, const void *src, uint32_t bdfo, int size);
|
||||
|
||||
typedef struct pci_device * pci_device_t;
|
||||
|
||||
void pci_init(void);
|
||||
void pci_free(pci_device_t dev);
|
||||
|
||||
// Config space accessors
|
||||
uint8_t pci_config_read8(pci_device_t dev, uint16_t offset);
|
||||
uint16_t pci_config_read16(pci_device_t dev, uint16_t offset);
|
||||
uint32_t pci_config_read32(pci_device_t dev, uint16_t offset);
|
||||
void pci_config_write8(pci_device_t dev, uint16_t offset, uint8_t value);
|
||||
void pci_config_write16(pci_device_t dev, uint16_t offset, uint16_t value);
|
||||
void pci_config_write32(pci_device_t dev, uint16_t offset, uint32_t value);
|
||||
|
||||
uint64_t pci_get_bar_size(pci_device_t dev, unsigned bar_idx);
|
||||
pci_device_t pci_get_bridge(pci_device_t dev);
|
||||
uint32_t pci_get_class_code(pci_device_t dev);
|
||||
uint16_t pci_get_device_id(pci_device_t dev);
|
||||
uint8_t pci_get_header_type(pci_device_t dev);
|
||||
uint8_t pci_get_revision_id(pci_device_t dev);
|
||||
uint16_t pci_get_vendor_id(pci_device_t dev);
|
||||
|
||||
uintptr_t pci_map_bar(pci_device_t dev, unsigned bar_idx);
|
||||
void pci_bus_master_enable(pci_device_t dev, bool enable);
|
||||
void pci_memory_space_enable(pci_device_t dev, bool enable);
|
||||
|
||||
// Capabilities
|
||||
uint16_t pci_find_capability(pci_device_t dev, uint16_t capability_id);
|
||||
uint16_t pci_find_extended_capability(pci_device_t dev, uint16_t capability_id, uint8_t min_version);
|
||||
|
||||
// Power management
|
||||
void pci_set_powerstate(pci_device_t dev, uint8_t powerstate);
|
||||
void pci_enable_pcie_aspm(pci_device_t dev);
|
||||
void pci_enable_pcie_l1ss(pci_device_t dev);
|
||||
bool pci_enable_pcie_ltr(pci_device_t dev);
|
||||
|
||||
// Random info
|
||||
void pci_set_name(pci_device_t dev, const char *name);
|
||||
const char *pci_get_name(pci_device_t dev);
|
||||
|
||||
// Bridges
|
||||
bool pci_is_bridge(pci_device_t dev);
|
||||
pci_device_t pci_create_host_bridge(const char *name, uint8_t bus_num, uint32_t memory_base, uint32_t memory_size, void *priv, pci_config_read_cb_t read_cb, pci_config_write_cb_t write_cb);
|
||||
pci_device_t pci_bridge_probe(pci_device_t bridge, uint8_t device_num, utime_t timeout);
|
||||
void pci_bridge_assign_secondary_bus(pci_device_t bridge);
|
||||
void pci_bridge_serr_enable(pci_device_t dev, bool enable);
|
||||
|
||||
#define PCI_BUS_SHIFT 20
|
||||
#define PCI_DEVICE_SHIFT 15
|
||||
#define PCI_FUNCTION_SHIFT 12
|
||||
#define PCI_BDFO(bus, device, function, offset) ((((uint32_t)bus) << PCI_BUS_SHIFT) | (((uint32_t)device) << PCI_DEVICE_SHIFT) | (((uint32_t)function) << PCI_FUNCTION_SHIFT) | (offset))
|
||||
#define PCI_BDF(bus, device, function) (PCI_BDFO((bus), (device), (function), 0))
|
||||
#define PCI_DFO(device, function, offset) (PCI_BDFO(0, (device), (function), (offset)))
|
||||
#define PCI_DFO_MASK ((1 << PCI_BUS_SHIFT)-1)
|
||||
#define PCI_DEVICE_MASK (0x1F << PCI_DEVICE_SHIFT)
|
||||
#define PCI_FUNCTION_MASK (0x7 << PCI_FUNCTION_SHIFT)
|
||||
#define PCI_BUS(bdfo) (bdfo >> PCI_BUS_SHIFT)
|
||||
#define PCI_DEVICE(bdfo) (((bdfo) & PCI_DEVICE_MASK) >> PCI_DEVICE_SHIFT)
|
||||
#define PCI_FUNCTION(bdfo) (((bdfo) & PCI_FUNCTION_MASK) >> PCI_FUNCTION_SHIFT)
|
||||
|
||||
#define PCI_CONFIG_VENDOR_ID 0x00
|
||||
#define PCI_CONFIG_DEVICE_ID 0x02
|
||||
#define PCI_CONFIG_COMMAND 0x04
|
||||
#define PCI_CONFIG_STATUS 0x06
|
||||
#define PCI_CONFIG_REVISION_ID 0x08
|
||||
#define PCI_CONFIG_CLASS_CODE 0x09
|
||||
#define PCI_CONFIG_CACHE_LINE_SIZE 0x0C
|
||||
#define PCI_CONFIG_LATENCY_TIMER 0x0D
|
||||
#define PCI_CONFIG_HEADER_TYPE 0x0E
|
||||
#define PCI_CONFIG_BIST 0x0F
|
||||
#define PCI_CONFIG_BASE_ADDRESS0 0x10
|
||||
#define PCI_CONFIG_BASE_ADDRESS1 0x14
|
||||
#define PCI_CONFIG_BASE_ADDRESS2 0x18
|
||||
#define PCI_CONFIG_BASE_ADDRESS3 0x1C
|
||||
#define PCI_CONFIG_BASE_ADDRESS4 0x20
|
||||
#define PCI_CONFIG_BASE_ADDRESS5 0x24
|
||||
#define PCI_CONFIG_CARDBUS_CIS_PTR 0x28
|
||||
#define PCI_CONFIG_SUBSYSTEM_VENDOR_ID 0x2C
|
||||
#define PCI_CONFIG_SUBSYSTEM_ID 0x2E
|
||||
#define PCI_CONFIG_EXPANSION_ROM_BASE 0x30
|
||||
#define PCI_CONFIG_CAPABILITIES_PTR 0x34
|
||||
#define PCI_CONFIG_INTERRUPT_LINE 0x3C
|
||||
#define PCI_CONFIG_INTERRUPT_PIN 0x3D
|
||||
#define PCI_CONFIG_MINIMUM_GRANT 0x3E
|
||||
#define PCI_CONFIG_MAXIMUM_LATENCY 0x3F
|
||||
|
||||
#define PCI_CONFIG_PRIMARY_BUS_NUMBER 0x18
|
||||
#define PCI_CONFIG_SECONDARY_BUS_NUMBER 0x19
|
||||
#define PCI_CONFIG_SUBORDINATE_BUS_NUMBER 0x1A
|
||||
#define PCI_CONFIG_SECONDARY_LATENCY_TIMER 0x1B
|
||||
#define PCI_CONFIG_IO_BASE 0x1C
|
||||
#define PCI_CONFIG_IO_LIMIT 0x1D
|
||||
#define PCI_CONFIG_SECONDARY_STATUS 0x1E
|
||||
#define PCI_CONFIG_MEMORY_BASE 0x20
|
||||
#define PCI_CONFIG_MEMORY_LIMIT 0x22
|
||||
#define PCI_CONFIG_PREFETCHABLE_BASE 0x24
|
||||
#define PCI_CONFIG_PREFETCHABLE_LIMIT 0x26
|
||||
#define PCI_CONFIG_PREFETCHABLE_BASE_UPPER32 0x28
|
||||
#define PCI_CONFIG_PREFETCHABLE_LIMIT_UPPER32 0x2C
|
||||
#define PCI_CONFIG_IO_BASE_UPPER16 0x30
|
||||
#define PCI_CONFIG_IO_LIMIT_UPPER16 0x32
|
||||
#define PCI_CONFIG_BRIDGE_CONTROL 0x3E
|
||||
|
||||
#define PCI_CMD_IO_SPACE_ENABLE (1 << 0)
|
||||
#define PCI_CMD_MEMORY_SPACE_ENABLE (1 << 1)
|
||||
#define PCI_CMD_BUS_MASTER_ENABLE (1 << 2)
|
||||
#define PCI_CMD_SERR_ENABLE (1 << 8)
|
||||
|
||||
#define PCI_BRIDGE_CTRL_SERR_ENABLE (1 << 1)
|
||||
|
||||
#define PCI_STATUS_CAPABILITIES_LIST (1 << 4)
|
||||
|
||||
#define PCI_CAP_ID_PM (0x01)
|
||||
|
||||
#define PCI_PM_CAP_PMC (0x02)
|
||||
#define PCI_PM_CAP_PMCSR (0x04)
|
||||
#define PCI_PM_CAP_PMCSR_BSE (0x06)
|
||||
#define PCI_PM_CAP_DATA (0x07)
|
||||
|
||||
#define PCI_PM_POWERSTATE_D0 (0x0)
|
||||
#define PCI_PM_POWERSTATE_D3 (0x3)
|
||||
|
||||
// PCIe r3.0 section 7.8
|
||||
#define PCI_CAP_ID_PCIE (0x10)
|
||||
|
||||
#define PCI_PCIE_CAP_PCIE_CAPABILITIES (0x02)
|
||||
#define PCI_PCIE_CAP_LINK_CAPABILITIES (0x0C)
|
||||
#define PCI_PCIE_CAP_LINK_CONTROL (0x10)
|
||||
#define PCI_PCIE_CAP_DEVICE_CAPABILITIES2 (0x24)
|
||||
#define PCI_PCIE_CAP_DEVICE_CONTROL2 (0x28)
|
||||
#define PCI_PCIE_CAP_LINK_CAPABILITIES2 (0x2C)
|
||||
#define PCI_PCIE_CAP_LINK_CONTROL2 (0x30)
|
||||
|
||||
// PCIe r3.0 section 7.8.2
|
||||
#define PCI_PCIE_TYPE_ENDPOINT (0)
|
||||
#define PCI_PCIE_TYPE_ROOT_PORT (4)
|
||||
#define PCI_PCIE_TYPE_UPSTREAM (5)
|
||||
#define PCI_PCIE_TYPE_DOWNSTREAM (6)
|
||||
#define PCI_PCIE_TYPE_UNKNOWN (UINT8_MAX) // for endpoints without a PCIe capability
|
||||
|
||||
// PCIe r3.0 section 7.8.6/7.8.18
|
||||
#define PCI_PCIE_SPEED_GEN1 (0)
|
||||
#define PCI_PCIE_SPEED_GEN2 (1)
|
||||
#define PCI_PCIE_SPEED_GEN3 (2)
|
||||
|
||||
// PCIe r3.0 section 7.25
|
||||
#define PCI_EXT_CAP_ID_LTR (0x18)
|
||||
|
||||
#define PCI_LTR_CAP_MAX_SNOOP_LATENCY (0x04)
|
||||
#define PCI_LTR_CAP_MAX_NO_SNOOP_LATENCY (0x06)
|
||||
|
||||
#define PCI_EXT_CAP_ID_L1SS (0x1E)
|
||||
|
||||
#define PCI_L1SS_CAP_CAPABILITIES (0x04)
|
||||
#define PCI_L1SS_CAP_CONTROL1 (0x08)
|
||||
#define PCI_L1SS_CAP_CONTROL2 (0x0c)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Apple 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.
|
||||
*/
|
||||
/*
|
||||
* Ethernet PHY support.
|
||||
*/
|
||||
#ifndef __DRIVERS_PHY_H
|
||||
#define __DRIVERS_PHY_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
enum phy_speed {
|
||||
PHY_SPEED_UNKNOWN,
|
||||
PHY_SPEED_AUTO,
|
||||
PHY_SPEED_10,
|
||||
PHY_SPEED_100,
|
||||
PHY_SPEED_1000
|
||||
};
|
||||
|
||||
int phy_init(int port);
|
||||
int phy_set_speed(int port, enum phy_speed speed);
|
||||
bool phy_get_link(int port);
|
||||
extern int phy_read_reg(int port, uint32_t reg, uint16_t *data);
|
||||
extern int phy_write_reg(int port, uint32_t reg, uint16_t data);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_PHY_H */
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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 __DRIVERS_PKE_H
|
||||
#define __DRIVERS_PKE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
bool pke_do_exp(uint8_t *dst, size_t *len,
|
||||
size_t uKeyLen,
|
||||
uint8_t * const base, size_t base_length,
|
||||
uint8_t * const expn, size_t expn_length,
|
||||
uint8_t * const mods, size_t mods_length);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_PKE_H */
|
||||
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2010 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 __DRIVERS_POWER_H
|
||||
#define __DRIVERS_POWER_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define kPowerBootFlagCold (0)
|
||||
#define kPowerBootFlagColdButton (1)
|
||||
#define kPowerBootFlagWarm (2)
|
||||
#define kPowerBootFlagResumeLost (3)
|
||||
|
||||
int power_init(void);
|
||||
int power_late_init(void);
|
||||
int power_backlight_enable(u_int32_t backlight_level);
|
||||
int power_get_boot_flag(void);
|
||||
|
||||
void power_suspend(void);
|
||||
void power_shutdown(void); // tell the pmu to pull the plug
|
||||
int power_set_soc_voltage(unsigned mv, int override);
|
||||
int power_set_cpu_voltage(unsigned mv, int override);
|
||||
int power_set_ram_voltage(unsigned mv, int override);
|
||||
|
||||
#define POWER_RAIL_CPU 0
|
||||
#define POWER_RAIL_VDD_FIXED 1
|
||||
#define POWER_RAIL_SOC 2
|
||||
#define POWER_RAIL_CPU_RAM 3
|
||||
#define POWER_RAIL_GPU 4
|
||||
#define POWER_RAIL_GPU_RAM 5
|
||||
// not a rail, might move this to target
|
||||
#define POWER_RAIL_COUNT 6
|
||||
|
||||
// @rail one of POWER_RAIL_* (replace power_get_buck_value(), backward compatible)
|
||||
int power_get_rail_value(int rail, unsigned mv, u_int32_t *buffer);
|
||||
// @rail one of POWER_RAIL_* (backward compatible with power_convert_dwi_to_mv())
|
||||
int power_convert_dwi_to_mv(int rail, u_int32_t dwival);
|
||||
// deprecated, use power_get_rail_value() ( buck is not the buck# )
|
||||
int power_get_buck_value(int buck, unsigned mv, u_int32_t *buffer);
|
||||
|
||||
int power_set_display_voltage_offset(u_int32_t voltage_offset, bool fixed_boost);
|
||||
|
||||
void power_set_usb_state(bool configured, bool suspended);
|
||||
void power_set_usb_enabled(bool enabed);
|
||||
int power_set_gpio(u_int32_t gpio, u_int32_t direction, u_int32_t value);
|
||||
int power_set_ldo(u_int32_t ldo, u_int32_t voltage);
|
||||
int power_enable_ldo(u_int32_t ldo, bool enable);
|
||||
bool power_get_gpio(u_int32_t gpio);
|
||||
void power_gpio_configure(u_int32_t gpio, u_int32_t config);
|
||||
|
||||
bool power_needs_precharge(void);
|
||||
bool power_needs_thermal_trap(void);
|
||||
bool power_do_chargetrap(void);
|
||||
void power_cancel_buttonwait(void);
|
||||
bool power_is_suspended(void);
|
||||
void power_will_resume(void);
|
||||
bool power_has_usb(void);
|
||||
int power_read_dock_id(unsigned *id);
|
||||
bool power_get_diags_dock(void);
|
||||
u_int32_t power_get_boot_battery_level(void);
|
||||
u_int32_t power_get_battery_level(void);
|
||||
void power_get_usb_brick_id(uint32_t *id, size_t count);
|
||||
bool power_has_batterypack(void);
|
||||
bool power_enable_charging(bool inflow, bool charging);
|
||||
uint32_t power_get_available_charge_current(void);
|
||||
|
||||
int power_get_nvram(u_int8_t key, u_int8_t *data);
|
||||
int power_set_nvram(u_int8_t key, u_int8_t data);
|
||||
void power_clr_events(int wake);
|
||||
|
||||
|
||||
#define kPowerNVRAMiBootStateName "iBootState"
|
||||
#define kPowerNVRAMiBootStateKey (0)
|
||||
|
||||
#define kPowerNVRAMiBootStatePrecharge (1 << 5) // can be or'd with modes below
|
||||
#define kPowerNVRAMiBootStateThermalTrap (1 << 0)
|
||||
#define kPowerNVRAMiBootStateModeMask (0xd0) // bits 4, 6 and 7 (keep backwards compatible)
|
||||
#define kPowerNVRAMiBootStateModeNormalBoot (0x00)
|
||||
#define kPowerNVRAMiBootStateModeResumed (0x40)
|
||||
#define kPowerNVRAMiBootStateModeSuspended (0x80)
|
||||
#define kPowerNVRAMiBootStateModeButtonwaitWithGraphics (0x10)
|
||||
#define kPowerNVRAMiBootStateModeButtonwaitNoGraphics (0x90)
|
||||
|
||||
#define kPowerNVRAMiBootDebugName "iBootDebug"
|
||||
#define kPowerNVRAMiBootDebugKey (1)
|
||||
#define kPowerNVRAMiBootDebugIAPSerial (1 << 0)
|
||||
#define kPowerNVRAMiBootDebugAltSerial (1 << 1)
|
||||
#define kPowerNVRAMiBootDebugJtag (1 << 2)
|
||||
#define kPowerNVRAMiBootDebugEarlyTracing (1 << 3)
|
||||
#define kPowerNVRAMiBootDebugBatteryTrap (1 << 4)
|
||||
#define kPowerNVRAMiBootDebugWDTWake (1 << 7)
|
||||
|
||||
#define kPowerNVRAMiBootStageName "iBootStage"
|
||||
#define kPowerNVRAMiBootStageKey (2)
|
||||
#define kPowerNVRAMiBootStageOff (0x00)
|
||||
#define kPowerNVRAMiBootStageLLBStart (0x10)
|
||||
#define kPowerNVRAMiBootStageLLBEnd (0x1F)
|
||||
#define kPowerNVRAMiBootStageiBootStart (0x20)
|
||||
#define kPowerNVRAMiBootStageiBootEnd (0x2F)
|
||||
#define kPowerNVRAMDiagsStageDiagsBootComplete (0xD0)
|
||||
#define kPowerNVRAMiBootStagePanicSave (0xE0)
|
||||
#define kPowerNVRAMiBootStagePanicReboot (0xE1)
|
||||
#define kPowerNVRAMiBootStagePrechargeReboot (0xE2)
|
||||
#define kPowerNVRAMiBootStageBooted (0xFF)
|
||||
|
||||
#if PRODUCT_LLB
|
||||
#define kPowerNVRAMiBootStageProductStart kPowerNVRAMiBootStageLLBStart
|
||||
#define kPowerNVRAMiBootStageProductEnd kPowerNVRAMiBootStageLLBEnd
|
||||
#endif
|
||||
|
||||
#if PRODUCT_IBOOT || PRODUCT_IBEC
|
||||
#define kPowerNVRAMiBootStageProductStart kPowerNVRAMiBootStageiBootStart
|
||||
#define kPowerNVRAMiBootStageProductEnd kPowerNVRAMiBootStageiBootEnd
|
||||
#endif
|
||||
|
||||
#if PRODUCT_IBSS
|
||||
#define kPowerNVRAMiBootStageProductStart kPowerNVRAMiBootStageLLBStart
|
||||
#define kPowerNVRAMiBootStageProductEnd kPowerNVRAMiBootStageiBootEnd
|
||||
#endif
|
||||
|
||||
#define kPowerNVRAMiBootErrorCountName "iBootErrorCount"
|
||||
#define kPowerNVRAMiBootErrorCountKey (3)
|
||||
#define kPowerNVRAMiBootErrorCountMask (0x0F)
|
||||
#define kPowerNVRAMiBootErrorPanicShift (4)
|
||||
#define kPowerNVRAMiBootErrorBootShift (0)
|
||||
|
||||
#define kPowerNVRAMiBootErrorStageName "iBootErrorStage"
|
||||
#define kPowerNVRAMiBootErrorStageKey (4)
|
||||
|
||||
#define kPowerNVRAMiBootMemCalCAOffset0Key (5) // CA offset need 2 bytes
|
||||
#define kPowerNVRAMiBootMemCalCAOffset1Key (6)
|
||||
#define kPowerNVRAMiBootMemCalCAOffset2Key (7)
|
||||
#define kPowerNVRAMiBootMemCalCAOffset3Key (8)
|
||||
|
||||
#define kPowerNVRAMiBootMemCalCAOffset0Name "iBootMemCalCAOffset0"
|
||||
#define kPowerNVRAMiBootMemCalCAOffset1Name "iBootMemCalCAOffset1"
|
||||
#define kPowerNVRAMiBootMemCalCAOffset2Name "iBootMemCalCAOffset2"
|
||||
#define kPowerNVRAMiBootMemCalCAOffset3Name "iBootMemCalCAOffset3"
|
||||
|
||||
#define kPowerNVRAMiBootBootFlags0Key (9)
|
||||
#define kPowerNVRAMiBootBootFlags1Key (10)
|
||||
|
||||
#define kPowerNVRAMiBootBootFlags0Name "iBootBootFlags0"
|
||||
#define kPowerNVRAMiBootBootFlags1Name "iBootBootFlags1"
|
||||
|
||||
#define kPowerNVRAMiBootEnterDFUName "iBootEnterDFU"
|
||||
#define kPowerNVRAMiBootEnterDFUKey (11)
|
||||
#define kPowerNVRAMiBootEnterDFURequest (0xA0)
|
||||
#define kPowerNVRAMiBootEnterDFUOff (0x00)
|
||||
|
||||
#define kPowerNVRAMPropertyCount (12)
|
||||
|
||||
struct power_charge_limits
|
||||
{
|
||||
uint16_t upperVoltageLimit; /* mV */
|
||||
int16_t lowerTempLimit; /* cC */
|
||||
int16_t upperTempLimit; /* cC */
|
||||
uint16_t currentSetting; /* charger-dependent */
|
||||
};
|
||||
|
||||
bool power_load_memory_calibration(void *settings, uint32_t settingsSize);
|
||||
bool power_store_memory_calibration(void *settings, uint32_t settingsSize);
|
||||
|
||||
void pmu_early_init(void);
|
||||
void pmu_setup(void);
|
||||
void pmu_late_init(void);
|
||||
void pmu_will_resume(void);
|
||||
void pmu_shutdown(void);
|
||||
void pmu_suspend(void);
|
||||
void pmu_set_backlight_enable(uint32_t backlight_level);
|
||||
u_int32_t pmu_read_brick_id_level(void);
|
||||
int pmu_read_system_temperature(int idx, int *centiCelsiusTemperature);
|
||||
void pmu_check_events(bool *powersupply_change_event,
|
||||
bool *button_event,
|
||||
bool *other_wake_event);
|
||||
int pmu_uvwarn_config(int dev, uint32_t thresholdMV);
|
||||
|
||||
bool power_load_voltage_knobs(void *settings, uint32_t settingsSize);
|
||||
bool power_store_voltage_knobs(void *settings, uint32_t settingsSize);
|
||||
|
||||
utime_t power_get_calendar_time(void);
|
||||
|
||||
|
||||
// Dark boot API's
|
||||
|
||||
void power_clear_dark_boot_flag (void); // Clears the dark boot flag from NVRAM. Call on every startup AFTER nvram is writable
|
||||
void power_disable_dark_boot (void); // Disables dark boot by lighting up display to previous backlight command
|
||||
void power_dark_boot_checkpoint (void); // Checks for button presses and disables dark boot if needed.
|
||||
bool power_is_dark_boot (void); // Returns true if we are doing a dark boot.
|
||||
|
||||
// smartport API
|
||||
//
|
||||
|
||||
#define SMARTPORT_EXT_PWR_IN_SEL 1
|
||||
#define SMARTPORT_ACC_PWR_IN_SEL 0
|
||||
|
||||
int smartport_get_data(int dev, uint16_t reg, uint8_t *byte); // low level, you don't need this
|
||||
int smartport_get_pwr_in_sel(int dev, uint8_t *sel); // power switch state
|
||||
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_POWER_H */
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 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 __DRIVERS_PRC_H
|
||||
#define __DRIVERS_PRC_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void prc_init(uint32_t display_width, uint32_t display_height);
|
||||
void prc_install_gamma_table(u_int32_t *red_lut, u_int32_t *green_lut, u_int32_t *blue_lut, struct syscfg_wpcl *wpcl);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_PRC_H */
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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.
|
||||
*/
|
||||
|
||||
#if WITH_HW_MCU
|
||||
|
||||
#ifndef PROCESS_EDID_H
|
||||
#define PROCESS_EDID_H 1
|
||||
|
||||
#if WITH_HW_DISPLAY_DISPLAYPORT
|
||||
#include <drivers/displayport.h>
|
||||
#endif
|
||||
|
||||
#if WITH_HW_DISPLAY_HDMI
|
||||
#include <drivers/hdmi.h>
|
||||
#endif
|
||||
|
||||
// Collect EDID data and decide on the best scoring display mode.
|
||||
int obtain_edid(void);
|
||||
|
||||
// Break out of the EDID polling loop.
|
||||
void abort_edid(void);
|
||||
|
||||
// Reject timings not matching these dimensions.
|
||||
void restrict_edid(uint32_t h_active, uint32_t v_active);
|
||||
|
||||
// Get previously collected best display mode.
|
||||
int get_edid_timings(struct video_timing_data *data);
|
||||
|
||||
// Get the detected downstream port type, e.g kDPDownstreamTypeHDMI
|
||||
int get_edid_downstream_type(void);
|
||||
|
||||
#endif // PROCESS_EDID_H
|
||||
|
||||
#endif // WITH_HW_MCU
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2009 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 __DRIVERS_RADIO_H
|
||||
#define __DRIVERS_RADIO_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if WITH_DEVICETREE
|
||||
#include <lib/devicetree.h>
|
||||
#endif
|
||||
|
||||
#include <target.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
bool radio_get_property(enum target_property prop, void *data, int maxdata, int *retlen);
|
||||
void radio_init(void);
|
||||
void radio_early_init(void);
|
||||
void radio_late_init(void);
|
||||
void radio_quiesce(void);
|
||||
void radio_power_off(void);
|
||||
|
||||
void radio_init_pins( void );
|
||||
|
||||
void radio_pmu_power_on(void);
|
||||
void radio_pmu_power_off(void);
|
||||
|
||||
bool radio_board_present(void);
|
||||
|
||||
#if WITH_DEVICETREE
|
||||
int radio_update_device_tree(DTNode *radio_node);
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* ! __DRIVERS_RADIO_H */
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2013-2014 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 __RECONFIG_H
|
||||
#define __RECONFIG_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/boot.h>
|
||||
|
||||
typedef enum {
|
||||
AWAKE_AOP_DDR_PRE = 0,
|
||||
AWAKE_AOP_DDR_POST,
|
||||
AOP_DDR_S2R_AOP_PRE,
|
||||
AOP_DDR_S2R_AOP_POST,
|
||||
S2R_AOP_AOP_DDR_PRE,
|
||||
S2R_AOP_AOP_DDR_POST,
|
||||
AOP_DDR_AWAKE_PRE,
|
||||
AOP_DDR_AWAKE_POST,
|
||||
MAX_STAGE
|
||||
} reconfig_stage_t;
|
||||
|
||||
enum {
|
||||
END_COMMAND = 0x0,
|
||||
WRITE_COMMAND = 0x1,
|
||||
READ_COMMAND = 0x2,
|
||||
DELAY_COMMAND = 0x4,
|
||||
NOP_COMMAND = 0x4,
|
||||
};
|
||||
|
||||
typedef struct write_command_t {
|
||||
uint32_t in_progress;
|
||||
uint64_t address;
|
||||
uint32_t is_reg64;
|
||||
uint32_t offsets[4];
|
||||
uint32_t value_count;
|
||||
uint64_t values[16];
|
||||
|
||||
} write_command_t;
|
||||
|
||||
typedef enum {
|
||||
REGION_ONLY,
|
||||
COMMAND_ONLY,
|
||||
REGION_AND_COMMAND,
|
||||
} reconfig_dump_t;
|
||||
|
||||
void reconfig_init(enum boot_target target);
|
||||
|
||||
void reconfig_command_write(reconfig_stage_t stage, uint64_t addr, uint64_t value, uint32_t is_reg64);
|
||||
|
||||
void reconfig_command_read(reconfig_stage_t stage, uint64_t addr, uint64_t value, uint64_t mask, uint32_t retry_cnt, uint32_t is_reg64);
|
||||
|
||||
void reconfig_command_delay(reconfig_stage_t stage, uint32_t delay);
|
||||
|
||||
void reconfig_command_nop(reconfig_stage_t stage);
|
||||
|
||||
void reconfig_command_raw(reconfig_stage_t stage, const uint32_t *cmd, uint32_t cmdItems);
|
||||
|
||||
void reconfig_commit(reconfig_stage_t stage);
|
||||
|
||||
void reconfig_lock(enum boot_target target);
|
||||
|
||||
void dump_reconfig(reconfig_dump_t option);
|
||||
|
||||
static void validate_stage(reconfig_stage_t stage);
|
||||
static void commit_write_command(reconfig_stage_t stage, write_command_t *wc);
|
||||
static void bounds_check_stage(reconfig_stage_t stage);
|
||||
static void reconfig_write_pending(reconfig_stage_t stage);
|
||||
|
||||
// For 64 bit registers the data/mask etc.. need to be aligned to 64 bits
|
||||
// count * 4 is the register offset from the 64 bit aligned base. So the following should
|
||||
// tell if we are aligned or not
|
||||
#define ALIGNED_64(count) ((count) % 2 == 0)
|
||||
#define ALIGNMENT_MARKER 0xDEADBEEF
|
||||
#define SEQUENCE_END 0xDEADDEAD
|
||||
|
||||
#endif /* __RECONFIG_H */
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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 __DRIVERS_RSECC_H
|
||||
#define __DRIVERS_RSECC_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
enum rsecc_mode {
|
||||
ECC_4BIT = 0,
|
||||
ECC_6BIT,
|
||||
ECC_8BIT,
|
||||
};
|
||||
|
||||
int rsecc_encode(enum rsecc_mode mode, int sector_count, const void *datapointer, void *eccbuf);
|
||||
int rsecc_decode(enum rsecc_mode mode, int sector_count, void *datapointer, const void *eccbuf);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_RSECC_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2014 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 __DRIVERS_SHA1_H
|
||||
#define __DRIVERS_SHA1_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/hash.h>
|
||||
|
||||
#if WITH_CORECRYPTO
|
||||
#include <corecrypto/ccsha1.h>
|
||||
#else
|
||||
#define CCSHA1_OUTPUT_SIZE (20) // bytes
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void sha1_calculate(const void *buffer, size_t length, void *result);
|
||||
#if WITH_CORECRYPTO
|
||||
const struct ccdigest_info *sha1_get_ccsha1_ccdigest_info();
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_SHA1_H */
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2011 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 __DRIVERS_SHMCON_H
|
||||
#define __DRIVERS_SHMCON_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* High-level shared memory console interface.
|
||||
* Port argument exists for compatibility with UART functions
|
||||
*/
|
||||
int shmcon_init(void);
|
||||
|
||||
int shmcon_getc(int port, bool wait);
|
||||
int shmcon_putc(int port, char c);
|
||||
int shmcon_puts(int port, const char *s);
|
||||
|
||||
int shmcon_set_child(uint64_t phys_address, uint32_t num);
|
||||
|
||||
#endif /* __DRIVERS_SHMCON_H */
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2007 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 __DRIVERS_SPI_H
|
||||
#define __DRIVERS_SPI_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void spi_setup(int port, int baud, int width, bool master, int clkpol, int clkpha);
|
||||
int spi_write_etc(int port, const void *buf, size_t len, bool wait, bool with_rx);
|
||||
int spi_read_etc(int port, void *buf, size_t len, bool wait, bool with_tx);
|
||||
void spi_select(int port, bool select_state);
|
||||
|
||||
void spi_init(void);
|
||||
|
||||
u_int32_t spi_gpio_read(int port);
|
||||
void spi_gpio_write(int port, u_int32_t val);
|
||||
void spi_gpio_configure(int port, u_int32_t config);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_SPI_H */
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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 __DRIVERS_SW_H2FMI_H
|
||||
#define __DRIVERS_SW_H2FMI_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <lib/blockdev.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int sw_h2fmi_init(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_SW_H2FMI_H */
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2009 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 __DRIVERS_THERMAL_H
|
||||
#define __DRIVERS_THERMAL_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Thermal management.
|
||||
*
|
||||
* Thermal status is reported via the following nodes in the MIB:
|
||||
*
|
||||
* Thermal.Temperature unit current temperature in degrees Celsius.
|
||||
* Thermal.Fanspeed current fan speed
|
||||
*/
|
||||
|
||||
/*
|
||||
* thermal_init
|
||||
*
|
||||
* Initialise the thermal management system.
|
||||
*
|
||||
* If the default target is passed as 0, it is assumed the system already
|
||||
* knows the default.
|
||||
*/
|
||||
int thermal_init(u_int32_t default_target);
|
||||
|
||||
/*
|
||||
* thermal_set_target_temperature
|
||||
*
|
||||
* Set the target temperature to be maintained by the thermal system in degrees Celsius.
|
||||
*/
|
||||
int thermal_set_target_temperature(u_int32_t temperature);
|
||||
|
||||
/*
|
||||
* thermal_soft_regulation_fail
|
||||
*
|
||||
* Called when the system is no longer able to provide services that may be required
|
||||
* to perform soft thermal regulation, e.g. during a panic. This allows a soft
|
||||
* regulation algorithm to e.g. set the cooling system to maximum, as long as care is
|
||||
* taken.
|
||||
*/
|
||||
void thermal_soft_regulation_fail(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_THERMAL_H */
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2013 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 THUNDERBOLT_NHI_H
|
||||
#define THUNDERBOLT_NHI_H
|
||||
|
||||
#include <drivers/pci.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define NHI_STATUS_OK (0)
|
||||
#define NHI_STATUS_UNKNOWN_ERROR (-1)
|
||||
#define NHI_STATUS_CRC_ERROR (-2)
|
||||
#define NHI_STATUS_INVALID_DESCRIPTOR (-3)
|
||||
#define NHI_STATUS_TIMEOUT (-4)
|
||||
|
||||
typedef struct nhi_sgl {
|
||||
void *buffer;
|
||||
uint32_t bytes;
|
||||
struct nhi_sgl *next;
|
||||
} nhi_sgl_t;
|
||||
|
||||
typedef struct nhi nhi_t;
|
||||
|
||||
nhi_t *nhi_init(pci_device_t bridge, uint32_t dart_id);
|
||||
void nhi_quiesce_and_free(nhi_t *nhi);
|
||||
void nhi_init_tx_ring(nhi_t *nhi, uint32_t ring_idx, uint32_t num_buffers, uint32_t buffer_size);
|
||||
void nhi_init_rx_ring(nhi_t *nhi, uint32_t ring_idx, uint32_t num_buffers, uint32_t buffer_size);
|
||||
void nhi_disable_tx_ring(nhi_t *nhi, uint32_t ring_idx);
|
||||
void nhi_disable_rx_ring(nhi_t *nhi, uint32_t ring_idx);
|
||||
int32_t nhi_send_sgl(nhi_t *nhi, uint32_t ring_idx, const nhi_sgl_t *sgl, uint8_t sof_pdf, uint8_t eof_pdf);
|
||||
int32_t nhi_send_buffer(nhi_t *nhi, uint32_t ring_idx, void *buffer, uint32_t bytes, uint8_t sof_pdf, uint8_t eof_pdf);
|
||||
bool nhi_rx_buffer_available(nhi_t *nhi, uint32_t ring_idx);
|
||||
int32_t nhi_rx_buffer(nhi_t *nhi, uint32_t ring_idx, void *buffer, uint32_t bytes, uint8_t *sof_pdf, uint8_t *eof_pdf);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2013 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 THUNDERBOOT_H
|
||||
#define THUNDERBOOT_H
|
||||
|
||||
#include <drivers/pci.h>
|
||||
|
||||
typedef struct thunderboot thunderboot_t;
|
||||
|
||||
thunderboot_t * thunderboot_init(pci_device_t bridge, uint32_t dart_id);
|
||||
void thunderboot_quiesce_and_free(thunderboot_t *tb);
|
||||
|
||||
int thunderboot_get_dfu_image(void *load_address, int load_length);
|
||||
|
||||
void thunderboot_putchar(int c);
|
||||
|
||||
int thunderboot_serial_send_cmd_string(u_int8_t *buffer, u_int32_t len);
|
||||
void thunderboot_transfer_prepare(void *load_address, uint32_t length);
|
||||
int thunderboot_transfer_wait(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2011 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 __DRIVERS_TRISTAR_H
|
||||
#define __DRIVERS_TRISTAR_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
bool tristar_set_usb_brick_detect(int select);
|
||||
bool tristar_read_id(uint8_t digital_id[6]);
|
||||
bool tristar_enable_acc_pwr(bool enabled);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_CHARGER_H */
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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 __DRIVERS_UART_H
|
||||
#define __DRIVERS_UART_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* High-level UART interface.
|
||||
*/
|
||||
int uart_init(void);
|
||||
|
||||
int uart_getc(int port, bool wait);
|
||||
int uart_puts(int port, const char *s);
|
||||
int uart_putc(int port, char c);
|
||||
|
||||
int uart_send_break(int port, bool enable);
|
||||
|
||||
/*
|
||||
* Low-level UART primitives required by the drivers/uart module.
|
||||
*/
|
||||
enum uart_parity {
|
||||
PARITY_NONE,
|
||||
PARITY_ODD,
|
||||
PARITY_EVEN
|
||||
};
|
||||
int uart_hw_init(u_int32_t port, u_int32_t baudrate);
|
||||
int uart_hw_getc(u_int32_t port);
|
||||
int uart_hw_putc(u_int32_t port, char c);
|
||||
|
||||
/* optional, backdoor for tweaking UART config */
|
||||
int uart_hw_init_extended(u_int32_t port, u_int32_t baudrate, u_int32_t databits,
|
||||
enum uart_parity parity, u_int32_t stopbits);
|
||||
/* set interrupt mode on/off, explicit buffer size */
|
||||
int uart_hw_set_rx_buf(u_int32_t port, bool interrupt, size_t buffer_len);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_UART_H */
|
||||
@@ -0,0 +1,95 @@
|
||||
#ifndef _SYNOPSYS_OTG_PUBLIC_H_
|
||||
#define _SYNOPSYS_OTG_PUBLIC_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <drivers/usb/usb_chap9.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
//===================================================================================
|
||||
// Enums, structs and Typedefs
|
||||
//===================================================================================
|
||||
enum
|
||||
{
|
||||
USB_IO_ERROR = -1,
|
||||
USB_IO_SUCCESS = 0,
|
||||
USB_IO_ABORTED
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CABLE_CONNECTED = 0,
|
||||
CABLE_DISCONNECTED,
|
||||
USB_RESET,
|
||||
USB_ENUM_DONE
|
||||
};
|
||||
|
||||
enum {
|
||||
CONNECTION_SPEED_FULL = 0,
|
||||
CONNECTION_SPEED_HIGH
|
||||
};
|
||||
|
||||
struct usb_device_io_request
|
||||
{
|
||||
u_int32_t endpoint;
|
||||
volatile u_int8_t *io_buffer;
|
||||
int status;
|
||||
int io_length;
|
||||
int return_count;
|
||||
void (*callback) (struct usb_device_io_request *io_request);
|
||||
struct usb_device_io_request *next;
|
||||
};
|
||||
|
||||
struct usb_endpoint_instance
|
||||
{
|
||||
int endpoint_address;
|
||||
int max_packet_size;
|
||||
int attributes;
|
||||
int bInterval;
|
||||
|
||||
int transfer_size;
|
||||
int packet_count;
|
||||
|
||||
struct usb_endpoint_instance *next_ep;
|
||||
|
||||
struct usb_device_io_request *io_head;
|
||||
struct usb_device_io_request *io_tail;
|
||||
|
||||
int tx_fifo_number;
|
||||
};
|
||||
|
||||
struct usb_controller_ops
|
||||
{
|
||||
void (*start) (void);
|
||||
void (*stop) (void);
|
||||
void (*set_address) (int new_address);
|
||||
void (*stall_endpoint) (u_int32_t endpoint, bool stall);
|
||||
void (*reset_endpoint_data_toggle) (u_int32_t endpoint);
|
||||
bool (*is_endpoint_stalled) (u_int32_t endpoint);
|
||||
void (*do_endpoint_io) (struct usb_device_io_request *req);
|
||||
void (*activate_endpoint) (u_int32_t endpoint, int type, int max_packet_size, int interval);
|
||||
void (*deactivate_endpoint) (u_int32_t endpoint);
|
||||
void (*abort_endpoint) (u_int32_t endpoint);
|
||||
void (*do_test_mode)(int test_selector);
|
||||
int (*get_connection_speed) (void);
|
||||
};
|
||||
|
||||
struct usb_interface_instance
|
||||
{
|
||||
int (*interface_request_handler) (struct usb_device_request *request, u_int8_t ** out_data);
|
||||
void (*non_setup_data_phase_finished_callback) (int data_rcvd);
|
||||
void (*activate_interface) (void);
|
||||
void (*bus_reset_handler) (void);
|
||||
int (*get_interface_handler) (void);
|
||||
int (*set_interface_handler) (int alt_setting);
|
||||
};
|
||||
|
||||
//===================================================================================
|
||||
// Global APIs
|
||||
//===================================================================================
|
||||
|
||||
void usb_init (void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* 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 _USB_CHAP9_H_
|
||||
#define _USB_CHAP9_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
//====================================================================
|
||||
// USB Descriptor Types
|
||||
//====================================================================
|
||||
#define USB_DT_DEVICE 1
|
||||
#define USB_DT_CONFIGURATION 2
|
||||
#define USB_DT_STRING 3
|
||||
#define USB_DT_INTERFACE 4
|
||||
#define USB_DT_ENDPOINT 5
|
||||
#define USB_DT_DEVICE_QUALIFIER 6
|
||||
#define USB_DT_OTHER_SPEED_CONFIGURATION 7
|
||||
|
||||
//====================================================================
|
||||
// USB Endpoints Types
|
||||
//====================================================================
|
||||
#define USB_ENDPOINT_CONTROL 0x00
|
||||
#define USB_ENDPOINT_ISOCHRONOUS 0x01
|
||||
#define USB_ENDPOINT_BULK 0x02
|
||||
#define USB_ENDPOINT_INTERRUPT 0x03
|
||||
|
||||
//====================================================================
|
||||
// USB Standard Request Types
|
||||
//====================================================================
|
||||
#define USB_REQ_GET_STATUS 0x00
|
||||
#define USB_REQ_CLEAR_FEATURE 0x01
|
||||
#define USB_REQ_SET_FEATURE 0x03
|
||||
#define USB_REQ_SET_ADDRESS 0x05
|
||||
#define USB_REQ_GET_DESCRIPTOR 0x06
|
||||
#define USB_REQ_SET_DESCRIPTOR 0x07
|
||||
#define USB_REQ_GET_CONFIGURATION 0x08
|
||||
#define USB_REQ_SET_CONFIGURATION 0x09
|
||||
#define USB_REQ_GET_INTERFACE 0x0A
|
||||
#define USB_REQ_SET_INTERFACE 0x0B
|
||||
|
||||
//====================================================================
|
||||
// USB Feature Types
|
||||
//====================================================================
|
||||
#define USB_FEATURE_ENDPOINT_HALT 0x00
|
||||
#define USB_FEATURE_REMOTE_WAKEUP 0x01
|
||||
#define USB_FEATURE_TEST_MODE 0x02
|
||||
|
||||
//====================================================================
|
||||
// USB Device Request Types
|
||||
//====================================================================
|
||||
#define USB_REQ_TYPE_STANDARD 0x00
|
||||
#define USB_REQ_TYPE_CLASS 0x20
|
||||
#define USB_REQ_TYPE_VENDOR 0x40
|
||||
|
||||
//====================================================================
|
||||
// USB Class Codes
|
||||
//====================================================================
|
||||
#define USB_CLASS_INTERFACE_SPECIFIC 0
|
||||
#define USB_CLASS_VENDOR_SPECIFIC 0xff
|
||||
|
||||
//====================================================================
|
||||
// USB Chap9 specific consts
|
||||
//====================================================================
|
||||
#define USB_DT_DEVICE_SIZE 18
|
||||
#define USB_DT_CONFIGURATION_SIZE 9
|
||||
#define USB_DT_INTERFACE_SIZE 9
|
||||
#define USB_DT_ENDPOINT_SIZE 7
|
||||
#define USB_DT_DEVICE_QUALIFIER_SIZE 10
|
||||
#define USB_DT_STRING_SIZE 6
|
||||
|
||||
#define USB_DIR_OUT 0
|
||||
#define USB_DIR_IN 0x80
|
||||
|
||||
#define USB_ENDPOINT_MASK 0x03
|
||||
#define USB_ENDPOINT_NUMBER_MASK 0x0f
|
||||
#define USB_ENDPOINT_DIR_MASK 0x80
|
||||
|
||||
#define USB_BCD_VERSION 0x0200
|
||||
|
||||
#define USB_REQ_DIRECTION_MASK 0x80
|
||||
#define USB_REQ_TYPE_MASK 0x60
|
||||
#define USB_REQ_RECIPIENT_MASK 0x1f
|
||||
|
||||
#define USB_REQ_DEVICE2HOST 0x80
|
||||
#define USB_REQ_HOST2DEVICE 0x00
|
||||
|
||||
#define USB_REQ_RECIPIENT_DEVICE 0x00
|
||||
#define USB_REQ_RECIPIENT_INTERFACE 0x01
|
||||
#define USB_REQ_RECIPIENT_ENDPOINT 0x02
|
||||
#define USB_REQ_RECIPIENT_OTHER 0x03
|
||||
|
||||
#define SETUP_PACKET_LEN 0x8
|
||||
|
||||
#define EP0_IN 0x80
|
||||
#define EP0_OUT 0x0
|
||||
//====================================================================
|
||||
// Enums, structs and typedefs
|
||||
//====================================================================
|
||||
struct usb_device_request
|
||||
{
|
||||
u_int8_t bmRequestType;
|
||||
u_int8_t bRequest;
|
||||
u_int16_t wValue;
|
||||
u_int16_t wIndex;
|
||||
u_int16_t wLength;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct usb_device_descriptor
|
||||
{
|
||||
u_int8_t bLength;
|
||||
u_int8_t bDescriptorType;
|
||||
u_int16_t bcdUSB;
|
||||
u_int8_t bDeviceClass;
|
||||
u_int8_t bDeviceSubClass;
|
||||
u_int8_t bDeviceProtocol;
|
||||
u_int8_t bMaxPacketSize0;
|
||||
u_int16_t idVendor;
|
||||
u_int16_t idProduct;
|
||||
u_int16_t bcdDevice;
|
||||
u_int8_t iManufacturer;
|
||||
u_int8_t iProduct;
|
||||
u_int8_t iSerialNumber;
|
||||
u_int8_t bNumConfigurations;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct usb_configuration_descriptor
|
||||
{
|
||||
u_int8_t bLength;
|
||||
u_int8_t bDescriptorType;
|
||||
u_int16_t wTotalLength;
|
||||
u_int8_t bNumInterfaces;
|
||||
u_int8_t bConfigurationValue;
|
||||
u_int8_t iConfiguration;
|
||||
u_int8_t bmAttributes;
|
||||
u_int8_t bMaxPower;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct usb_interface_descriptor
|
||||
{
|
||||
u_int8_t bLength;
|
||||
u_int8_t bDescriptorType;
|
||||
u_int8_t bInterfaceNumber;
|
||||
u_int8_t bAlternateSetting;
|
||||
u_int8_t bNumEndpoints;
|
||||
u_int8_t bInterfaceClass;
|
||||
u_int8_t bInterfaceSubClass;
|
||||
u_int8_t bInterfaceProtocol;
|
||||
u_int8_t iInterface;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct usb_endpoint_descriptor
|
||||
{
|
||||
u_int8_t bLength;
|
||||
u_int8_t bDescriptorType;
|
||||
u_int8_t bEndpointAddress;
|
||||
u_int8_t bmAttributes;
|
||||
u_int16_t wMaxPacketSize;
|
||||
u_int8_t bInterval;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct usb_string_descriptor
|
||||
{
|
||||
u_int8_t bLength;
|
||||
u_int8_t bDescriptorType;
|
||||
u_int8_t wData[2];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct usb_device_qualifier_descriptor
|
||||
{
|
||||
u_int8_t bLength;
|
||||
u_int8_t bDescriptorType;
|
||||
u_int16_t bcdUSB;
|
||||
u_int8_t bDeviceClass;
|
||||
u_int8_t bDeviceSubClass;
|
||||
u_int8_t bDeviceProtocol;
|
||||
u_int8_t bMaxPacketSize0;
|
||||
u_int8_t bNumConfigurations;
|
||||
u_int8_t bReserved;
|
||||
} __attribute__((packed));
|
||||
|
||||
enum
|
||||
{
|
||||
DEVICE_ST_UNKNOWN = -1,
|
||||
DEVICE_ST_INIT = 0,
|
||||
DEVICE_ST_ATTACHED,
|
||||
DEVICE_ST_POWERED,
|
||||
DEVICE_ST_DEFAULT,
|
||||
DEVICE_ST_ADDRESSED,
|
||||
DEVICE_ST_CONFIGURED,
|
||||
DEVICE_ST_SUSPENDED
|
||||
};
|
||||
|
||||
//====================================================================
|
||||
// USB driver specific consts
|
||||
//====================================================================
|
||||
#define EP0_MAX_PACKET_SIZE 0x40
|
||||
#define HS_BULK_EP_MAX_PACKET_SIZE 0x200
|
||||
#define HS_INT_EP_MAX_PACKET_SIZE 0x40
|
||||
#define FS_EP_MAX_PACKET_SIZE 0x40
|
||||
|
||||
#endif // _USB_CHAP9_H_
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 Apple 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 _USB_CONTROLLER_H_
|
||||
#define _USB_CONTROLLER_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <drivers/usb/usb_core.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define MAX_SUPPORTED_USB_CONTROLLER (2)
|
||||
|
||||
typedef enum {
|
||||
USB_CONTROLLER_synopsys_otg,
|
||||
USB_CONTROLLER_dbgfifo,
|
||||
} USB_CONTROLLER_T;
|
||||
|
||||
struct usb_controller_functions {
|
||||
int (*init)(void);
|
||||
void (*free_func)(void);
|
||||
int (*start)(void);
|
||||
void (*stop)(void);
|
||||
void (*set_address)(uint32_t new_address);
|
||||
int (*get_connection_speed)(void);
|
||||
void (*activate_endpoint)(uint32_t endpoint, int type, int max_packet_size, int interval);
|
||||
void (*do_endpoint_io)(struct usb_device_io_request *req);
|
||||
void (*stall_endpoint)(uint32_t endpoint, bool stall);
|
||||
void (*reset_endpoint_data_toggle)(uint32_t endpoint);
|
||||
bool (*is_endpoint_stalled)(uint32_t endpoint);
|
||||
void (*do_test_mode)(uint32_t selector);
|
||||
void (*abort_endpoint)(uint32_t endpoint);
|
||||
void (*deactivate_endpoint)(uint32_t endpoint);
|
||||
};
|
||||
|
||||
int usb_controller_register(const struct usb_controller_functions *controller_functions);
|
||||
int usb_controller_init(void);
|
||||
void usb_controller_free(void);
|
||||
int usb_controller_start(void);
|
||||
void usb_controller_stop(void);
|
||||
void usb_controller_set_address(u_int32_t new_address);
|
||||
int usb_controller_get_connection_speed(void);
|
||||
void usb_controller_activate_endpoint(u_int32_t endpoint, int type, int max_packet_size, int interval);
|
||||
void usb_controller_do_endpoint_io(struct usb_device_io_request *req);
|
||||
void usb_controller_stall_endpoint(u_int32_t endpoint, bool stall);
|
||||
void usb_controller_reset_endpoint_data_toggle(u_int32_t endpoint);
|
||||
bool usb_controller_is_endpoint_stalled(u_int32_t endpoint);
|
||||
void usb_controller_do_test_mode(u_int32_t selector);
|
||||
void usb_controller_abort_endpoint(u_int32_t endpoint);
|
||||
void usb_controller_deactivate_endpoint(u_int32_t endpoint);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // _USB_CONTROLLER_H_
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2013 Apple 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 _USB_CORE_H_
|
||||
#define _USB_CORE_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <drivers/usb/usb_chap9.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
//===================================================================================
|
||||
// consts and macros
|
||||
//===================================================================================
|
||||
|
||||
#define APPLE_USB_DFU_INTF 0
|
||||
#define APPLE_USB_TRNSFR_INTF APPLE_USB_DFU_INTF
|
||||
#define APPLE_USB_SERIAL_INTF 0x1
|
||||
|
||||
#define APPLE_USB_SERIAL_CONFIG_STRING_IDX 4
|
||||
#define APPLE_USB_SERIAL_INTF_STRING_INDEX 5
|
||||
|
||||
#define APPLE_USB_SERIAL_EP_BULK_IN 0x81
|
||||
#define APPLE_USB_SERIAL_EP_BULK_OUT 0x2
|
||||
#define APPLE_USB_TRNSFR_EP_BULK_OUT 0x4
|
||||
#define APPLE_USB_TRNSFR_EP_BULK_IN 0x85
|
||||
|
||||
#define APPLE_USB_DFU_TOTAL_INTFS 1
|
||||
#define APPLE_USB_DFU_CLASS 0xfe
|
||||
#define APPLE_USB_DFU_SUBCLASS 0x1
|
||||
#define APPLE_USB_DFU_PROTOCOL 0x0
|
||||
|
||||
#define APPLE_USB_SERIAL_TOTAL_EPS 2
|
||||
#define APPLE_USB_SERIAL_TOTAL_INTFS 2
|
||||
#define APPLE_USB_SERIAL_CLASS 0xff
|
||||
#define APPLE_USB_SERIAL_SUBCLASS 0xff
|
||||
#define APPLE_USB_SERIAL_PROTOCOL 0x51
|
||||
|
||||
#if WITH_BULK_UPLOAD
|
||||
#define APPLE_USB_TRNSFR_TOTAL_EPS 2
|
||||
#else
|
||||
#define APPLE_USB_TRNSFR_TOTAL_EPS 1
|
||||
#endif
|
||||
|
||||
#define APPLE_USB_TRNSFR_TOTAL_INTFS 1
|
||||
#define APPLE_USB_DFU_TRNSFR_CLASS 0xfe
|
||||
#define APPLE_USB_DFU_TRNSFR_SUBCLASS 0x1
|
||||
#define APPLE_USB_DFU_TRNSFR_PROTOCOL 0x2
|
||||
#define APPLE_USB_TRNSFR_CLASS APPLE_USB_DFU_TRNSFR_CLASS
|
||||
#define APPLE_USB_TRNSFR_SUBCLASS APPLE_USB_DFU_TRNSFR_SUBCLASS
|
||||
#define APPLE_USB_TRNSFR_PROTOCOL APPLE_USB_DFU_TRNSFR_PROTOCOL
|
||||
|
||||
//===================================================================================
|
||||
// Enums, structs and Typedefs
|
||||
//===================================================================================
|
||||
|
||||
enum
|
||||
{
|
||||
USB_IO_ERROR = -1,
|
||||
USB_IO_SUCCESS = 0,
|
||||
USB_IO_ABORTED
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CABLE_CONNECTED = 0,
|
||||
CABLE_DISCONNECTED,
|
||||
USB_RESET,
|
||||
USB_ENUM_DONE
|
||||
};
|
||||
|
||||
enum {
|
||||
CONNECTION_SPEED_FULL = 0,
|
||||
CONNECTION_SPEED_HIGH
|
||||
};
|
||||
|
||||
#if WITH_RECOVERY_MODE
|
||||
enum {
|
||||
PR_RESET_REQUEST = 0, // put device into reset state before starting restore with bulk blaster protocol
|
||||
PR_VENDOR_REQUEST = 0,
|
||||
PR_VENDOR_BLIND_REQUEST // return success on usb before executing the command, primarily for fsboot or reboot
|
||||
};
|
||||
#endif
|
||||
|
||||
struct usb_device_io_request
|
||||
{
|
||||
u_int32_t endpoint;
|
||||
volatile u_int8_t *io_buffer;
|
||||
int status;
|
||||
u_int32_t io_length;
|
||||
u_int32_t return_count;
|
||||
void (*callback) (struct usb_device_io_request *io_request);
|
||||
struct usb_device_io_request *next;
|
||||
};
|
||||
|
||||
struct usb_interface_instance
|
||||
{
|
||||
int total_interfaces;
|
||||
struct usb_interface_descriptor *interface_descs;
|
||||
int total_other_descs;
|
||||
void *other_descs;
|
||||
int total_endpoints;
|
||||
struct usb_endpoint_descriptor *endpoint_descs;
|
||||
int total_string_descs;
|
||||
char **string_descs;
|
||||
|
||||
int (*handle_request) (struct usb_device_request *request, u_int8_t ** out_data);
|
||||
void (*non_setup_data_phase_finished_callback) (u_int32_t data_rcvd);
|
||||
void (*activate_interface) (void);
|
||||
void (*deactivate_interface) (void);
|
||||
void (*activate_endpoints) (void);
|
||||
void (*deactivate_endpoints) (void);
|
||||
void (*handle_bus_reset) (void);
|
||||
int (*handle_get_interface) (void);
|
||||
int (*handle_set_interface) (int alt_setting);
|
||||
int (*handle_vendor_request) (struct usb_device_request *request);
|
||||
};
|
||||
|
||||
//===================================================================================
|
||||
// Global APIs
|
||||
//===================================================================================
|
||||
|
||||
int usb_core_init (const char *config_desc_string);
|
||||
void usb_core_free (void);
|
||||
int usb_core_start();
|
||||
void usb_core_stop();
|
||||
void usb_core_handle_usb_control_receive (u_int8_t *ep0_rx_buffer, bool is_setup, int receive_length, bool *data_phase);
|
||||
void usb_core_register_interface (struct usb_interface_instance *if_ops);
|
||||
void usb_core_event_handler (int event);
|
||||
void usb_core_do_transfer (int endpoint, u_int8_t *buffer, int length, void (*callback)(struct usb_device_io_request *));
|
||||
void usb_core_send_zlp (void);
|
||||
void usb_core_complete_endpoint_io (struct usb_device_io_request *req);
|
||||
void usb_core_activate_endpoint (u_int32_t endpoint, int type, int max_packet_size, int interval);
|
||||
void usb_core_deactivate_endpoint (u_int32_t endpoint);
|
||||
void usb_core_abort_endpoint (int endpoint);
|
||||
bool usb_core_get_connection_speed (void);
|
||||
bool usb_core_get_cable_state (void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.
|
||||
*/
|
||||
|
||||
int usb_send_data_to_file(const char *filename, size_t amount, uintptr_t address, int printCompletionStatus);
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2013 Apple 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 _USB_PUBLIC_H_
|
||||
#define _USB_PUBLIC_H_
|
||||
|
||||
#include <drivers/usb/usb_controller.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
enum {
|
||||
USB_TRANSFER_TYPE_DFU_GET,
|
||||
USB_TRANSFER_TYPE_DFU_PUT,
|
||||
USB_TRANSFER_TYPE_BULK_GET,
|
||||
USB_TRANSFER_TYPE_BULK_PUT
|
||||
};
|
||||
|
||||
//===================================================================================
|
||||
// Global APIs
|
||||
//===================================================================================
|
||||
|
||||
int usb_early_init();
|
||||
int usb_init_with_controller(struct usb_controller_functions *controller_funcs);
|
||||
int usb_init();
|
||||
void usb_quiesce(void);
|
||||
|
||||
int getDFUImage(void* buffer, int len);
|
||||
int usb_dfu_init(void);
|
||||
void usb_dfu_exit(void);
|
||||
|
||||
int usb_transfer_init(void);
|
||||
void usb_transfer_exit(void);
|
||||
void usb_transfer_prepare(int type, void *address, u_int32_t maxlen);
|
||||
u_int32_t usb_transfer_start();
|
||||
|
||||
int usb_serial_early_init(void);
|
||||
int usb_serial_init(void);
|
||||
void usb_serial_exit(void);
|
||||
void usb_serial_putchar(int);
|
||||
int usb_serial_send_cmd_string(u_int8_t *buffer, u_int32_t len);
|
||||
bool usb_serial_is_active();
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2007 Apple 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 __DRIVERS_USBPHY_H
|
||||
#define __DRIVERS_USBPHY_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if WITH_DEVICETREE
|
||||
#include <lib/devicetree.h>
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void usbphy_power_up(void);
|
||||
void usbphy_enable_pullup(void);
|
||||
void usbphy_power_down(void);
|
||||
bool usbphy_is_cable_connected(void);
|
||||
bool usbphy_set_dpdm_monitor(int select);
|
||||
#if WITH_CONJOINED_USB_PHYS
|
||||
void usbphy_select_phy(int index);
|
||||
#endif
|
||||
|
||||
#if WITH_DEVICETREE
|
||||
extern void usbphy_update_device_tree(DTNode *pmgr_node);
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 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 __DRIVERS_WPC_H
|
||||
#define __DRIVERS_WPC_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void wpc_init(uint32_t display_width, uint32_t display_height);
|
||||
void wpc_install_gamma_table(u_int32_t *red_lut, u_int32_t *green_lut, u_int32_t *blue_lut, struct syscfg_wpcl *wpcl);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __DRIVERS_WPC_H */
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef ENDIAN_TOOLS_H
|
||||
#define ENDIAN_TOOLS_H 1
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 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.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static inline uint16_t read_le_16(const void *buf, size_t offset)
|
||||
{
|
||||
const uint8_t *p = (const uint8_t *) buf + offset;
|
||||
return
|
||||
(((uint16_t) p[0]) << 0) |
|
||||
(((uint16_t) p[1]) << 8);
|
||||
}
|
||||
|
||||
static inline uint32_t read_le_32(const void *buf, size_t offset)
|
||||
{
|
||||
const uint8_t *p = (const uint8_t *) buf + offset;
|
||||
return
|
||||
(((uint32_t) p[0]) << 0) |
|
||||
(((uint32_t) p[1]) << 8) |
|
||||
(((uint32_t) p[2]) << 16) |
|
||||
(((uint32_t) p[3]) << 24);
|
||||
}
|
||||
|
||||
static inline void write_le_16(void *buf, size_t offset, uint16_t value)
|
||||
{
|
||||
uint8_t *p = (uint8_t *) buf + offset;
|
||||
p[0] = (value >> 0) & 0xff;
|
||||
p[1] = (value >> 8) & 0xff;
|
||||
}
|
||||
|
||||
static inline void write_le_32(void *buf, size_t offset, uint32_t value)
|
||||
{
|
||||
uint8_t *p = (uint8_t *) buf + offset;
|
||||
p[0] = (value >> 0) & 0xff;
|
||||
p[1] = (value >> 8) & 0xff;
|
||||
p[2] = (value >> 16) & 0xff;
|
||||
p[3] = (value >> 24) & 0xff;
|
||||
}
|
||||
|
||||
#endif // defined(ENDIAN_TOOLS_H)
|
||||
@@ -0,0 +1,120 @@
|
||||
/* This administrivia gets added to the beginning of limits.h
|
||||
if the system has its own version of limits.h. */
|
||||
|
||||
/* APPLE LOCAL begin 4401222 */
|
||||
#ifndef _LIBC_LIMITS_H_
|
||||
/* Use "..." so that we find syslimits.h only in this same directory. */
|
||||
#include "syslimits.h"
|
||||
#endif
|
||||
/*
|
||||
#ifdef _GCC_NEXT_LIMITS_H
|
||||
#include_next <limits.h>
|
||||
#undef _GCC_NEXT_LIMITS_H
|
||||
#endif
|
||||
*/
|
||||
/* APPLE LOCAL end 4401222 */
|
||||
#ifndef _LIMITS_H___
|
||||
#define _LIMITS_H___
|
||||
|
||||
/* Number of bits in a `char'. */
|
||||
#undef CHAR_BIT
|
||||
#define CHAR_BIT __CHAR_BIT__
|
||||
|
||||
/* Maximum length of a multibyte character. */
|
||||
#ifndef MB_LEN_MAX
|
||||
#define MB_LEN_MAX 1
|
||||
#endif
|
||||
|
||||
/* Minimum and maximum values a `signed char' can hold. */
|
||||
#undef SCHAR_MIN
|
||||
#define SCHAR_MIN (-SCHAR_MAX - 1)
|
||||
#undef SCHAR_MAX
|
||||
#define SCHAR_MAX __SCHAR_MAX__
|
||||
|
||||
/* Maximum value an `unsigned char' can hold. (Minimum is 0). */
|
||||
#undef UCHAR_MAX
|
||||
#if __SCHAR_MAX__ == __INT_MAX__
|
||||
# define UCHAR_MAX (SCHAR_MAX * 2U + 1U)
|
||||
#else
|
||||
# define UCHAR_MAX (SCHAR_MAX * 2 + 1)
|
||||
#endif
|
||||
|
||||
/* Minimum and maximum values a `char' can hold. */
|
||||
#ifdef __CHAR_UNSIGNED__
|
||||
# undef CHAR_MIN
|
||||
# if __SCHAR_MAX__ == __INT_MAX__
|
||||
# define CHAR_MIN 0U
|
||||
# else
|
||||
# define CHAR_MIN 0
|
||||
# endif
|
||||
# undef CHAR_MAX
|
||||
# define CHAR_MAX UCHAR_MAX
|
||||
#else
|
||||
# undef CHAR_MIN
|
||||
# define CHAR_MIN SCHAR_MIN
|
||||
# undef CHAR_MAX
|
||||
# define CHAR_MAX SCHAR_MAX
|
||||
#endif
|
||||
|
||||
/* Minimum and maximum values a `signed short int' can hold. */
|
||||
#undef SHRT_MIN
|
||||
#define SHRT_MIN (-SHRT_MAX - 1)
|
||||
#undef SHRT_MAX
|
||||
#define SHRT_MAX __SHRT_MAX__
|
||||
|
||||
/* Maximum value an `unsigned short int' can hold. (Minimum is 0). */
|
||||
#undef USHRT_MAX
|
||||
#if __SHRT_MAX__ == __INT_MAX__
|
||||
# define USHRT_MAX (SHRT_MAX * 2U + 1U)
|
||||
#else
|
||||
# define USHRT_MAX (SHRT_MAX * 2 + 1)
|
||||
#endif
|
||||
|
||||
/* Minimum and maximum values a `signed int' can hold. */
|
||||
#undef INT_MIN
|
||||
#define INT_MIN (-INT_MAX - 1)
|
||||
#undef INT_MAX
|
||||
#define INT_MAX __INT_MAX__
|
||||
|
||||
/* Maximum value an `unsigned int' can hold. (Minimum is 0). */
|
||||
#undef UINT_MAX
|
||||
#define UINT_MAX (INT_MAX * 2U + 1U)
|
||||
|
||||
/* Minimum and maximum values a `signed long int' can hold.
|
||||
(Same as `int'). */
|
||||
#undef LONG_MIN
|
||||
#define LONG_MIN (-LONG_MAX - 1L)
|
||||
#undef LONG_MAX
|
||||
#define LONG_MAX __LONG_MAX__
|
||||
|
||||
/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */
|
||||
#undef ULONG_MAX
|
||||
#define ULONG_MAX (LONG_MAX * 2UL + 1UL)
|
||||
|
||||
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
/* Minimum and maximum values a `signed long long int' can hold. */
|
||||
# undef LLONG_MIN
|
||||
# define LLONG_MIN (-LLONG_MAX - 1LL)
|
||||
# undef LLONG_MAX
|
||||
# define LLONG_MAX __LONG_LONG_MAX__
|
||||
|
||||
/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */
|
||||
# undef ULLONG_MAX
|
||||
# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
|
||||
#endif
|
||||
|
||||
#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__)
|
||||
/* Minimum and maximum values a `signed long long int' can hold. */
|
||||
# undef LONG_LONG_MIN
|
||||
# define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL)
|
||||
# undef LONG_LONG_MAX
|
||||
# define LONG_LONG_MAX __LONG_LONG_MAX__
|
||||
|
||||
/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */
|
||||
# undef ULONG_LONG_MAX
|
||||
# define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1ULL)
|
||||
#endif
|
||||
|
||||
#endif /* _LIMITS_H___ */
|
||||
/* APPLE LOCAL begin 4401222 */
|
||||
/* APPLE LOCAL end 4401222 */
|
||||
@@ -0,0 +1,133 @@
|
||||
/* Copyright (C) 1989, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
GCC is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GCC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GCC; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* As a special exception, if you include this header file into source
|
||||
files compiled by GCC, this header file does not by itself cause
|
||||
the resulting executable to be covered by the GNU General Public
|
||||
License. This exception does not however invalidate any other
|
||||
reasons why the executable file might be covered by the GNU General
|
||||
Public License. */
|
||||
|
||||
/*
|
||||
* ISO C Standard: 7.15 Variable arguments <stdarg.h>
|
||||
*/
|
||||
|
||||
#ifndef _STDARG_H
|
||||
#ifndef _ANSI_STDARG_H_
|
||||
#ifndef __need___va_list
|
||||
#define _STDARG_H
|
||||
#define _ANSI_STDARG_H_
|
||||
#endif /* not __need___va_list */
|
||||
#undef __need___va_list
|
||||
|
||||
/* Define __gnuc_va_list. */
|
||||
|
||||
#ifndef __GNUC_VA_LIST
|
||||
#define __GNUC_VA_LIST
|
||||
typedef __builtin_va_list __gnuc_va_list;
|
||||
#endif
|
||||
|
||||
/* Define the standard macros for the user,
|
||||
if this invocation was from the user program. */
|
||||
#ifdef _STDARG_H
|
||||
|
||||
#define va_start(v,l) __builtin_va_start(v,l)
|
||||
#define va_end(v) __builtin_va_end(v)
|
||||
#define va_arg(v,l) __builtin_va_arg(v,l)
|
||||
#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L
|
||||
#define va_copy(d,s) __builtin_va_copy(d,s)
|
||||
#endif
|
||||
#define __va_copy(d,s) __builtin_va_copy(d,s)
|
||||
|
||||
/* Define va_list, if desired, from __gnuc_va_list. */
|
||||
/* We deliberately do not define va_list when called from
|
||||
stdio.h, because ANSI C says that stdio.h is not supposed to define
|
||||
va_list. stdio.h needs to have access to that data type,
|
||||
but must not use that name. It should use the name __gnuc_va_list,
|
||||
which is safe because it is reserved for the implementation. */
|
||||
|
||||
#ifdef _HIDDEN_VA_LIST /* On OSF1, this means varargs.h is "half-loaded". */
|
||||
#undef _VA_LIST
|
||||
#endif
|
||||
|
||||
#ifdef _BSD_VA_LIST
|
||||
#undef _BSD_VA_LIST
|
||||
#endif
|
||||
|
||||
#if defined(__svr4__) || (defined(_SCO_DS) && !defined(__VA_LIST))
|
||||
/* SVR4.2 uses _VA_LIST for an internal alias for va_list,
|
||||
so we must avoid testing it and setting it here.
|
||||
SVR4 uses _VA_LIST as a flag in stdarg.h, but we should
|
||||
have no conflict with that. */
|
||||
#ifndef _VA_LIST_
|
||||
#define _VA_LIST_
|
||||
#ifdef __i860__
|
||||
#ifndef _VA_LIST
|
||||
#define _VA_LIST va_list
|
||||
#endif
|
||||
#endif /* __i860__ */
|
||||
typedef __gnuc_va_list va_list;
|
||||
#ifdef _SCO_DS
|
||||
#define __VA_LIST
|
||||
#endif
|
||||
#endif /* _VA_LIST_ */
|
||||
#else /* not __svr4__ || _SCO_DS */
|
||||
|
||||
/* The macro _VA_LIST_ is the same thing used by this file in Ultrix.
|
||||
But on BSD NET2 we must not test or define or undef it.
|
||||
(Note that the comments in NET 2's ansi.h
|
||||
are incorrect for _VA_LIST_--see stdio.h!) */
|
||||
#if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT)
|
||||
/* The macro _VA_LIST_DEFINED is used in Windows NT 3.5 */
|
||||
#ifndef _VA_LIST_DEFINED
|
||||
/* The macro _VA_LIST is used in SCO Unix 3.2. */
|
||||
#ifndef _VA_LIST
|
||||
/* The macro _VA_LIST_T_H is used in the Bull dpx2 */
|
||||
#ifndef _VA_LIST_T_H
|
||||
/* The macro __va_list__ is used by BeOS. */
|
||||
#ifndef __va_list__
|
||||
typedef __gnuc_va_list va_list;
|
||||
#endif /* not __va_list__ */
|
||||
#endif /* not _VA_LIST_T_H */
|
||||
#endif /* not _VA_LIST */
|
||||
#endif /* not _VA_LIST_DEFINED */
|
||||
#if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__))
|
||||
#define _VA_LIST_
|
||||
#endif
|
||||
#ifndef _VA_LIST
|
||||
#define _VA_LIST
|
||||
#endif
|
||||
#ifndef _VA_LIST_DEFINED
|
||||
#define _VA_LIST_DEFINED
|
||||
#endif
|
||||
#ifndef _VA_LIST_T_H
|
||||
#define _VA_LIST_T_H
|
||||
#endif
|
||||
#ifndef __va_list__
|
||||
#define __va_list__
|
||||
#endif
|
||||
|
||||
#endif /* not _VA_LIST_, except on certain systems */
|
||||
|
||||
#endif /* not __svr4__ */
|
||||
|
||||
#endif /* _STDARG_H */
|
||||
|
||||
#endif /* not _ANSI_STDARG_H_ */
|
||||
#endif /* not _STDARG_H */
|
||||
@@ -0,0 +1,8 @@
|
||||
/* syslimits.h stands for the system's own limits.h file.
|
||||
If we can use it ok unmodified, then we install this text.
|
||||
If fixincludes fixes it, then the fixed version is installed
|
||||
instead of this text. */
|
||||
|
||||
#define _GCC_NEXT_LIMITS_H /* tell gcc's limits.h to recurse */
|
||||
/* APPLE LOCAL begin 4401222 */
|
||||
/* APPLE LOCAL end 4401222 */
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2011 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 DERAPTICKET_H
|
||||
#define DERAPTICKET_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <libDER/libDER.h>
|
||||
|
||||
/* AP Ticket */
|
||||
typedef struct {
|
||||
DERItem signatureAlgorithm; /* AlgorithmId */
|
||||
DERItem body; /* SET OF OCTECT STRING, DER_DEC_SAVE_DER */
|
||||
DERItem signature; /* OCTET STRING */
|
||||
DERItem certificates; /* SEQUENCE of CERTIFICATE */
|
||||
} DERApTicket;
|
||||
|
||||
/* Cert extension */
|
||||
typedef struct {
|
||||
DERItem version; /* current version is 0; omitted until version 1 */
|
||||
DERItem override;
|
||||
DERItem append; /* optional; unsupported in version 0 */
|
||||
DERItem remove; /* optional; unsupported in version 0 */
|
||||
} DERApTicketCertExtension;
|
||||
|
||||
/* DERItemSpecs to decode into a DERApTicket */
|
||||
extern const DERItemSpec DERApTicketItemSpecs[];
|
||||
extern const DERSize DERNumApTicketItemSpecs;
|
||||
|
||||
DERReturn
|
||||
DERApTicketCopyTagData(
|
||||
const DERItem *container,
|
||||
DERTag tag,
|
||||
uint8_t *buffer,
|
||||
DERSize *ioLength );
|
||||
|
||||
DERReturn
|
||||
DERApTicketDecode(
|
||||
const DERItem * contents,
|
||||
DERApTicket * outTicket,
|
||||
DERSize * outNumUsedBytes );
|
||||
|
||||
DERReturn
|
||||
DERApTicketValidate(
|
||||
const DERApTicket *ticket,
|
||||
bool isRestore );
|
||||
|
||||
DERReturn
|
||||
DERApTicketParseLengthFromBuffer(
|
||||
const uint8_t * buffer,
|
||||
size_t length,
|
||||
size_t * outTicketLength );
|
||||
|
||||
#endif /* DERAPTICKET_H */
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Image2 on-media format.
|
||||
*
|
||||
* The I2 layout is described by the I2 superblock, which is located at
|
||||
* kI2SuperblockOffset from the top of the media. The superblock is a write-once
|
||||
* item; it should only be updated when the bootblock code is rewritten, implying
|
||||
* a complete re-initialisation of the media.
|
||||
*
|
||||
* Following the superblock there is a reserved area for boot code, after which
|
||||
* image headers describe individual images.
|
||||
*
|
||||
* 0 --------------------
|
||||
*
|
||||
* kI2SuperblockOffset Image2Superblock
|
||||
*
|
||||
* isImageGranule --------------------
|
||||
* bootcode
|
||||
* + isBootBlockSize --------------------
|
||||
* ...
|
||||
* + isImageOffset Image2Header
|
||||
* ...
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined (__LIB_IMAGE2FORMAT_H)
|
||||
#define __LIB_IMAGE2FORMAT_H 1
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* XXX 7561698 isImageOffset is documented inconsistently
|
||||
* and not used as described above.
|
||||
*/
|
||||
typedef struct {
|
||||
u_int32_t isMagic;
|
||||
#define kImage2SuperMagic 0x494d4732 /* "IMG2" */
|
||||
u_int32_t isImageGranule; /* fundamental block size (bytes) */
|
||||
u_int32_t isImageOffset; /* image header offset within granule (image granules) */
|
||||
u_int32_t isBootBlockSize; /* size of the bootblock (image granules) */
|
||||
u_int32_t isImageAvail; /* total granules available for images. */
|
||||
u_int32_t isNvramGranule; /* size of NVRAM blocks (bytes) */
|
||||
u_int32_t isNvramOffset; /* offset to first NVRAM block (nvram granules) */
|
||||
u_int32_t isFlags; /* flags field reserved for future use */
|
||||
u_int32_t isRsvd1; /* reserved 1 for future use */
|
||||
u_int32_t isRsvd2; /* reserved 2 for future use */
|
||||
u_int32_t isRsvd3; /* reserved 3 for future use */
|
||||
u_int32_t isRsvd4; /* reserved 4 for future use */
|
||||
u_int32_t isCheck; /* CRC-32 of header fields preceding this one */
|
||||
} Image2Superblock;
|
||||
|
||||
|
||||
/*
|
||||
* Image types
|
||||
*/
|
||||
typedef u_int32_t Image2ImageType;
|
||||
#define kImage2ImageTypeWildcard 0x2a2a2a2a /* **** */
|
||||
#define kImage2ImageTypeIdent 0x49646e74 /* Idnt - ASCII string identifying the image
|
||||
* collection */
|
||||
#define kImage2ImageTypeDTree 0x64747265 /* dtre */
|
||||
#define kImage2ImageTypeDiag 0x64696167 /* diag */
|
||||
#define kImage2ImageTypeLogo 0x6c6f676f /* logo */
|
||||
#define kImage2ImageTypeiBoot 0x69626f74 /* "ibot" => iBoot */
|
||||
#define kImage2ImageTypeLLB 0x6c6c627a /* "llbz" => LLB */
|
||||
#define kImage2ImageTypeEOT 0x04040404 /* EOT */
|
||||
|
||||
/*
|
||||
* On-media image header.
|
||||
*/
|
||||
typedef struct {
|
||||
u_int32_t ihMagic;
|
||||
#define kImage2ImageMagic 0x496d6732 /* "Img2" */
|
||||
Image2ImageType ihType;
|
||||
u_int16_t ihRevision;
|
||||
u_int16_t ihSecurityEpoch; /* Image is from this security epoch */
|
||||
u_int32_t ihLoadAddress; /* preferred load address */
|
||||
u_int32_t ihDataSize; /* payload data size (bytes) */
|
||||
u_int32_t ihEncryptedDataSize; /* payload data size after decryption (bytes) */
|
||||
u_int32_t ihAllocationSize; /* allocation size including header (granules) */
|
||||
u_int32_t ihOptions;
|
||||
#define kImage2OptionSignatureTypeExternal (1<<0) /* signature present elsewhere */
|
||||
#define kImage2OptionSignatureTypeInternalSHA1 (1<<1) /* SHA-1 hash in ihSignatureData */
|
||||
#define kImage2OptionSignatureTypeInternalCRC (1<<2) /* CRC-32 in first word of ihSignatureData*/
|
||||
#define kImage2OptionsTrustedImage (1<<8) /* Image was written down with trust */
|
||||
#define kImage2OptionsEncryptedImage (1<<9) /* Image body is encrypted */
|
||||
#define kImage2OptionsInstalledWithSB (1<<24) /* Image was written with secure boot support */
|
||||
#define kImage2OptionsExtensionPresent (1<<30) /* Extension header follows this main */
|
||||
#define kImage2OptionsImmutable (1<<31)
|
||||
u_int32_t ihSignatureData[16];
|
||||
u_int32_t ihNextSize; /* Size in bytes of the next extension */
|
||||
#define kImage2HeaderExtensionMaxSize 128
|
||||
u_int32_t ihCheck; /* CRC-32 of the preceeding fields */
|
||||
} Image2Header;
|
||||
#define kImage2HeaderReservation 1024
|
||||
|
||||
typedef u_int32_t Image2HeaderExtensionType;
|
||||
#define kImage2HeaderExtensionVersionString 0x76657273 /* "vers" => version string */
|
||||
|
||||
typedef struct {
|
||||
u_int32_t iheCheck; /* CRC-32 of the preceeding fields */
|
||||
u_int32_t iheNextSize; /* Size in bytes of te next extension */
|
||||
Image2HeaderExtensionType iheType;
|
||||
u_int32_t ihOptions;
|
||||
/* Extension prese*/
|
||||
u_int32_t iheData; /* extension data. This field is not
|
||||
written, instead the actual data is. */
|
||||
} Image2HeaderExtension;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __LIB_IMAGE2FORMAT_H*/
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) 2006-2011 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 __LIB_BLOCKDEV_H
|
||||
#define __LIB_BLOCKDEV_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef uint32_t block_addr;
|
||||
|
||||
#define BLOCKDEV_FLAG_NEEDS_ERASE (1 << 0) /* writes do not implicitly erase */
|
||||
#define BLOCKDEV_FLAG_UPGRADE_PARTITION (1 << 1)
|
||||
|
||||
struct blockdev {
|
||||
struct blockdev *next;
|
||||
uint32_t flags;
|
||||
|
||||
/* geometry */
|
||||
uint32_t block_size;
|
||||
uint32_t block_count;
|
||||
|
||||
uint32_t block_shift; /* calculated from the block size (assumes multiple of 2) */
|
||||
uint64_t total_len;
|
||||
|
||||
uint32_t alignment; /* required alignment for source/destination buffers in bytes */
|
||||
uint32_t alignment_shift;
|
||||
|
||||
/* io hooks */
|
||||
int (*read_hook)(struct blockdev *, void *ptr, off_t offset, uint64_t len); // read bytes
|
||||
int (*read_block_hook)(struct blockdev *, void *ptr, block_addr block, uint32_t count); // read count blocks
|
||||
int (*write_hook)(struct blockdev *, const void *ptr, off_t offset, uint64_t len); // write bytes
|
||||
int (*write_block_hook)(struct blockdev *, const void *ptr, block_addr block, uint32_t count); // write count blocks
|
||||
int (*erase_hook)(struct blockdev *, off_t offset, uint64_t len);
|
||||
|
||||
/* name */
|
||||
char name[16];
|
||||
|
||||
/* write-protected region */
|
||||
off_t protect_start;
|
||||
off_t protect_end;
|
||||
};
|
||||
|
||||
struct blockdev *lookup_blockdev(const char *name);
|
||||
int register_blockdev(struct blockdev *);
|
||||
struct blockdev *first_blockdev(void);
|
||||
struct blockdev *next_blockdev(struct blockdev *dev);
|
||||
|
||||
/* fill out a new blockdev structure with geometry data and default hooks */
|
||||
int construct_blockdev(struct blockdev *, const char *name, uint64_t len, uint32_t block_size);
|
||||
|
||||
/* user api */
|
||||
#define blockdev_read(bdev, ptr, off, len) (bdev)->read_hook((bdev), ptr, off, len)
|
||||
#define blockdev_read_block(bdev, ptr, block, count) (bdev)->read_block_hook((bdev), ptr, block, count)
|
||||
#define blockdev_write(bdev, ptr, off, len) blockdev_write_protected((bdev), ptr, off, len)
|
||||
#define blockdev_write_block(bdev, ptr, block, count) blockdev_write_block_protected((bdev), ptr, block, count)
|
||||
#define blockdev_erase(bdev, off, len) (bdev)->erase_hook((bdev), off, len)
|
||||
|
||||
int blockdev_compare(struct blockdev *dev, const void *ptr, off_t bdev_offset, uint64_t len);
|
||||
int blockdev_set_protection(struct blockdev *dev, off_t offset, uint64_t length);
|
||||
void blockdev_set_buffer_alignment(struct blockdev *dev, uint32_t alignment);
|
||||
int blockdev_write_protected(struct blockdev *dev, const void *ptr, off_t offset, uint64_t len);
|
||||
int blockdev_write_block_protected(struct blockdev *dev, const void *ptr, block_addr block, uint32_t count);
|
||||
|
||||
/* a default memory based block device */
|
||||
struct blockdev *create_mem_blockdev(const char *name, void *ptr, uint64_t len, uint32_t block_size);
|
||||
|
||||
/* a subdevice device, which lets you access a range of a device as another device */
|
||||
struct blockdev *create_subdev_blockdev(const char *name, struct blockdev *parent, off_t off, uint64_t len, uint32_t block_size);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 __LIB_CBUF_H
|
||||
#define __LIB_CBUF_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/task.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* circular buffer implementation */
|
||||
struct cbuf {
|
||||
void *buf;
|
||||
unsigned int head;
|
||||
unsigned int tail;
|
||||
size_t has;
|
||||
size_t len;
|
||||
uint32_t len_mask;
|
||||
|
||||
/* optional event for locking */
|
||||
struct task_event *event;
|
||||
};
|
||||
|
||||
/* create a circular buffer, len must be power of 2 */
|
||||
struct cbuf *cbuf_create(size_t len, struct task_event *event); // event is optional
|
||||
void cbuf_destroy(struct cbuf *);
|
||||
|
||||
/* read/write unstructured data */
|
||||
ssize_t cbuf_write_raw(struct cbuf *, const void *data, size_t len);
|
||||
ssize_t cbuf_read_raw(struct cbuf *, void *data, size_t len);
|
||||
|
||||
/* read/write individual chars */
|
||||
ssize_t cbuf_write_char(struct cbuf *, char c);
|
||||
ssize_t cbuf_read_char(struct cbuf *, char *c);
|
||||
|
||||
/* read/write strings */
|
||||
ssize_t cbuf_write_string(struct cbuf *, const char *str);
|
||||
ssize_t cbuf_read_string(struct cbuf *, char *str, size_t maxlen);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 __LIB_CKSUM_H
|
||||
#define __LIB_CKSUM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* various checksum & crc routines */
|
||||
|
||||
/* POSIX 1003.2 checksum (same as cksum command) */
|
||||
#define INITIAL_CRC (0)
|
||||
uint32_t crc(const void *buf, size_t len);
|
||||
|
||||
/* same as above, but on a single byte */
|
||||
uint32_t crc_byte(uint32_t thecrc, uint32_t byte_val);
|
||||
|
||||
/* adler32 */
|
||||
uint32_t adler32(const uint8_t *buf, long len);
|
||||
|
||||
/* crc32 CCITT*/
|
||||
uint32_t update_crc32(uint32_t crc, const uint8_t *buf, int len);
|
||||
|
||||
uint32_t crc32(const uint8_t *buf, int len);
|
||||
|
||||
void siphash(uint8_t *out, const uint8_t *in, size_t inlen, const uint8_t *k);
|
||||
void siphash_aligned(uint64_t *out, const uint64_t *in_aligned, size_t inlen, const uint64_t *k);
|
||||
|
||||
#define SIPHASH_KEY_SIZE (16)
|
||||
#define SIPHASH_HASH_SIZE (8)
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2008-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 _BOOTX_DEVICE_TREE_H_
|
||||
#define _BOOTX_DEVICE_TREE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define kPropNameLength (32)
|
||||
#define kPropValueMaxLength (0x100000)
|
||||
typedef struct DTProperty DTProperty, *DTPropertyPtr;
|
||||
|
||||
int dt_load(void);
|
||||
int dt_load_file(const char *path);
|
||||
|
||||
extern addr_t gDeviceTreeAddr;
|
||||
extern size_t gDeviceTreeSize;
|
||||
|
||||
typedef struct dtnode dt_node_t;
|
||||
|
||||
void dt_init(void);
|
||||
dt_node_t *dt_deserialize(void *dtaddr, size_t dtlength);
|
||||
void dt_serialize(dt_node_t *dt, void *buffer, size_t bufferlen);
|
||||
size_t dt_get_size(void);
|
||||
dt_node_t *dt_get_root(void);
|
||||
bool dt_find_node(dt_node_t *root, const char *path, dt_node_t **node);
|
||||
const char *dt_get_node_name(dt_node_t *node);
|
||||
bool dt_get_prop(dt_node_t *node, char **prop_name, void **prop_data, uint32_t *prop_size);
|
||||
bool dt_find_prop(dt_node_t *node, const char *prop_name, void **prop_data, uint32_t *prop_size);
|
||||
bool dt_has_prop(dt_node_t *node, const char *prop_name);
|
||||
void dt_set_prop(dt_node_t *node, const char *name, const void *data, uint32_t size);
|
||||
void dt_set_prop_32(dt_node_t *node, const char *name, uint32_t value);
|
||||
void dt_set_prop_64(dt_node_t *node, const char *name, uint64_t value);
|
||||
void dt_set_prop_addr(dt_node_t *node, const char *name, uintptr_t value);
|
||||
void dt_set_prop_str(dt_node_t *node, const char *name, const char *str);
|
||||
bool dt_remove_prop(dt_node_t *node, const char *name);
|
||||
bool dt_rename_prop(dt_node_t *node, const char *name, const char *new_name);
|
||||
void dt_seal(void);
|
||||
int dt_num_children(dt_node_t *node);
|
||||
|
||||
dt_node_t *dt_get_child(dt_node_t *node, int n);
|
||||
dt_node_t *dt_get_next(dt_node_t *node);
|
||||
|
||||
// compatibility with legacy code
|
||||
typedef dt_node_t DTNode;
|
||||
typedef dt_node_t * DTNodePtr;
|
||||
#define FindNode dt_find_node
|
||||
#define FindProperty dt_get_prop
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* ! _BOOTX_DEVICE_TREE_H_ */
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 __LIB_ENV_H
|
||||
#define __LIB_ENV_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* systemwide environment variables */
|
||||
struct env_var {
|
||||
char *str;
|
||||
size_t u;
|
||||
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
#define ENV_PERSISTENT 0x1 /* saved with 'saveenv' or not */
|
||||
#define ENV_SHADOW 0x2 // hidden from env_get or not
|
||||
|
||||
const char *env_get(const char *name);
|
||||
size_t env_get_uint(const char *name, size_t default_val);
|
||||
bool env_get_bool(const char *name, bool default_val);
|
||||
const struct env_var *env_get_etc(const char *name);
|
||||
|
||||
int env_set(const char *name, const char *val, uint32_t flags);
|
||||
int env_set_uint(const char *name, size_t val, uint32_t flags);
|
||||
int env_unset(const char *name);
|
||||
|
||||
/* supplied by code that wants to blacklist environment variables */
|
||||
bool env_blacklist(const char *name, bool write);
|
||||
bool env_blacklist_nvram(const char *name);
|
||||
|
||||
/* used by the nvram system */
|
||||
size_t env_serialize(uint8_t *buf, size_t buf_len);
|
||||
int env_unserialize(const uint8_t *buf, size_t buf_len);
|
||||
|
||||
/* get an ip address from the environment */
|
||||
int env_get_ipaddr(const char *name, uint32_t *ip);
|
||||
int env_get_ethaddr(const char *name, uint8_t ethaddr[6]);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* 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 __LIB_FS_H
|
||||
#define __LIB_FS_H
|
||||
|
||||
#include <list.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* limits */
|
||||
#define FS_MAXNAMLEN 255 /* maximum component name */
|
||||
#define FS_MAXPATHLEN 512 /* maximum path length */
|
||||
|
||||
|
||||
/* statfs structure. */
|
||||
struct statfs {
|
||||
uint32_t f_bsize; /* Size of a cluster in bytes. */
|
||||
uint32_t f_blocks; /* Number of clusters. */
|
||||
uint32_t f_bfree; /* Number of free clusters. */
|
||||
};
|
||||
|
||||
enum file_type {
|
||||
FILE_TYPE_UNKNOWN = 0,
|
||||
FILE_TYPE_FILE,
|
||||
FILE_TYPE_DIR,
|
||||
};
|
||||
|
||||
/* directory entry. */
|
||||
struct dirent {
|
||||
uint32_t d_fileno;
|
||||
uint32_t d_reclen;
|
||||
uint8_t d_type;
|
||||
uint8_t d_namlen;
|
||||
char d_name[FS_MAXNAMLEN + 1];
|
||||
|
||||
int32_t d_ctime;
|
||||
int32_t d_atime;
|
||||
int32_t d_mtime;
|
||||
};
|
||||
|
||||
/* stat structure. */
|
||||
struct stat {
|
||||
uint32_t st_ino; /* Inode number. */
|
||||
uint32_t st_size; /* Lenght of file (bytes). */
|
||||
uint32_t st_blocks; /* Length of file (blocks). */
|
||||
enum file_type st_type;
|
||||
uint32_t st_flags;
|
||||
int32_t st_ctime; /* Creation time. */
|
||||
int32_t st_mtime; /* Modification time. */
|
||||
int32_t st_atime; /* Access time. */
|
||||
};
|
||||
|
||||
/* File I/O */
|
||||
#define FILE_SEEK_SET 0
|
||||
#define FILE_SEEK_CUR 1
|
||||
#define FILE_SEEK_END 2
|
||||
|
||||
/* read only fs ops */
|
||||
struct fs_ops {
|
||||
int (*mount)(void **ctxt, const char *dev);
|
||||
void (*unmount)(void *ctxt);
|
||||
int (*fsstat)(void *ctxt, struct statfs *stat);
|
||||
|
||||
void *(*open)(void *ctxt, const char *path, uint8_t flags);
|
||||
int (*read)(void *filectxt, void *buf, size_t len);
|
||||
int (*fstat)(void *filectxt, struct stat *st);
|
||||
off_t (*seek)(void *filectxt, off_t offset, int whence);
|
||||
void (*close)(void *filectxt);
|
||||
|
||||
void *(*opendir)(void *ctxt, const char *path);
|
||||
int (*readdir)(void *dirctxt, struct dirent *ent);
|
||||
void (*rewinddir)(void *dirctxt);
|
||||
void (*closedir)(void *dirctxt);
|
||||
};
|
||||
|
||||
struct fs_struct {
|
||||
const char *name;
|
||||
const struct fs_ops *ops;
|
||||
};
|
||||
|
||||
/* user fs api */
|
||||
int fs_mount(const char *dev, const char *fs_name, const char *mountpoint);
|
||||
void fs_unmount(const char *dev);
|
||||
int fs_fsstat(void *fscookie, struct statfs *stat);
|
||||
|
||||
int fs_open(const char *path, uint8_t flags);
|
||||
int fs_read(int handle, void *buf, size_t len);
|
||||
int fs_stat(int handle, struct stat *st);
|
||||
off_t fs_seek(int handle, off_t offset, int whence);
|
||||
int fs_close(int handle);
|
||||
|
||||
int fs_opendir(const char *path);
|
||||
int fs_readdir(int handle, struct dirent *ent);
|
||||
int fs_rewinddir(int handle);
|
||||
int fs_closedir(int handle);
|
||||
const char *fs_get_fsname(const int index);
|
||||
|
||||
|
||||
/* some debug routines */
|
||||
void fs_stat_dump(const struct stat *st);
|
||||
void fs_statfs_dump(const struct statfs *st);
|
||||
int fs_dump_dir(const char *dirpath, bool recurse);
|
||||
void fs_dump_mounts(void);
|
||||
|
||||
/* convenience routines */
|
||||
int fs_load_file(const char *path, addr_t addr, size_t *maxsize);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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 __HEAP_H
|
||||
#define __HEAP_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* The public heap allocation functions will never return NULL. The internal
|
||||
* implementation will always call panic() if an allocation cannot be
|
||||
* satisfied. You should not check for NULL being returned as this is a waste
|
||||
* of code and gives other readers the incorrect impression that this is
|
||||
* required.
|
||||
*/
|
||||
|
||||
#define HEAP_COOKIE_SIZE 16
|
||||
|
||||
void heap_add_chunk(void *chunk, size_t size, bool clear_memory);
|
||||
void heap_set_cookie(uint8_t *cookie);
|
||||
u_int32_t heap_get_free_mem(void);
|
||||
bool heap_is_initialized(void);
|
||||
|
||||
void *heap_malloc(size_t size, const char *caller_name);
|
||||
void *heap_realloc(void *ptr, size_t size, const char *caller_name);
|
||||
void *heap_memalign(size_t size, size_t alignment, const char *caller_name);
|
||||
int heap_posix_memalign(void **memptr, size_t size, size_t alignment, const char *caller_name);
|
||||
void *heap_calloc(size_t count, size_t size, const char *caller_name);
|
||||
void heap_free(void *ptr);
|
||||
void heap_verify(void);
|
||||
|
||||
#ifndef __clang_analyzer__
|
||||
#ifndef HEAP_UNITTEST
|
||||
# if DEBUG_BUILD
|
||||
# define malloc(_s) heap_malloc(_s, __FUNCTION__)
|
||||
# define realloc(_p, _s) heap_realloc(_p, _s, __FUNCTION__)
|
||||
# define memalign(_s, _a) heap_memalign(_s, _a, __FUNCTION__)
|
||||
# define posix_memalign(_m, _s, _a) heap_posix_memalign(_m, _s, _a, __FUNCTION__)
|
||||
# define calloc(_c, _s) heap_calloc(_c, _s, __FUNCTION__)
|
||||
# else
|
||||
# define malloc(_s) heap_malloc(_s, NULL)
|
||||
# define realloc(_p, _s) heap_realloc(_p, _s, NULL)
|
||||
# define memalign(_s, _a) heap_memalign(_s, _a, NULL)
|
||||
# define posix_memalign(_m, _s, _a) heap_posix_memalign(_m, _s, _a, NULL)
|
||||
# define calloc(_c, _s) heap_calloc(_c, _s, NULL)
|
||||
# endif
|
||||
# define free(_p) heap_free(_p)
|
||||
#endif // HEAP_UNITTEST
|
||||
#else // __clang_analyzer__
|
||||
// the clang static analyzer needs malloc and friends to have their normal
|
||||
// names with underscores prepended in order to find things like use after free
|
||||
void *malloc(size_t size);
|
||||
void *realloc(void *ptr, size_t size);
|
||||
void *memalign(size_t size, size_t alignment);
|
||||
void *calloc(size_t count, size_t size);
|
||||
void free(void *ptr);
|
||||
int posix_memalign(void **memptr, size_t alignment, size_t size);
|
||||
#endif
|
||||
|
||||
/* heap debugging features */
|
||||
enum
|
||||
{
|
||||
HEAP_BLOCK__FREE,
|
||||
HEAP_BLOCK__MALLOC,
|
||||
HEAP_BLOCK__MEMALIGN,
|
||||
HEAP_BLOCK__SENTINEL,
|
||||
};
|
||||
|
||||
struct walker_info_t
|
||||
{
|
||||
unsigned block_type;
|
||||
void *raw_block;
|
||||
size_t block_size;
|
||||
unsigned extended_info;
|
||||
uint32_t checksum;
|
||||
|
||||
/* these are only meaningful for HEAP_BLOCK__MALLOC & HEAP_BLOCK__MEMALIGN */
|
||||
void *user_block;
|
||||
size_t user_size; /* only when extended_info != 0 */
|
||||
utime_t timestamp; /* only when extended_info != 0 */
|
||||
void *requestor; /* only when extended_info != 0 */
|
||||
|
||||
/* this is only meaningful for HEAP_BLOCK__MEMALIGN, set to zero for HEAP_BLOCK__MALLOC */
|
||||
size_t alignment; /* only when extended_info != 0 */
|
||||
};
|
||||
|
||||
typedef int (heap_walker_f)(void *cookie, struct walker_info_t const *);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2013 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 __LIB_IMAGE_H
|
||||
#define __LIB_IMAGE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <lib/blockdev.h>
|
||||
#include <list.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct image_info {
|
||||
u_int32_t imageLength;
|
||||
u_int32_t imageAllocation;
|
||||
u_int32_t imageType;
|
||||
u_int32_t imagePrivateMagic;
|
||||
#define IMAGE_MEMORY_INFO_MAGIC 'Memz'
|
||||
#define IMAGE2_IMAGE_INFO_MAGIC 'img2'
|
||||
#define IMAGE3_IMAGE_INFO_MAGIC 'img3'
|
||||
#define IMAGE4_IMAGE_INFO_MAGIC 'img4'
|
||||
u_int32_t imageOptions;
|
||||
void *imagePrivate;
|
||||
};
|
||||
|
||||
// images we might be interested in
|
||||
#define IMAGE_TYPE_ANY 0 // any image type
|
||||
#define IMAGE_TYPE_DIAG 'diag' // diagnostics
|
||||
#define IMAGE_TYPE_LLB 'illb' // iboot first-stage loader
|
||||
#define IMAGE_TYPE_IBOOT 'ibot' // iboot second-stage loader
|
||||
#define IMAGE_TYPE_IBSS 'ibss' // iboot single stage
|
||||
#define IMAGE_TYPE_IBEC 'ibec' // iboot epoch change
|
||||
#define IMAGE_TYPE_DALI 'dali' // dali
|
||||
#define IMAGE_TYPE_DEVTREE 'dtre' // darwin device tree
|
||||
#define IMAGE_TYPE_DEVTREE_RESTORE 'rdtr' // darwin device tree for restore
|
||||
#define IMAGE_TYPE_RAMDISK 'rdsk' // darwin ram disk for restore
|
||||
#define IMAGE_TYPE_KERNELCACHE 'krnl' // darwin kernel cache
|
||||
#define IMAGE_TYPE_KERNELCACHE_RESTORE 'rkrn' // darwin kernel cache for restore
|
||||
#define IMAGE_TYPE_LOGO 'logo' // boot logo image
|
||||
#define IMAGE_TYPE_RECMODE 'recm' // recovery mode image
|
||||
#define IMAGE_TYPE_NEEDSERVICE 'nsrv' // need service image
|
||||
#define IMAGE_TYPE_GLYPHCHRG 'glyC' // glyph charge image
|
||||
#define IMAGE_TYPE_GLYPHPLUGIN 'glyP' // glyph plug in image
|
||||
#define IMAGE_TYPE_BATTERYCHARGING0 'chg0' // battery charging image - bright
|
||||
#define IMAGE_TYPE_BATTERYCHARGING1 'chg1' // battery charging image - dim
|
||||
#define IMAGE_TYPE_BATTERYLOW0 'bat0' // battery low image - empty
|
||||
#define IMAGE_TYPE_BATTERYLOW1 'bat1' // battery low image - red (composed onto empty)
|
||||
#define IMAGE_TYPE_BATTERYFULL 'batF' // battery full image list
|
||||
#define IMAGE_TYPE_BATTERYFULL_N_TOTAL (18) // total number of images
|
||||
#define IMAGE_TYPE_BATTERYFULL_N_START (2) // first image that's part of batF list (first two are bat0 and bat1)
|
||||
#define IMAGE_TYPE_BATTERYFULL_N_RED (4) // last red battery image
|
||||
#define IMAGE_TYPE_BATTERYFULL_N_FULL (IMAGE_TYPE_BATTERYFULL_N_TOTAL-1) // battery full image
|
||||
#define IMAGE_TYPE_ENV 'ienv' // environment vars
|
||||
#define IMAGE_TYPE_TSYS 'tsys' // tsys tester
|
||||
#define IMAGE_TYPE_MONITOR 'hypr' // monitor/hypervisor
|
||||
#define IMAGE_TYPE_OS_RESTORE 'rosi' // OS image for restore
|
||||
#define IMAGE_TYPE_SEP_OS 'sepi' // SEP OS image
|
||||
#define IMAGE_TYPE_SEP_OS_RESTORE 'rsep' // SEP OS image for restore
|
||||
#define IMAGE_TYPE_CFE_LOADER 'cfel' // SiVal's CFE loader
|
||||
#define IMAGE_TYPE_RBM 'rbmt' // SiVal's RBM test
|
||||
#define IMAGE_TYPE_PHLEET 'phlt' // SiVal's PHLEET test
|
||||
#define IMAGE_TYPE_PE_RTOS 'pert' // PE's RTOS environment
|
||||
#define IMAGE_TYPE_HAMMER 'hmmr' // PE's Hammer test
|
||||
#define IMAGE_TYPE_FDRT 'fdrt' // FDR Trust object for AP
|
||||
#define IMAGE_TYPE_FDRS 'fdrs' // FDR Trust object for SEP
|
||||
|
||||
// image options
|
||||
#define IMAGE_OPTION_GREATER_EPOCH (1 << 0) // Allow platform epoch or greater
|
||||
#define IMAGE_OPTION_REQUIRE_TRUST (1 << 1) // Regardless of security, require image
|
||||
// trust
|
||||
#define IMAGE_OPTION_LOCAL_STORAGE (1 << 2) // Image came from local (personalised) storage
|
||||
#define IMAGE_OPTION_NEW_TRUST_CHAIN (1 << 3) // New chain of trust. Image load library can use this information
|
||||
// enforce various policies.
|
||||
|
||||
#define IMAGE_OPTION_JUST_LOAD (1 << 8) // Just load the whole image, don't validate or look for a payload
|
||||
#define IMAGE_OPTION_MEMORY (1 << 9) // Image comes from a memory bdev, so its hash isn't personalized
|
||||
|
||||
// XXX backwards compatibility
|
||||
#define IMAGE_OPTION_ANY_EPOCH IMAGE_OPTION_GREATER_EPOCH // Allow any epoch for this image
|
||||
|
||||
|
||||
// image keybag selectors
|
||||
#define IMAGE_KEYBAG_SELECTOR_PROD (1)
|
||||
#define IMAGE_KEYBAG_SELECTOR_DEV (2)
|
||||
|
||||
|
||||
/**
|
||||
* Load an image from a file.
|
||||
*
|
||||
* \param[in] path Path including mountpoint from which to read.
|
||||
* \param[inout] address Address for the buffer used both for file reading and into which
|
||||
* the resulting image data will be placed. Referenced pointer will
|
||||
* be zeroed on failure.
|
||||
* \param[inout] length On input, the size of the buffer. The file must file entirely
|
||||
* within this size. Updated on return to the size of the image
|
||||
* data extracted from the image.
|
||||
* \param[in] types An array of types that the image must conform to one of,
|
||||
* or NULL if no type checking should be performed.
|
||||
* \param[in] count The count of image types in the types array,
|
||||
* or zero if NULL was passed.
|
||||
* \param[out] actual A pointer to receive the actual type for given image.
|
||||
* Optional if count is 0 or 1.
|
||||
* \param[in] options Options to be passed when creating the image.
|
||||
*
|
||||
* \return 0 on success.
|
||||
*/
|
||||
int
|
||||
image_load_file(
|
||||
const char *path,
|
||||
addr_t *address,
|
||||
size_t *length,
|
||||
const uint32_t *types,
|
||||
uint32_t count,
|
||||
uint32_t *actual,
|
||||
uint32_t options);
|
||||
|
||||
/**
|
||||
* Load an image from memory.
|
||||
*
|
||||
* \param[in] fromAddress Address of the buffer containing the image.
|
||||
* \param[in] fromLength Size of the buffer containing the image.
|
||||
* \param[inout] address Address for the buffer into which the resulting image data will
|
||||
* be placed. Referenced pointer will be zeroed on failure.
|
||||
* \param[inout] length On input, the size of the destination buffer. The image must file
|
||||
* entirely within this size. Updated on return to the size of the image
|
||||
* data extracted from the image.
|
||||
* \param[in] types An array of types that the image must conform to one of,
|
||||
* or NULL if no type checking should be performed.
|
||||
* \param[in] count The count of image types in the types array,
|
||||
* or zero if NULL was passed.
|
||||
* \param[out] actual A pointer to receive the actual type for given image.
|
||||
* Optional if count is 0 or 1.
|
||||
* \param[in] options Options to be passed when creating the image.
|
||||
*
|
||||
* \return 0 on success.
|
||||
*/
|
||||
int
|
||||
image_load_memory(
|
||||
addr_t fromAddress,
|
||||
size_t fromLength,
|
||||
addr_t *address,
|
||||
size_t *length,
|
||||
const uint32_t *types,
|
||||
uint32_t count,
|
||||
uint32_t *actual,
|
||||
uint32_t options);
|
||||
|
||||
|
||||
/**
|
||||
* Load an image of a given type from the set of known images.
|
||||
*
|
||||
* \param[inout] address Address for the buffer into which the resulting image data will
|
||||
* be placed. Referenced pointer will be zeroed on failure.
|
||||
* \param[inout] length On input, the size of the destination buffer. The image must file
|
||||
* entirely within this size. Updated on return to the size of the image
|
||||
* data extracted from the image.
|
||||
* \param[in] type The image type to be looked up.
|
||||
* \param[in] options Options to be passed when creating the image.
|
||||
*
|
||||
* \return 0 on success.
|
||||
*/
|
||||
int
|
||||
image_load_type(
|
||||
addr_t *address,
|
||||
size_t *length,
|
||||
uint32_t type,
|
||||
uint32_t options);
|
||||
|
||||
/*
|
||||
* Lower-level primitives - avoid when possible.
|
||||
*/
|
||||
int
|
||||
image_search_bdev(
|
||||
struct blockdev *bdev,
|
||||
off_t map_offset,
|
||||
uint32_t imageOptions);
|
||||
|
||||
void
|
||||
image_free_bdev(
|
||||
struct blockdev *bdev);
|
||||
|
||||
int
|
||||
image_load(
|
||||
struct image_info *image,
|
||||
const uint32_t *types,
|
||||
uint32_t count,
|
||||
uint32_t *actual,
|
||||
void **load_addr,
|
||||
size_t *load_len);
|
||||
|
||||
struct image_info *
|
||||
image_find(
|
||||
u_int32_t type);
|
||||
|
||||
void
|
||||
image_dump_list(
|
||||
bool detailed);
|
||||
|
||||
struct image_info *
|
||||
image_create_from_memory(
|
||||
void *address,
|
||||
size_t length,
|
||||
uint32_t imageOptions);
|
||||
|
||||
void
|
||||
image_free(
|
||||
struct image_info *image);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2014 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 __LIB_IMAGE4_SPI_H
|
||||
#define __LIB_IMAGE4_SPI_H
|
||||
|
||||
|
||||
/*
|
||||
* An image of type 'image_type' is being loaded.
|
||||
*
|
||||
* Return true if you'd like its properties captured, false otherwise.
|
||||
*/
|
||||
typedef bool (*image4_start_capture_callback)(uint32_t image_type);
|
||||
|
||||
/*
|
||||
* Property callbacks for supported property types:
|
||||
*
|
||||
* tag: 32-bit property tag (e.g. 'EPRO')
|
||||
* is_object_property: true for object property, false for manifest property
|
||||
*
|
||||
* Note that for the string variant, 'buffer' is only valid within the scope of the callback.
|
||||
*/
|
||||
typedef void (*image4_boolean_property_callback)(uint32_t tag, bool is_object_property, bool val);
|
||||
typedef void (*image4_integer_property_callback)(uint32_t tag, bool is_object_property, uint64_t val);
|
||||
typedef void (*image4_string_property_callback)(uint32_t tag, bool is_object_property, uint8_t* buffer, size_t length);
|
||||
|
||||
|
||||
/*
|
||||
* Validity callback:
|
||||
*
|
||||
* true: Image has been validated -- captured properties can be used
|
||||
* false: Image is not valid. You should zero out any previously captured properties!
|
||||
*/
|
||||
typedef void (*image4_validity_callback)(bool valid);
|
||||
|
||||
/*
|
||||
* image4_register_property_capture_callbacks
|
||||
*
|
||||
* On some targets, we would like to stash away various image4 properties for a particular payload type.
|
||||
* Register callbacks for property captures, as well as a callback to let you know whether or not the image ended
|
||||
* up being valid.
|
||||
*
|
||||
* Note for security reasons, you are expected to zero out your stored properties if you find out that
|
||||
* image4_validity_callback is called with false.
|
||||
*/
|
||||
extern void
|
||||
image4_register_property_capture_callbacks(image4_start_capture_callback start_cb, image4_boolean_property_callback bool_cb,
|
||||
image4_integer_property_callback int_cb, image4_string_property_callback string_cb,
|
||||
image4_validity_callback validity);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2009 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 __LIB_LIBC_H
|
||||
#define __LIB_LIBC_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <compiler.h>
|
||||
|
||||
#if !WITH_HOST_LIBC
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <lib/heap.h>
|
||||
|
||||
#define LIBC_FUNC(x) x
|
||||
|
||||
// for compatibility with code that gets is_pow2, ROUNDUP, etc through
|
||||
// the standard lib headers. new/updated code should include libiboot.h
|
||||
// directly instead of getting it through libc.h
|
||||
#include <lib/libiboot.h>
|
||||
|
||||
#else // WITH_HOST_LIBC
|
||||
|
||||
// Prefix function names with libc_ in order to not collide with the real functions
|
||||
#define LIBC_FUNC(x) libc_##x
|
||||
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* stdio stuff */
|
||||
int LIBC_FUNC(puts)(const char *str);
|
||||
int LIBC_FUNC(getchar)(void);
|
||||
int LIBC_FUNC(putchar)(int c);
|
||||
|
||||
int LIBC_FUNC(printf)(const char *fmt, ...) __printflike(1, 2);
|
||||
int LIBC_FUNC(vprintf)(const char *fmt, va_list ap);
|
||||
int LIBC_FUNC(snprintf)(char *str, size_t size, const char *fmt, ...) __printflike(3, 4);
|
||||
int LIBC_FUNC(vsnprintf)(char *str, size_t size, const char *fmt, va_list ap);
|
||||
|
||||
/* fake fprintf to accomodate AssertMacros.h */
|
||||
#if !WITH_HOST_LIBC
|
||||
#define stdout 0
|
||||
#define stderr 0
|
||||
#endif
|
||||
int LIBC_FUNC(fprintf)(void *stream, const char *fmt, ...) __printflike(2, 3);
|
||||
|
||||
/* string */
|
||||
void * LIBC_FUNC(memchr)(void const *, int, size_t);
|
||||
int LIBC_FUNC(memcmp)(void const *, const void *, size_t);
|
||||
int LIBC_FUNC(memcmp_secure)(void const *, const void *, size_t);
|
||||
void * LIBC_FUNC(memcpy)(void *, void const *, size_t);
|
||||
void * LIBC_FUNC(memmove)(void *, void const *, size_t);
|
||||
void * LIBC_FUNC(memset)(void *, int, size_t);
|
||||
|
||||
char * LIBC_FUNC(strchr)(char const *, int);
|
||||
int LIBC_FUNC(strcmp)(char const *, char const *);
|
||||
size_t LIBC_FUNC(strlen)(char const *);
|
||||
int LIBC_FUNC(strncmp)(char const *, char const *, size_t);
|
||||
char * LIBC_FUNC(strpbrk)(char const *, char const *);
|
||||
char * LIBC_FUNC(strrchr)(char const *, int);
|
||||
size_t LIBC_FUNC(strspn)(char const *, char const *);
|
||||
size_t LIBC_FUNC(strcspn)(const char *s, const char *);
|
||||
char * LIBC_FUNC(strstr)(char const *, char const *);
|
||||
char * LIBC_FUNC(strtok)(char *, char const *);
|
||||
int LIBC_FUNC(strcoll)(const char *s1, const char *s2);
|
||||
size_t LIBC_FUNC(strxfrm)(char *dest, const char *src, size_t n);
|
||||
char * LIBC_FUNC(strdup)(const char *str);
|
||||
|
||||
/* non standard string */
|
||||
void * LIBC_FUNC(bcopy)(void const *, void *, size_t);
|
||||
void LIBC_FUNC(bzero)(void *, size_t);
|
||||
size_t LIBC_FUNC(strlcat)(char *, char const *, size_t);
|
||||
size_t LIBC_FUNC(strlcpy)(char *, char const *, size_t);
|
||||
int LIBC_FUNC(strncasecmp)(char const *, char const *, size_t);
|
||||
int LIBC_FUNC(strnicmp)(char const *, char const *, size_t);
|
||||
size_t LIBC_FUNC(strnlen)(char const *s, size_t count);
|
||||
char * LIBC_FUNC(strsep)(char **stringp, const char *delim);
|
||||
|
||||
/* secure string functions */
|
||||
#if !WITH_HOST_LIBC
|
||||
#if !defined(__cplusplus)
|
||||
#if __has_builtin(__builtin___memcpy_chk)
|
||||
#define memcpy(dest, src, len) __builtin___memcpy_chk(dest, src, len, __builtin_object_size(dest, 0))
|
||||
#endif
|
||||
#if __has_builtin(__builtin___memmove_chk)
|
||||
#define memmove(dest, src, len) __builtin___memmove_chk(dest, src, len, __builtin_object_size(dest, 0))
|
||||
#endif
|
||||
#if __has_builtin(__builtin___memset_chk)
|
||||
#define memset(dest, c, len) __builtin___memset_chk(dest, c, len, __builtin_object_size(dest, 0))
|
||||
#endif
|
||||
|
||||
#define bcopy(src, dest, len) memcpy(dest, src, len)
|
||||
#define bzero(dest, len) memset(dest, 0, len)
|
||||
#if __has_builtin(__builtin___strlcat_chk)
|
||||
#define strlcat(dest, src, len) __builtin___strlcat_chk(dest, src, len, __builtin_object_size(dest, 1))
|
||||
#endif
|
||||
#if __has_builtin(__builtin___strlcpy_chk)
|
||||
#define strlcpy(dest, src, len) __builtin___strlcpy_chk(dest, src, len, __builtin_object_size(dest, 1))
|
||||
#endif
|
||||
|
||||
#if __has_builtin(__builtin___snprintf_chk)
|
||||
#define snprintf(dst, size, ...) __builtin___snprintf_chk(dst, size, 0, __builtin_object_size(dst, 1), __VA_ARGS__)
|
||||
#endif
|
||||
#if __has_builtin(__builtin___vsnprintf_chk)
|
||||
#define vsnprintf(dst, size, fmt, ap) __builtin___vsnprintf_chk(dst, size, 0, __builtin_object_size(dst, 1), fmt, ap)
|
||||
#endif
|
||||
|
||||
#endif // __cplusplus
|
||||
#endif // !WITH_HOST_LIBC
|
||||
|
||||
/* ctype */
|
||||
int LIBC_FUNC(isalnum)(int c);
|
||||
int LIBC_FUNC(isalpha)(int c);
|
||||
int LIBC_FUNC(iscntrl)(int c);
|
||||
int LIBC_FUNC(isdigit)(int c);
|
||||
int LIBC_FUNC(isgraph)(int c);
|
||||
int LIBC_FUNC(islower)(int c);
|
||||
int LIBC_FUNC(isprint)(int c);
|
||||
int LIBC_FUNC(ispunct)(int c);
|
||||
int LIBC_FUNC(isspace)(int c);
|
||||
int LIBC_FUNC(isupper)(int c);
|
||||
int LIBC_FUNC(isxdigit)(int c);
|
||||
int LIBC_FUNC(isascii)(int c);
|
||||
int LIBC_FUNC(toascii)(int c);
|
||||
|
||||
unsigned char LIBC_FUNC(tolower)(unsigned char c);
|
||||
unsigned char LIBC_FUNC(toupper)(unsigned char c);
|
||||
|
||||
/* errno */
|
||||
#if !WITH_HOST_LIBC
|
||||
extern int errno;
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
/* numbers */
|
||||
long LIBC_FUNC(strtol)(const char *nptr, char **endptr, int base);
|
||||
unsigned long LIBC_FUNC(strtoul)(const char *nptr, char **endptr, int base);
|
||||
unsigned long long LIBC_FUNC(strtoull)(const char * __restrict nptr, char ** __restrict endptr, int base);
|
||||
int LIBC_FUNC(atoi)(const char *nptr);
|
||||
|
||||
/* stdlib */
|
||||
int LIBC_FUNC(system)(const char *command);
|
||||
void LIBC_FUNC(exit)(int status);
|
||||
void LIBC_FUNC(qsort)(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *));
|
||||
void LIBC_FUNC(srand)(unsigned int seed);
|
||||
int LIBC_FUNC(rand)(void);
|
||||
|
||||
#if !WITH_HOST_LIBC
|
||||
uint32_t swap32(uint32_t x);
|
||||
uint16_t swap16(uint16_t x);
|
||||
|
||||
/* ntohl and friends */
|
||||
uint32_t LIBC_FUNC(htonl)(uint32_t hostlong);
|
||||
uint16_t LIBC_FUNC(htons)(uint16_t hostshort);
|
||||
uint32_t LIBC_FUNC(ntohl)(uint32_t netlong);
|
||||
uint16_t LIBC_FUNC(ntohs)(uint16_t netshort);
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2009 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 __LIB_LIBIBOOT_H
|
||||
#define __LIB_LIBIBOOT_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* for powers of 2 only */
|
||||
#define ROUNDUP(a, b) (((a) + ((b) - 1)) & (~((b) - 1)))
|
||||
#define ROUNDDOWN(a, b) (((a) / (b)) * (b))
|
||||
|
||||
/* some of our own stuff */
|
||||
void hexdump(const void *_ptr, size_t len);
|
||||
|
||||
#define is_pow2(n) ((((n)-1) & (n)) == 0)
|
||||
int log2_int(unsigned int val);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This 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 OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __LIB_LZSS_H
|
||||
#define __LIB_LZSS_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
uint32_t decompress_lzss(uint8_t * __restrict dst, uint32_t dstlen, const uint8_t * __restrict src, uint32_t srclen);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (C) 2006-2012 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 __LIB_MACHO_H
|
||||
#define __LIB_MACHO_H
|
||||
|
||||
#include <lib/image.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* load a kernelcache from memory, return the entry point
|
||||
*
|
||||
* \param[in] addr Address of the kernelcache in memory.
|
||||
* \param[in] size Size of the kernelcache in memory.
|
||||
* \param[in] type Type of kernelcache (restore or local boot).
|
||||
* \param[out] entry Entrypoint recovered from the kernelcache.
|
||||
* \param[out] boot_args_out Boot arguments to pass to the kernelcache entry point.
|
||||
*
|
||||
* \return 0 Kernelcache was loaded successfully.
|
||||
* \return -2 Kernelcache is too large.
|
||||
* \return -3 Kernelcache container failed validation (signature,
|
||||
* wrong system, etc.)
|
||||
* \return -4 Not a valid kernelcache (bad magic number).
|
||||
* \return -5 Decompression failed.
|
||||
* \return -6 Not a valid Mach-o image (bad magic number).
|
||||
* \return -7 Mach-o load failed.
|
||||
*/
|
||||
int load_kernelcache(addr_t addr, size_t size, uint32_t type, addr_t *entry, addr_t *boot_args_out);
|
||||
|
||||
/**
|
||||
* load a kernelcache from a path, return the entry point
|
||||
*
|
||||
* \param[in] path Filesystem path from which to read the kernelcache.
|
||||
* \param[in] type Type of kernelcache (restore or local boot).
|
||||
* \param[out] entry Entrypoint recovered from the kernelcache.
|
||||
* \param[out] boot_args_out Boot arguments to pass to the kernelcache entry point.
|
||||
*
|
||||
* \return 0 Kernelcache was loaded successfully.
|
||||
* \return -2 Kernelcache is too large.
|
||||
* \return -3 Kernelcache container failed validation (signature,
|
||||
* wrong system, etc.)
|
||||
* \return -4 Not a valid kernelcache (bad magic number).
|
||||
* \return -5 Decompression failed.
|
||||
* \return -6 Not a valid Mach-o image (bad magic number).
|
||||
* \return -7 Mach-o load failed.
|
||||
*/
|
||||
int load_kernelcache_file(const char *path, uint32_t type, addr_t *entry, addr_t *boot_args_out);
|
||||
|
||||
/**
|
||||
* load a kernelcache from a known image, return the entry point
|
||||
*
|
||||
* \param[in] image Known image from which to read the kernelcache.
|
||||
* \param[in] type Type of kernelcache (restore or local boot).
|
||||
* \param[out] entry Entrypoint recovered from the kernelcache.
|
||||
* \param[out] boot_args_out Boot arguments to pass to the kernelcache entry point.
|
||||
*
|
||||
* \return 0 Kernelcache was loaded successfully.
|
||||
* \return -2 Kernelcache is too large.
|
||||
* \return -3 Kernelcache container failed validation (signature,
|
||||
* wrong system, etc.)
|
||||
* \return -4 Not a valid kernelcache (bad magic number).
|
||||
* \return -5 Decompression failed.
|
||||
* \return -6 Not a valid Mach-o image (bad magic number).
|
||||
* \return -7 Mach-o load failed.
|
||||
*/
|
||||
int load_kernelcache_image(struct image_info *image, uint32_t type, addr_t *entry, addr_t *boot_args_out);
|
||||
|
||||
/**
|
||||
* load a monitor from a path
|
||||
*
|
||||
* A loaded monitor is recognised by the kernelcache loader; the
|
||||
* appropriate entrypoint will be returned at kernelcache load time.
|
||||
*
|
||||
* \param[in] path Filesystem path from which to read the kernelcache.
|
||||
*
|
||||
* \return 0 Monitor was loaded successfully.
|
||||
* \return -2 Monitor is too large.
|
||||
* \return -3 Monitor container failed validation (signature,
|
||||
* wrong system, etc.)
|
||||
* \return -6 Not a valid Mach-o image (bad magic number).
|
||||
* \return -7 Mach-o load failed.
|
||||
*/
|
||||
int load_monitor_file(const char *path);
|
||||
|
||||
/**
|
||||
* load a monitor from a known image
|
||||
*
|
||||
* \param[in] address Known image address
|
||||
* \param[in] size Known image size
|
||||
*
|
||||
* \return 0 Monitor was loaded successfully.
|
||||
* \return -2 Monitor is too large.
|
||||
* \return -3 Monitor container failed validation (signature,
|
||||
* wrong system, etc.)
|
||||
* \return -6 Not a valid Mach-o image (bad magic number).
|
||||
* \return -7 Mach-o load failed.
|
||||
*/
|
||||
int load_monitor_image(addr_t address, size_t size);
|
||||
|
||||
bool macho_valid(addr_t addr);
|
||||
bool macho_load(addr_t imageAddr, size_t imageSize, addr_t loadAddr, addr_t *virtualBase, addr_t *virtualEnd, addr_t *entryPoint, size_t slide);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (C) 2008-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 _MIB_H
|
||||
#define _MIB_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <lib/mib/mib_nodes.h>
|
||||
#include <sys/linker_set.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* Standard MIB application/product definitions.
|
||||
*/
|
||||
#define MIB_APP_PROD_UNKNOWN (0)
|
||||
#define MIB_APP_PROD_SECUREROM (1)
|
||||
#define MIB_APP_PROD_IBSS (2)
|
||||
#define MIB_APP_PROD_IBEC (3)
|
||||
#define MIB_APP_PROD_IBOOT (4)
|
||||
#define MIB_APP_PROD_LLB (5)
|
||||
#define MIB_APP_PROD_EMBEDDEDIOP (8)
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define OID_SUBSYSTEM(_o) ((_o)>>24)
|
||||
#define OID_NODE(_o) (((_o)>>16)&0xff)
|
||||
|
||||
#define OID_SUBSYSTEM_MASK (0xff<<24)
|
||||
#define OID_NODE_MASK (0xff<<16)
|
||||
|
||||
typedef void (* mib_func_t)(uint32_t oid, void *arg, void *value);
|
||||
|
||||
struct mib_func_spec {
|
||||
mib_func_t func;
|
||||
void *arg;
|
||||
};
|
||||
|
||||
union mib_value {
|
||||
uint32_t v32;
|
||||
uint64_t v64;
|
||||
bool v_bool;
|
||||
void *v_ptr;
|
||||
struct mib_func_spec v_func;
|
||||
};
|
||||
|
||||
struct mib_node {
|
||||
uint32_t node_oid;
|
||||
uint32_t node_type;
|
||||
union mib_value node_data;
|
||||
};
|
||||
|
||||
/* node data types */
|
||||
#define kOIDTypeUInt32 (0x00<<16) /* node data is uint32_t */
|
||||
#define kOIDTypeInt32 (0x01<<16) /* node data is int32_t */
|
||||
#define kOIDTypeUInt64 (0x02<<16) /* node data is uint64_t */
|
||||
#define kOIDTypeInt64 (0x03<<16) /* node data is int64_t */
|
||||
#if defined(__LP64__)
|
||||
#define kOIDTypeAddr kOIDTypeUInt64 /* node data is uint64_t */
|
||||
#define kOIDTypeSize kOIDTypeUInt64 /* node data is uint64_t */
|
||||
#else
|
||||
#define kOIDTypeAddr kOIDTypeUInt32 /* node data is uint32_t */
|
||||
#define kOIDTypeSize kOIDTypeUInt32 /* node data is uint32_t */
|
||||
#endif
|
||||
#define kOIDTypeBoolean (0x04<<16) /* node data is bool */
|
||||
#define kOIDTypeString (0x05<<16) /* node data is const char * */
|
||||
#define kOIDTypeStruct (0x06<<16) /* node data is void * */
|
||||
#define kOIDTypeOIDIndirect (0x07<<16) /* node data is oid (reference to another node) */
|
||||
|
||||
#define kOIDTypeMask (0xff<<16)
|
||||
#define kOIDStructSizeMask (0xffff)
|
||||
|
||||
/* node data qualifiers */
|
||||
#define kOIDDataIndirect (1<<24) /* data is indirected through v_ptr */
|
||||
#define kOIDFunction (2<<24) /* data is obtained by calling v_func */
|
||||
#define kOIDWeak (4<<24) /* node only valid if no other node present */
|
||||
|
||||
# define MIB_CONSTANT(_oid, _type, _value) \
|
||||
static const struct mib_node __attribute__((used)) \
|
||||
__mib_node_ ## _oid = { \
|
||||
.node_oid = _oid, \
|
||||
.node_type = _type, \
|
||||
.node_data.v64 = (uint64_t)(_value) \
|
||||
}; \
|
||||
LINKER_SET_ENTRY(mib, __mib_node_ ## _oid)
|
||||
|
||||
# define MIB_CONSTANT_WEAK(_oid, _type, _value) \
|
||||
static const struct mib_node __attribute__((used)) \
|
||||
__mib_node_weak_ ## _oid = { \
|
||||
.node_oid = _oid, \
|
||||
.node_type = _type | kOIDWeak, \
|
||||
.node_data.v64 = (uint64_t)(_value) \
|
||||
}; \
|
||||
LINKER_SET_ENTRY(mib, __mib_node_weak_ ## _oid)
|
||||
|
||||
# define MIB_CONSTANT_PTR(_oid, _type, _value) \
|
||||
static const struct mib_node __attribute__((used)) \
|
||||
__mib_node_ ## _oid = { \
|
||||
.node_oid = _oid, \
|
||||
.node_type = _type, \
|
||||
.node_data.v_ptr = (_value) \
|
||||
}; \
|
||||
LINKER_SET_ENTRY(mib, __mib_node_ ## _oid)
|
||||
|
||||
# define MIB_CONSTANT_PTR_WEAK(_oid, _type, _value) \
|
||||
static const struct mib_node __attribute__((used)) \
|
||||
__mib_node_weak_ ## _oid = { \
|
||||
.node_oid = _oid, \
|
||||
.node_type = _type | kOIDWeak, \
|
||||
.node_data.v_ptr = (_value) \
|
||||
}; \
|
||||
LINKER_SET_ENTRY(mib, __mib_node_weak_ ## _oid)
|
||||
|
||||
# define MIB_VARIABLE(_oid, _type, _var) \
|
||||
static const struct mib_node __attribute__((used)) \
|
||||
__mib_node_##_oid = { \
|
||||
.node_oid = _oid, \
|
||||
.node_type = _type | kOIDDataIndirect, \
|
||||
.node_data.v_ptr = (void *)(&_var) \
|
||||
}; \
|
||||
LINKER_SET_ENTRY(mib, __mib_node_ ## _oid)
|
||||
|
||||
# define MIB_VARIABLE_WEAK(_oid, _type, _var) \
|
||||
static const struct mib_node __attribute__((used)) \
|
||||
__mib_node_weak_ ## _oid = { \
|
||||
.node_oid = _oid, \
|
||||
.node_type = _type | kOIDDataIndirect | kOIDWeak, \
|
||||
.node_data.v_ptr = (void *)(&_var) \
|
||||
}; \
|
||||
LINKER_SET_ENTRY(mib, __mib_node_weak_ ## _oid)
|
||||
|
||||
# define MIB_FUNCTION(_oid, _type, _func, _arg) \
|
||||
static const struct mib_node __attribute__((used)) \
|
||||
__mib_node_##_oid = { \
|
||||
.node_oid = _oid, \
|
||||
.node_type = _type | kOIDFunction, \
|
||||
.node_data.v_func = {_func, _arg} \
|
||||
}; \
|
||||
LINKER_SET_ENTRY(mib, __mib_node_ ## _oid)
|
||||
|
||||
# define MIB_FUNCTION_WEAK(_oid, _type, _func, _arg) \
|
||||
static const struct mib_node __attribute__((used)) \
|
||||
__mib_node_weak_ ## _oid = { \
|
||||
.node_oid = _oid, \
|
||||
.node_type = _type | kOIDFunction | kOIDWeak, \
|
||||
.node_data.v_func = {_func, _arg} \
|
||||
}; \
|
||||
LINKER_SET_ENTRY(mib, __mib_node_weak_ ## _oid)
|
||||
|
||||
|
||||
/*
|
||||
* Find a node in the MIB.
|
||||
*/
|
||||
union mib_value *mib_find_oid(uint32_t oid);
|
||||
|
||||
/*
|
||||
* Find a node of an expected type in the MIB and return its value.
|
||||
* Returns false if the OID is not present.
|
||||
*
|
||||
* This interface should only be used for optional nodes; if a node
|
||||
* is expected to exist, use the mib_get_* interfaces to avoid duplicating
|
||||
* error checking.
|
||||
*/
|
||||
bool _mib_find(uint32_t oid, uint32_t node_type, void *value);
|
||||
bool mib_exists(uint32_t oid, void *value);
|
||||
/*
|
||||
* Return the value of an OID expected to be in the MIB; the
|
||||
* MIB will panic on behalf of the caller if the node is not
|
||||
* found.
|
||||
*/
|
||||
void _mib_get(uint32_t oid, uint32_t node_type, void *value);
|
||||
|
||||
#define MIB_GET_TEMPLATE(stype, type, oid_type) \
|
||||
static inline type \
|
||||
mib_get_##stype(uint32_t oid) { \
|
||||
type ret; \
|
||||
_mib_get(oid, oid_type, &ret); \
|
||||
return ret; \
|
||||
} \
|
||||
\
|
||||
static inline type \
|
||||
mib_get_##stype##_opt(uint32_t oid, type def) { \
|
||||
type ret = def; \
|
||||
_mib_find(oid, oid_type, &ret); \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
MIB_GET_TEMPLATE(u32, uint32_t, kOIDTypeUInt32)
|
||||
MIB_GET_TEMPLATE(s32, int32_t, kOIDTypeInt32)
|
||||
MIB_GET_TEMPLATE(u64, uint64_t, kOIDTypeUInt32)
|
||||
MIB_GET_TEMPLATE(s64, int64_t, kOIDTypeInt64)
|
||||
MIB_GET_TEMPLATE(addr, uintptr_t, kOIDTypeAddr)
|
||||
MIB_GET_TEMPLATE(size, size_t, kOIDTypeSize)
|
||||
MIB_GET_TEMPLATE(bool, bool, kOIDTypeBoolean)
|
||||
MIB_GET_TEMPLATE(str, const char *, kOIDTypeString)
|
||||
MIB_GET_TEMPLATE(ptr, const void *, kOIDTypeStruct)
|
||||
|
||||
#undef MIB_GET_TEMPLATE
|
||||
|
||||
/*
|
||||
* MIB node descriptions are automatically generated at build time.
|
||||
*/
|
||||
struct mib_description {
|
||||
uint32_t oid;
|
||||
const char *desc;
|
||||
};
|
||||
|
||||
extern struct mib_description mib_desc[];
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _MIB_H */
|
||||
@@ -0,0 +1,143 @@
|
||||
// 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 _MIB_DEF_H
|
||||
#define _MIB_DEF_H
|
||||
|
||||
#include <lib/mib.h>
|
||||
#include <platform/memmap.h>
|
||||
|
||||
// Application/Product selection
|
||||
#if PRODUCT_IBSS
|
||||
#define MIB_APP_PROD MIB_APP_PROD_IBSS
|
||||
#elif PRODUCT_IBEC
|
||||
#define MIB_APP_PROD MIB_APP_PROD_IBEC
|
||||
#elif PRODUCT_IBOOT
|
||||
#define MIB_APP_PROD MIB_APP_PROD_IBOOT
|
||||
#elif PRODUCT_LLB
|
||||
#define MIB_APP_PROD MIB_APP_PROD_LLB
|
||||
#elif APPLICATION_EMBEDDEDIOP
|
||||
#define MIB_APP_PROD MIB_APP_PROD_EMBEDDEDIOP
|
||||
#elif APPLICATION_SECUREROM
|
||||
#define MIB_APP_PROD MIB_APP_PROD_SECUREROM
|
||||
#else
|
||||
#error "Unknown APPLICATION/PRODUCT"
|
||||
#endif
|
||||
|
||||
// Standard MIB constants for all platforms and targets
|
||||
MIB_CONSTANT(kMIBPlatformCacheLineSize, kOIDTypeSize, CPU_CACHELINE_SIZE);
|
||||
MIB_CONSTANT(kMIBPlatformSDRAMBaseAddress, kOIDTypeAddr, SDRAM_BASE);
|
||||
MIB_CONSTANT(kMIBPlatformSDRAMSize, kOIDTypeSize, (SDRAM_END - SDRAM_BASE));
|
||||
MIB_CONSTANT(kMIBTargetApplicationProduct, kOIDTypeUInt32, MIB_APP_PROD);
|
||||
MIB_CONSTANT(kMIBPlatformPageSize, kOIDTypeSize, PAGE_SIZE);
|
||||
|
||||
#if WITH_IMAGE4
|
||||
MIB_CONSTANT(kMIBPlatformImageFormat, kOIDTypeUInt32, 4);
|
||||
#elif WITH_IMAGE3
|
||||
MIB_CONSTANT(kMIBPlatformImageFormat, kOIDTypeUInt32, 3);
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_ENTROPY_RATIO
|
||||
MIB_CONSTANT(kMIBPlatformEntropyRatio, kOIDTypeUInt32, PLATFORM_ENTROPY_RATIO);
|
||||
#endif
|
||||
|
||||
// All of the following depend upon INSECURE_MEMORY_BASE being defined
|
||||
#ifdef INSECURE_MEMORY_BASE
|
||||
|
||||
#ifdef DEFAULT_DEVICETREE_ADDRESS
|
||||
MIB_CONSTANT(kMIBTargetDefaultDeviceTreeAddress,kOIDTypeAddr, DEFAULT_DEVICETREE_ADDRESS);
|
||||
#endif
|
||||
|
||||
#ifdef DEFAULT_DEVICETREE_SIZE
|
||||
MIB_CONSTANT(kMIBTargetDefaultDeviceTreeSize, kOIDTypeSize, DEFAULT_DEVICETREE_SIZE);
|
||||
#endif
|
||||
|
||||
#ifdef DEFAULT_FREE_ADDRESS
|
||||
MIB_CONSTANT(kMIBTargetDefaultFreeAddress, kOIDTypeAddr, DEFAULT_FREE_ADDRESS);
|
||||
#endif
|
||||
|
||||
#ifdef DEFAULT_LOAD_ADDRESS
|
||||
MIB_CONSTANT(kMIBTargetDefaultLoadAddress, kOIDTypeAddr, DEFAULT_LOAD_ADDRESS);
|
||||
#endif
|
||||
|
||||
#ifdef DEFAULT_LOAD_SIZE
|
||||
MIB_CONSTANT(kMIBTargetDefaultLoadSize, kOIDTypeSize, DEFAULT_LOAD_SIZE);
|
||||
#endif
|
||||
|
||||
#ifdef DEFAULT_KERNEL_ADDRESS
|
||||
MIB_CONSTANT(kMIBTargetDefaultKernelAddress, kOIDTypeAddr, DEFAULT_KERNEL_ADDRESS);
|
||||
#endif
|
||||
|
||||
#ifdef DEFAULT_KERNEL_SIZE
|
||||
MIB_CONSTANT(kMIBTargetDefaultKernelSize, kOIDTypeSize, DEFAULT_KERNEL_SIZE);
|
||||
#endif
|
||||
|
||||
#ifdef DEFAULT_RAMDISK_ADDRESS
|
||||
MIB_CONSTANT(kMIBTargetDefaultRamdiskAddress, kOIDTypeAddr, DEFAULT_RAMDISK_ADDRESS);
|
||||
#endif
|
||||
|
||||
#ifdef DEFAULT_RAMDISK_SIZE
|
||||
MIB_CONSTANT(kMIBTargetDefaultRamdiskSize, kOIDTypeSize, DEFAULT_RAMDISK_SIZE);
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_BASE
|
||||
MIB_CONSTANT(kMIBTargetDisplayBaseAddress, kOIDTypeAddr, DISPLAY_BASE);
|
||||
#endif
|
||||
|
||||
#endif // INSECURE_MEMORY_BASE
|
||||
|
||||
#ifdef PANIC_BASE
|
||||
MIB_CONSTANT(kMIBTargetPanicBufferAddress, kOIDTypeAddr, PANIC_BASE);
|
||||
#endif
|
||||
|
||||
#ifdef PANIC_SIZE
|
||||
MIB_CONSTANT(kMIBTargetPanicBufferSize, kOIDTypeSize, PANIC_SIZE);
|
||||
#endif
|
||||
|
||||
#if (PRODUCT_LLB || APPLICATION_SECUREROM) && WITH_NO_RANDOM_HEAP_COOKIE
|
||||
MIB_CONSTANT(kMIBTargetRandomHeapCookie, kOIDTypeBoolean, false);
|
||||
#else
|
||||
MIB_CONSTANT(kMIBTargetRandomHeapCookie, kOIDTypeBoolean, true);
|
||||
#endif
|
||||
|
||||
// Target-specified MIB weak overrides
|
||||
#if WITH_HW_ASP
|
||||
MIB_CONSTANT(kMIBTargetWithHwAsp, kOIDTypeBoolean, true);
|
||||
#endif
|
||||
|
||||
#if WITH_EFFACEABLE
|
||||
MIB_CONSTANT(kMIBTargetWithEffaceable, kOIDTypeBoolean, true);
|
||||
#endif
|
||||
|
||||
#if WITH_FS
|
||||
MIB_CONSTANT(kMIBTargetWithFileSystem, kOIDTypeBoolean, true);
|
||||
#endif
|
||||
|
||||
#if WITH_HW_FLASH_NAND
|
||||
MIB_CONSTANT(kMIBTargetWithHwFlashNand, kOIDTypeBoolean, true);
|
||||
#endif
|
||||
|
||||
#if WITH_HW_FLASH_NOR
|
||||
MIB_CONSTANT(kMIBTargetWithHwFlashNor, kOIDTypeBoolean, true);
|
||||
#endif
|
||||
|
||||
#if WITH_NVME
|
||||
MIB_CONSTANT(kMIBTargetWithHwNvme, kOIDTypeBoolean, true);
|
||||
#endif
|
||||
|
||||
#if WITH_LEGACY_PANIC_LOGS
|
||||
MIB_CONSTANT(kMIBTargetWithLegacyPanicLogs, kOIDTypeBoolean, true);
|
||||
#endif
|
||||
|
||||
// Get rid of intermediate abstractions
|
||||
#undef MIB_APP_PROD
|
||||
|
||||
#endif /* _MIB_DEF_H */
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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 __LIB_NET_H
|
||||
#define __LIB_NET_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int start_network_stack(void);
|
||||
int stop_network_stack(void);
|
||||
|
||||
/* ip and mac address string manipulation routines */
|
||||
void mac2str(uint8_t mac[6], char *ascii, size_t size);
|
||||
void ip2str(const uint8_t *ip, char *str, size_t size);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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 __ARP_H__
|
||||
#define __ARP_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define ARP_OFFSET_HTYPE 0
|
||||
#define ARP_OFFSET_PTYPE 2
|
||||
#define ARP_OFFSET_HLEN 4
|
||||
#define ARP_OFFSET_PLEN 5
|
||||
#define ARP_OFFSET_OPER 6
|
||||
#define ARP_OFFSET_SHA 8
|
||||
|
||||
int arp_layer(bool on);
|
||||
int arp_get_macaddr(uint32_t ip,char *mac);
|
||||
int arp_fill(uint32_t ip, utime_t timeout); /* send arp requests until it is satisfied or timeout */
|
||||
void arp_dump_table(void);
|
||||
|
||||
#define ARP_CACHE_SIZE 32
|
||||
|
||||
typedef struct arp_cache_entry {
|
||||
uint32_t ip;
|
||||
char mac[6];
|
||||
struct arp_cache_entry *next;
|
||||
} arp_cache_entry_t;
|
||||
|
||||
typedef struct arp_cache {
|
||||
arp_cache_entry_t cache[ARP_CACHE_SIZE];
|
||||
} arp_cache_t;
|
||||
|
||||
__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 __CALLBACKS_H__
|
||||
#define __CALLBACKS_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef int (*callback_handler)(char *data,int offset,int len,void *prevlayerdata);
|
||||
|
||||
struct listentry;
|
||||
|
||||
typedef struct listentry {
|
||||
int cb_id;
|
||||
int port; //port/service/etc
|
||||
callback_handler callback;
|
||||
struct listentry *next;
|
||||
} listentry_t;
|
||||
|
||||
typedef struct callbacks {
|
||||
listentry_t *first;
|
||||
}callbacks_t;
|
||||
|
||||
|
||||
int registerCallback(callbacks_t *,int port,callback_handler cb);
|
||||
int unregisterCallback(callbacks_t *cbs,int cb_id);
|
||||
callback_handler find_callback(callbacks_t *cbs,int port);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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 __ETHERNET_H__
|
||||
#define __ETHERNET_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/callout.h>
|
||||
|
||||
#include "callbacks.h"
|
||||
#include "xp.h"
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define ETHERTYPE_ARP 0x806
|
||||
#define ETHERTYPE_IPV4 0x800
|
||||
|
||||
#define ETHERNET_OFFSET 14
|
||||
|
||||
int registerEtherTypeHandler(int type,callback_handler cb);
|
||||
int unregisterEtherTypeHandler(int id);
|
||||
|
||||
int add_eth_and_transmit(mymbuf_t *,char *dstmac,int ethertype);
|
||||
|
||||
void ethernet_init(void);
|
||||
void ethernet_uninit(void);
|
||||
void ethernet_workloop(struct callout *c, void *param);
|
||||
void ethernet_input(mymbuf_t *inputbuf);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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 __ICMP_H___
|
||||
#define __ICMP_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "callbacks.h"
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define ICMP_ECHO 8
|
||||
#define ICMP_ECHOREPLY 0
|
||||
|
||||
int registerICMPHandler(int messagetype,callback_handler cb);
|
||||
int unregisterICMPHandler(int id);
|
||||
|
||||
int icmp_layer(bool on);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 __IPV4_H__
|
||||
#define __IPV4_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "callbacks.h"
|
||||
#include "xp.h"
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define IPV4_ICMP 1
|
||||
#define IPV4_TCP 6
|
||||
#define IPV4_UDP 17
|
||||
|
||||
int ipv4_layer(bool on);
|
||||
int registerIPV4Handler(int protocol,callback_handler handler);
|
||||
int unregisterIPV4Handler(int id);
|
||||
|
||||
uint32_t ipv4_get_ip();
|
||||
void ipv4_set_ip(uint32_t ip);
|
||||
|
||||
int transmit_and_add_ipv4(mymbuf_t *mbuf,uint32_t dest,int protocol);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 __LIB_NET_MBUF_H
|
||||
#define __LIB_NET_MBUF_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define USE_BUILTIN_MBUF 1
|
||||
#if defined(USE_BUILTIN_MBUF) && USE_BUILTIN_MBUF
|
||||
struct mbufentry;
|
||||
|
||||
typedef struct mbufentry {
|
||||
int flag;
|
||||
int len;
|
||||
char *data;
|
||||
struct mbufentry *next;
|
||||
} mbufentry_t;
|
||||
|
||||
typedef struct mymbuf {
|
||||
mbufentry_t *first;
|
||||
int allocated_length;
|
||||
int current_length;
|
||||
char *primarydata;
|
||||
int offset;
|
||||
}mymbuf_t;
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
|
||||
mymbuf_t * mbuf_initialize(int packetsize,int header,int trailer);
|
||||
void mbuf_destroy(mymbuf_t *data);
|
||||
char* mbuf_head(mymbuf_t *buffer, int len);
|
||||
char* mbuf_tail(mymbuf_t *buffer, int len);
|
||||
int mbuf_getlength(mymbuf_t *buffer);
|
||||
char * mbuf_getlinear(mymbuf_t *buffer);
|
||||
void mbuf_setlength(mymbuf_t *buffer,int len);
|
||||
void mbuf_setoffset(mymbuf_t *buffer,int offset);
|
||||
int mbuf_getallocatedlength(mymbuf_t *buffer);
|
||||
int mbuf_copy(mymbuf_t *dest, const mymbuf_t *src);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 __UDP_H__
|
||||
#define __UDP_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int transmit_udp(mymbuf_t *data, uint32_t toip,int toport, int fromport);
|
||||
int unregisterUDPHandler(int id);
|
||||
int registerUDPHandler(int port,callback_handler cb);
|
||||
int udp_layer(bool on);
|
||||
|
||||
|
||||
typedef struct udpinfo {
|
||||
uint32_t srcip;
|
||||
uint16_t srcport;
|
||||
uint16_t length;
|
||||
} udpinfo_t;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 __XP_H__
|
||||
#define __XP_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <lib/net/mbuf.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
//Card specific instructions.
|
||||
|
||||
int xp_initialize(void);
|
||||
int xp_getmac(uint8_t *addr);
|
||||
void xp_packet_input(void *ethptr, mymbuf_t *inputbuf);
|
||||
//mymbuf_t * xp_get_packet(mymbuf_t *);
|
||||
int xp_transmit_packet(mymbuf_t *buffer);
|
||||
#define htons(A) ( (((A) & 0xff00) >> 8) | \
|
||||
((A) & 0x00ff) << 8)
|
||||
#define htonl(A) ( (((A) & 0xff000000) >> 24) | \
|
||||
(((A) & 0x00ff0000) >> 8) | \
|
||||
(((A) & 0x0000ff00) << 8) | \
|
||||
(((A) & 0x000000ff) << 24))
|
||||
#define ntohs htons
|
||||
#define ntohl htonl
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 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 _NONCE_H_
|
||||
#define _NONCE_H_
|
||||
|
||||
// =============================================================================
|
||||
|
||||
#include <sys/hash.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if HASH_OUTPUT_SIZE > 32 // Bytes
|
||||
#define NONCE_HASH_OUTPUT_SIZE (32)
|
||||
#else
|
||||
#define NONCE_HASH_OUTPUT_SIZE HASH_OUTPUT_SIZE
|
||||
#endif
|
||||
|
||||
int mobile_ap_nonce_consume_nonce(uint64_t *nonce);
|
||||
|
||||
#endif /* _NONCE_H_ */
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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 __LIB_NVRAM_H
|
||||
#define __LIB_NVRAM_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <lib/devicetree.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int nvram_load(void);
|
||||
int nvram_save(void); // write out the environment
|
||||
int nvram_set_panic(const void *base, size_t length); // copy panic log to staging
|
||||
int nvram_update_devicetree(dt_node_t *node, const char *propname); // copy nvram content to devicetree
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
Loaded 100 of 2612 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user