1/* 2 * Copyright 2013, winocm. <winocm@icloud.com> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without modification, 6 * are permitted provided that the following conditions are met: 7 * 8 * Redistributions of source code must retain the above copyright notice, this 9 * list of conditions and the following disclaimer. 10 * 11 * Redistributions in binary form must reproduce the above copyright notice, this 12 * list of conditions and the following disclaimer in the documentation and/or 13 * other materials provided with the distribution. 14 * 15 * If you are going to use this software in any form that does not involve 16 * releasing the source to this project or improving it, let me know beforehand. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29/* 30 * Compatibility support to bridge old pe_arm_xxx api and new 31 * AWESOME SOC DISPATCH STUFF. 32 */ 33 34#include <mach/mach_types.h> 35 36#include <pexpert/pexpert.h> 37#include <pexpert/arm/protos.h> 38#include <pexpert/arm/boot.h> 39 40#include <machine/machine_routines.h> 41 42#include <kern/debug.h> 43 44/** 45 * pe_arm_init_interrupts 46 * 47 * Initialize the SoC dependent interrrupt controller. 48 */ 49uint32_t pe_arm_init_interrupts(__unused void *args) 50{ 51 if (gPESocDispatch.interrupt_init == NULL) 52 panic("gPESocDispatch.interrupt_init was null, did you forget to set up the table?"); 53 54 gPESocDispatch.interrupt_init(); 55 56 return 0; 57} 58 59/** 60 * pe_arm_init_interrupts 61 * 62 * Initialize the SoC dependent interrrupt controller. 63 */ 64uint32_t pe_arm_init_timebase(__unused void *args) 65{ 66 if (gPESocDispatch.timebase_init == NULL) 67 panic("gPESocDispatch.interrupt_init was null, did you forget to set up the table?"); 68 69 gPESocDispatch.timebase_init(); 70 71 return 0; 72} 73 74/** 75 * pe_arm_dispatch_interrupt 76 * 77 * Dispatch IRQ requests to the SoC specific handler. 78 */ 79boolean_t pe_arm_dispatch_interrupt(void *context) 80{ 81 if (gPESocDispatch.handle_interrupt == NULL) 82 panic("gPESocDispatch.handle_interrupt was null, did you forget to set up the table?"); 83 84 gPESocDispatch.handle_interrupt(context); 85 86 return TRUE; 87} 88 89/** 90 * pe_arm_get_timebase 91 * 92 * Get current system timebase from the SoC handler. 93 */ 94uint64_t pe_arm_get_timebase(__unused void *args) 95{ 96 if (gPESocDispatch.get_timebase == NULL) 97 panic("gPESocDispatch.interrupt_init was null, did you forget to set up the table?"); 98 99 return gPESocDispatch.get_timebase(); 100} 101 102/** 103 * pe_arm_get_timebase 104 * 105 * Get current system timebase from the SoC handler. 106 */ 107void pe_arm_set_timer_enabled(boolean_t enable) 108{ 109 if (gPESocDispatch.timer_enabled == NULL) 110 panic("gPESocDispatch.interrupt_init was null, did you forget to set up the table?"); 111 112 gPESocDispatch.timer_enabled(enable); 113} 114 115/* 116 * iOS like functionality. 117 */ 118uint32_t debug_enabled = 1; 119 120uint32_t PE_i_can_has_debugger(uint32_t * pe_debug) 121{ 122 if (pe_debug) { 123 if (debug_enabled) 124 *pe_debug = 1; 125 else 126 *pe_debug = 0; 127 } 128 return debug_enabled; 129} 130 131uint32_t PE_get_security_epoch(void) 132{ 133 return 0; 134} 135