first and last commit
This commit is contained in:
commit
1bf4efd552
2612 files changed
+636500
No files matched your search
@@ -0,0 +1 @@
|
||||
// Empty file
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/////
|
||||
//
|
||||
// Whimory Feature Definitions
|
||||
//
|
||||
/////
|
||||
|
||||
#include "WMRTypes.h"
|
||||
|
||||
#ifndef _WMR_FEATURES_H_
|
||||
#define _WMR_FEATURES_H_
|
||||
|
||||
// Define the platform we're on
|
||||
#define WMR_BUILDING_IBOOT (1)
|
||||
|
||||
// Don't bother collect stats in read-only mode
|
||||
//#define AND_COLLECT_STATISTICS (1)
|
||||
|
||||
// Defined by platform, but they're all OK with 30 for now
|
||||
#define FIL_MAX_ECC_CORRECTION (30)
|
||||
|
||||
// =============================================================================
|
||||
// configurable preprocessor compilation control
|
||||
// =============================================================================
|
||||
|
||||
// Set H2FMI_DEBUG below to 1 if you want to build for debugging (default
|
||||
// to 0).
|
||||
#define H2FMI_DEBUG 1
|
||||
|
||||
// Set H2FMI_TEST_HOOK below to 1 if you want to insert tests at the end
|
||||
// of FIL_Init in iBoot (default to 0).
|
||||
#define H2FMI_TEST_HOOK 0
|
||||
|
||||
// Set H2FMI_WAIT_USING_ISR to true if you want operations to wait for
|
||||
// dma and bus events by hooking an interrupt service routine to the
|
||||
// FMI interrupt vector; set to false for waiting using register
|
||||
// polling with yield (default to true).
|
||||
#define H2FMI_WAIT_USING_ISR 1
|
||||
|
||||
#define H2FMI_INSTRUMENT_BUS_1 0
|
||||
|
||||
// Change the constant below to 1 if you want to see all FMI
|
||||
// subsystem register writes; note that doing so is likely to change
|
||||
// timing and therefore behavior, so it should be a rare case that you
|
||||
// would ever want to do this. In cases where you want to see just
|
||||
// one or two writes, consider calling the 'h2fmi_dbg_wr' or
|
||||
// 'h2fmi_dbg_wr8' function directly (default to 0).
|
||||
#define H2FMI_TRACE_REG_WRITES 0
|
||||
|
||||
// Change the constant below to 1 if you want to see all FMI
|
||||
// subsystem register reads; note that doing so is likely to change
|
||||
// timing and therefore behavior, so it should be a rare case that you
|
||||
// would ever want to do this. In cases where you want to see just
|
||||
// one or two reads, consider calling the 'h2fmi_dbg_rd' or
|
||||
// 'h2fmi_dbg_rd8' function directly (default to 0).
|
||||
#define H2FMI_TRACE_REG_READS 0
|
||||
|
||||
// =============================================================================
|
||||
// fixed preprocessor compilation control
|
||||
// =============================================================================
|
||||
|
||||
#define H2FMI_BOOTROM 0
|
||||
#define H2FMI_IOP 1
|
||||
#define H2FMI_IBOOT 0
|
||||
#define H2FMI_EFI 0
|
||||
|
||||
#define H2FMI_READONLY 0
|
||||
#endif /* _WMR_FEATURES_H_ */
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
#include "WMRConfig.h"
|
||||
#include "ANDTypes.h"
|
||||
#include "WMROAM.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <lib/heap.h>
|
||||
#include <sys.h>
|
||||
#include <sys/task.h>
|
||||
#include <platform.h>
|
||||
#include <platform/soc/hwclocks.h>
|
||||
#include <platform/timer.h>
|
||||
|
||||
void *
|
||||
WMR_MALLOC(UInt32 nSize)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = memalign(nSize, CPU_CACHELINE_SIZE);
|
||||
WMR_MEMSET(p, 0, nSize);
|
||||
return p;
|
||||
}
|
||||
|
||||
BOOL32
|
||||
OAM_Init(void)
|
||||
{
|
||||
return TRUE32;
|
||||
}
|
||||
|
||||
void OAM_Beep(UInt32 dwMs)
|
||||
{
|
||||
}
|
||||
|
||||
void WMR_FREE(void * ptr, UInt32 size)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
BOOL32 WMR_CHECK_BUFFER(const void * buffer, UInt32 length)
|
||||
{
|
||||
return (((UInt32) buffer % CPU_CACHELINE_SIZE) == 0) ? TRUE32 : FALSE32;
|
||||
}
|
||||
|
||||
BOOL32
|
||||
WMR_FILL_STRUCT(void *pDstBuff, UInt32 *pdwDstBuffSize, const void *pSrcBuff, UInt32 dwSrcBuffSize)
|
||||
{
|
||||
BOOL32 boolRes = TRUE32;
|
||||
|
||||
if (!pDstBuff && pdwDstBuffSize)
|
||||
{
|
||||
// Just return the buffer size
|
||||
*pdwDstBuffSize = dwSrcBuffSize;
|
||||
}
|
||||
else if (!pdwDstBuffSize || (*pdwDstBuffSize < dwSrcBuffSize))
|
||||
{
|
||||
// Supplied buffer is too small
|
||||
UInt32 dwPrintedSize = pdwDstBuffSize ? *pdwDstBuffSize : (UInt32) ~0;
|
||||
WMR_PRINT(ERROR,"IOCtl on buffer of size %d with %d bytes of src data!\n",
|
||||
dwPrintedSize, dwSrcBuffSize);
|
||||
boolRes = FALSE32;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have a valid buffer pointer and buffer size
|
||||
WMR_MEMCPY(pDstBuff, pSrcBuff, dwSrcBuffSize);
|
||||
*pdwDstBuffSize = dwSrcBuffSize;
|
||||
}
|
||||
|
||||
return boolRes;
|
||||
}
|
||||
|
||||
void _WMR_PRINT(const char * format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
// retrieve the variable arguments
|
||||
va_start(args, format);
|
||||
|
||||
vprintf(format, args);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
WMR_BEEP(UInt32 milliseconds)
|
||||
{
|
||||
printf("WMR_BEEP\n");
|
||||
}
|
||||
|
||||
const char * WMR_GETVERSION(void)
|
||||
{
|
||||
static char version[] = "version string";
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
BOOL32
|
||||
WMR_I_CAN_HAZ_DEBUGGER(void)
|
||||
{
|
||||
return FALSE32;
|
||||
}
|
||||
|
||||
void WMR_WAIT_US(UInt64 microseconds)
|
||||
{
|
||||
spin(microseconds);
|
||||
}
|
||||
|
||||
void WMR_SLEEP_US(UInt32 microseconds)
|
||||
{
|
||||
task_sleep(microseconds);
|
||||
}
|
||||
|
||||
void WMR_YIELD(void)
|
||||
{
|
||||
// Task yield is not available to libraries, so can't build it into Whimory
|
||||
task_yield();
|
||||
}
|
||||
|
||||
void
|
||||
WMR_DEADLOOP(void)
|
||||
{
|
||||
volatile int i = 1;
|
||||
while (i)
|
||||
{
|
||||
(void) 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WMR_CLOCK_RESET_DEVICE(UInt32 device)
|
||||
{
|
||||
int clock;
|
||||
|
||||
if( device == 0 )
|
||||
{
|
||||
clock = CLK_FMI0;
|
||||
}
|
||||
else if( device == 1 )
|
||||
{
|
||||
clock = CLK_FMI1;
|
||||
}
|
||||
else
|
||||
{
|
||||
panic("invalid WMR_CLOCK_RESET_DEVICE");
|
||||
}
|
||||
|
||||
clock_reset_device(clock);
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "ANDTypes.h"
|
||||
#include "WMRFeatures.h"
|
||||
|
||||
#include <string.h> // memcmp
|
||||
#include <sys.h> // panic
|
||||
#include <platform.h> // cache
|
||||
#include <platform/timer.h> // ticks
|
||||
|
||||
#ifndef _WMR_PLATFORM_H_
|
||||
#define _WMR_PLATFORM_H_
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WMR_LOG2
|
||||
//
|
||||
// Returns the floor(log2) of the given number
|
||||
//
|
||||
#define WMR_LOG2(x) (31UL - __builtin_clz((UInt32)(x)))
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WMR_MEMSET
|
||||
// WMR_MEMCPY
|
||||
// WMR_MEMCMP
|
||||
//
|
||||
// Standard memory operations (libraries where available)
|
||||
//
|
||||
|
||||
#define WMR_MEMSET(dest, pattern, length) memset((dest), (pattern), (length))
|
||||
#define WMR_MEMCPY(dest, src, length) memcpy((dest), (src), (length))
|
||||
#define WMR_MEMCMP(buf1, buf2, length) memcmp((buf1), (buf2), (length))
|
||||
#define WMR_STRLEN(str) strlen((str))
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WMR_ASSERT
|
||||
//
|
||||
// Print an error and panic if the given condition is not true
|
||||
//
|
||||
|
||||
# define WMR_ASSERT(_expr) \
|
||||
do { \
|
||||
if (__builtin_expect(!(_expr), 0)) \
|
||||
panic("WMR_ASSERT failed:(%s) %s:%u", \
|
||||
#_expr, __FILE__, __LINE__); \
|
||||
} while(0);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WMR_PANIC
|
||||
//
|
||||
// Reset the system
|
||||
//
|
||||
# define WMR_PANIC(fmt, ...) \
|
||||
panic("WMR_PANIC: " #fmt " %s:%u", \
|
||||
## __VA_ARGS__, __FILE__, __LINE__)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WMR_PREPARE_WRITE_BUFFER
|
||||
//
|
||||
// Call before an outgoing I/O operation to ensure cache coherency
|
||||
//
|
||||
|
||||
#define WRITE_PREP_CACHE_CMD (CACHE_CLEAN)
|
||||
|
||||
#if (defined(WMR_USE_FULL_CACHE_FLUSH) && WMR_USE_FULL_CACHE_FLUSH)
|
||||
#define WMR_PREPARE_WRITE_BUFFER(buf, length) \
|
||||
platform_cache_operation(WRITE_PREP_CACHE_CMD, 0, 0)
|
||||
#else //WMR_USE_FULL_CACHE_FLUSH
|
||||
#if WMR_DEBUG
|
||||
#define WMR_PREPARE_WRITE_BUFFER(buf, length) \
|
||||
do{ \
|
||||
WMR_ASSERT(0 == ((UInt32)(buf) % CPU_CACHELINE_SIZE)); \
|
||||
platform_cache_operation(WRITE_PREP_CACHE_CMD, (buf), ROUNDUPTO((length), CPU_CACHELINE_SIZE));\
|
||||
}while(0)
|
||||
#else
|
||||
#define WMR_PREPARE_WRITE_BUFFER(buf, length) \
|
||||
platform_cache_operation(WRITE_PREP_CACHE_CMD, (buf), ROUNDUPTO((length), CPU_CACHELINE_SIZE))
|
||||
#endif// !WMR_DEBUG
|
||||
#endif // !WMR_USE_FULL_CACHE_FLUSH
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WMR_PREPARE_READ_BUFFER
|
||||
//
|
||||
// Call before an incoming I/O operation to ensure cache coherency
|
||||
//
|
||||
// Note: On the IOP, we only prepare aligned read buffers from the host, so we
|
||||
// shouldn't have to actually clean any dirty lines
|
||||
#define READ_PREP_CACHE_CMD (CACHE_CLEAN | CACHE_INVALIDATE)
|
||||
|
||||
#if (defined(WMR_USE_FULL_CACHE_FLUSH) && WMR_USE_FULL_CACHE_FLUSH)
|
||||
#define WMR_PREPARE_READ_BUFFER(buf, length) \
|
||||
platform_cache_operation(READ_PREP_CACHE_CMD, 0, 0)
|
||||
#else //WMR_USE_FULL_CACHE_FLUSH
|
||||
#if WMR_DEBUG
|
||||
#define WMR_PREPARE_READ_BUFFER(buf, length) \
|
||||
do{ \
|
||||
WMR_ASSERT(0 == ((UInt32)(buf) % CPU_CACHELINE_SIZE)); \
|
||||
platform_cache_operation(READ_PREP_CACHE_CMD, (buf), ROUNDUPTO((length), CPU_CACHELINE_SIZE));\
|
||||
}while(0)
|
||||
#else
|
||||
#define WMR_PREPARE_READ_BUFFER(buf, length) \
|
||||
platform_cache_operation(READ_PREP_CACHE_CMD, (buf), ROUNDUPTO((length), CPU_CACHELINE_SIZE))
|
||||
#endif// !WMR_DEBUG
|
||||
#endif // !WMR_USE_FULL_CACHE_FLUSH
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WMR_COMPLETE_READ_BUFFER
|
||||
//
|
||||
// Call after an incoming I/O operation to ensure cache coherency
|
||||
//
|
||||
// Note: On the IOP, we only prepare aligned read buffers from the host, so we
|
||||
// shouldn't have to actually clean any dirty lines
|
||||
#define WMR_COMPLETE_READ_BUFFER(buf, length) \
|
||||
WMR_PREPARE_READ_BUFFER(buf, length)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WMR_GET_TICKS_PER_US
|
||||
//
|
||||
// Return the number of native ticks (as returned from WMR_CLOCK_NATIVE) per
|
||||
// microsecond.
|
||||
//
|
||||
|
||||
// UInt32
|
||||
#define WMR_GET_TICKS_PER_US() (timer_get_tick_rate() / 1000000UL)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WMR_CLOCK_NATIVE
|
||||
//
|
||||
// Get the current system time in microseconds to be passed to
|
||||
// WMR_HAS_TIME_ELAPSED_US and WMR_HAS_TIME_ELAPSED_MS, but NOT
|
||||
// WMR_HAS_TIME_ELAPSED_TICKS
|
||||
//
|
||||
|
||||
// UInt64
|
||||
#define WMR_CLOCK_NATIVE() system_time()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WMR_CLOCK_TICKS
|
||||
//
|
||||
// Get the current system time in ticks (suitable for WMR_HAS_TIME_ELAPSED_TICKS)
|
||||
//
|
||||
|
||||
//UInt64
|
||||
#define WMR_CLOCK_TICKS() timer_get_ticks()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WMR_HAS_TIME_ELAPSED_US
|
||||
//
|
||||
// Supply a start timestamp from WMR_CLOCK_NATIVE to determine if the given
|
||||
// time has elapsed
|
||||
//
|
||||
|
||||
//UInt64 startTicks, UInt64 elapsedUS
|
||||
#define WMR_HAS_TIME_ELAPSED_US(startTicks, elapsedUS) \
|
||||
(time_has_elapsed((startTicks), (elapsedUS)) ? TRUE32 : FALSE32)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WMR_HAS_TIME_ELAPSED_TICKS
|
||||
//
|
||||
// Supply a start timestamp from WMR_CLOCK_NATIVE to determine if the given
|
||||
// time has elapsed.
|
||||
|
||||
//UInt64 startTicks, UInt64 elapsedTicks
|
||||
#define WMR_HAS_TIME_ELAPSED_TICKS(startTicks, elapsedTicks) \
|
||||
((timer_get_ticks() - (startTicks)) > (elapsedTicks) ? TRUE32 : FALSE32)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WMR_ENTER_CRITICAL_SECTION
|
||||
//
|
||||
// Disable pre-emption, reference counted (safe to call in interrupt)
|
||||
|
||||
#define WMR_ENTER_CRITICAL_SECTION() enter_critical_section()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WMR_EXIT_CRITICAL_SECTION
|
||||
//
|
||||
// Enable pre-emption, reference counted (safe to call in interrupt)
|
||||
|
||||
#define WMR_EXIT_CRITICAL_SECTION() exit_critical_section()
|
||||
|
||||
#endif /* _WMR_PLATFORM_H_ */
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef _WMR_TYPES_H_
|
||||
#define _WMR_TYPES_H_
|
||||
|
||||
# include <sys/types.h>
|
||||
# include "spTypes.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Basic Types */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef UInt32 BOOL32;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Basic Constants */
|
||||
/*****************************************************************************/
|
||||
|
||||
#define FALSE32 ((BOOL32)0)
|
||||
#define TRUE32 ((BOOL32)1)
|
||||
|
||||
#ifndef NULL
|
||||
#ifdef __cplusplus
|
||||
#define NULL 0
|
||||
#else
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
# define __align(_x)
|
||||
/*****************************************************************************/
|
||||
/* Basic Compiler Flags */
|
||||
/*****************************************************************************/
|
||||
|
||||
#define INLINE __inline
|
||||
|
||||
#ifdef DEBUG_BUILD
|
||||
#define WMR_DEBUG (1)
|
||||
#else
|
||||
#define WMR_RELEASE (1)
|
||||
#endif
|
||||
|
||||
#endif /* _WMR_TYPES_H_ */
|
||||
|
||||
Reference in new issue
Block a user