├── .gitignore ├── .gitmodules ├── Doxyfile ├── LICENSE.txt ├── Makefile ├── README.md ├── SConstruct ├── acm ├── SConscript └── acm.c ├── actions.c ├── aes_wrap.c ├── arch-arm ├── SConscript ├── arm.c ├── asmhelpers.sx ├── entry.sx └── includes │ ├── arm │ └── arm.h │ └── hardware │ └── arm.h ├── audiohw-null.c ├── audiohw.c ├── bdev.c ├── commands.c ├── device.c ├── docs └── readme.txt ├── doxygen └── readme.txt ├── framebuffer.c ├── ftl-yaftl ├── SConscript ├── includes │ └── ftl │ │ ├── l2v.h │ │ ├── yaftl.h │ │ ├── yaftl_common.h │ │ ├── yaftl_gc.h │ │ └── yaftl_mem.h ├── l2v.c ├── yaftl.c ├── yaftl_common.c ├── yaftl_gc.c └── yaftl_mem.c ├── ftl.c ├── hfs ├── SConscript ├── bdev.c ├── btree.c ├── catalog.c ├── extents.c ├── fastunicodecompare.c ├── fs.c ├── hfscompress.c ├── rawfile.c ├── utility.c ├── volume.c └── xattr.c ├── images.c ├── images ├── .gitignore ├── README ├── SConscript └── bin2c.c ├── includes ├── actions.h ├── aes.h ├── als.h ├── audiocodec.h ├── bdev.h ├── buttons.h ├── camera.h ├── chipid.h ├── clock.h ├── commands.h ├── device.h ├── dma.h ├── error.h ├── event.h ├── framebuffer.h ├── ftl.h ├── gpio.h ├── hardware │ └── edgeic.h ├── hfs │ ├── bdev.h │ ├── common.h │ ├── fs.h │ ├── hfscompress.h │ ├── hfscprotect.h │ ├── hfslib.h │ └── hfsplus.h ├── i2c.h ├── images.h ├── interrupt.h ├── lcd.h ├── malloc-2.8.3.h ├── miu.h ├── mmu.h ├── mtd.h ├── multitouch.h ├── nand.h ├── nvram.h ├── openiboot.h ├── piezo.h ├── platform.h ├── pmu.h ├── power.h ├── printf.h ├── radio.h ├── scripting.h ├── sdio.h ├── sha1.h ├── spi.h ├── stb_image.h ├── syscfg.h ├── tasks.h ├── timer.h ├── uart.h ├── usb.h ├── usbphy.h ├── util.h ├── vfl.h ├── vibrator.h ├── wdt.h └── wlan.h ├── init.c ├── installer ├── SConscript ├── images │ ├── .gitignore │ ├── installerBar.svg │ ├── installerBarEmpty.png │ ├── installerBarFull.png │ └── installerLogo.png └── installer.c ├── malloc.c ├── menu ├── SConscript ├── images │ ├── .gitignore │ ├── AndroidOS.png │ ├── AndroidOSSelected.png │ ├── Console.png │ ├── ConsoleSelected.png │ ├── Header.png │ ├── iPhoneOS.png │ └── iPhoneOSSelected.png └── menu.c ├── mk8900image ├── .gitignore ├── 8900.h ├── Makefile ├── SConscript ├── abstractfile.h ├── blank ├── common.h ├── iboot-template.img2 ├── ibootim.h ├── img2.h ├── iphonelinux.der ├── lzss.h ├── lzssfile.h ├── mac-x86 │ ├── libcommon.a │ └── libxpwn.a ├── mk8900image.c ├── nor_files.h ├── template-3g.img3 ├── template-4g.img3 ├── template-ipt1g.img3 ├── template-ipt2g.img3 ├── template-wtf.img2 ├── template.img2 ├── template.img3 ├── x86 │ ├── libcommon.a │ └── libxpwn.a └── x86_64 │ ├── libcommon.a │ └── libxpwn.a ├── mtd.c ├── nand.c ├── nor-cfi ├── SConscript ├── includes │ └── hardware │ │ └── nor.h └── nor.c ├── nor-spi ├── SConscript ├── includes │ └── hardware │ │ └── nor.h └── nor.c ├── nvram.c ├── openiboot.S.h ├── openiboot.c ├── pcf ├── 6x10.h ├── 9x15.h ├── Makefile ├── README ├── bin2.c ├── oif.c └── pcf.c ├── plat-a4 ├── SConscript ├── a4.c ├── aTV2G.SConscript ├── accel.c ├── aes.c ├── buttons.c ├── cdma.c ├── chipid.c ├── clcd.c ├── clock.c ├── event.c ├── gpio.c ├── h2fmi.c ├── i2c.c ├── iPad1G.SConscript ├── iPhone4G.SConscript ├── iPodTouch4G.SConscript ├── includes │ ├── a4 │ │ └── pmu.h │ ├── cdma.h │ ├── h2fmi.h │ ├── hardware │ │ ├── a4.h │ │ ├── accel.h │ │ ├── buttons.h │ │ ├── chipid.h │ │ ├── clcd.h │ │ ├── clock.h │ │ ├── dma.h │ │ ├── gpio.h │ │ ├── h2fmi.h │ │ ├── i2c.h │ │ ├── interrupt.h │ │ ├── mipi_dsim.h │ │ ├── platform.h │ │ ├── pmu.h │ │ ├── power.h │ │ ├── radio.h │ │ ├── sdio.h │ │ ├── spi.h │ │ ├── timer.h │ │ ├── uart.h │ │ └── usbphy.h │ └── mipi_dsim.h ├── interrupt.c ├── mcu.c ├── mipi_dsim.c ├── miu.c ├── mmu.c ├── pmu.c ├── power.c ├── sdio.c ├── spi.c ├── timer.c ├── uart.c └── usbphy.c ├── plat-s5l8720 ├── SConscript ├── accel.c ├── aes.c ├── buttons.c ├── chipid.c ├── clcd.c ├── clock.c ├── dma.c ├── event.c ├── gpio.c ├── i2c.c ├── iPodTouch2G.SConscript ├── includes │ ├── hardware │ │ ├── accel.h │ │ ├── aes.h │ │ ├── buttons.h │ │ ├── chipid.h │ │ ├── clcd.h │ │ ├── clock.h │ │ ├── dma.h │ │ ├── gpio.h │ │ ├── i2c.h │ │ ├── interrupt.h │ │ ├── lcd.h │ │ ├── mipi_dsim.h │ │ ├── platform.h │ │ ├── pmu.h │ │ ├── power.h │ │ ├── radio.h │ │ ├── s5l8720.h │ │ ├── spi.h │ │ ├── timer.h │ │ ├── uart.h │ │ └── usbphy.h │ └── mipi_dsim.h ├── interrupt.c ├── mipi_dsim.c ├── miu.c ├── mmu.c ├── pmu.c ├── power.c ├── s5l8720.c ├── spi.c ├── timer.c ├── uart.c ├── usbphy.c └── wdt.c ├── plat-s5l8900 ├── SConscript ├── accel.c ├── aes.c ├── als-ISL29003.c ├── als-TSL2561.c ├── buttons.c ├── camera.c ├── chipid.c ├── clock.c ├── dma.c ├── event.c ├── ftl.c ├── gpio.c ├── i2c.c ├── iPhone2G.SConscript ├── iPhone3G.SConscript ├── iPodTouch1G.SConscript ├── includes │ ├── hardware │ │ ├── accel.h │ │ ├── aes.h │ │ ├── als.h │ │ ├── audiocodec.h │ │ ├── buttons.h │ │ ├── camera.h │ │ ├── chipid.h │ │ ├── clock.h │ │ ├── dma.h │ │ ├── gpio.h │ │ ├── i2c.h │ │ ├── i2s.h │ │ ├── interrupt.h │ │ ├── lcd.h │ │ ├── multitouch.h │ │ ├── nand.h │ │ ├── platform.h │ │ ├── pmu.h │ │ ├── power.h │ │ ├── radio.h │ │ ├── s5l8900.h │ │ ├── sdio.h │ │ ├── spi.h │ │ ├── timer.h │ │ ├── uart.h │ │ └── usbphy.h │ └── s5l8900 │ │ ├── ftl.h │ │ └── nand.h ├── interrupt.c ├── lcd.c ├── miu.c ├── mmu.c ├── multitouch-z1.c ├── multitouch-z2.c ├── nand.c ├── piezo.c ├── pmu.c ├── power.c ├── s5l8900.c ├── sdio.c ├── spi.c ├── timer.c ├── uart.c ├── usbphy.c ├── vibrator-2G.c ├── vibrator-3G.c ├── wdt.c ├── wlan.c ├── wm8958.c └── wm8991.c ├── plat-s5l8920 ├── SConscript ├── aes.c ├── buttons.c ├── cdma.c ├── chipid.c ├── clcd.c ├── clock.c ├── event.c ├── gpio.c ├── h2fmi.c ├── i2c.c ├── iPhone3GS.SConscript ├── includes │ ├── cdma.h │ ├── h2fmi.h │ ├── hardware │ │ ├── buttons.h │ │ ├── chipid.h │ │ ├── clcd.h │ │ ├── clock.h │ │ ├── dma.h │ │ ├── gpio.h │ │ ├── h2fmi.h │ │ ├── i2c.h │ │ ├── interrupt.h │ │ ├── lcd.h │ │ ├── mipi_dsim.h │ │ ├── platform.h │ │ ├── power.h │ │ ├── radio.h │ │ ├── s5l8920.h │ │ ├── spi.h │ │ ├── timer.h │ │ ├── uart.h │ │ └── usbphy.h │ └── mipi_dsim.h ├── interrupt.c ├── lcd.c ├── mipi_dsim.c ├── miu.c ├── mmu.c ├── power.c ├── s5l8920.c ├── spi.c ├── timer.c ├── uart.c └── usbphy.c ├── printf.c ├── radio-pmb8876 ├── SConscript └── radio.c ├── radio-pmb8878 ├── SConscript └── radio.c ├── radio-xgold618 ├── SConscript └── radio.c ├── scons ├── ARMEnvironment.SConscript ├── Doxygen.SConscript ├── Git.SConscript └── Module.SConscript ├── scripting.c ├── sentinel.c ├── sha1.c ├── stb_image.c ├── syscfg.c ├── tasks.c ├── usb-synopsys ├── SConscript ├── includes │ └── hardware │ │ └── usb.h └── usb.c ├── util.c ├── vfl-vfl ├── SConscript ├── includes │ └── vfl │ │ └── vfl.h └── vfl.c ├── vfl-vsvfl ├── SConscript ├── includes │ └── vfl │ │ └── vsvfl.h └── vsvfl.c └── vfl.c /.gitignore: -------------------------------------------------------------------------------- 1 | .sconsign.dblite 2 | *.img3 3 | *.img2 4 | *.bin 5 | *_openiboot 6 | *_openiboot_debug 7 | *_installer 8 | *_installer_debug 9 | iBSS.* 10 | *.o 11 | .oibc-history 12 | doxygen/* 13 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/.gitmodules -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(PLATFORM),IPHONE2G) 2 | TARGET = iphone_2g_openiboot.img3 3 | endif 4 | 5 | ifeq ($(PLATFORM),IPHONE3G) 6 | TARGET = iphone_3g_openiboot.img3 7 | endif 8 | 9 | ifeq ($(PLATFORM),IPT1G) 10 | TARGET = ipt_1g_openiboot.img3 11 | endif 12 | 13 | ifeq ($(PLATFORM),IPT2G) 14 | TARGET = ipt_2g_openiboot.img3 15 | endif 16 | 17 | ifeq ($(PLATFORM),IPHONE4) 18 | TARGET = iphone_4_openiboot.bin 19 | endif 20 | 21 | ifeq ($(PLATFORM),IPAD1G) 22 | TARGET = ipad_1g_openiboot.bin 23 | endif 24 | 25 | ifeq ($(PLATFORM),IPT4G) 26 | TARGET = ipt_4g_openiboot.bin 27 | endif 28 | 29 | ifeq ($(PLATFORM),ATV2G) 30 | TARGET = atv_2g_openiboot.bin 31 | endif 32 | 33 | all: 34 | scons $(TARGET) 35 | 36 | clean: 37 | scons -c * 38 | @cd ../utils/syringe; make clean_all 39 | @cd ../utils/oibc; make clean 40 | 41 | install: 42 | make -C ../utils/syringe 43 | sudo ../utils/syringe/utilities/loadibec $(TARGET) 44 | -------------------------------------------------------------------------------- /SConstruct: -------------------------------------------------------------------------------- 1 | # 2 | # The root build file for OpeniBoot. 3 | # 4 | 5 | import SCons 6 | 7 | # 8 | # Configuration, change this stuff 9 | # 10 | version="0.3" 11 | # /Configuration 12 | 13 | SConscript([ 14 | 'scons/ARMEnvironment.SConscript', 15 | 'scons/Git.SConscript', 16 | ]) 17 | Import('*') 18 | 19 | henv = Environment() 20 | Export('henv') 21 | henv.SConscript(['scons/Doxygen.SConscript']) 22 | 23 | env = ARMEnvironment() 24 | env.Append(CPPDEFINES=[ 25 | 'OPENIBOOT_VERSION='+version, 26 | 'OPENIBOOT_VERSION_BUILD='+GetGitCommit(), 27 | ]) 28 | env.Append(CPPFLAGS = ['-Wall', '-Werror', '-O2', '-Ttext=0x0']) 29 | Export('env') 30 | 31 | def localize(env, ls): 32 | return [File(f) for f in ls] 33 | env.AddMethod(localize, "Localize") 34 | 35 | # Documentation 36 | docs = henv.Doxygen("Doxyfile") 37 | Alias("docs", docs) 38 | 39 | # Base Target Sources 40 | base_src = env.Localize([ 41 | 'device.c', 42 | 'mtd.c', 43 | 'bdev.c', 44 | 'nand.c', 45 | 'vfl.c', 46 | 'ftl.c', 47 | 'audiohw.c', 48 | 'actions.c', 49 | 'commands.c', 50 | 'framebuffer.c', 51 | 'images.c', 52 | 'malloc.c', 53 | 'nvram.c', 54 | 'openiboot.c', 55 | 'printf.c', 56 | 'scripting.c', 57 | 'sha1.c', 58 | 'stb_image.c', 59 | 'syscfg.c', 60 | 'tasks.c', 61 | 'util.c', 62 | 'aes_wrap.c', 63 | ]) 64 | Export('base_src') 65 | 66 | # Build-Environment Modules 67 | henv.SConscript([ 68 | 'images/SConscript', 69 | 'mk8900image/SConscript', 70 | 'scons/Module.SConscript', 71 | ]) 72 | 73 | # Target Modules 74 | env.SConscript([ 75 | 'hfs/SConscript', 76 | 'radio-pmb8876/SConscript', 77 | 'radio-pmb8878/SConscript', 78 | 'radio-xgold618/SConscript', 79 | 'usb-synopsys/SConscript', 80 | 'nor-cfi/SConscript', 81 | 'nor-spi/SConscript', 82 | 'vfl-vfl/SConscript', 83 | 'vfl-vsvfl/SConscript', 84 | 'ftl-yaftl/SConscript', 85 | 'acm/SConscript', 86 | 'menu/SConscript', 87 | 'installer/SConscript', 88 | 'arch-arm/SConscript', 89 | ]) 90 | -------------------------------------------------------------------------------- /acm/SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | acm_src = env.Localize([ 4 | 'acm.c', 5 | ]) 6 | 7 | acm = env.CreateModule('acm', acm_src) 8 | acm.Append(CPPPATH = [Dir('includes')]) 9 | -------------------------------------------------------------------------------- /arch-arm/SConscript: -------------------------------------------------------------------------------- 1 | Import("*") 2 | 3 | env = env.Clone() 4 | env.Append(CPPPATH = [Dir('includes')]) 5 | env.Append(CPPDEFINES = ['CONFIG_ARM']) 6 | 7 | arch_arm_src = env.Localize([ 8 | 'entry.sx', 9 | 'asmhelpers.sx', 10 | 'arm.c', 11 | ]) 12 | Export('arch_arm_src') 13 | 14 | env.SConscript([ 15 | '#plat-s5l8720/SConscript', 16 | '#plat-s5l8900/SConscript', 17 | '#plat-s5l8920/SConscript', 18 | '#plat-a4/SConscript', 19 | ], 'env') 20 | -------------------------------------------------------------------------------- /arch-arm/includes/arm/arm.h: -------------------------------------------------------------------------------- 1 | #ifndef ARM_H 2 | #define ARM_H 3 | 4 | int arm_setup(); 5 | void arm_disable_caches(); 6 | void DataCacheOperation(uint8_t mode, uint32_t buffer, uint32_t size); 7 | 8 | void IncrementCriticalLock(); 9 | void DecrementCriticalLock(); 10 | void EnterCriticalSection(); 11 | void LeaveCriticalSection(); 12 | 13 | void EnableCPUIRQ(); 14 | void EnableCPUFIQ(); 15 | void DisableCPUIRQ(); 16 | void DisableCPUFIQ(); 17 | 18 | uint32_t ReadAuxiliaryControlRegister(); 19 | void ClearCPUInstructionCache(); 20 | uint32_t ReadControlRegisterConfigData(); 21 | 22 | uint32_t ReadControlRegisterConfigData(); 23 | void WriteControlRegisterConfigData(uint32_t regData); 24 | uint32_t ReadAuxiliaryControlRegister(); 25 | void WriteAuxiliaryControlRegister(uint32_t regData); 26 | void WriteDomainAccessControlRegister(uint32_t regData); 27 | uint32_t ReadDataFaultStatusRegister(); 28 | uint32_t ReadFaultAddressRegister(); 29 | void WritePeripheralPortMemoryRemapRegister(uint32_t regData); 30 | void GiveFullAccessCP10CP11(); 31 | void EnableVFP(); 32 | void WaitForInterrupt(); 33 | void WriteTranslationTableBaseRegister0(void* translationTableBase); 34 | uint32_t ReadTranslationTableBaseRegister0(); 35 | 36 | void InvalidateUnifiedTLBUnlockedEntries(); 37 | void DataSynchronizationBarrier(); 38 | void ClearCPUInstructionCache(); 39 | void CleanDataCacheLineMVA(); 40 | void InvalidateDataCacheLineMVA(); 41 | void CleanAndInvalidateDataCacheLineMVA(); 42 | void CleanCPUDataCache(); 43 | void InvalidateCPUDataCache(); 44 | void CleanAndInvalidateCPUDataCache(); 45 | void ClearCPUCaches(); 46 | 47 | uint32_t GetC9C012(); 48 | void SetC9C012(uint32_t _val); 49 | 50 | void CallArm(uint32_t address); 51 | void CallThumb(uint32_t address); 52 | 53 | void Reboot(); 54 | void EndlessLoop(); 55 | 56 | void SwapTask(TaskDescriptor *_td); 57 | void StartTask(); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /audiohw-null.c: -------------------------------------------------------------------------------- 1 | /* 2 | * audiohw-null.c - Dummy audio driver 3 | * 4 | * Copyright 2010 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #include "openiboot.h" 25 | #include "audiocodec.h" 26 | 27 | void audiohw_init() 28 | { 29 | } 30 | 31 | void audiohw_postinit() 32 | { 33 | } 34 | 35 | void audiohw_play_pcm(const void* addr_in, uint32_t size, int use_speaker) 36 | { 37 | } 38 | 39 | void audiohw_set_headphone_vol(int vol_l, int vol_r) 40 | { 41 | } 42 | 43 | void audiohw_set_lineout_vol(int vol_l, int vol_r) 44 | { 45 | } 46 | 47 | void audiohw_set_aux_vol(int vol_l, int vol_r) 48 | { 49 | } 50 | 51 | int audiohw_transfers_done() 52 | { 53 | return 1; 54 | } 55 | 56 | void audiohw_pause() 57 | { 58 | } 59 | 60 | void audiohw_resume() 61 | { 62 | } 63 | 64 | uint32_t audiohw_get_position() 65 | { 66 | return 0; 67 | } 68 | 69 | uint32_t audiohw_get_total() 70 | { 71 | return 0; 72 | } 73 | 74 | void audiohw_mute(int mute) 75 | { 76 | } 77 | 78 | void audiohw_switch_normal_call(int in_call) 79 | { 80 | } 81 | 82 | void audiohw_set_speaker_vol(int vol) 83 | { 84 | } 85 | 86 | const struct sound_settings_info audiohw_settings[] = { 87 | }; 88 | -------------------------------------------------------------------------------- /docs/readme.txt: -------------------------------------------------------------------------------- 1 | This folder contains tidbits of information about the design of 2 | OpeniBoot, and the hardware it's designed to run on. 3 | 4 | Please put files in a readable format (such as PDF, or txt) in 5 | a suitable path under this folder. 6 | -------------------------------------------------------------------------------- /doxygen/readme.txt: -------------------------------------------------------------------------------- 1 | This folder will contain doxygen generated documentation. 2 | 3 | To generate the documentation, make sure you have the appropriate 4 | doxygen package installed for your operating system (and that it's 5 | on the system path), then run `scons docs`. 6 | 7 | This will generated html and latex directories alongside this 8 | document. 9 | 10 | 11 | 12 | The documentation is only generated from specific comments in the 13 | source code. To add a comment that will be read by doxygen, 14 | start it with /**, and put it before the item of interest. 15 | 16 | For example, in a header: 17 | 18 | /** 19 | * This function does cool stuff. 20 | * 21 | * A longer explanation of the cool stuff the function does. 22 | * 23 | * @param _x some top-secret X value! 24 | */ 25 | void my_test_function(int _x); 26 | -------------------------------------------------------------------------------- /ftl-yaftl/SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | ftl_yaftl_src = env.Localize([ 4 | 'yaftl_mem.c', 5 | 'yaftl_common.c', 6 | 'yaftl.c', 7 | 'yaftl_gc.c', 8 | 'l2v.c', 9 | ]) 10 | 11 | ftl_yaftl = env.CreateModule('ftl-yaftl', ftl_yaftl_src) 12 | ftl_yaftl.Append(CPPPATH = [Dir('includes')]) 13 | ftl_yaftl.Append(CPPDEFINES = ['CONFIG_FTL_YAFTL']) 14 | -------------------------------------------------------------------------------- /ftl-yaftl/includes/ftl/l2v.h: -------------------------------------------------------------------------------- 1 | #ifndef FTL_L2V_H 2 | #define FTL_L2V_H 3 | 4 | #include "openiboot.h" 5 | #include "ftl/yaftl_common.h" 6 | 7 | #define L2V_VPN_SPECIAL (0x1FF0002) 8 | #define L2V_VPN_MISS (0x1FF0003) 9 | 10 | #define L2V_VPN_ISNORMAL(v) ((v) < L2V_VPN_SPECIAL) 11 | 12 | /* Types */ 13 | 14 | typedef struct { 15 | uint32_t numRoots; 16 | uint32_t* Tree; 17 | uint32_t* TreeNodes; 18 | uint32_t* UpdatesSinceRepack; 19 | L2VNode* previousNode; 20 | L2VNode* nextNode; 21 | uint32_t numBlocks; 22 | uint32_t pagesPerSublk; 23 | L2VNode* Pool; 24 | L2VNode* firstNode; 25 | uint32_t nodeCount; 26 | } L2VDesc; 27 | 28 | typedef struct 29 | { 30 | L2VNode* Node[204]; //offset 0 - 0x3300 31 | uint32_t span[3276]; //offset 0x3330 32 | uint32_t bottomIdx; //offset 0x6660 33 | uint32_t ovhSize; //offset 0x6664 34 | uint32_t nodeSize; //offset 0x6668 35 | uint32_t field_666C[32]; 36 | uint32_t field_66EC; 37 | } L2VStruct; 38 | 39 | error_t L2V_Init(uint32_t totalPages, uint32_t numBlocks, uint32_t pagesPerSublk); 40 | 41 | void L2V_Open(); 42 | 43 | void L2V_Update(uint32_t _start, uint32_t _count, uint32_t _vpn); 44 | 45 | void L2V_UpdateFromTOC(uint32_t _tocIdx, uint32_t* _tocBuffer); 46 | 47 | void L2V_Search(GCReadC* _c); 48 | 49 | void L2V_Repack(uint32_t _rootNum); 50 | 51 | #endif // FTL_L2V_H 52 | -------------------------------------------------------------------------------- /ftl-yaftl/includes/ftl/yaftl.h: -------------------------------------------------------------------------------- 1 | #ifndef FTL_YAFTL_H 2 | #define FTL_YAFTL_H 3 | 4 | #include "ftl.h" 5 | #include "vfl.h" 6 | #include "nand.h" 7 | #include "openiboot.h" 8 | #include "yaftl_common.h" 9 | 10 | typedef struct _ftl_yaftl_device { 11 | ftl_device_t ftl; 12 | } ftl_yaftl_device_t; 13 | 14 | ftl_yaftl_device_t *ftl_yaftl_device_allocate(); 15 | 16 | #endif // FTL_YAFTL_H 17 | -------------------------------------------------------------------------------- /ftl-yaftl/includes/ftl/yaftl_gc.h: -------------------------------------------------------------------------------- 1 | #ifndef FTL_YAFTL_GC_H 2 | #define FTL_YAFTL_GC_H 3 | 4 | #include "openiboot.h" 5 | #include "util.h" 6 | #include "ftl/yaftl_common.h" 7 | 8 | error_t gcInit(); 9 | 10 | void gcResetReadCache(GCReadC* _readC); 11 | 12 | void gcListPushBack(GCList* _gcList, uint32_t _block); 13 | 14 | void gcFreeBlock(uint32_t _block, uint8_t _scrub); 15 | 16 | void gcPrepareToWrite(uint32_t _numPages); 17 | 18 | void gcFreeIndexPages(uint32_t _victim, uint8_t _scrub); 19 | 20 | void gcPrepareToFlush(); 21 | 22 | #endif // FTL_YAFTL_GC_H 23 | -------------------------------------------------------------------------------- /ftl-yaftl/includes/ftl/yaftl_mem.h: -------------------------------------------------------------------------------- 1 | #ifndef FTL_YAFTL_MEM_H 2 | #define FTL_YAFTL_MEM_H 3 | 4 | #include "openiboot.h" 5 | 6 | typedef struct 7 | { 8 | uint32_t buffer; 9 | uint32_t endOfBuffer; 10 | uint32_t size; 11 | uint32_t numAllocs; 12 | uint32_t numRebases; 13 | uint32_t paddingsSize; 14 | uint32_t state; 15 | } bufzone_t; 16 | 17 | // TODO: documentation 18 | void* yaftl_alloc(size_t size); 19 | void bufzone_init(bufzone_t* _zone); 20 | void* bufzone_alloc(bufzone_t* _zone, size_t size); 21 | error_t bufzone_finished_allocs(bufzone_t* _zone); 22 | void* bufzone_rebase(bufzone_t* _zone, void* buf); 23 | error_t bufzone_finished_rebases(bufzone_t* _zone); 24 | 25 | #endif // FTL_YAFTL_MEM_H 26 | -------------------------------------------------------------------------------- /ftl-yaftl/yaftl_mem.c: -------------------------------------------------------------------------------- 1 | #include "ftl/yaftl_mem.h" 2 | #include "openiboot.h" 3 | #include "util.h" 4 | 5 | void* yaftl_alloc(size_t size) 6 | { 7 | void* buffer = memalign(0x40, size); 8 | 9 | if (!buffer) 10 | system_panic("yaftl_alloc failed\r\n"); 11 | 12 | memset(buffer, 0, size); 13 | return buffer; 14 | } 15 | 16 | void bufzone_init(bufzone_t* _zone) 17 | { 18 | _zone->buffer = 0; 19 | _zone->endOfBuffer = 0; 20 | _zone->size = 0; 21 | _zone->numAllocs = 0; 22 | _zone->numRebases = 0; 23 | _zone->paddingsSize = 0; 24 | _zone->state = 1; 25 | } 26 | 27 | // returns the sub-buffer offset 28 | void* bufzone_alloc(bufzone_t* _zone, size_t size) 29 | { 30 | size_t oldSizeRounded; 31 | 32 | if (_zone->state != 1) 33 | system_panic("bufzone_alloc: bad state\r\n"); 34 | 35 | oldSizeRounded = ROUND_UP(_zone->size, 64); 36 | _zone->paddingsSize = _zone->paddingsSize + (oldSizeRounded - _zone->size); 37 | _zone->size = oldSizeRounded + size; 38 | _zone->numAllocs++; 39 | 40 | return (void*)oldSizeRounded; 41 | } 42 | 43 | error_t bufzone_finished_allocs(bufzone_t* _zone) 44 | { 45 | uint8_t* buff; 46 | 47 | if (_zone->state != 1) { 48 | bufferPrintf("bufzone_finished_allocs: bad state\r\n"); 49 | return EINVAL; 50 | } 51 | 52 | _zone->size = ROUND_UP(_zone->size, 64); 53 | buff = yaftl_alloc(_zone->size); 54 | 55 | if (!buff) { 56 | bufferPrintf("bufzone_finished_alloc: No buffer.\r\n"); 57 | return EINVAL; 58 | } 59 | 60 | _zone->buffer = (uint32_t)buff; 61 | _zone->endOfBuffer = (uint32_t)(buff + _zone->size); 62 | _zone->state = 2; 63 | 64 | return SUCCESS; 65 | } 66 | 67 | void* bufzone_rebase(bufzone_t* _zone, void* buf) 68 | { 69 | _zone->numRebases++; 70 | return buf + _zone->buffer; 71 | } 72 | 73 | error_t bufzone_finished_rebases(bufzone_t* _zone) 74 | { 75 | if (_zone->numAllocs != _zone->numRebases) { 76 | bufferPrintf("WMR_BufZone_FinishedRebases: _zone->numAllocs != _zone->numRebases\r\n"); 77 | return EINVAL; 78 | } 79 | 80 | return SUCCESS; 81 | } 82 | -------------------------------------------------------------------------------- /hfs/SConscript: -------------------------------------------------------------------------------- 1 | Import("*") 2 | 3 | hfs_src = env.Localize([ 4 | 'bdev.c', 5 | 'btree.c', 6 | 'catalog.c', 7 | 'extents.c', 8 | 'fastunicodecompare.c', 9 | 'fs.c', 10 | 'rawfile.c', 11 | 'utility.c', 12 | 'volume.c', 13 | 'xattr.c', 14 | 'hfscompress.c', 15 | ]) 16 | Export('hfs_src') 17 | -------------------------------------------------------------------------------- /hfs/bdev.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "hfs/common.h" 3 | #include "hfs/bdev.h" 4 | #include "util.h" 5 | 6 | typedef struct _bdevio_device 7 | { 8 | io_func io; 9 | block_device_handle_t handle; 10 | } bdevio_device_t; 11 | 12 | #define bdevio_device_get(x) (CONTAINER_OF(bdevio_device_t, io, (x))) 13 | 14 | 15 | static int bdevio_read(io_func *_io, off_t _addr, size_t _sz, void *_dest) 16 | { 17 | bdevio_device_t *bdev = bdevio_device_get(_io); 18 | int ret = block_device_seek(bdev->handle, seek_begin, _addr); 19 | if(ret < 0) 20 | return ret; 21 | 22 | return block_device_read(bdev->handle, _dest, _sz); 23 | } 24 | 25 | static int bdevio_write(io_func *_io, off_t _addr, size_t _sz, void *_src) 26 | { 27 | bdevio_device_t *bdev = bdevio_device_get(_io); 28 | int ret = block_device_seek(bdev->handle, seek_begin, _addr); 29 | if(ret < 0) 30 | return ret; 31 | 32 | return block_device_write(bdev->handle, _src, _sz); 33 | } 34 | 35 | void bdevio_close(io_func *_io) 36 | { 37 | bdevio_device_t *bdev = bdevio_device_get(_io); 38 | free(bdev); 39 | } 40 | 41 | io_func *bdevio_open(block_device_handle_t _handle) 42 | { 43 | bdevio_device_t *ret = malloc(sizeof(bdevio_device_t)); 44 | memset(ret, 0, sizeof(bdevio_device_t)); 45 | 46 | ret->handle = _handle; 47 | ret->io.read = bdevio_read; 48 | ret->io.write = bdevio_write; 49 | ret->io.close = bdevio_close; 50 | 51 | return &ret->io; 52 | } 53 | 54 | bdevfs_device_t *bdevfs_open(int _devIdx, int _pIdx) 55 | { 56 | block_device_t *dev = NULL; 57 | while(_devIdx >= 0 && (dev = block_device_find(dev))) 58 | _devIdx--; 59 | 60 | if(!dev) 61 | return NULL; 62 | 63 | block_device_handle_t handle = block_device_open(dev, _pIdx); 64 | if(!handle) 65 | return NULL; 66 | 67 | bdevfs_device_t *ret = malloc(sizeof(bdevfs_device_t)); 68 | ret->handle = handle; 69 | ret->io = bdevio_open(handle); 70 | ret->volume = openVolume(ret->io); 71 | return ret; 72 | } 73 | 74 | void bdevfs_close(bdevfs_device_t *bdev) 75 | { 76 | closeVolume(bdev->volume); 77 | bdevio_close(bdev->io); 78 | block_device_close(bdev->handle); 79 | free(bdev); 80 | }; 81 | -------------------------------------------------------------------------------- /hfs/utility.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void hfs_panic(const char* hfs_panicString) { 4 | bufferPrintf("%s\n", hfs_panicString); 5 | panic(); 6 | } 7 | 8 | void printUnicode(HFSUniStr255* str) { 9 | int i; 10 | 11 | for(i = 0; i < str->length; i++) { 12 | bufferPrintf("%c", (char)(str->unicode[i] & 0xff)); 13 | } 14 | } 15 | 16 | char* unicodeToAscii(HFSUniStr255* str) { 17 | int i; 18 | char* toReturn; 19 | 20 | toReturn = (char*) malloc(sizeof(char) * (str->length + 1)); 21 | 22 | for(i = 0; i < str->length; i++) { 23 | toReturn[i] = (char)(str->unicode[i] & 0xff); 24 | } 25 | toReturn[i] = '\0'; 26 | 27 | return toReturn; 28 | } 29 | -------------------------------------------------------------------------------- /images/.gitignore: -------------------------------------------------------------------------------- 1 | bin2c 2 | -------------------------------------------------------------------------------- /images/README: -------------------------------------------------------------------------------- 1 | openiBoot Image Resources 2 | ------------------------- 3 | Images used by openiboot are PNGs linked into the binary via bin2c. 4 | The original graphicsi for openiBoot were provided by poorlad and 5 | modified by galiaxy. 6 | 7 | The current graphics were provided by nickp666 with the intention of giving 8 | openiBoot a bit more of a polished look. 9 | 10 | The Apple logo is a trademark of Apple Inc., and is included for proper 11 | identification of Apple software on the device, and is believed to be 12 | necessary to avoid tarnishing or misrepresenting its image. It does not imply 13 | any association with or endorsement by the company, and its inclusion is 14 | believed to be fair use under copyright law. 15 | 16 | The Android logo & associated text representation is a trademark of Google Inc., 17 | and is included for proper identification of Google software on the device, and 18 | is believed to be necessary to avoid tarnishing or misrepresenting its image. 19 | It does not imply any association with or endorsement by the company, and its 20 | inclusion is believed to be fair use under copyright law. 21 | 22 | The console icon is taken from the LGPL licenced Crystal icon set from: http://www.everaldo.com/crystal/ 23 | 24 | Example use of bin2c 25 | ------------------------ 26 | bin2c dataHeaderPNG < Header.png > HeaderPNG.h 27 | -------------------------------------------------------------------------------- /images/SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | # 4 | # Build file for bin2c, and image headers. 5 | # 6 | 7 | bin2c = henv.Program('bin2c', ['bin2c.c']) 8 | 9 | def generate_actions(source, target, env, for_signature=False): 10 | Depends(target, bin2c) 11 | return "%s %s < %s > %s" % (str(bin2c[0]), env['BASE'], source[0], target[0]) 12 | 13 | env.Append(BUILDERS = {'Bin2C': Builder(generator=generate_actions)}) 14 | 15 | def Bin2CList(env, sources, src_pattern, dest_pattern, data_pattern): 16 | ret = [] 17 | for s in sources: 18 | src = src_pattern % s 19 | dest = dest_pattern % s 20 | data = data_pattern % s 21 | target = env.Bin2C(dest, src, BASE=data) 22 | ret.append(target) 23 | return ret 24 | env.AddMethod(Bin2CList, "Bin2CList") 25 | -------------------------------------------------------------------------------- /images/bin2c.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Unloved program to convert a binary on stdin to a C include on stdout 3 | * 4 | * Jan 1999 Matt Mackall 5 | * 6 | * This software may be used and distributed according to the terms 7 | * of the GNU General Public License, incorporated herein by reference. 8 | */ 9 | 10 | #include 11 | 12 | int main(int argc, char *argv[]) 13 | { 14 | int ch, total=0; 15 | 16 | if (argc > 1) 17 | printf("const char %s[] %s=\n", 18 | argv[1], argc > 2 ? argv[2] : ""); 19 | 20 | do { 21 | printf("\t\""); 22 | while ((ch = getchar()) != EOF) 23 | { 24 | total++; 25 | printf("\\x%02x",ch); 26 | if (total % 16 == 0) 27 | break; 28 | } 29 | printf("\"\n"); 30 | } while (ch != EOF); 31 | 32 | if (argc > 1) 33 | printf("\t;\n\nconst int %s_size = %d;\n", argv[1], total); 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /includes/als.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Header file for the Ambient Light sensor (ALS) 5 | * 6 | * Defines the setup and functionality of the Ambient Light Sensor. 7 | * 8 | * @defgroup ALS 9 | */ 10 | 11 | /* 12 | * als.h 13 | * 14 | * Copyright 2011 iDroid Project 15 | * 16 | * This file is part of iDroid. An android distribution for Apple products. 17 | * For more information, please visit http://www.idroidproject.org/. 18 | * 19 | * This program is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU General Public License 21 | * as published by the Free Software Foundation; either version 3 22 | * of the License, or (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 32 | */ 33 | 34 | #ifndef ALS_H 35 | #define ALS_H 36 | 37 | /** 38 | * Setup the Ambient Light Sensor 39 | * 40 | * Returns 0 on correct initialisation and -1 on incorrect initialisation. 41 | * 42 | * @ingroup ALS 43 | */ 44 | int als_setup(); 45 | 46 | /** 47 | * Set the high light threshold value 48 | * 49 | * @ingroup ALS 50 | */ 51 | void als_sethighthreshold(unsigned int value); 52 | 53 | /** 54 | * Set the low light threshold value 55 | * 56 | * @ingroup ALS 57 | */ 58 | void als_setlowthreshold(unsigned int value); 59 | 60 | /** 61 | * Collect data from the Ambient Light Sensor 62 | * 63 | * @ingroup ALS 64 | */ 65 | unsigned int als_data(); 66 | 67 | void als_setchannel(int channel); 68 | void als_enable_interrupt(); 69 | void als_disable_interrupt(); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /includes/buttons.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Header file for OiB knowing if a button if being pushed. 5 | * 6 | * Yes that is all it does.. Expected more? 7 | * 8 | * @defgroup Buttons 9 | */ 10 | 11 | /* 12 | * buttons.h 13 | * 14 | * Copyright 2011 iDroid Project 15 | * 16 | * This file is part of iDroid. An android distribution for Apple products. 17 | * For more information, please visit http://www.idroidproject.org/. 18 | * 19 | * This program is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU General Public License 21 | * as published by the Free Software Foundation; either version 3 22 | * of the License, or (at your option) any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 32 | */ 33 | 34 | #ifndef BUTTONS_H 35 | #define BUTTONS_H 36 | 37 | #include "openiboot.h" 38 | #include "hardware/buttons.h" 39 | 40 | /** 41 | * Check to see if a button is being pressed 42 | * 43 | * Returns TRUE or FALSE 44 | * 45 | * @ingroup Buttons 46 | */ 47 | int buttons_is_pushed(int); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /includes/camera.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Header file for camera functions in OiB 5 | * 6 | * @defgroup Camera 7 | */ 8 | 9 | /* 10 | * actions.h 11 | * 12 | * Copyright 2011 iDroid Project 13 | * 14 | * This file is part of iDroid. An android distribution for Apple products. 15 | * For more information, please visit http://www.idroidproject.org/. 16 | * 17 | * This program is free software; you can redistribute it and/or 18 | * modify it under the terms of the GNU General Public License 19 | * as published by the Free Software Foundation; either version 3 20 | * of the License, or (at your option) any later version. 21 | * 22 | * This program is distributed in the hope that it will be useful, 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 | * GNU General Public License for more details. 26 | * 27 | * You should have received a copy of the GNU General Public License 28 | * along with this program; if not, write to the Free Software 29 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30 | */ 31 | 32 | #ifndef CAMERA_H 33 | #define CAMERA_H 34 | 35 | /** 36 | * Setup the camera to work in OiB 37 | * 38 | * Note: The camera setup currently on recognises the existence of the camera and returns its model number 39 | * 40 | * Returns 0 on successful setup. 41 | * 42 | * @ingroup Camera 43 | */ 44 | int camera_setup(); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /includes/chipid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Header file for Chip identification 5 | */ 6 | 7 | /* 8 | * chipid.h 9 | * 10 | * Copyright 2011 iDroid Project 11 | * 12 | * This file is part of iDroid. An android distribution for Apple products. 13 | * For more information, please visit http://www.idroidproject.org/. 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 3 18 | * of the License, or (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 28 | */ 29 | 30 | #ifndef CHIPID_H 31 | #define CHIPID_H 32 | 33 | #include "openiboot.h" 34 | 35 | int chipid_spi_clocktype(); 36 | unsigned int chipid_get_power_epoch(); 37 | unsigned int chipid_get_security_epoch(); 38 | unsigned int chipid_get_gpio_epoch(); 39 | uint32_t chipid_get_nand_epoch(); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /includes/commands.h: -------------------------------------------------------------------------------- 1 | /* 2 | * commands.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef COMMANDS_H 25 | #define COMMANDS_H 26 | 27 | #include "openiboot.h" 28 | 29 | typedef error_t (*OPIBCommandRoutine)(int argc, char** argv); 30 | 31 | typedef struct OPIBCommand { 32 | char* name; 33 | char* description; 34 | OPIBCommandRoutine routine; 35 | } OPIBCommand; 36 | 37 | typedef OPIBCommand **OIBCommandIterator; 38 | 39 | extern OPIBCommand *command_list_init; 40 | OPIBCommand *command_get_next(OIBCommandIterator*); 41 | char **command_parse(char *str, int *argc); 42 | error_t command_run(int argc, char **argv); 43 | 44 | #define COMMAND(_name, _desc, _fn) OPIBCommand _fn##_struct = { \ 45 | .name = _name, \ 46 | .description = _desc, \ 47 | .routine = &_fn, \ 48 | }; \ 49 | OPIBCommand *_fn##_structptr __attribute__((section(".commands"))) = &_fn##_struct; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /includes/event.h: -------------------------------------------------------------------------------- 1 | /* 2 | * event.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef EVENT_H 25 | #define EVENT_H 26 | 27 | #include "openiboot.h" 28 | 29 | extern Event EventList; 30 | 31 | int event_setup(); 32 | int event_add(Event* newEvent, uint64_t timeout, EventHandler handler, void* opaque); 33 | int event_readd(Event* event, uint64_t new_interval); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /includes/hardware/edgeic.h: -------------------------------------------------------------------------------- 1 | /** 2 | * hardware/edgeic.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef HW_EDGEIC_H 25 | #define HW_EDGEIC_H 26 | 27 | // Devices 28 | #define EDGEIC 0x38E02000 29 | 30 | // Registers 31 | #define EDGEICCONFIG0 0x0 32 | #define EDGEICCONFIG1 0x4 33 | #define EDGEICLOWSTATUS 0x8 34 | #define EDGEICHIGHSTATUS 0xC 35 | 36 | // Values 37 | #define EDGEIC_CONFIG0RESET 0 38 | #define EDGEIC_CONFIG1RESET 0 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /includes/hfs/bdev.h: -------------------------------------------------------------------------------- 1 | /** 2 | * hfs/bdev.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef HFS_BDEV_H 25 | #define HFS_BDEV_H 26 | 27 | #include "openiboot.h" 28 | #include "../bdev.h" 29 | #include "hfs/common.h" 30 | #include "hfs/hfsplus.h" 31 | 32 | typedef struct _bdevfs_device 33 | { 34 | block_device_handle_t handle; 35 | io_func *io; 36 | Volume *volume; 37 | } bdevfs_device_t; 38 | 39 | void bdevio_close(io_func *_io); 40 | io_func *bdevio_open(block_device_handle_t _handle); 41 | 42 | bdevfs_device_t *bdevfs_open(int _devIdx, int _pIdx); 43 | void bdevfs_close(bdevfs_device_t *bdev); 44 | 45 | #endif //HFS_BDEV_H 46 | -------------------------------------------------------------------------------- /includes/hfs/fs.h: -------------------------------------------------------------------------------- 1 | /** 2 | * hfs/fs.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef FS_H 25 | #define FS_H 26 | 27 | #include "openiboot.h" 28 | #include "hfs/hfsplus.h" 29 | 30 | typedef struct ExtentListItem { 31 | uint32_t startBlock; 32 | uint32_t blockCount; 33 | } ExtentListItem; 34 | 35 | typedef struct ExtentList { 36 | uint32_t numExtents; 37 | ExtentListItem extents[16]; 38 | } ExtentList; 39 | 40 | extern int HasFSInit; 41 | 42 | uint32_t readHFSFile(HFSPlusCatalogFile* file, uint8_t** buffer, Volume* volume); 43 | 44 | error_t fs_setup(); 45 | int add_hfs(Volume* volume, uint8_t* buffer, size_t size, const char* outFileName); 46 | ExtentList* fs_get_extents(int device, int partition, const char* fileName); 47 | error_t fs_extract(int device, int partition, const char* file, void* location); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /includes/hfs/hfscprotect.h: -------------------------------------------------------------------------------- 1 | /** 2 | * hfs/hfscprotect.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef HFSCPROTECT_H 25 | #define HFSCPROTECT_H 26 | 27 | typedef struct HFSPlusCprotectV2 28 | { 29 | uint16_t xattr_version; //=2 (version?) 30 | uint16_t zero ; //=0 31 | uint32_t unknown; // leaks stack dword in one code path :) 32 | uint32_t protection_class_id; 33 | uint32_t wrapped_length; //0x28 34 | uint8_t wrapped_key[0x28]; 35 | } __attribute__ ((packed)) HFSPlusCprotectV2; 36 | 37 | typedef struct HFSPlusCprotectV4 38 | { 39 | uint16_t xattr_version; //=2 (version?) 40 | uint16_t zero ; //=0 41 | uint32_t xxx_length; // 0xc 42 | uint32_t protection_class_id; 43 | uint32_t wrapped_length; //0x28 44 | uint8_t xxx_junk[20]; //uninitialized ? 45 | uint8_t wrapped_key[0x28]; 46 | } __attribute__ ((packed)) HFSPlusCprotectV4; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /includes/hfs/hfslib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * hfs/hfslib.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #include "common.h" 25 | #include "hfsplus.h" 26 | #include "abstractfile.h" 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | void writeToFile(HFSPlusCatalogFile* file, AbstractFile* output, Volume* volume); 32 | void writeToHFSFile(HFSPlusCatalogFile* file, AbstractFile* input, Volume* volume); 33 | void get_hfs(Volume* volume, const char* inFileName, AbstractFile* output); 34 | int add_hfs(Volume* volume, AbstractFile* inFile, const char* outFileName); 35 | void grow_hfs(Volume* volume, uint64_t newSize); 36 | void removeAllInFolder(HFSCatalogNodeID folderID, Volume* volume, const char* parentName); 37 | void addAllInFolder(HFSCatalogNodeID folderID, Volume* volume, const char* parentName); 38 | void addall_hfs(Volume* volume, const char* dirToMerge, const char* dest); 39 | void extractAllInFolder(HFSCatalogNodeID folderID, Volume* volume); 40 | int copyAcrossVolumes(Volume* volume1, Volume* volume2, char* path1, char* path2); 41 | 42 | void hfs_untar(Volume* volume, AbstractFile* tarFile); 43 | void hfs_ls(Volume* volume, const char* path); 44 | void hfs_setsilence(int s); 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /includes/interrupt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * interrupt.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef INTERRUPT_H 25 | #define INTERRUPT_H 26 | 27 | #include "openiboot.h" 28 | #include "hardware/interrupt.h" 29 | 30 | typedef void (*InterruptServiceRoutine)(uint32_t token); 31 | 32 | typedef struct InterruptHandler { 33 | InterruptServiceRoutine handler; 34 | uint32_t token; 35 | uint32_t useEdgeIC; 36 | } InterruptHandler; 37 | 38 | extern InterruptHandler InterruptHandlerTable[VIC_MaxInterrupt]; 39 | 40 | int interrupt_setup(); 41 | int interrupt_install(int irq_no, InterruptServiceRoutine handler, uint32_t token); 42 | int interrupt_enable(int irq_no); 43 | int interrupt_disable(int irq_no); 44 | int interrupt_clear(int irq_no); 45 | 46 | int interrupt_set_int_type(int irq_no, uint8_t type); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /includes/miu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * miu.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef MIU_H 25 | #define MIU_H 26 | 27 | #include "openiboot.h" 28 | 29 | int miu_setup(); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /includes/mmu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mmu.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef MMU_H 25 | #define MMU_H 26 | 27 | #include "openiboot.h" 28 | 29 | #define MMU_SECTION_SIZE 0x100000 30 | #define MMU_SECTION_MASK 0xFFF00000 31 | 32 | #define MMU_SECTION 0x2 33 | #define MMU_AP_NOACCESS 0x0 34 | #define MMU_AP_PRIVILEGEDONLY 0xA00 35 | #define MMU_AP_BOTH 0xB00 36 | #define MMU_AP_BOTHWRITE 0xC00 37 | #define MMU_EXECUTENEVER 0x10 38 | #define MMU_CACHEABLE 0x8 39 | #define MMU_BUFFERABLE 0x4 40 | 41 | extern uint32_t* CurrentPageTable; 42 | 43 | int mmu_setup(); 44 | void mmu_enable(); 45 | void mmu_disable(); 46 | void mmu_map_section(uint32_t section, uint32_t target, Boolean cacheable, Boolean bufferable); 47 | void mmu_map_section_range(uint32_t rangeStart, uint32_t rangeEnd, uint32_t target, Boolean cacheable, Boolean bufferable); 48 | 49 | typedef struct PhysicalAddressMap { 50 | uint32_t logicalStart; 51 | uint32_t logicalEnd; 52 | uint32_t physicalStart; 53 | uint32_t size; 54 | } PhysicalAddressMap; 55 | 56 | PhysicalAddressMap* get_address_map(uint32_t address, uint32_t* address_map_base); 57 | uint32_t get_physical_address(uint32_t address); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /includes/piezo.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Header file for OpeniBoot's piezo electric buzzer interface. 5 | * 6 | * The piezo buzzer interface (iPod Touch 1G only) allows the playing of 7 | * 'notes' using the iPod Touch's built in buzzer. The sound is generated by 8 | * distorting the piece of metal inside the buzzer, you can choose the 9 | * frequency and duration through OpeniBoot. 10 | */ 11 | 12 | /* 13 | * piezo.h 14 | * 15 | * Copyright 2011 iDroid Project 16 | * 17 | * This file is part of iDroid. An android distribution for Apple products. 18 | * For more information, please visit http://www.idroidproject.org/. 19 | * 20 | * This program is free software; you can redistribute it and/or 21 | * modify it under the terms of the GNU General Public License 22 | * as published by the Free Software Foundation; either version 3 23 | * of the License, or (at your option) any later version. 24 | * 25 | * This program is distributed in the hope that it will be useful, 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | * GNU General Public License for more details. 29 | * 30 | * You should have received a copy of the GNU General Public License 31 | * along with this program; if not, write to the Free Software 32 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 33 | */ 34 | 35 | #ifndef PIEZO_H 36 | #define PIEZO_H 37 | 38 | /** 39 | * 'Buzz' the piezo electric buzzer at a given frequncy for a given number of 40 | * seconds. 41 | * 42 | * @param Frequency to 'buzz' buzzer at 43 | * 44 | * @param Duration of 'buzz' 45 | */ 46 | void piezo_buzz(int hertz, unsigned int microseconds); 47 | 48 | /** 49 | * Play a tune using a string of notes. 50 | * 51 | * @param Input to be played. 52 | */ 53 | void piezo_play(const char* command); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /includes/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * platform.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef PLATFORM_H 25 | #define PLATFORM_H 26 | 27 | void platform_init(); 28 | void platform_shutdown(); 29 | 30 | #endif //PLATFORM_H 31 | -------------------------------------------------------------------------------- /includes/power.h: -------------------------------------------------------------------------------- 1 | /* 2 | * power.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef POWER_H 25 | #define POWER_H 26 | 27 | #include "openiboot.h" 28 | 29 | int power_setup(); 30 | int power_ctrl(uint32_t device, OnOff on_off); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /includes/printf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * printf.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef PRINTF_H 25 | #define PRINTF_H 26 | 27 | int vsprintf(char *buf, const char *fmt, va_list args); 28 | int sprintf(char *buf, const char *fmt, ...); 29 | int vprintf(const char *fmt, va_list args); 30 | int printf(const char *fmt, ...); 31 | int puts(const char *str); 32 | #endif 33 | -------------------------------------------------------------------------------- /includes/radio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * radio.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef RADIO_H 25 | 26 | int radio_setup(); 27 | int radio_write(const char* str); 28 | int radio_read(char* buf, int len); 29 | int radio_wait_for_ok(int tries); 30 | int radio_cmd(const char* cmd, int tries); 31 | 32 | void radio_nvram_list(); 33 | 34 | int speaker_setup(); 35 | void loudspeaker_vol(int vol); 36 | void speaker_vol(int vol); 37 | int radio_register(int timeout); 38 | void radio_call(const char* number); 39 | void radio_hangup(); 40 | int radio_nvram_get(int type_in, uint8_t** data_out); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /includes/scripting.h: -------------------------------------------------------------------------------- 1 | /* 2 | * scripting.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef SCRIPTING_H 25 | #define SCRIPTING_H 26 | 27 | uint8_t *script_load_hfs_file(int disk, int part, char *path, uint32_t *size); 28 | uint8_t *script_load_file(char *id, uint32_t *size); 29 | char **script_split_file(char *_data, uint32_t _sz, uint32_t *_count); 30 | int script_run_command(char* command); 31 | int script_run_commands(char** cmds, uint32_t count); 32 | int script_run_file(char *path); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /includes/sdio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sdio.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef SDIO_H 25 | #define SDIO_H 26 | 27 | #include "openiboot.h" 28 | #include "interrupt.h" 29 | 30 | void sdio_status(); 31 | 32 | int sdio_set_block_size(int function, int blocksize); 33 | int sdio_claim_irq(int function, InterruptServiceRoutine handler, uint32_t token); 34 | int sdio_enable_func(int function); 35 | uint8_t sdio_readb(int function, uint32_t address, int* err_ret); 36 | void sdio_writeb(int function, uint8_t val, uint32_t address, int* err_ret); 37 | int sdio_writesb(int function, uint32_t address, void* src, int count); 38 | int sdio_readsb(int function, void* dst, uint32_t address, int count); 39 | int sdio_memcpy_toio(int function, uint32_t address, void* src, int count); 40 | int sdio_memcpy_fromio(int function, void* dst, uint32_t address, int count); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /includes/sha1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sha1.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef SHA1_H 25 | 26 | #include "openiboot.h" 27 | 28 | typedef struct { 29 | unsigned long state[5]; 30 | unsigned long count[2]; 31 | unsigned char buffer[64]; 32 | } SHA1_CTX; 33 | 34 | void SHA1Transform(unsigned long state[5], unsigned char buffer[64]); 35 | void SHA1Init(SHA1_CTX* context); 36 | void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len); 37 | void SHA1Final(unsigned char digest[20], SHA1_CTX* context); 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /includes/syscfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * syscfg.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef SYSCFG_H 25 | 26 | #include "openiboot.h" 27 | 28 | #define SCFG_PxCl 0x5078436C 29 | #define SCFG_MtCl 0x4D74436C 30 | 31 | int syscfg_setup(); 32 | uint8_t* syscfg_get_entry(uint32_t type, int* size); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /includes/tasks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tasks.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef TASKS_H 25 | #define TASKS_H 26 | 27 | #include "openiboot.h" 28 | 29 | #define TASK_DEFAULT_STACK_SIZE (1*1024*1024) // 1MB 30 | 31 | void tasks_setup(); 32 | void tasks_run(); 33 | 34 | void task_init(TaskDescriptor *_td, char *_name, size_t _stack_size); 35 | void task_destroy(TaskDescriptor *_td); 36 | error_t task_start(TaskDescriptor *_td, void *_fn, void *_arg); 37 | void task_stop(); 38 | 39 | error_t task_yield(); 40 | error_t task_sleep(int _ms); 41 | 42 | void task_wait(); 43 | error_t task_wait_timeout(int _ms); 44 | void task_wake(TaskDescriptor *_task); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /includes/usbphy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * usbphy.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | 25 | #ifndef USBPHY_H 26 | #define USBPHY_H 27 | 28 | typedef enum USBChargerIdentificationMode { 29 | USBChargerIdentificationDN, 30 | USBChargerIdentificationDP, 31 | USBChargerIdentificationNone, 32 | } USBChargerIdentificationMode; 33 | 34 | void usb_phy_init(); 35 | void usb_phy_shutdown(); 36 | void usb_set_charger_identification_mode(USBChargerIdentificationMode mode); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /includes/vibrator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * vibrator.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef VIBRATOR_H 25 | 26 | #ifdef CONFIG_IPHONE_2G 27 | void vibrator_loop(int frequency, int period, int time); 28 | void vibrator_once(int frequency, int time); 29 | void vibrator_off(); 30 | #endif 31 | #ifdef CONFIG_IPHONE_3G 32 | void vibrator_loop(int frequency, int period, int time); 33 | void vibrator_once(int time); 34 | void vibrator_off(); 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /includes/wdt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Header file for OpeniBoot's Watchdog Timer implementation. 5 | * 6 | * @defgroup WDT 7 | */ 8 | 9 | /* 10 | * wdt.h 11 | * 12 | * Copyright 2011 iDroid Project 13 | * 14 | * This file is part of iDroid. An android distribution for Apple products. 15 | * For more information, please visit http://www.idroidproject.org/. 16 | * 17 | * This program is free software; you can redistribute it and/or 18 | * modify it under the terms of the GNU General Public License 19 | * as published by the Free Software Foundation; either version 3 20 | * of the License, or (at your option) any later version. 21 | * 22 | * This program is distributed in the hope that it will be useful, 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 | * GNU General Public License for more details. 26 | * 27 | * You should have received a copy of the GNU General Public License 28 | * along with this program; if not, write to the Free Software 29 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30 | */ 31 | 32 | #ifndef WDT_H 33 | #define WDT_H 34 | 35 | #include "openiboot.h" 36 | 37 | /** 38 | * Setup Watchdog Timer 39 | * 40 | * @return Returns 0 on successful setup. Device will not function if unsuccessful. 41 | * 42 | * @ingroup WDT 43 | */ 44 | int wdt_setup(); 45 | 46 | /** 47 | * Check the Watchdog Timer's counter 48 | * 49 | * @return The value of the counter. 50 | * 51 | * @ingroup WDT 52 | */ 53 | int wdt_counter(); 54 | 55 | /** 56 | * Enable Watchdog Timer 57 | * 58 | * @ingroup WDT 59 | */ 60 | void wdt_enable(); 61 | 62 | /** 63 | * Disable Watchdog Timer 64 | * 65 | * @ingroup WDT 66 | */ 67 | void wdt_disable(); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /includes/wlan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wlan.h 3 | * 4 | * Copyright 2011 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef WLAN_H 25 | #define WLAN_H 26 | 27 | int wlan_setup(); 28 | int wlan_prog_helper(const uint8_t * firmware, int size); 29 | int wlan_prog_real(const uint8_t* firmware, size_t size); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /installer/SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | installer_src = env.Localize([ 4 | 'installer.c', 5 | ]) 6 | 7 | installer = env.CreateModule('installer', installer_src) 8 | installer.Append(CPPPATH = [Dir('includes'), Dir('.')]) 9 | 10 | images = env.Bin2CList([ 11 | 'installerLogo', 12 | 'installerBarEmpty', 13 | 'installerBarFull', 14 | ], "images/%s.png", "images/%sPNG.h", "data%sPNG") 15 | installer.Depends(images) 16 | 17 | def InstallerEnv(env): 18 | e2 = env.Clone() 19 | e2.AddModules(["installer"]) 20 | return e2 21 | env.AddMethod(InstallerEnv, "InstallerEnv") 22 | -------------------------------------------------------------------------------- /installer/images/.gitignore: -------------------------------------------------------------------------------- 1 | *.h 2 | -------------------------------------------------------------------------------- /installer/images/installerBarEmpty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/installer/images/installerBarEmpty.png -------------------------------------------------------------------------------- /installer/images/installerBarFull.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/installer/images/installerBarFull.png -------------------------------------------------------------------------------- /installer/images/installerLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/installer/images/installerLogo.png -------------------------------------------------------------------------------- /menu/SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | menu_src = env.Localize([ 4 | 'menu.c', 5 | ]) 6 | 7 | menu = env.CreateModule('menu', menu_src) 8 | menu.Append(CPPPATH = [Dir('includes'), Dir('.')]) 9 | 10 | #images = env.Bin2CList([ 11 | # 'Console', 12 | # 'ConsoleSelected', 13 | # 'Header', 14 | # 'iPhoneOS', 15 | # 'iPhoneOSSelected', 16 | # 'AndroidOSSelected', 17 | # 'AndroidOS', 18 | # ], "images/%s.png", "images/%sPNG.h", "data%sPNG") 19 | #menu.Depends(images) 20 | 21 | def MenuEnv(env): 22 | e2 = env.Clone() 23 | e2.AddModules(["menu"]) 24 | return e2 25 | env.AddMethod(MenuEnv, "MenuEnv") 26 | -------------------------------------------------------------------------------- /menu/images/.gitignore: -------------------------------------------------------------------------------- 1 | *.h 2 | -------------------------------------------------------------------------------- /menu/images/AndroidOS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/menu/images/AndroidOS.png -------------------------------------------------------------------------------- /menu/images/AndroidOSSelected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/menu/images/AndroidOSSelected.png -------------------------------------------------------------------------------- /menu/images/Console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/menu/images/Console.png -------------------------------------------------------------------------------- /menu/images/ConsoleSelected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/menu/images/ConsoleSelected.png -------------------------------------------------------------------------------- /menu/images/Header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/menu/images/Header.png -------------------------------------------------------------------------------- /menu/images/iPhoneOS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/menu/images/iPhoneOS.png -------------------------------------------------------------------------------- /menu/images/iPhoneOSSelected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/menu/images/iPhoneOSSelected.png -------------------------------------------------------------------------------- /mk8900image/.gitignore: -------------------------------------------------------------------------------- 1 | mk8900image 2 | -------------------------------------------------------------------------------- /mk8900image/8900.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "abstractfile.h" 4 | 5 | #ifndef INC_8900_H 6 | #define INC_8900_H 7 | 8 | typedef struct { 9 | uint32_t magic; /* string "8900" */ 10 | unsigned char version[3]; /* string "1.0" */ 11 | uint8_t format; /* plaintext format is 0x4, encrypted format is 0x3 */ 12 | uint32_t unknown1; 13 | uint32_t sizeOfData; /* size of data (ie, filesize - header(0x800) - footer signature(0x80) - footer certificate(0xC0A)) */ 14 | uint32_t footerSignatureOffset; /* offset to footer signature */ 15 | uint32_t footerCertOffset; /* offset to footer certificate, from end of header (0x800) */ 16 | uint32_t footerCertLen; 17 | unsigned char salt[0x20]; /* a seemingly random salt (an awfully big one though... needs more attention) */ 18 | uint16_t unknown2; 19 | uint16_t epoch; /* the security epoch of the file */ 20 | unsigned char headerSignature[0x10]; /* encrypt(sha1(header[0:0x40])[0:0x10], key_0x837, zero_iv) */ 21 | unsigned char padding[0x7B0]; 22 | } __attribute__((__packed__)) Apple8900Header; 23 | 24 | #define SIGNATURE_8900 0x38393030 25 | 26 | static uint8_t key_0x837[] = {0x18, 0x84, 0x58, 0xA6, 0xD1, 0x50, 0x34, 0xDF, 0xE3, 0x86, 0xF2, 0x3B, 0x61, 0xD4, 0x37, 0x74}; 27 | 28 | typedef struct Info8900 { 29 | AbstractFile* file; 30 | 31 | Apple8900Header header; 32 | size_t offset; 33 | void* buffer; 34 | 35 | unsigned char footerSignature[0x80]; 36 | unsigned char* footerCertificate; 37 | 38 | AES_KEY encryptKey; 39 | AES_KEY decryptKey; 40 | 41 | char dirty; 42 | } Info8900; 43 | 44 | AbstractFile* createAbstractFileFrom8900(AbstractFile* file); 45 | AbstractFile* duplicate8900File(AbstractFile* file, AbstractFile* backing); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /mk8900image/Makefile: -------------------------------------------------------------------------------- 1 | MKIMAGEOBJS=mk8900image.o 2 | LIBRARIES=-L/usr/lib -lm -ldl -lpng -lcrypto -lz 3 | CFLAGS += 4 | UNAME := $(shell uname -s) 5 | 6 | ifeq ($(UNAME),Darwin) 7 | LIBXPWN=x86-osx/libxpwn.a x86-osx/libcommon.a 8 | else 9 | ifeq ($(ARCH), x86_64) 10 | LIBXPWN=x86_64/libxpwn.a x86_64/libcommon.a 11 | else 12 | LIBXPWN=x86/libxpwn.a x86/libcommon.a 13 | endif 14 | endif 15 | 16 | %.o: %.c 17 | @echo "Compiling $@" 18 | @$(CC) $(CFLAGS) -c $< -o $@ 19 | 20 | mk8900image: $(MKIMAGEOBJS) $(LIBXPWN) 21 | @echo "Building $@" 22 | @$(CC) $(CFLAGS) $(MKIMAGEOBJS) $(LIBXPWN) $(LIBRARIES) -o $@ 23 | 24 | clean: 25 | @rm -f *.o 26 | @rm -f mk8900image 27 | -------------------------------------------------------------------------------- /mk8900image/SConscript: -------------------------------------------------------------------------------- 1 | Import("*") 2 | 3 | import platform 4 | 5 | libs = [] 6 | if platform.system() == 'Linux': 7 | if platform.machine() == 'x86_64': 8 | libs += ["x86_64/libxpwn.a", "x86_64/libcommon.a"] 9 | else: 10 | libs += ["x86/libxpwn.a", "x86/libcommon.a"] 11 | 12 | if platform.system() == 'Darwin': 13 | libs += ["mac-x86/libxpwn.a", "mac-x86/libcommon.a"] 14 | 15 | mk8900image = henv.Program('mk8900image', ['mk8900image.c'] + libs, LIBPATH='/usr/X11/lib', LIBS=['m', 'dl', 'png', 'crypto', 'z']) 16 | 17 | def generate_actions(source, target, env, for_sig=False, **kw): 18 | Depends(target, mk8900image) 19 | 20 | if len(source) > 2: 21 | return "%s %s %s %s %s" % (str(mk8900image[0]), source[0], target[0], source[1], source[2]) 22 | 23 | if len(source) > 1: 24 | return "%s %s %s %s" % (str(mk8900image[0]), source[0], target[0], source[1]) 25 | 26 | return "%s %s %s" % (str(mk8900image[0]), source[0], target[0]) 27 | 28 | env.Append(BUILDERS = {'Make8900Image': Builder(generator=generate_actions)}) 29 | -------------------------------------------------------------------------------- /mk8900image/abstractfile.h: -------------------------------------------------------------------------------- 1 | #ifndef ABSTRACTFILE_H 2 | #define ABSTRACTFILE_H 3 | 4 | #include "common.h" 5 | 6 | typedef struct AbstractFile AbstractFile; 7 | 8 | typedef size_t (*WriteFunc)(AbstractFile* file, const void* data, size_t len); 9 | typedef size_t (*ReadFunc)(AbstractFile* file, void* data, size_t len); 10 | typedef int (*SeekFunc)(AbstractFile* file, off_t offset); 11 | typedef off_t (*TellFunc)(AbstractFile* file); 12 | typedef void (*CloseFunc)(AbstractFile* file); 13 | typedef off_t (*GetLengthFunc)(AbstractFile* file); 14 | 15 | struct AbstractFile { 16 | void* data; 17 | WriteFunc write; 18 | ReadFunc read; 19 | SeekFunc seek; 20 | TellFunc tell; 21 | GetLengthFunc getLength; 22 | CloseFunc close; 23 | }; 24 | 25 | typedef struct { 26 | size_t offset; 27 | void** buffer; 28 | size_t bufferSize; 29 | } MemWrapperInfo; 30 | 31 | typedef struct { 32 | size_t offset; 33 | void** buffer; 34 | size_t* bufferSize; 35 | size_t actualBufferSize; 36 | } MemFileWrapperInfo; 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | AbstractFile* createAbstractFileFromFile(FILE* file); 42 | AbstractFile* createAbstractFileFromDummy(); 43 | AbstractFile* createAbstractFileFromMemory(void** buffer, size_t size); 44 | AbstractFile* createAbstractFileFromMemoryFile(void** buffer, size_t* size); 45 | AbstractFile* createAbstractFileFromMemoryFileBuffer(void** buffer, size_t* size, size_t actualBufferSize); 46 | void abstractFilePrint(AbstractFile* file, const char* format, ...); 47 | io_func* IOFuncFromAbstractFile(AbstractFile* file); 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /mk8900image/blank: -------------------------------------------------------------------------------- 1 | This file is intentionally left blank. 2 | -------------------------------------------------------------------------------- /mk8900image/common.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_H 2 | #define COMMON_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #ifdef WIN32 9 | #define fseeko fseeko64 10 | #define ftello ftello64 11 | #define off_t off64_t 12 | #define mkdir(x, y) mkdir(x) 13 | #endif 14 | 15 | #define TRUE 1 16 | #define FALSE 0 17 | 18 | #define FLIPENDIAN(x) flipEndian((unsigned char *)(&(x)), sizeof(x)) 19 | #define FLIPENDIANLE(x) flipEndianLE((unsigned char *)(&(x)), sizeof(x)) 20 | 21 | #define IS_BIG_ENDIAN 0 22 | #define IS_LITTLE_ENDIAN 1 23 | 24 | #define TIME_OFFSET_FROM_UNIX 2082844800L 25 | #define APPLE_TO_UNIX_TIME(x) ((x) - TIME_OFFSET_FROM_UNIX) 26 | #define UNIX_TO_APPLE_TIME(x) ((x) + TIME_OFFSET_FROM_UNIX) 27 | 28 | #define ASSERT(x, m) if(!(x)) { fflush(stdout); fprintf(stderr, "error: %s\n", m); perror("error"); fflush(stderr); exit(1); } 29 | 30 | extern char endianness; 31 | 32 | static inline void flipEndian(unsigned char* x, int length) { 33 | int i; 34 | unsigned char tmp; 35 | 36 | if(endianness == IS_BIG_ENDIAN) { 37 | return; 38 | } else { 39 | for(i = 0; i < (length / 2); i++) { 40 | tmp = x[i]; 41 | x[i] = x[length - i - 1]; 42 | x[length - i - 1] = tmp; 43 | } 44 | } 45 | } 46 | 47 | static inline void flipEndianLE(unsigned char* x, int length) { 48 | int i; 49 | unsigned char tmp; 50 | 51 | if(endianness == IS_LITTLE_ENDIAN) { 52 | return; 53 | } else { 54 | for(i = 0; i < (length / 2); i++) { 55 | tmp = x[i]; 56 | x[i] = x[length - i - 1]; 57 | x[length - i - 1] = tmp; 58 | } 59 | } 60 | } 61 | 62 | struct io_func_struct; 63 | 64 | typedef int (*readFunc)(struct io_func_struct* io, off_t location, size_t size, void *buffer); 65 | typedef int (*writeFunc)(struct io_func_struct* io, off_t location, size_t size, void *buffer); 66 | typedef void (*closeFunc)(struct io_func_struct* io); 67 | 68 | typedef struct io_func_struct { 69 | void* data; 70 | readFunc read; 71 | writeFunc write; 72 | closeFunc close; 73 | } io_func; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /mk8900image/iboot-template.img2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/mk8900image/iboot-template.img2 -------------------------------------------------------------------------------- /mk8900image/ibootim.h: -------------------------------------------------------------------------------- 1 | #ifndef IBOOTIM_H 2 | #define IBOOTIM_H 3 | 4 | #include 5 | #include "abstractfile.h" 6 | 7 | typedef struct IBootIMHeader { 8 | char signature[8]; 9 | uint32_t unknown; 10 | uint32_t compression_type; 11 | uint32_t format; 12 | uint16_t width; 13 | uint16_t height; 14 | uint8_t padding[0x28]; 15 | } __attribute__((__packed__)) IBootIMHeader; 16 | 17 | #define IBOOTIM_SIG_UINT 0x69426F6F 18 | #define IBOOTIM_SIGNATURE "iBootIm" 19 | #define IBOOTIM_LZSS_TYPE 0x6C7A7373 20 | #define IBOOTIM_ARGB 0x61726762 21 | #define IBOOTIM_GREY 0x67726579 22 | 23 | typedef struct InfoIBootIM { 24 | AbstractFile* file; 25 | 26 | IBootIMHeader header; 27 | size_t length; 28 | size_t compLength; 29 | size_t offset; 30 | void* buffer; 31 | 32 | char dirty; 33 | } InfoIBootIM; 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | AbstractFile* createAbstractFileFromIBootIM(AbstractFile* file); 39 | AbstractFile* duplicateIBootIMFile(AbstractFile* file, AbstractFile* backing); 40 | void* replaceBootImage(AbstractFile* imageWrapper, AbstractFile* png, size_t *fileSize); 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /mk8900image/img2.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "abstractfile.h" 3 | 4 | #define IMG2_SIGNATURE 0x496D6732 5 | 6 | typedef struct Img2Header { 7 | uint32_t signature; /* 0x0 */ 8 | uint32_t imageType; /* 0x4 */ 9 | uint16_t unknown1; /* 0x8 */ 10 | uint16_t security_epoch; /* 0xa */ 11 | uint32_t flags1; /* 0xc */ 12 | uint32_t dataLenPadded; /* 0x10 */ 13 | uint32_t dataLen; /* 0x14 */ 14 | uint32_t unknown3; /* 0x18 */ 15 | uint32_t flags2; /* 0x1c */ /* 0x01000000 has to be unset */ 16 | uint8_t reserved[0x40]; /* 0x20 */ 17 | uint32_t unknown4; /* 0x60 */ /* some sort of length field? */ 18 | uint32_t header_checksum; /* 0x64 */ /* standard crc32 on first 0x64 bytes */ 19 | uint32_t checksum2; /* 0x68 */ 20 | uint8_t unknown5[0x394]; /* 0x68 */ 21 | } __attribute__((__packed__)) Img2Header; 22 | 23 | typedef struct InfoImg2 { 24 | AbstractFile* file; 25 | 26 | Img2Header header; 27 | size_t offset; 28 | void* buffer; 29 | 30 | char dirty; 31 | } InfoImg2; 32 | 33 | AbstractFile* createAbstractFileFromImg2(AbstractFile* file); 34 | AbstractFile* duplicateImg2File(AbstractFile* file, AbstractFile* backing); 35 | -------------------------------------------------------------------------------- /mk8900image/iphonelinux.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/mk8900image/iphonelinux.der -------------------------------------------------------------------------------- /mk8900image/lzss.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | uint32_t lzadler32(uint8_t *buf, int32_t len); 4 | int decompress_lzss(uint8_t *dst, uint8_t *src, uint32_t srclen); 5 | uint8_t *compress_lzss(uint8_t *dst, uint32_t dstlen, uint8_t *src, uint32_t srcLen); 6 | -------------------------------------------------------------------------------- /mk8900image/lzssfile.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "abstractfile.h" 3 | 4 | #define COMP_SIGNATURE 0x636F6D70 5 | #define LZSS_SIGNATURE 0x6C7A7373 6 | 7 | typedef struct CompHeader { 8 | uint32_t signature; 9 | uint32_t compression_type; 10 | uint32_t checksum; 11 | uint32_t length_uncompressed; 12 | uint32_t length_compressed; 13 | uint8_t padding[0x16C]; 14 | } __attribute__((__packed__)) CompHeader; 15 | 16 | typedef struct InfoComp { 17 | AbstractFile* file; 18 | 19 | CompHeader header; 20 | size_t offset; 21 | void* buffer; 22 | 23 | char dirty; 24 | } InfoComp; 25 | 26 | AbstractFile* createAbstractFileFromComp(AbstractFile* file); 27 | AbstractFile* duplicateCompFile(AbstractFile* file, AbstractFile* backing); 28 | -------------------------------------------------------------------------------- /mk8900image/mac-x86/libcommon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/mk8900image/mac-x86/libcommon.a -------------------------------------------------------------------------------- /mk8900image/mac-x86/libxpwn.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/mk8900image/mac-x86/libxpwn.a -------------------------------------------------------------------------------- /mk8900image/nor_files.h: -------------------------------------------------------------------------------- 1 | #ifndef NOR_FILES_H 2 | #define NOR_FILES_H 3 | 4 | #include "common.h" 5 | #include "8900.h" 6 | #include "img2.h" 7 | #include "lzssfile.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | AbstractFile* openAbstractFile(AbstractFile* file); 13 | AbstractFile* openAbstractFile2(AbstractFile* file, const unsigned int* key, const unsigned int* iv); 14 | AbstractFile* openAbstractFile3(AbstractFile* file, const unsigned int* key, const unsigned int* iv, int layers); 15 | AbstractFile* duplicateAbstractFile(AbstractFile* file, AbstractFile* backing); 16 | AbstractFile* duplicateAbstractFile2(AbstractFile* file, AbstractFile* backing, const unsigned int* key, const unsigned int* iv, AbstractFile* certificate); 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /mk8900image/template-3g.img3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/mk8900image/template-3g.img3 -------------------------------------------------------------------------------- /mk8900image/template-4g.img3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/mk8900image/template-4g.img3 -------------------------------------------------------------------------------- /mk8900image/template-ipt1g.img3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/mk8900image/template-ipt1g.img3 -------------------------------------------------------------------------------- /mk8900image/template-ipt2g.img3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/mk8900image/template-ipt2g.img3 -------------------------------------------------------------------------------- /mk8900image/template-wtf.img2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/mk8900image/template-wtf.img2 -------------------------------------------------------------------------------- /mk8900image/template.img2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/mk8900image/template.img2 -------------------------------------------------------------------------------- /mk8900image/template.img3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/mk8900image/template.img3 -------------------------------------------------------------------------------- /mk8900image/x86/libcommon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/mk8900image/x86/libcommon.a -------------------------------------------------------------------------------- /mk8900image/x86/libxpwn.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/mk8900image/x86/libxpwn.a -------------------------------------------------------------------------------- /mk8900image/x86_64/libcommon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/mk8900image/x86_64/libcommon.a -------------------------------------------------------------------------------- /mk8900image/x86_64/libxpwn.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iDroid-Project/openiBoot/866562fdb1cfd019bcd77885c80fbf0af65d5c15/mk8900image/x86_64/libxpwn.a -------------------------------------------------------------------------------- /nor-cfi/SConscript: -------------------------------------------------------------------------------- 1 | Import("*") 2 | 3 | nor_cfi_src = env.Localize([ 4 | 'nor.c' 5 | ]) 6 | 7 | nor_cfi = env.CreateModule('nor-cfi', nor_cfi_src) 8 | nor_cfi.Append(CPPPATH=[Dir('includes')]) 9 | -------------------------------------------------------------------------------- /nor-cfi/includes/hardware/nor.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_NOR_H 2 | #define HW_NOR_H 3 | 4 | #include "openiboot.h" 5 | 6 | // Device 7 | #define NOR 0x24000000 8 | 9 | // Registers 10 | #define NOR_COMMAND 0xAAAA 11 | #define LOCK 0x5554 12 | #define VENDOR 0 13 | #define DEVICE 2 14 | 15 | // Values 16 | #define DATA_MODE 0xFFFF 17 | #define COMMAND_UNLOCK 0xAAAA 18 | #define COMMAND_LOCK 0xF0F0 19 | #define COMMAND_IDENTIFY 0x9090 20 | #define COMMAND_WRITE 0xA0A0 21 | #define COMMAND_ERASE 0x8080 22 | #define ERASE_DATA 0x3030 23 | #define LOCK_UNLOCK 0x5555 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /nor-spi/SConscript: -------------------------------------------------------------------------------- 1 | Import("*") 2 | 3 | nor_spi_src = env.Localize([ 4 | 'nor.c' 5 | ]) 6 | 7 | nor_spi = env.CreateModule('nor-spi', nor_spi_src) 8 | nor_spi.Append(CPPPATH=[Dir('includes')]) 9 | -------------------------------------------------------------------------------- /openiboot.c: -------------------------------------------------------------------------------- 1 | /* 2 | * openiboot.c - ASCIItastic! 3 | * 4 | * Copyright 2010 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #include "openiboot.h" 25 | #include "platform.h" 26 | #include "tasks.h" 27 | #include "util.h" 28 | 29 | mainfn_t OpenIBootMain = NULL; 30 | 31 | void OpenIBootConsole() 32 | { 33 | init_modules(); 34 | bufferPrintf( " ___ _ ____ _ \r\n" 35 | " / _ \\ _ __ ___ _ __ (_) __ ) ___ ___ | |_ \r\n" 36 | "| | | | '_ \\ / _ \\ '_ \\| | _ \\ / _ \\ / _ \\| __|\r\n" 37 | "| |_| | |_) | __/ | | | | |_) | (_) | (_) | |_ \r\n" 38 | " \\___/| .__/ \\___|_| |_|_|____/ \\___/ \\___/ \\__|\r\n" 39 | " |_| \r\n" 40 | "\r\n" 41 | "version: %s\r\n", OPENIBOOT_VERSION_STR); 42 | DebugPrintf(" DEBUG MODE\r\n"); 43 | } 44 | 45 | void OpenIBootStart() 46 | { 47 | platform_init(); 48 | init_setup(); 49 | 50 | OpenIBootMain = &OpenIBootConsole; 51 | init_boot_modules(); 52 | 53 | OpenIBootMain(); 54 | 55 | tasks_run(); // Runs forever. 56 | } 57 | 58 | void OpenIBootShutdown() 59 | { 60 | exit_modules(); 61 | platform_shutdown(); 62 | } 63 | -------------------------------------------------------------------------------- /pcf/Makefile: -------------------------------------------------------------------------------- 1 | PCF_OBJS = pcf.o 2 | OIF_OBJS = oif.o 3 | BIN2C_OBJS = bin2.o 4 | LIBRARIES = 5 | 6 | %.o: %.c 7 | $(CC) $(CFLAGS) -c $< -o $@ 8 | 9 | 10 | all: pcf oif bin2c 11 | 12 | pcf: $(PCF_OBJS) 13 | $(CC) $(CFLAGS) $(PCF_OBJS) $(LIBRARIES) -o $@ 14 | 15 | oif: $(OIF_OBJS) 16 | $(CC) $(CFLAGS) $(OIF_OBJS) $(LIBRARIES) -o $@ 17 | 18 | bin2c: $(BIN2C_OBJS) 19 | $(CC) $(CFLAGS) $(BIN2C_OBJS) $(LIBRARIES) -o $@ 20 | 21 | clean: 22 | -rm *.o 23 | -rm oif 24 | -rm pcf 25 | 26 | -------------------------------------------------------------------------------- /pcf/README: -------------------------------------------------------------------------------- 1 | PCF <-> OIF Conversion 2 | ---------------------- 3 | 4 | X11 PCF font files are too heavy-weight to use in OpenIBoot, though many of 5 | the terminal font files we could use is in this format. This utility converts 6 | fixed-width, Terminal pcf fonts to a more compact format I just made up. This 7 | format just has the width and height of each character, and then a bitstream 8 | of the bitmaps of all the characters from 0x00 to 0xff, row by row. 9 | 10 | The resulting data is small enough to be included in openiboot after being 11 | passed through bin2c. 12 | 13 | I know this code is a mess, but I don't foresee it being used more than once 14 | or twice. Even so, the unpolished code is dumped here for reference. 15 | 16 | See the commands themselves for usage. 17 | 18 | -------------------------------------------------------------------------------- /pcf/oif.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | typedef struct OpenIBootFont { 6 | uint32_t width; 7 | uint32_t height; 8 | uint8_t data[]; 9 | } __attribute__ ((packed)) OpenIBootFont; 10 | 11 | inline int getCharPixel(OpenIBootFont* font, int ch, int x, int y) { 12 | register int bitIndex = ((font->width * font->height) * ch) + (font->width * y) + x; 13 | return (font->data[bitIndex / 8] >> (bitIndex % 8)) & 0x1; 14 | } 15 | 16 | int main(int argc, char* argv[]) { 17 | if(argc < 3) { 18 | printf("Usage: %s \n", argv[0]); 19 | return; 20 | } 21 | 22 | FILE* file = fopen(argv[1], "rb"); 23 | if(file == NULL) { 24 | printf("File not found\n"); 25 | return; 26 | } 27 | 28 | fseek(file, 0, SEEK_END); 29 | size_t fileSize = ftell(file); 30 | fseek(file, 0, SEEK_SET); 31 | 32 | OpenIBootFont* font = (OpenIBootFont*) malloc(fileSize); 33 | 34 | fread(font, 1, fileSize, file); 35 | fclose(file); 36 | 37 | 38 | int i, j; 39 | for(i = 0; i < font->height; i++) { 40 | for(j = 0; j < font->width; j++) { 41 | if(getCharPixel(font, argv[2][0], j, i)) 42 | printf("@"); 43 | else 44 | printf(" "); 45 | } 46 | printf("\n"); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /plat-a4/SConscript: -------------------------------------------------------------------------------- 1 | Import("*") 2 | 3 | env = env.Clone() 4 | env.Append(CPPPATH = [Dir('includes')]) 5 | env.Append(CPPDEFINES = ['ARM_A8', 'CONFIG_A4', 'MALLOC_NO_WDT', 'BIG_FONT']) 6 | 7 | env.AddModules([ 8 | "acm", 9 | "usb-synopsys", 10 | "vfl-vfl", 11 | "vfl-vsvfl", 12 | "ftl-yaftl", 13 | ]) 14 | 15 | plat_a4_src = arch_arm_src + base_src + env.Localize([ 16 | 'a4.c', 17 | 'aes.c', 18 | 'buttons.c', 19 | 'chipid.c', 20 | 'clock.c', 21 | 'event.c', 22 | 'gpio.c', 23 | 'i2c.c', 24 | 'interrupt.c', 25 | 'mipi_dsim.c', 26 | 'clcd.c', 27 | 'miu.c', 28 | 'mmu.c', 29 | 'pmu.c', 30 | 'power.c', 31 | 'spi.c', 32 | 'timer.c', 33 | 'uart.c', 34 | 'cdma.c', 35 | 'usbphy.c', 36 | 'h2fmi.c', 37 | 'sdio.c', 38 | ]) + hfs_src 39 | Export('plat_a4_src') 40 | 41 | env.SConscript('iPhone4G.SConscript', 'env') 42 | env.SConscript('iPad1G.SConscript', 'env') 43 | env.SConscript('aTV2G.SConscript', 'env') 44 | env.SConscript('iPodTouch4G.SConscript', 'env') 45 | -------------------------------------------------------------------------------- /plat-a4/a4.c: -------------------------------------------------------------------------------- 1 | #include "aes.h" 2 | #include "arm/arm.h" 3 | #include "clock.h" 4 | #include "dma.h" 5 | #include "event.h" 6 | #include "framebuffer.h" 7 | #include "gpio.h" 8 | #include "interrupt.h" 9 | #include "i2c.h" 10 | #include "lcd.h" 11 | #include "miu.h" 12 | #include "mmu.h" 13 | #include "openiboot.h" 14 | #include "pmu.h" 15 | #include "power.h" 16 | #include "spi.h" 17 | #include "tasks.h" 18 | #include "timer.h" 19 | #include "uart.h" 20 | #include "wdt.h" 21 | #include "audiocodec.h" 22 | 23 | void platform_init() 24 | { 25 | arm_setup(); 26 | mmu_setup(); 27 | tasks_setup(); 28 | 29 | // Basic prerequisites for everything else 30 | miu_setup(); 31 | power_setup(); 32 | 33 | clock_setup(); 34 | 35 | // Need interrupts for everything afterwards 36 | interrupt_setup(); 37 | 38 | gpio_setup(); 39 | 40 | // For scheduling/sleeping niceties 41 | timer_setup(); 42 | event_setup(); 43 | 44 | // Other devices 45 | uart_setup(); 46 | i2c_setup(); 47 | 48 | dma_setup(); 49 | 50 | spi_setup(); 51 | 52 | LeaveCriticalSection(); 53 | 54 | aes_setup(); 55 | 56 | if(!displaypipe_init()) { 57 | framebuffer_setup(); 58 | framebuffer_setdisplaytext(TRUE); 59 | lcd_set_backlight_level(1500); 60 | } 61 | 62 | pmu_setup_gpio(0, 1, 1); 63 | pmu_setup_ldo(10, 1800, 0, 1); 64 | } 65 | 66 | void platform_shutdown() 67 | { 68 | //dma_shutdown(); 69 | //wdt_disable(); 70 | arm_disable_caches(); 71 | mmu_disable(); 72 | } 73 | -------------------------------------------------------------------------------- /plat-a4/aTV2G.SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | # 4 | # Apple TV 2G 5 | # 6 | 7 | atv_2g_src = [plat_a4_src, 8 | env.Localize([ 9 | '#audiohw-null.c', 10 | 'mcu.c', 11 | ])] 12 | Export('atv_2g_src') 13 | 14 | env = env.Clone() 15 | env.Append(CPPDEFINES=['OPENIBOOT_VERSION_CONFIG=\\" for aTV 2G\\"', 'MACH_ID=3594']) 16 | 17 | env.OpenIBootTarget('aTV2G', 'atv_2g_openiboot', 'CONFIG_ATV_2G', atv_2g_src, None) 18 | -------------------------------------------------------------------------------- /plat-a4/accel.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "commands.h" 3 | #include "util.h" 4 | #include "i2c.h" 5 | #include "hardware/accel.h" 6 | 7 | int accel_get_reg(int reg) { 8 | uint8_t registers[1]; 9 | uint8_t out[1]; 10 | 11 | registers[0] = reg; 12 | 13 | i2c_rx(ACCEL_I2C_BUS, ACCEL_GETADDR, registers, 1, out, 1); 14 | return out[0]; 15 | } 16 | 17 | int accel_write_reg(int reg, int data, int verify) { 18 | uint8_t command[2]; 19 | 20 | command[0] = reg; 21 | command[1] = data; 22 | 23 | i2c_tx(ACCEL_I2C_BUS, ACCEL_SETADDR, command, sizeof(command)); 24 | 25 | if(!verify) 26 | return 0; 27 | 28 | uint8_t accelReg = reg; 29 | uint8_t buffer = 0; 30 | i2c_rx(ACCEL_I2C_BUS, ACCEL_GETADDR, &accelReg, 1, &buffer, 1); 31 | 32 | if(buffer == data) 33 | return 0; 34 | else 35 | return -1; 36 | } 37 | 38 | void accel_init() 39 | { 40 | int whoami = accel_get_reg(ACCEL_WHOAMI); 41 | if(whoami != ACCEL_WHOAMI_VALUE) 42 | { 43 | bufferPrintf("accel: incorrect whoami value\n"); 44 | return; 45 | } 46 | 47 | accel_write_reg(ACCEL_CTRL_REG2, ACCEL_CTRL_REG2_BOOT, FALSE); 48 | accel_write_reg(ACCEL_CTRL_REG1, ACCEL_CTRL_REG1_PM0 | ACCEL_CTRL_REG1_XEN | ACCEL_CTRL_REG1_YEN | ACCEL_CTRL_REG1_ZEN, FALSE); 49 | } 50 | MODULE_INIT(accel_init); 51 | 52 | int accel_get_x() 53 | { 54 | return (signed char)(accel_get_reg(ACCEL_OUTX)); 55 | } 56 | 57 | int accel_get_y() 58 | { 59 | return (signed char)(accel_get_reg(ACCEL_OUTY)); 60 | } 61 | 62 | int accel_get_z() 63 | { 64 | return (signed char)(accel_get_reg(ACCEL_OUTZ)); 65 | } 66 | 67 | static error_t cmd_accel(int argc, char** argv) 68 | { 69 | int x = accel_get_x(); 70 | int y = accel_get_y(); 71 | int z = accel_get_z(); 72 | 73 | bufferPrintf("x: %d, y: %d, z: %d\r\n", x, y, z); 74 | 75 | return SUCCESS; 76 | } 77 | COMMAND("accel", "display accelerometer data", cmd_accel); 78 | -------------------------------------------------------------------------------- /plat-a4/buttons.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "buttons.h" 3 | #include "hardware/buttons.h" 4 | #include "gpio.h" 5 | 6 | int buttons_is_pushed(int which) { 7 | if(!gpio_pin_state(which)) 8 | return TRUE; 9 | else 10 | return FALSE; 11 | } 12 | -------------------------------------------------------------------------------- /plat-a4/chipid.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "chipid.h" 3 | #include "hardware/chipid.h" 4 | 5 | int chipid_spi_clocktype() { 6 | return GET_SPICLOCKTYPE(GET_REG(CHIPID + SPICLOCKTYPE)); 7 | } 8 | 9 | unsigned int chipid_get_power_epoch() { 10 | return CHIPID_GET_POWER_EPOCH(GET_REG(CHIPID)); 11 | } 12 | 13 | unsigned int chipid_get_gpio_epoch() { 14 | return CHIPID_GET_GPIO(GET_REG(CHIPID)); 15 | } 16 | 17 | uint32_t chipid_get_nand_epoch() 18 | { 19 | uint32_t ret = chipid_get_power_epoch(); 20 | if(ret == 0) 21 | return 1; 22 | 23 | return ret; 24 | } 25 | -------------------------------------------------------------------------------- /plat-a4/iPad1G.SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | # 4 | # iPad 1G 5 | # 6 | 7 | ipad_1g_src = [plat_a4_src, 8 | env.Localize([ 9 | '#audiohw-null.c', 10 | 'accel.c', 11 | ])] 12 | Export('ipad_1g_src') 13 | 14 | env = env.Clone() 15 | env.Append(CPPDEFINES=['OPENIBOOT_VERSION_CONFIG=\\" for iPad 1G\\"', 'MACH_ID=3593']) 16 | 17 | env.AddModules([ 18 | "nor-spi", 19 | ]) 20 | 21 | env.OpenIBootTarget('iPad1G', 'ipad_1g_openiboot', 'CONFIG_IPAD_1G', ipad_1g_src, None) 22 | -------------------------------------------------------------------------------- /plat-a4/iPhone4G.SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | # 4 | # iPhone 4G 5 | # 6 | 7 | iphone_4_src = [plat_a4_src, 8 | env.Localize([ 9 | '#audiohw-null.c', 10 | 'accel.c', 11 | ])] 12 | Export('iphone_4_src') 13 | 14 | env = env.Clone() 15 | env.Append(CPPDEFINES=['OPENIBOOT_VERSION_CONFIG=\\" for iPhone 4\\"', 'MACH_ID=3563']) 16 | 17 | env.AddModules([ 18 | "radio-xgold618", 19 | ]) 20 | 21 | env.OpenIBootTarget('iPhone4', 'iphone_4_openiboot', 'CONFIG_IPHONE_4', iphone_4_src, None) 22 | -------------------------------------------------------------------------------- /plat-a4/iPodTouch4G.SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | # 4 | # iPod Touch 4G 5 | # 6 | 7 | ipt_4g_src = [plat_a4_src, 8 | env.Localize([ 9 | '#audiohw-null.c', 10 | 'accel.c', 11 | ])] 12 | Export('ipt_4g_src') 13 | 14 | env = env.Clone() 15 | env.Append(CPPDEFINES=['OPENIBOOT_VERSION_CONFIG=\\" for iPod Touch 4G\\"', 'MACH_ID=3564']) 16 | 17 | env.OpenIBootTarget('iPodTouch4G', 'ipt_4g_openiboot', 'CONFIG_IPOD_TOUCH_4G', ipt_4g_src, None) 18 | -------------------------------------------------------------------------------- /plat-a4/includes/a4/pmu.h: -------------------------------------------------------------------------------- 1 | #ifndef A4_PMU_H 2 | #define A4_PMU_H 3 | 4 | /** 5 | * @brief A4 Specific gpio setup 6 | * 7 | * @param _idx 8 | * @param _dir 9 | * @param _pol 10 | * 11 | * @return error_t 12 | */ 13 | error_t pmu_setup_gpio(int _idx, int _dir, int _pol); 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /plat-a4/includes/cdma.h: -------------------------------------------------------------------------------- 1 | #ifndef _CDMA_H 2 | #define _CDMA_H 3 | 4 | typedef struct dmaAES { 5 | uint32_t inverse; 6 | uint32_t type; 7 | uint32_t *key; 8 | uint32_t dataSize; 9 | void (*ivGenerator)(uint32_t _param, uint32_t _segment, uint32_t* _iv); 10 | uint32_t ivParameter; 11 | } dmaAES; 12 | 13 | typedef struct DMASegmentInfo { 14 | uint32_t ptr; 15 | uint32_t size; 16 | } DMASegmentInfo; 17 | 18 | typedef struct dmaAES_CRYPTO { 19 | uint32_t *unkn0; 20 | uint32_t unkn1; 21 | uint32_t *buffer; 22 | uint32_t size; 23 | uint32_t unkn4; 24 | uint32_t unkn5; 25 | uint32_t unkn6; 26 | uint32_t unkn7; 27 | uint32_t unkn8; 28 | uint32_t unkn9; 29 | uint32_t unkn10; 30 | uint32_t unkn11; 31 | uint32_t unkn12; 32 | uint32_t unkn13; 33 | uint32_t unkn14; 34 | uint32_t unkn15; 35 | } __attribute__((packed)) dmaAES_CRYPTO; 36 | 37 | int dma_setup(); 38 | signed int dma_init_channel(uint8_t direction, uint32_t channel, DMASegmentInfo* segmentsInfo, 39 | uint32_t txrx_register, uint32_t size, uint32_t Setting1Index, uint32_t Setting2Index, void* handler); 40 | void dma_continue_async(int channel); 41 | int dma_set_aes(int channel, dmaAES* dmaAESInfo); 42 | int dma_cancel(int channel); 43 | uint32_t aes_crypto_cmd(uint32_t _encrypt, void *_inBuf, void *_outBuf, uint32_t _size, uint32_t _type, void *_key, void *_iv); 44 | 45 | #endif //_CDMA_H 46 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/a4.h: -------------------------------------------------------------------------------- 1 | #ifndef A4_H 2 | #define A4_H 3 | 4 | /* 5 | * Constants 6 | */ 7 | 8 | #define MemoryStart 0x00000000 9 | #define MemoryEnd 0xFFFFFFFF 10 | #define RAMStart 0x40000000 11 | #if defined(CONFIG_IPHONE_4) 12 | #define RAMEnd 0x60000000 13 | #else 14 | #define RAMEnd 0x50000000 15 | #endif 16 | #define LargeMemoryStart 0x46000000 17 | #define MemoryHigher 0xC0000000 18 | #define ExceptionVector MemoryStart 19 | #ifdef SMALL 20 | #define PageTable (OpenIBootLoad + 0x24000) 21 | #define HeapStart (PageTable + 0x4000) 22 | #else 23 | #define OpenIBootLoad 0x00000000 24 | #define GeneralStack (PageTable - 4) 25 | #define HeapStart (LargeMemoryStart + 0x02000000) 26 | #define PageTable (RAMEnd - 0x8000) 27 | #endif 28 | 29 | /* 30 | * Devices 31 | */ 32 | 33 | #define PeripheralPort 0x38000000 34 | #define AMC0 0x84000000 35 | #define AMC0End 0x84400000 36 | #define AMC0Higher 0x84C00000 37 | #define AMC0HigherEnd 0x85000000 38 | 39 | #define WDT_CTRL 0x3E300000 40 | #define WDT_CNT 0x3E300004 41 | 42 | #define WDT_INT 0x33 43 | /* 44 | * Values 45 | */ 46 | 47 | #define EDRAM_CLOCKGATE 0x1B 48 | #define WDT_ENABLE 0x100000 49 | #define WDT_PRE_SHIFT 16 50 | #define WDT_PRE_MASK 0xF 51 | #define WDT_CS_SHIFT 12 52 | #define WDT_CS_MASK 0x7 53 | #define WDT_CLR 0xA00 54 | #define WDT_DIS 0xA5 55 | #define WDT_INT_EN 0x8000 56 | 57 | #define DMA_ALIGN 0x40 58 | 59 | #endif 60 | 61 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/accel.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_ACCEL_H 2 | #define HW_ACCEL_H 3 | 4 | // See http://www.st.com/stonline/products/literature/ds/15094/lis331dlh.pdf 5 | 6 | #define ACCEL_I2C_BUS 2 7 | 8 | #define ACCEL_SETADDR 0x32 9 | #define ACCEL_GETADDR 0x33 10 | 11 | #define ACCEL_WHOAMI 0x0F 12 | #define ACCEL_CTRL_REG1 0x20 13 | #define ACCEL_CTRL_REG2 0x21 14 | #define ACCEL_STATUS 0x27 15 | #define ACCEL_OUTX 0x29 16 | #define ACCEL_OUTY 0x2B 17 | #define ACCEL_OUTZ 0x2D 18 | 19 | #define ACCEL_WHOAMI_VALUE 0x32 20 | 21 | #define ACCEL_CTRL_REG1_PM2 (1 << 7) 22 | #define ACCEL_CTRL_REG1_PM1 (1 << 6) 23 | #define ACCEL_CTRL_REG1_PM0 (1 << 5) 24 | #define ACCEL_CTRL_REG1_DR1 (1 << 4) 25 | #define ACCEL_CTRL_REG1_DR0 (1 << 3) 26 | #define ACCEL_CTRL_REG1_ZEN (1 << 2) 27 | #define ACCEL_CTRL_REG1_YEN (1 << 1) 28 | #define ACCEL_CTRL_REG1_XEN (1 << 0) 29 | 30 | #define ACCEL_CTRL_REG2_BOOT (1 << 7) 31 | #define ACCEL_CTRL_REG2_HPM1 (1 << 6) 32 | #define ACCEL_CTRL_REG2_HPM0 (1 << 5) 33 | #define ACCEL_CTRL_REG2_FDS (1 << 4) 34 | #define ACCEL_CTRL_REG2_HPEN2 (1 << 3) 35 | #define ACCEL_CTRL_REG2_HPEN1 (1 << 2) 36 | #define ACCEL_CTRL_REG2_HPCF1 (1 << 1) 37 | #define ACCEL_CTRL_REG2_HPCF0 (1 << 0) 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/buttons.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_BUTTONS_H 2 | #define HW_BUTTONS_H 3 | 4 | // Device 5 | 6 | #define BUTTONS_HOME 0x0 7 | #define BUTTONS_HOLD 0x1 8 | #define BUTTONS_VOLUP 0x2 9 | #define BUTTONS_VOLDOWN 0x3 10 | #define BUTTONS_RINGERAB 0x4 11 | 12 | #define BUTTONS_IIC_STATE 0x4B 13 | 14 | #define BUTTONS_HOLD_IRQ 0x2D 15 | #define BUTTONS_VOLUP_IRQ 0x29 16 | #define BUTTONS_VOLDOWN_IRQ 0x2A 17 | #define BUTTONS_RINGERAB_IRQ 0x2B 18 | 19 | #define BUTTONS_HOLD_IRQTYPE 1 20 | #define BUTTONS_HOME_IRQTYPE 1 21 | #define BUTTONS_VOLUP_IRQTYPE 1 22 | #define BUTTONS_VOLDOWN_IRQTYPE 1 23 | #define BUTTONS_RINGERAB_IRQTYPE 1 24 | 25 | #define BUTTONS_HOLD_IRQLEVEL 1 26 | #define BUTTONS_HOME_IRQLEVEL 1 27 | #define BUTTONS_VOLUP_IRQLEVEL 0 28 | #define BUTTONS_VOLDOWN_IRQLEVEL 0 29 | #define BUTTONS_RINGERAB_IRQLEVEL 1 30 | 31 | #define BUTTONS_HOLD_IRQAUTOFLIP 1 32 | #define BUTTONS_HOME_IRQAUTOFLIP 1 33 | #define BUTTONS_VOLUP_IRQAUTOFLIP 1 34 | #define BUTTONS_VOLDOWN_IRQAUTOFLIP 1 35 | #define BUTTONS_RINGERAB_IRQAUTOFLIP 1 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/chipid.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_CHIPID_H 2 | #define HW_CHIPID_H 3 | 4 | // Device 5 | #define CHIPID 0xBF500000 6 | 7 | // Registers 8 | #define SPICLOCKTYPE 0x4 9 | 10 | // Values 11 | #define GET_SPICLOCKTYPE(x) GET_BITS(x, 24, 4) 12 | #define CHIPID_GET_GPIO(x) GET_BITS((x), 4, 2) 13 | #define CHIPID_GET_POWER_EPOCH(x) GET_BITS((x), 9, 7) 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/clcd.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_CLCD_H 2 | #define HW_CLCD_H 3 | 4 | #define DISPLAY_PIPE0 0x89000000 5 | #define DISPLAY_PIPE1 0x89100000 6 | #define CLCD 0x89200000 7 | #define RGBOUT 0x89600000 8 | 9 | #if !defined(CONFIG_ATV_2G) 10 | #define DISPLAY_PIPE DISPLAY_PIPE0 11 | #else 12 | #define DISPLAY_PIPE DISPLAY_PIPE1 13 | #endif 14 | #if defined(CONFIG_IPHONE_4) 15 | #define CLCD_FRAMEBUFFER 0x5F700000 16 | #else 17 | #define CLCD_FRAMEBUFFER 0x4F700000 18 | #endif 19 | 20 | #define VIDCON1_IVCLKSHIFT 3 21 | #define VIDCON1_IHSYNCSHIFT 2 22 | #define VIDCON1_IVSYNCSHIFT 1 23 | #define VIDCON1_IVDENSHIFT 0 24 | 25 | #define VIDTCON_BACKPORCHSHIFT 16 26 | #define VIDTCON_BACKPORCHMASK 0xFF 27 | #define VIDTCON_FRONTPORCHSHIFT 8 28 | #define VIDTCON_FRONTPORCHMASK 0xFF 29 | #define VIDTCON_SYNCPULSEWIDTHSHIFT 0 30 | #define VIDTCON_SYNCPULSEWIDTHMASK 0xFF 31 | #define VIDTCON2_LINEVALMASK 0x3FF 32 | #define VIDTCON2_LINEVALSHIFT 0 33 | #define VIDTCON2_HOZVALMASK 0x3FF 34 | #define VIDTCON2_HOZVALSHIFT 16 35 | 36 | #if defined(CONFIG_IPHONE_4) 37 | #define DISPLAYID 0 38 | #elif defined(CONFIG_IPAD_1G) 39 | #define DISPLAYID 1 40 | #elif defined(CONFIG_IPOD_TOUCH_4G) 41 | #define DISPLAYID 2 42 | #elif defined(CONFIG_ATV_2G) 43 | #define DISPLAYID 3 44 | #endif 45 | 46 | #define LCD_MAX_BACKLIGHT 2047 47 | #define LCD_BACKLIGHT_HIGH_REG 0x66 48 | #define LCD_BACKLIGHT_LOW_REG 0x67 49 | #define LCD_BACKLIGHT_HIGH_SHIFT 3 50 | #define LCD_BACKLIGHT_LOW_MASK 7 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/dma.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_DMA_H 2 | #define HW_DMA_H 3 | 4 | #include "hardware/a4.h" 5 | 6 | // Device 7 | #define DMA 0x87000000 8 | 9 | // Registers 10 | #define DMA_OFF 0x8 11 | #define DMA_STATUS 0x10 12 | #define DMA_INTERRUPT_ERROR 0x18 13 | #define DMA_CHANNEL_INTERRUPT_BASE 0x30 14 | 15 | // Channel Registers 16 | #define DMA_SETTINGS 0x4 17 | #define DMA_TXRX_REGISTER 0x8 18 | #define DMA_SIZE 0xC 19 | 20 | // AES Registers 21 | #define DMA_AES 0x800000 22 | #define DMA_AES_KEY_0 0x20 23 | #define DMA_AES_KEY_1 0x24 24 | #define DMA_AES_KEY_2 0x28 25 | #define DMA_AES_KEY_3 0x2C 26 | #define DMA_AES_KEY_4 0x30 27 | #define DMA_AES_KEY_5 0x34 28 | #define DMA_AES_KEY_6 0x38 29 | #define DMA_AES_KEY_7 0x3C 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/gpio.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_GPIO_H 2 | #define HW_GPIO_H 3 | 4 | // gpioBaseAddress 5 | #define GPIO 0xBFA00000 6 | 7 | // Interrupt 8 | #define GPIO_INTERRUPT 0x74 9 | 10 | // Registers 11 | #define GPIO_INTLEVEL 0x80 12 | #define GPIO_INTSTAT 0xA0 13 | #define GPIO_INTEN 0xC0 14 | #define GPIO_INTTYPE 0xE0 15 | #define GPIO_FSEL 0x320 16 | 17 | #define GPIOIC_INT 0xC00 18 | #define GPIOIC_DISABLE 0x800 19 | #define GPIOIC_ENABLE 0x840 20 | #define GPIOIC_INTSTS 0x880 21 | 22 | // Values 23 | #define GPIO_NUMINTGROUPS 7 24 | #define GPIO_INTSTAT_RESET 0xFFFFFFFF 25 | #define GPIO_INTEN_RESET 0 26 | 27 | #define GPIO_FSEL_MAJSHIFT 16 28 | #define GPIO_FSEL_MAJMASK 0x1F 29 | #define GPIO_FSEL_MINSHIFT 8 30 | #define GPIO_FSEL_MINMASK 0x7 31 | #define GPIO_FSEL_USHIFT 0 32 | #define GPIO_FSEL_UMASK 0xF 33 | 34 | #define GPIO_CLOCKGATE 0x2C 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/h2fmi.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_H2FMI_H 2 | #define HW_H2FMI_H 3 | 4 | #define H2FMI0_BASE 0x81200000 5 | #define H2FMI1_BASE 0x81300000 6 | 7 | #define H2FMI0_CLOCK_GATE 0x27 8 | #define H2FMI1_CLOCK_GATE 0x29 9 | #define H2FMI0_INTERRUPT 0x22 10 | #define H2FMI1_INTERRUPT 0x23 11 | 12 | #define H2FMI_CHIP_COUNT 16 13 | #define H2FMI_CHIPID_LENGTH 8 14 | 15 | #define H2FMI_REG(x, y) (((x)->base_address)+(y)) 16 | #define H2FMI_UNKREG1(x) (H2FMI_REG(x, 0x40008)) 17 | #define H2FMI_UNKREG2(x) (H2FMI_REG(x, 0x40000)) 18 | #define H2FMI_UNKREG3(x) (H2FMI_REG(x, 0x80014)) 19 | #define H2FMI_UNKREG4(x) (H2FMI_REG(x, 0x40014)) 20 | #define H2FMI_UNKREG5(x) (H2FMI_REG(x, 0x40010)) 21 | #define H2FMI_UNKREG6(x) (H2FMI_REG(x, 0x40044)) 22 | #define H2FMI_CHIP_MASK(x) (H2FMI_REG(x, 0x4000C)) 23 | #define H2FMI_UNKREG8(x) (H2FMI_REG(x, 0x40024)) 24 | #define H2FMI_UNKREG9(x) (H2FMI_REG(x, 0x40018)) 25 | #define H2FMI_UNKREG10(x) (H2FMI_REG(x, 0x40020)) 26 | #define H2FMI_UNK4(x) (H2FMI_REG(x, 0x4)) 27 | #define H2FMI_UNK440(x) (H2FMI_REG(x, 0x40040)) 28 | #define H2FMI_UNK448(x) (H2FMI_REG(x, 0x40048)) 29 | #define H2FMI_UNK44C(x) (H2FMI_REG(x, 0x4004C)) 30 | #define H2FMI_UNK8(x) (H2FMI_REG(x, 0x8)) 31 | #define H2FMI_UNKC(x) (H2FMI_REG(x, 0xC)) 32 | #define H2FMI_UNK10(x) (H2FMI_REG(x, 0x10)) 33 | #define H2FMI_DATA(x) (H2FMI_REG(x, 0x14)) // UNK14 34 | #define H2FMI_UNK18(x) (H2FMI_REG(x, 0x18)) 35 | #define H2FMI_UNKREG15(x) (H2FMI_REG(x, 0x34)) 36 | #define H2FMI_UNKREG16(x) (H2FMI_REG(x, 0x1C)) 37 | #define H2FMI_UNK80C(x) (H2FMI_REG(x, 0x8000C)) 38 | #define H2FMI_UNK810(x) (H2FMI_REG(x, 0x80010)) 39 | #define H2FMI_UNK41C(x) (H2FMI_REG(x, 0x4001C)) 40 | #define H2FMI_PAGE_SIZE(x) (H2FMI_REG(x, 0x0)) 41 | #define H2FMI_ECC_BITS(x) (H2FMI_REG(x, 0x80008)) 42 | 43 | #endif //HW_H2FMI_H 44 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/i2c.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_I2C_H 2 | #define HW_I2C_H 3 | 4 | // Device 5 | #define I2C0 0x83200000 6 | #define I2C1 0x83300000 7 | #define I2C2 0x83400000 8 | 9 | // Registers 10 | #define IICREG0 0x0 11 | #define IICREG8 0x8 12 | #define IICREGC 0xC 13 | #define IICREG10 0x10 14 | #define IICREG14 0x14 15 | #define IICREG18 0x18 16 | #define IICREG20 0x20 17 | #define IICREG24 0x24 18 | 19 | // Values 20 | #define IICCON_INIT 0x3F00 21 | #define IICCON_ACKGEN (1 << 7) 22 | #define IICCON_TXCLKSRC_FPCLK16 (0 << 6) 23 | #define IICCON_TXCLKSRC_FPCLK512 (1 << 6) 24 | #define IICCON_INTENABLE (1 << 5) 25 | #define IICCON_INTPENDING (1 << 4) 26 | #define IICCON_TXCLKPRESCALEMASK 0xF 27 | 28 | #define IICSTAT_MODE_SLAVERX 0 29 | #define IICSTAT_MODE_SLAVETX 1 30 | #define IICSTAT_MODE_MASTERRX 2 31 | #define IICSTAT_MODE_MASTERTX 3 32 | #define IICSTAT_MODE_SHIFT 6 33 | #define IICSTAT_MODE_MASK 3 34 | #define IICSTAT_STARTSTOPGEN_START 1 35 | #define IICSTAT_STARTSTOPGEN_STOP 0 36 | #define IICSTAT_STARTSTOPGEN_MASK 1 37 | #define IICSTAT_STARTSTOPGEN_SHIFT 5 38 | #define IICSTAT_DATAOUTPUT_ENABLE_SHIFT 4 39 | #define IICSTAT_LASTRECEIVEDBIT (1 << 0) 40 | 41 | #define I2C0_SCL_GPIO 0xB02 42 | #define I2C0_SDA_GPIO 0xB03 43 | #define I2C1_SCL_GPIO 0x801 44 | #define I2C1_SDA_GPIO 0x802 45 | 46 | #define I2C0_CLOCKGATE 0x24 47 | #define I2C1_CLOCKGATE 0x26 48 | 49 | #define TXFREQ 25000 50 | 51 | #define OPERATION_SEND (1 << 8) 52 | #define OPERATION_CONDITIONCHANGE (1 << 13) 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/interrupt.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_INTERRUPT_H 2 | #define HW_INTERRUPT_H 3 | 4 | // This appears to be a PL192 5 | 6 | // Constants 7 | 8 | #define VIC_MaxInterrupt 0x80 9 | #define VIC_InterruptSeparator 0x20 10 | 11 | // Devices 12 | 13 | #define VIC0 0xBF200000 14 | #define VIC1 0xBF210000 15 | #define VIC2 0xBF220000 16 | #define VIC3 0xBF230000 17 | 18 | // Registers 19 | 20 | #define VICIRQSTATUS 0x000 21 | #define VICRAWINTR 0x8 22 | #define VICINTSELECT 0xC 23 | #define VICINTENABLE 0x10 24 | #define VICINTENCLEAR 0x14 25 | #define VICSWPRIORITYMASK 0x24 26 | #define VICVECTADDRS 0x100 27 | #define VICADDRESS 0xF00 28 | #define VICPERIPHID0 0xFE0 29 | #define VICPERIPHID1 0xFE4 30 | #define VICPERIPHID2 0xFE8 31 | #define VICPERIPHID3 0xFEC 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/platform.h: -------------------------------------------------------------------------------- 1 | #include "hardware/a4.h" 2 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/pmu.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_PMU_H 2 | #define HW_PMU_H 3 | 4 | // I2C bus and addresses 5 | #define PMU_I2C_BUS 0 6 | 7 | #define PMU_SETADDR 0xE9 8 | #define PMU_GETADDR 0xE8 9 | 10 | // Registers 11 | #define PMU_ADC_REG 0x2 12 | #define PMU_POWERSUPPLY_REG 0x7 13 | #define PMU_OOCSHDWN_REG 0x12 14 | #define PMU_MUXSEL_REG 0x30 15 | #define PMU_ADCVAL_REG 0x31 16 | #define PMU_VOLTAGE_HIGH_REG 0x8E 17 | #define PMU_VOLTAGE_LOW_REG 0x8D 18 | 19 | // General-purpose registers 20 | #define PMU_MAXREG 0xF 21 | 22 | // Unknown registers 23 | #define PMU_UNK1_REG 0xC 24 | #define PMU_UNK2_REG 0x1 25 | #define PMU_UNKREG_START 0x50 26 | #define PMU_UNKREG_END 0x5A 27 | 28 | // GPIO 29 | #define PMU_GPIO 0x50 30 | #define PMU_GPIO_COUNT 10 31 | 32 | // LDO 33 | #define PMU_LDO_GATES 0x5f 34 | #define PMU_LDO_V 0x1d 35 | #define PMU_LDO_COUNT 19 36 | 37 | // Values 38 | #define PMU_POWERSUPPLY_USB 0x8 39 | #define PMU_POWERSUPPLY_FIREWIRE 0x10 40 | 41 | #define PMU_CHARGER_IDENTIFY_MAX 2 42 | #define PMU_CHARGER_IDENTIFY_NONE 0 43 | #define PMU_CHARGER_IDENTIFY_DP 1 44 | #define PMU_CHARGER_IDENTIFY_DN 2 45 | 46 | #define PMU_ADCMUX_USBCHARGER 6 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/power.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_POWER_H 2 | #define HW_POWER_H 3 | 4 | // Device 5 | #define POWER 0xBF100000 6 | 7 | // Power 8 | #define POWER_DEFAULT_DEVICES 0xEC 9 | #define POWER_LCD 0x100 10 | #define POWER_USB 0x200 11 | #define POWER_VROM 0x1000 12 | 13 | // Registers 14 | #define POWER_CONFIG0 0x0 15 | #define POWER_CONFIG1 0x20 16 | #define POWER_CONFIG2 0x6C 17 | #define POWER_ONCTRL 0xC 18 | #define POWER_OFFCTRL 0x10 19 | #define POWER_SETSTATE 0x8 20 | #define POWER_ID 0x6000 21 | #define POWER_ID_EPOCH(x) ((x) >> 24) 22 | 23 | // Values 24 | #define POWER_CONFIG0_RESET 0x1123009 25 | #define POWER_CONFIG1_RESET 0x20 26 | #define POWER_CONFIG2_RESET 0x0 27 | 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/radio.h: -------------------------------------------------------------------------------- 1 | #ifndef __A4_HARDWARE_RADIO 2 | #define __A4_HARDWARE_RADIO 3 | 4 | #define RADIO_UART 1 5 | 6 | #endif //__A4_HARDWARE_RADIO 7 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/sdio.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_SDIO_H 2 | #define HW_SDIO_H 3 | 4 | 5 | #define SDIO_CLOCKGATE 0x24 6 | #define SDIO_INTERRUPT 0x26 7 | #define SDIO_GPIO_DEVICE_RESET 0x6 8 | 9 | // hardware registers 10 | #define SDIO 0x80000000 11 | #define SDIO_SDMAADD 0x0 12 | #define SDIO_BLK 0x4 13 | #define SDIO_BLKCNT 0x6 14 | #define SDIO_ARGU 0x8 15 | #define SDIO_TRNMOD 0xC 16 | #define SDIO_CMD 0xE 17 | #define SDIO_RESP0 0x10 18 | #define SDIO_RESP1 0x14 19 | #define SDIO_RESP2 0x18 20 | #define SDIO_RESP3 0x1C 21 | #define SDIO_DBUF 0x20 22 | #define SDIO_STATE 0x24 23 | #define SDIO_HOSTCTL 0x28 24 | #define SDIO_PWRCON 0x29 25 | #define SDIO_BLKGAP 0x2A 26 | #define SDIO_WAKCON 0x2B 27 | #define SDIO_CLKCON 0x2C 28 | #define SDIO_TIMEOUTCON 0x2E 29 | #define SDIO_SWRESET 0x2F 30 | #define SDIO_IRQ 0x30 31 | #define SDIO_IRQEN 0x34 32 | #define SDIO_ISREN 0x38 33 | #define SDIO_ACMD12ERRSTAT 0x3C 34 | #define SDIO_CAPLO 0x40 35 | #define SDIO_CAPHI 0x44 36 | #define SDIO_MAXCAPLO 0x48 37 | #define SDIO_MAXCAPHI 0x4C 38 | #define SDIO_ACMD12 0x50 39 | #define SDIO_ADMA 0x54 40 | #define SDIO_INFO 0xFC 41 | 42 | // SWRESET 43 | #define SDIO_SWRESET_RSTDAT (1 << 2) 44 | #define SDIO_SWRESET_RSTCMD (1 << 1) 45 | #define SDIO_SWRESET_RSTALL (1 << 0) 46 | #define SDIO_SWRESET_ALL (SDIO_SWRESET_RSTDAT | SDIO_SWRESET_RSTCMD | SDIO_SWRESET_RSTALL) 47 | 48 | //settings 49 | #define SDIO_Base_Frequency 51300000 // 51.3MHz 50 | #define SDIO_Max_Frequency 51900000 // 51.9MHz 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/spi.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_SPI_H 2 | #define HW_SPI_H 3 | 4 | // Device 5 | #define SPI0 0x82000000 6 | #define SPI1 0x82100000 7 | #define SPI2 0x82200000 8 | #define SPI3 0x82300000 9 | #define SPI4 0x82400000 10 | 11 | #define SPI0_CLOCKGATE 0x2B 12 | #define SPI1_CLOCKGATE 0x2C 13 | #define SPI2_CLOCKGATE 0x2D 14 | #define SPI3_CLOCKGATE 0x2E 15 | #define SPI4_CLOCKGATE 0x2F 16 | 17 | #define SPI0_IRQ 0x1D 18 | #define SPI1_IRQ 0x1E 19 | #define SPI2_IRQ 0x1F 20 | #define SPI3_IRQ 0x20 21 | #define SPI4_IRQ 0x21 22 | 23 | #define NUM_SPIPORTS 5 24 | 25 | // Setup register 26 | #define SPISETUP_NO_TRANSMIT_JUNK (1 << 0) // 1 bit 27 | #define SPISETUP_LAST_CLOCK_EDGE_MISSING (1 << 1) // 1 bit 28 | #define SPISETUP_IS_ACTIVE_LOW (1 << 2) // 1 bit 29 | #define SPISETUP_IS_MASTER (1 << 3) // 2 bits 30 | #define SPISETUP_OPTION5 (1 << 5) // 2 bits 31 | #define SPISETUP_UNKN1 (1 << 7) // 1 bit 32 | #define SPISETUP_UNKN2 (1 << 8) // 1 bit 33 | #define SPISETUP_CLOCKSOURCE (1 << 14) // 1 bit 34 | #define SPISETUP_WORDSIZE_SHIFT 15 // 2 bits 35 | #define SPISETUP_UNKN3 (1 << 21) // 1 bit 36 | 37 | #define STATUS_RX 1 38 | 39 | #define TX_BUFFER_LEFT(x) (((x) >> 6) & 0x1f) 40 | #define RX_BUFFER_LEFT(x) (((x) >> 11) & 0x1f) 41 | 42 | #define MAX_TX_BUFFER 0x1f 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_TIMER_H 2 | #define HW_TIMER_H 3 | 4 | // Constants 5 | #define EventTimer 4 6 | 7 | // Devices 8 | #define TIMER 0xBF100000 9 | 10 | // Registers 11 | 12 | #define TIMER_0 0x0 13 | #define TIMER_1 0x20 14 | #define TIMER_2 0x40 15 | #define TIMER_3 0x60 16 | #define TIMER_4 0xA0 17 | #define TIMER_5 0xC0 18 | #define TIMER_6 0xE0 19 | #define TIMER_CONFIG 0 20 | #define TIMER_STATE 0x4 21 | #define TIMER_COUNT_BUFFER 0x8 22 | #define TIMER_COUNT_BUFFER2 0xC 23 | #define TIMER_PRESCALER 0x10 24 | #define TIMER_UNKNOWN3 0x14 25 | #define TIMER_TICKSHIGH 0x2004 26 | #define TIMER_TICKSLOW 0x2000 27 | #define TIMER_UNKREG0 0x88 28 | #define TIMER_UNKREG1 0x8C 29 | #define TIMER_UNKREG2 0x90 30 | #define TIMER_UNKREG3 0x94 31 | #define TIMER_UNKREG4 0x98 32 | #define TIMER_IRQSTAT 0x10000 33 | #define TIMER_IRQLATCH 0xF8 34 | 35 | // Timer 36 | #define NUM_TIMERS 7 37 | #define TIMER_CLOCKGATE 0x25 38 | #define TIMER_IRQ 0x6 39 | #define TIMER_REGISTER 0xBF102008 40 | #define TIMER_REGISTER_TICK 0xBF102010 41 | /* Argument == 1 42 | #define TIMER_IRQ 0x5 43 | #define TIMER_REGISTER 0xBF10200C 44 | #define TIMER_REGISTER_TICK 0xBF102014 45 | */ 46 | #define TIMER_STATE_START 1 47 | #define TIMER_STATE_STOP 0 48 | #define TIMER_STATE_MANUALUPDATE 2 49 | #define TIMER_UNKREG0_RESET1 0xA 50 | #define TIMER_UNKREG0_RESET2 0x18010 51 | #define TIMER_UNKREG1_RESET 0xFFFFFFFF 52 | #define TIMER_UNKREG2_RESET 0xFFFFFFFF 53 | #define TIMER_UNKREG3_RESET 0xFFFFFFFF 54 | #define TIMER_UNKREG4_RESET 0xFFFFFFFF 55 | #define TIMER_DIVIDER1 4 56 | #define TIMER_DIVIDER2 0 57 | #define TIMER_DIVIDER4 1 58 | #define TIMER_DIVIDER16 2 59 | #define TIMER_DIVIDER64 3 60 | #define TIMER_SPECIALTIMER_BIT0 0x1000000 61 | #define TIMER_SPECIALTIMER_BIT1 0x2000000 62 | 63 | #define TIMER_Separator 4 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /plat-a4/includes/hardware/usbphy.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_USBPHY_H 2 | #define HW_USBPHY_H 3 | 4 | #define USB_PHY 0x86000000 5 | 6 | // Registers 7 | #define OPHYPWR 0 8 | #define OPHYCLK 0x4 9 | #define ORSTCON 0x8 10 | #define OPHYUNK1 0x1C 11 | #define OPHYUNK2 0x44 12 | #define OPHYUNK3 0x48 13 | #define OPHYUNK4 0x60 14 | 15 | // Values 16 | #define OPHYPWR_FORCESUSPEND 0x1 17 | #define OPHYPWR_PLLPOWERDOWN 0x2 18 | #define OPHYPWR_XOPOWERDOWN 0x4 19 | #define OPHYPWR_ANALOGPOWERDOWN 0x8 20 | #define OPHYPWR_UNKNOWNPOWERDOWN 0x10 21 | #define OPHYPWR_POWERON 0x0 // all the previous flags are off 22 | 23 | #define OPHYCLK_CLKSEL_MASK 0x3 24 | 25 | #define OPHYCLK_SPEED_48MHZ 48000000 26 | #define OPHYCLK_SPEED_12MHZ 12000000 27 | #define OPHYCLK_SPEED_24MHZ 24000000 28 | 29 | #define OPHYCLK_CLKSEL_12MHZ 0x0 30 | #define OPHYCLK_CLKSEL_24MHZ 0x1 31 | #define OPHYCLK_CLKSEL_48MHZ 0x2 32 | #define OPHYCLK_CLKSEL_OTHER 0x3 33 | 34 | #define ORSTCON_PHYSWRESET 0x1 35 | #define ORSTCON_LINKSWRESET 0x2 36 | #define ORSTCON_PHYLINKSWRESET 0x4 37 | 38 | #define OPHYUNK4_START 0x200 39 | #define OPHYUNK1_START 0x6 40 | #define OPHYUNK1_STOP_MASK 0x2 41 | #define OPHYUNK2_START 0x733 42 | 43 | #define USB_PHYPWRPOWERON_DELAYUS 10 44 | #define USB_RESET2_DELAYUS 20 45 | #define USB_RESET_DELAYUS 1000 46 | 47 | // Clockgates 48 | #define USB_CLOCKGATE_UNK1 0x1D 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /plat-a4/includes/mipi_dsim.h: -------------------------------------------------------------------------------- 1 | #ifndef MIPIDSIM_H 2 | #define MIPIDSIM_H 3 | 4 | #include "openiboot.h" 5 | #include "lcd.h" 6 | 7 | typedef struct LCDInfo { 8 | char* name; 9 | uint32_t unkn1; 10 | uint32_t DrivingClockFrequency; 11 | uint32_t DotPitch; 12 | uint32_t width; 13 | uint32_t horizontalBackPorch; 14 | uint32_t horizontalFrontPorch; 15 | uint32_t horizontalSyncPulseWidth; 16 | uint32_t height; 17 | uint32_t verticalBackPorch; 18 | uint32_t verticalFrontPorch; 19 | uint32_t verticalSyncPulseWidth; 20 | uint32_t IVClk; 21 | uint32_t IHSync; 22 | uint32_t IVSync; 23 | uint32_t IVDen; 24 | uint32_t bitsPerPixel; 25 | uint32_t unkn17; 26 | uint32_t unkn18; 27 | } LCDInfo; 28 | 29 | int mipi_dsim_init(LCDInfo* LCDTable); 30 | void mipi_dsim_quiesce(); 31 | void mipi_dsim_framebuffer_on_off(OnOff on_off); 32 | void mipi_dsim_on_off(OnOff on_off); 33 | int mipi_dsim_read_write(int a1, uint8_t* buffer, uint32_t* read); 34 | int mipi_dsim_write_data(uint8_t data_id, uint8_t data0, uint8_t data1); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /plat-a4/miu.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "miu.h" 3 | #include "clock.h" 4 | #include "hardware/power.h" 5 | #include "util.h" 6 | #include "chipid.h" 7 | 8 | int miu_setup() { 9 | if(POWER_ID_EPOCH(GET_REG(POWER + POWER_ID)) != chipid_get_power_epoch()) { 10 | // Epoch mismatch 11 | bufferPrintf("miu: epoch mismatch\r\n"); 12 | return -1; 13 | } 14 | 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /plat-a4/power.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "power.h" 3 | #include "hardware/power.h" 4 | 5 | int power_setup() { 6 | // Deprecated in 2.x 7 | #if 0 8 | SET_REG(POWER + POWER_CONFIG0, POWER_CONFIG0_RESET); 9 | SET_REG(POWER + POWER_CONFIG1, POWER_CONFIG1_RESET); 10 | SET_REG(POWER + POWER_CONFIG2, POWER_CONFIG2_RESET); 11 | 12 | /* turn off everything */ 13 | int toReset = POWER_DEFAULT_DEVICES | POWER_VROM; 14 | SET_REG(POWER + POWER_OFFCTRL, toReset); 15 | 16 | /* wait for the new state to take effect */ 17 | while((GET_REG(POWER + POWER_SETSTATE) & toReset) != (GET_REG(POWER + POWER_STATE) & toReset)); 18 | #endif 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /plat-a4/usbphy.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "usbphy.h" 3 | #include "hardware/usbphy.h" 4 | #include "timer.h" 5 | #include "clock.h" 6 | 7 | void usb_phy_init() { 8 | // power on PHY 9 | SET_REG(USB_PHY + OPHYUNK4, OPHYUNK4_START); 10 | SET_REG(USB_PHY + OPHYPWR, OPHYPWR_PLLPOWERDOWN | OPHYPWR_XOPOWERDOWN); 11 | SET_REG(USB_PHY + OPHYUNK1, OPHYUNK1_START); 12 | SET_REG(USB_PHY + OPHYUNK2, OPHYUNK2_START); 13 | 14 | udelay(USB_PHYPWRPOWERON_DELAYUS); 15 | 16 | // select clock 17 | uint32_t phyClockBits; 18 | switch (clock_get_frequency(FrequencyBaseUsbPhy)) 19 | { 20 | case OPHYCLK_SPEED_12MHZ: 21 | phyClockBits = OPHYCLK_CLKSEL_12MHZ; 22 | break; 23 | 24 | case OPHYCLK_SPEED_24MHZ: 25 | phyClockBits = OPHYCLK_CLKSEL_24MHZ; 26 | break; 27 | 28 | case OPHYCLK_SPEED_48MHZ: 29 | phyClockBits = OPHYCLK_CLKSEL_48MHZ; 30 | break; 31 | 32 | default: 33 | phyClockBits = OPHYCLK_CLKSEL_OTHER; 34 | break; 35 | } 36 | SET_REG(USB_PHY + OPHYCLK, (GET_REG(USB_PHY + OPHYCLK) & ~OPHYCLK_CLKSEL_MASK) | phyClockBits); 37 | 38 | // reset phy 39 | SET_REG(USB_PHY + ORSTCON, GET_REG(USB_PHY + ORSTCON) | ORSTCON_PHYSWRESET); 40 | udelay(USB_RESET2_DELAYUS); 41 | SET_REG(USB_PHY + ORSTCON, GET_REG(USB_PHY + ORSTCON) & (~ORSTCON_PHYSWRESET)); 42 | udelay(USB_RESET_DELAYUS); 43 | } 44 | 45 | void usb_phy_shutdown() { 46 | SET_REG(USB_PHY + OPHYPWR, OPHYPWR_FORCESUSPEND | OPHYPWR_PLLPOWERDOWN 47 | | OPHYPWR_XOPOWERDOWN | OPHYPWR_ANALOGPOWERDOWN | OPHYPWR_UNKNOWNPOWERDOWN); // power down phy 48 | SET_REG(USB_PHY + ORSTCON, GET_REG(USB_PHY+ORSTCON) | ORSTCON_PHYSWRESET); // reset phy/link 49 | 50 | udelay(USB_RESET_DELAYUS); // wait a millisecond for the changes to stick 51 | 52 | SET_REG(USB_PHY + OPHYUNK1, GET_REG(USB_PHY + OPHYUNK1) &~ OPHYUNK1_STOP_MASK); 53 | } 54 | 55 | 56 | -------------------------------------------------------------------------------- /plat-s5l8720/SConscript: -------------------------------------------------------------------------------- 1 | Import("*") 2 | 3 | env = env.Clone() 4 | env.Append(CPPPATH = [Dir('includes')]) 5 | env.Append(CPPDEFINES = ['ARM11', 'CONFIG_S5L8720']) 6 | 7 | env.AddModules([ 8 | "acm", 9 | "nor-spi", 10 | "usb-synopsys", 11 | ]) 12 | 13 | plat_s5l8720_src = arch_arm_src + env.Localize([ 14 | # Include the bits of base_src we use 15 | # until we implement it all 16 | '#device.c', 17 | '#mtd.c', 18 | '#bdev.c', 19 | # '#audiohw.c', 20 | '#actions.c', 21 | '#commands.c', 22 | '#framebuffer.c', 23 | '#images.c', 24 | '#malloc.c', 25 | '#nvram.c', 26 | '#openiboot.c', 27 | '#printf.c', 28 | '#scripting.c', 29 | '#sha1.c', 30 | '#stb_image.c', 31 | '#syscfg.c', 32 | '#tasks.c', 33 | '#util.c', 34 | 35 | 's5l8720.c', 36 | 'accel.c', 37 | 'aes.c', 38 | 'buttons.c', 39 | 'chipid.c', 40 | 'clcd.c', 41 | 'clock.c', 42 | 'dma.c', 43 | 'event.c', 44 | # 'ftl.c', 45 | 'gpio.c', 46 | 'i2c.c', 47 | 'interrupt.c', 48 | 'mipi_dsim.c', 49 | 'miu.c', 50 | 'mmu.c', 51 | # 'nand.c', 52 | 'pmu.c', 53 | 'power.c', 54 | # 'sdio.c', 55 | 'spi.c', 56 | 'timer.c', 57 | 'uart.c', 58 | 'usbphy.c', 59 | 'wdt.c', 60 | # 'wlan.c', 61 | ]) + hfs_src 62 | Export('plat_s5l8720_src') 63 | 64 | env.SConscript('iPodTouch2G.SConscript', 'env') 65 | -------------------------------------------------------------------------------- /plat-s5l8720/accel.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "commands.h" 3 | #include "util.h" 4 | #include "i2c.h" 5 | #include "hardware/accel.h" 6 | 7 | int accel_get_reg(int reg) { 8 | uint8_t registers[1]; 9 | uint8_t out[1]; 10 | 11 | registers[0] = reg; 12 | 13 | i2c_rx(ACCEL_I2C_BUS, ACCEL_GETADDR, registers, 1, out, 1); 14 | return out[0]; 15 | } 16 | 17 | int accel_write_reg(int reg, int data, int verify) { 18 | uint8_t command[2]; 19 | 20 | command[0] = reg; 21 | command[1] = data; 22 | 23 | i2c_tx(ACCEL_I2C_BUS, ACCEL_SETADDR, command, sizeof(command)); 24 | 25 | if(!verify) 26 | return 0; 27 | 28 | uint8_t accelReg = reg; 29 | uint8_t buffer = 0; 30 | i2c_rx(ACCEL_I2C_BUS, ACCEL_GETADDR, &accelReg, 1, &buffer, 1); 31 | 32 | if(buffer == data) 33 | return 0; 34 | else 35 | return -1; 36 | } 37 | 38 | void accel_init() 39 | { 40 | int whoami = accel_get_reg(ACCEL_WHOAMI); 41 | if(whoami != ACCEL_WHOAMI_VALUE) 42 | { 43 | bufferPrintf("accel: incorrect whoami value\n"); 44 | return; 45 | } 46 | 47 | accel_write_reg(ACCEL_CTRL_REG2, ACCEL_CTRL_REG2_BOOT, FALSE); 48 | accel_write_reg(ACCEL_CTRL_REG1, ACCEL_CTRL_REG1_PD | ACCEL_CTRL_REG1_XEN | ACCEL_CTRL_REG1_YEN | ACCEL_CTRL_REG1_ZEN, FALSE); 49 | } 50 | MODULE_INIT(accel_init); 51 | 52 | int accel_get_x() 53 | { 54 | return (signed char)(accel_get_reg(ACCEL_OUTX)); 55 | } 56 | 57 | int accel_get_y() 58 | { 59 | return (signed char)(accel_get_reg(ACCEL_OUTY)); 60 | } 61 | 62 | int accel_get_z() 63 | { 64 | return (signed char)(accel_get_reg(ACCEL_OUTZ)); 65 | } 66 | 67 | static error_t cmd_accel(int argc, char** argv) 68 | { 69 | int x = accel_get_x(); 70 | int y = accel_get_y(); 71 | int z = accel_get_z(); 72 | 73 | bufferPrintf("x: %d, y: %d, z: %d\r\n", x, y, z); 74 | 75 | return SUCCESS; 76 | } 77 | COMMAND("accel", "display accelerometer data", cmd_accel); 78 | -------------------------------------------------------------------------------- /plat-s5l8720/buttons.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "buttons.h" 3 | #include "hardware/buttons.h" 4 | #include "pmu.h" 5 | #include "gpio.h" 6 | 7 | int buttons_is_pushed(int which) { 8 | if(gpio_pin_state(which) && pmu_get_reg(BUTTONS_IIC_STATE)) 9 | return TRUE; 10 | else 11 | return FALSE; 12 | } 13 | -------------------------------------------------------------------------------- /plat-s5l8720/chipid.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "chipid.h" 3 | #include "hardware/chipid.h" 4 | 5 | int chipid_spi_clocktype() { 6 | return GET_SPICLOCKTYPE(GET_REG(CHIPID + SPICLOCKTYPE)); 7 | } 8 | 9 | unsigned int chipid_get_security_epoch() { 10 | return CHIPID_GET_SECURITY_EPOCH(GET_REG(CHIPID + CHIPINFO)); 11 | } 12 | 13 | unsigned int chipid_get_power_epoch() { 14 | return CHIPID_GET_POWER_EPOCH(GET_REG(CHIPID + CHIPINFO)); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /plat-s5l8720/iPodTouch2G.SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | # 4 | # iPod Touch 2G 5 | # 6 | 7 | ipt_2g_src = [plat_s5l8720_src, 8 | env.Localize([ 9 | '#audiohw-null.c', 10 | ])] 11 | Export('ipt_2g_src') 12 | 13 | env = env.Clone() 14 | env.Append(CPPDEFINES=['OPENIBOOT_VERSION_CONFIG=\\" for iPod Touch 2G\\"']) 15 | 16 | elf, bin, img3 = env.OpenIBootTarget('iPodTouch2G', 'ipt_2g_openiboot', 'CONFIG_IPOD_TOUCH_2G', ipt_2g_src, 'template-ipt2g') 17 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/hardware/accel.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_ACCEL_H 2 | #define HW_ACCEL_H 3 | 4 | // See http://www.st.com/stonline/products/literature/ds/12726.pdf 5 | 6 | #define ACCEL_I2C_BUS 0 7 | 8 | // could be 0x72 and 0x73 as well 9 | #define ACCEL_SETADDR 0x3A 10 | #define ACCEL_GETADDR 0x3B 11 | 12 | #define ACCEL_WHOAMI 0x0F 13 | #define ACCEL_CTRL_REG1 0x20 14 | #define ACCEL_CTRL_REG2 0x21 15 | #define ACCEL_STATUS 0x27 16 | #define ACCEL_OUTX 0x29 17 | #define ACCEL_OUTY 0x2B 18 | #define ACCEL_OUTZ 0x2D 19 | 20 | #define ACCEL_WHOAMI_VALUE 0x3B 21 | 22 | #define ACCEL_CTRL_REG1_DR (1 << 7) 23 | #define ACCEL_CTRL_REG1_PD (1 << 6) 24 | #define ACCEL_CTRL_REG1_FS (1 << 5) 25 | #define ACCEL_CTRL_REG1_STP (1 << 4) 26 | #define ACCEL_CTRL_REG1_STM (1 << 3) 27 | #define ACCEL_CTRL_REG1_ZEN (1 << 2) 28 | #define ACCEL_CTRL_REG1_YEN (1 << 1) 29 | #define ACCEL_CTRL_REG1_XEN (1 << 0) 30 | 31 | #define ACCEL_CTRL_REG2_SIM (1 << 7) 32 | #define ACCEL_CTRL_REG2_BOOT (1 << 6) 33 | #define ACCEL_CTRL_REG2_FDS (1 << 4) 34 | #define ACCEL_CTRL_REG2_HPEN2 (1 << 3) 35 | #define ACCEL_CTRL_REG2_HPEN1 (1 << 2) 36 | #define ACCEL_CTRL_REG2_HP2 (1 << 1) 37 | #define ACCEL_CTRL_REG2_HP1 (1 << 0) 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/hardware/aes.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_AES_H 2 | #define HW_AES_H 3 | 4 | // Device 5 | #define AES 0x38C00000 6 | 7 | // Registers 8 | #define CONTROL 0x0 9 | #define GO 0x4 10 | #define UNKREG0 0x8 11 | #define STATUS 0xC 12 | #define UNKREG1 0x10 13 | #define KEYLEN 0x14 14 | #define INSIZE 0x18 15 | #define INADDR 0x20 16 | #define OUTSIZE 0x24 17 | #define OUTADDR 0x28 18 | #define AUXSIZE 0x2C 19 | #define AUXADDR 0x30 20 | #define SIZE3 0x34 21 | #define KEY 0x4C 22 | #define TYPE 0x6C 23 | #define IV 0x74 24 | 25 | // Values 26 | 27 | #define KEYSIZE 0x20 28 | #define IVSIZE 0x10 29 | 30 | #define AES_ENCRYPT 1 31 | #define AES_DECRYPT 0 32 | 33 | #define GET_KEYLEN(x) GET_BITS(x, 16, 2) 34 | 35 | #define AES_CLOCKGATE 0xA 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/hardware/buttons.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_BUTTONS_H 2 | #define HW_BUTTONS_H 3 | 4 | // Device 5 | #define BUTTONS_HOME 0xC01 6 | #define BUTTONS_HOLD 0xC02 7 | #define BUTTONS_VOLUP 0x902 8 | #define BUTTONS_VOLDOWN 0xC00 9 | 10 | #define BUTTONS_HOME_IRQ 0x79 11 | #define BUTTONS_HOLD_IRQ 0x7A 12 | #define BUTTONS_VOLUP_IRQ 0x62 13 | #define BUTTONS_VOLDOWN_IRQ 0x78 14 | 15 | #define BUTTONS_IIC_STATE 0x4B 16 | 17 | #define BUTTONS_HOLD_IRQTYPE 1 18 | #define BUTTONS_HOME_IRQTYPE 1 19 | #define BUTTONS_VOLUP_IRQTYPE 1 20 | #define BUTTONS_VOLDOWN_IRQTYPE 1 21 | #define BUTTONS_RINGERAB_IRQTYPE 1 22 | 23 | #define BUTTONS_HOLD_IRQLEVEL 1 24 | #define BUTTONS_HOME_IRQLEVEL 1 25 | #define BUTTONS_VOLUP_IRQLEVEL 1 26 | #define BUTTONS_VOLDOWN_IRQLEVEL 1 27 | #define BUTTONS_RINGERAB_IRQLEVEL 1 28 | 29 | #define BUTTONS_HOLD_IRQAUTOFLIP 1 30 | #define BUTTONS_HOME_IRQAUTOFLIP 1 31 | #define BUTTONS_VOLUP_IRQAUTOFLIP 1 32 | #define BUTTONS_VOLDOWN_IRQAUTOFLIP 1 33 | #define BUTTONS_RINGERAB_IRQAUTOFLIP 1 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/hardware/chipid.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_CHIPID_H 2 | #define HW_CHIPID_H 3 | 4 | // Device 5 | #define CHIPID 0x3D100000 6 | 7 | // Registers 8 | #define SPICLOCKTYPE 0x4 9 | #define CHIPINFO 0x8 10 | 11 | // Values 12 | #define GET_SPICLOCKTYPE(x) GET_BITS(x, 24, 4) 13 | #define CHIPID_GET_SECURITY_EPOCH(x) (GET_BITS((x), 0, 1)) 14 | #define CHIPID_GET_POWER_EPOCH(x) (GET_BITS((x), 4, 7) > 3 ? 3 : 4) 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/hardware/clcd.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_CLCD_H 2 | #define HW_CLCD_H 3 | 4 | #define CLCD 0x38900000 5 | #define CLCD_FRAMEBUFFER 0xfc00000 6 | 7 | #define VIDCON1_IVCLKSHIFT 3 8 | #define VIDCON1_IHSYNCSHIFT 2 9 | #define VIDCON1_IVSYNCSHIFT 1 10 | #define VIDCON1_IVDENSHIFT 0 11 | 12 | #define VIDTCON_BACKPORCHSHIFT 16 13 | #define VIDTCON_BACKPORCHMASK 0xFF 14 | #define VIDTCON_FRONTPORCHSHIFT 8 15 | #define VIDTCON_FRONTPORCHMASK 0xFF 16 | #define VIDTCON_SYNCPULSEWIDTHSHIFT 0 17 | #define VIDTCON_SYNCPULSEWIDTHMASK 0xFF 18 | #define VIDTCON2_LINEVALMASK 0x3FF 19 | #define VIDTCON2_LINEVALSHIFT 0 20 | #define VIDTCON2_HOZVALMASK 0x3FF 21 | #define VIDTCON2_HOZVALSHIFT 16 22 | 23 | #define DISPLAYID 0 24 | 25 | #define LCD_MAX_BACKLIGHT 245 26 | #define LCD_BACKLIGHT_REG 0x30 27 | #define LCD_BACKLIGHT_REGMASK 0xFF 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/hardware/gpio.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_GPIO_H 2 | #define HW_GPIO_H 3 | 4 | // gpioicBase 5 | // Device 6 | #define GPIOIC 0x39700000 /* probably a part of the system controller */ 7 | 8 | // gpioBaseAddress 9 | #define GPIO 0x3CF00000 10 | 11 | // Registers 12 | #define GPIO_INTLEVEL 0x80 13 | #define GPIO_INTSTAT 0xA0 14 | #define GPIO_INTEN 0xC0 15 | #define GPIO_INTTYPE 0xE0 16 | #define GPIO_FSEL 0x1E0 17 | 18 | // Values 19 | #define GPIO_NUMINTGROUPS 7 20 | #define GPIO_INTSTAT_RESET 0xFFFFFFFF 21 | #define GPIO_INTEN_RESET 0 22 | 23 | #define GPIO_FSEL_MAJSHIFT 16 24 | #define GPIO_FSEL_MAJMASK 0x1F 25 | #define GPIO_FSEL_MINSHIFT 8 26 | #define GPIO_FSEL_MINMASK 0x7 27 | #define GPIO_FSEL_USHIFT 0 28 | #define GPIO_FSEL_UMASK 0xF 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/hardware/i2c.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_I2C_H 2 | #define HW_I2C_H 3 | 4 | // Device 5 | #define I2C0 0x3C600000 6 | #define I2C1 0x3C900000 7 | 8 | // Registers 9 | #define IICCON 0x0 10 | #define IICSTAT 0x4 11 | #define IICADD 0x8 12 | #define IICDS 0xC 13 | #define IICLC 0x10 14 | #define IICREG14 0x14 15 | #define IICREG18 0x18 16 | #define IICREG1C 0x1C 17 | #define IICREG20 0x20 18 | 19 | // Values 20 | #define IICCON_INIT 0x3F00 21 | #define IICCON_ACKGEN (1 << 7) 22 | #define IICCON_TXCLKSRC_FPCLK16 (0 << 6) 23 | #define IICCON_TXCLKSRC_FPCLK512 (1 << 6) 24 | #define IICCON_INTENABLE (1 << 5) 25 | #define IICCON_INTPENDING (1 << 4) 26 | #define IICCON_TXCLKPRESCALEMASK 0xF 27 | 28 | #define IICSTAT_MODE_SLAVERX 0 29 | #define IICSTAT_MODE_SLAVETX 1 30 | #define IICSTAT_MODE_MASTERRX 2 31 | #define IICSTAT_MODE_MASTERTX 3 32 | #define IICSTAT_MODE_SHIFT 6 33 | #define IICSTAT_MODE_MASK 3 34 | #define IICSTAT_STARTSTOPGEN_START 1 35 | #define IICSTAT_STARTSTOPGEN_STOP 0 36 | #define IICSTAT_STARTSTOPGEN_MASK 1 37 | #define IICSTAT_STARTSTOPGEN_SHIFT 5 38 | #define IICSTAT_DATAOUTPUT_ENABLE_SHIFT 4 39 | #define IICSTAT_LASTRECEIVEDBIT (1 << 0) 40 | 41 | #define I2C0_SCL_GPIO 0x207 42 | #define I2C0_SDA_GPIO 0x300 43 | #define I2C1_SCL_GPIO 0x102 44 | #define I2C1_SDA_GPIO 0x103 45 | 46 | #define I2C0_CLOCKGATE 0x7 47 | #define I2C1_CLOCKGATE 0x8 48 | 49 | #define TXFREQ 25000 50 | 51 | #define OPERATION_SEND (1 << 8) 52 | #define OPERATION_CONDITIONCHANGE (1 << 13) 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/hardware/interrupt.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_INTERRUPT_H 2 | #define HW_INTERRUPT_H 3 | 4 | // This appears to be a PL192 5 | 6 | // Constants 7 | 8 | #define VIC_MaxInterrupt 0x40 9 | #define VIC_InterruptSeparator 0x20 10 | 11 | // Devices 12 | 13 | #define VIC0 0x38E00000 14 | #define VIC1 0x38E01000 15 | 16 | // Registers 17 | 18 | #define VICIRQSTATUS 0x000 19 | #define VICRAWINTR 0x8 20 | #define VICINTSELECT 0xC 21 | #define VICINTENABLE 0x10 22 | #define VICINTENCLEAR 0x14 23 | #define VICSWPRIORITYMASK 0x24 24 | #define VICVECTADDRS 0x100 25 | #define VICADDRESS 0xF00 26 | #define VICPERIPHID0 0xFE0 27 | #define VICPERIPHID1 0xFE4 28 | #define VICPERIPHID2 0xFE8 29 | #define VICPERIPHID3 0xFEC 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/hardware/platform.h: -------------------------------------------------------------------------------- 1 | #include "hardware/s5l8720.h" 2 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/hardware/pmu.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_PMU_H 2 | #define HW_PMU_H 3 | 4 | #define PMU_I2C_BUS 0 5 | 6 | // Power 7 | #define PMU_SETADDR 0xE6 8 | #define PMU_GETADDR 0xE7 9 | 10 | // Values 11 | #define PMU_MAXREG 0xF 12 | 13 | // Registers 14 | #define PMU_OOCSHDWN 0xA 15 | #define PMU_ADCSTS 0x2 16 | #define PMU_ADCCON 0x40 17 | #define PMU_ADCOUT1 0x41 18 | #define PMU_ADCOUT2 0x42 19 | #define PMU_GPMEM_START 0x60 20 | #define PMU_VOLTAGE1 0x6E 21 | #define PMU_VOLTAGE2 0x6D 22 | 23 | #define PMU_RTCSC_MASK 0x7F 24 | #define PMU_RTCMN_MASK 0x7F 25 | #define PMU_RTCHR_MASK 0x3F 26 | #define PMU_RTCWD_MASK 0x07 27 | #define PMU_RTCDT_MASK 0x3F 28 | #define PMU_RTCMT_MASK 0x1F 29 | #define PMU_RTCYR_MASK 0xFF 30 | 31 | #define PMU_OOCSHDWN_GOSTBY (1 << 0) 32 | 33 | #define PMU_MBCS1_ADAPTPRES (1 << 2) 34 | #define PMU_MBCS1_USBOK (1 << 0) 35 | 36 | #define PMU_ADCC1_ADCINMUX_SHIFT 4 37 | #define PMU_ADCC1_ADCINMUX_MASK 0xF 38 | #define PMU_ADCC1_ADC_AV_SHIFT 2 39 | #define PMU_ADCC1_ADCSTART 0x1 40 | #define PMU_ADCC1_ADCRES 0x2 41 | 42 | #define PMU_ADCC1_ADC_AV_1 0x0 43 | #define PMU_ADCC1_ADC_AV_4 0x1 44 | #define PMU_ADCC1_ADC_AV_8 0x2 45 | #define PMU_ADCC1_ADC_AV_16 0x3 46 | 47 | #define PMU_ADCC1_ADCINMUX_BATSNS_DIV 0x0 48 | #define PMU_ADCC1_ADCINMUX_BATSNS_SUB 0x1 49 | #define PMU_ADCC1_ADCINMUX_ADCIN2_DIV 0x2 50 | #define PMU_ADCC1_ADCINMUX_ADCIN2_SUB 0x3 51 | #define PMU_ADCC1_ADCINMUX_BATTEMP 0x6 52 | #define PMU_ADCC1_ADCINMUX_ADCIN1 0x7 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/hardware/power.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_POWER_H 2 | #define HW_POWER_H 3 | 4 | // Device 5 | #define POWER 0x39700000 /* probably a part of the system controller */ 6 | 7 | // Power 8 | #define POWER_DEFAULT_DEVICES 0xEC 9 | #define POWER_LCD 0x100 10 | #define POWER_USB 0x200 11 | #define POWER_VROM 0x1000 12 | 13 | // Registers 14 | #define POWER_CONFIG0 0x0 15 | #define POWER_CONFIG1 0x20 16 | #define POWER_CONFIG2 0x6C 17 | #define POWER_CONFIG3 0x74 18 | #define POWER_ONCTRL 0xC 19 | #define POWER_OFFCTRL 0x10 20 | #define POWER_SETSTATE 0x8 21 | #define POWER_STATE 0x14 22 | #define POWER_ID 0x44 23 | #define POWER_ID_EPOCH(x) ((x) >> 24) 24 | 25 | // Values 26 | #define POWER_CONFIG0_RESET 0x1021002 27 | #define POWER_CONFIG2_RESET 0x0 28 | #define POWER_CONFIG3_RESET_DIVIDER 1000000 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/hardware/radio.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_RADIO_H 2 | #define HW_RADIO_H 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/hardware/s5l8720.h: -------------------------------------------------------------------------------- 1 | #ifndef S5L8720_H 2 | #define S5L8720_H 3 | 4 | /* 5 | * Constants 6 | */ 7 | 8 | #define MemoryStart 0x00000000 9 | #define MemoryEnd 0xFFFFFFFF 10 | #define LargeMemoryStart 0x08000000 /* FIXME: This is an ugly hack to get around iBoot's memory rearrangement. Linux boot will only work for installed openiboot! */ 11 | #define RAMStart 0 12 | #define RAMEnd 0x08000000 13 | #define MemoryHigher 0x80000000 14 | #define ExceptionVector MemoryStart 15 | #ifdef SMALL 16 | #define PageTable (OpenIBootLoad + 0x24000) 17 | #define HeapStart (PageTable + 0x4000) 18 | #else 19 | #define OpenIBootLoad 0x00000000 20 | #define GeneralStack ((PageTable - 4) + LargeMemoryStart) 21 | #define HeapStart (LargeMemoryStart + 0x02000000) 22 | #define PageTable (RAMEnd - 0x4000) 23 | #endif 24 | 25 | /* 26 | * Devices 27 | */ 28 | 29 | #define PeripheralPort 0x38000000 30 | #define AMC0 0x38500000 31 | 32 | #define WDT_CTRL 0x3C800000 33 | #define WDT_CNT 0x3C800004 34 | 35 | #define WDT_INT 0x33 36 | 37 | /* 38 | * Values 39 | */ 40 | 41 | #define EDRAM_CLOCKGATE 0x1B 42 | #define WDT_ENABLE 0x100000 43 | #define WDT_PRE_SHIFT 16 44 | #define WDT_PRE_MASK 0xF 45 | #define WDT_CS_SHIFT 12 46 | #define WDT_CS_MASK 0x7 47 | #define WDT_CLR 0xA00 48 | #define WDT_DIS 0xA5 49 | #define WDT_INT_EN 0x8000 50 | 51 | #define DMA_ALIGN 0x40 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/hardware/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_TIMER_H 2 | #define HW_TIMER_H 3 | 4 | // Constants 5 | #define EventTimer 4 6 | 7 | // Devices 8 | #define TIMER 0x3C700000 9 | 10 | // Registers 11 | 12 | #define TIMER_0 0x0 13 | #define TIMER_1 0x20 14 | #define TIMER_2 0x40 15 | #define TIMER_3 0x60 16 | #define TIMER_4 0xA0 17 | #define TIMER_5 0xC0 18 | #define TIMER_6 0xE0 19 | #define TIMER_7 0x100 20 | #define TIMER_CONFIG 0 21 | #define TIMER_STATE 0x4 22 | #define TIMER_COUNT_BUFFER 0x8 23 | #define TIMER_COUNT_BUFFER2 0xC 24 | #define TIMER_PRESCALER 0x10 25 | #define TIMER_UNKNOWN3 0x14 26 | #define TIMER_TICKSHIGH 0x80 27 | #define TIMER_TICKSLOW 0x84 28 | #define TIMER_UNKREG0 0x88 29 | #define TIMER_UNKREG1 0x8C 30 | #define TIMER_UNKREG2 0x90 31 | #define TIMER_UNKREG3 0x94 32 | #define TIMER_UNKREG4 0x98 33 | #define TIMER_IRQSTAT 0x10000 34 | #define TIMER_IRQLATCH 0x118 35 | 36 | // Timer 37 | #define NUM_TIMERS 8 38 | #define TIMER_CLOCKGATE 0x13 39 | #define TIMER_IRQ 0x7 40 | #define TIMER_STATE_START 1 41 | #define TIMER_STATE_STOP 0 42 | #define TIMER_STATE_MANUALUPDATE 2 43 | #define TIMER_UNKREG0_RESET1 0xA 44 | #define TIMER_UNKREG0_RESET2 0x18010 45 | #define TIMER_UNKREG1_RESET 0xFFFFFFFF 46 | #define TIMER_UNKREG2_RESET 0xFFFFFFFF 47 | #define TIMER_UNKREG3_RESET 0xFFFFFFFF 48 | #define TIMER_UNKREG4_RESET 0xFFFFFFFF 49 | #define TIMER_DIVIDER1 4 50 | #define TIMER_DIVIDER2 0 51 | #define TIMER_DIVIDER4 1 52 | #define TIMER_DIVIDER16 2 53 | #define TIMER_DIVIDER64 3 54 | #define TIMER_SPECIALTIMER_BIT0 0x1000000 55 | #define TIMER_SPECIALTIMER_BIT1 0x2000000 56 | 57 | #define TIMER_Separator 4 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/hardware/usbphy.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_USBPHY_H 2 | #define HW_USBPHY_H 3 | 4 | #define USB_PHY 0x3C400000 5 | 6 | // Registers 7 | #define OPHYPWR 0 8 | #define OPHYCLK 0x4 9 | #define ORSTCON 0x8 10 | #define OPHYUNK1 0x1C 11 | #define OPHYUNK2 0x44 12 | #define OPHYCHARGER 0x48 13 | 14 | // Values 15 | #define OPHYPWR_FORCESUSPEND 0x1 16 | #define OPHYPWR_PLLPOWERDOWN 0x2 17 | #define OPHYPWR_XOPOWERDOWN 0x4 18 | #define OPHYPWR_ANALOGPOWERDOWN 0x8 19 | #define OPHYPWR_UNKNOWNPOWERDOWN 0x10 20 | #define OPHYPWR_POWERON 0x0 // all the previous flags are off 21 | 22 | #define OPHYCLK_CLKSEL_MASK 0x3 23 | 24 | #define OPHYCLK_SPEED_48MHZ 48000000 25 | #define OPHYCLK_SPEED_12MHZ 12000000 26 | #define OPHYCLK_SPEED_24MHZ 24000000 27 | 28 | #define OPHYCLK_CLKSEL_12MHZ 0x0 29 | #define OPHYCLK_CLKSEL_24MHZ 0x1 30 | #define OPHYCLK_CLKSEL_48MHZ 0x2 31 | #define OPHYCLK_CLKSEL_OTHER 0x3 32 | 33 | #define ORSTCON_PHYSWRESET 0x1 34 | #define ORSTCON_LINKSWRESET 0x2 35 | #define ORSTCON_PHYLINKSWRESET 0x4 36 | 37 | #define OPHYUNK1_START 0x6 38 | #define OPHYUNK1_STOP_MASK 0x2 39 | 40 | #define OPHYUNK2_START 0xE3F 41 | 42 | #define OPHYCHARGER_DN (1 << 2) 43 | #define OPHYCHARGER_DP (1 << 1) 44 | #define OPHYCHARGER_NONE 0 45 | #define OPHYCHARGER_MASK 0x6 46 | 47 | #define USB_PHYPWRPOWERON_DELAYUS 10 48 | #define USB_RESET2_DELAYUS 20 49 | #define USB_RESET_DELAYUS 1000 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /plat-s5l8720/includes/mipi_dsim.h: -------------------------------------------------------------------------------- 1 | #ifndef MIPIDSIM_H 2 | #define MIPIDSIM_H 3 | 4 | #include "openiboot.h" 5 | #include "lcd.h" 6 | 7 | typedef struct LCDInfo { 8 | char* name; 9 | uint32_t frequencyBase; 10 | uint32_t drivingClockFrequency; 11 | uint32_t dotPitch; 12 | uint32_t width; 13 | uint32_t horizontalBackPorch; 14 | uint32_t horizontalFrontPorch; 15 | uint32_t horizontalSyncPulseWidth; 16 | uint32_t height; 17 | uint32_t verticalBackPorch; 18 | uint32_t verticalFrontPorch; 19 | uint32_t verticalSyncPulseWidth; 20 | uint32_t IVClk; 21 | uint32_t IHSync; 22 | uint32_t IVSync; 23 | uint32_t IVDen; 24 | uint32_t bitsPerPixel; 25 | uint32_t unkn17; 26 | uint32_t unkn18; 27 | } LCDInfo; 28 | 29 | int mipi_dsim_init(LCDInfo* LCDTable); 30 | void mipi_dsim_quiesce(); 31 | void mipi_dsim_framebuffer_on_off(OnOff on_off); 32 | void mipi_dsim_on_off(OnOff on_off); 33 | int mipi_dsim_read_write(int a1, uint8_t* buffer, uint32_t* read); 34 | int mipi_dsim_write_data(uint8_t data_id, uint8_t data0, uint8_t data1); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /plat-s5l8720/miu.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "miu.h" 3 | #include "clock.h" 4 | #include "hardware/power.h" 5 | #include "util.h" 6 | #include "chipid.h" 7 | 8 | int miu_setup() { 9 | if(POWER_ID_EPOCH(GET_REG(POWER + POWER_ID)) != chipid_get_power_epoch()) { 10 | // Epoch mismatch 11 | bufferPrintf("miu: epoch mismatch\r\n"); 12 | return -1; 13 | } 14 | 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /plat-s5l8720/power.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "power.h" 3 | #include "hardware/power.h" 4 | #include "clock.h" 5 | 6 | int power_setup() { 7 | SET_REG(POWER + POWER_CONFIG0, POWER_CONFIG0_RESET); 8 | SET_REG(POWER + POWER_CONFIG2, POWER_CONFIG2_RESET); 9 | SET_REG(POWER + POWER_CONFIG3, clock_get_base_frequency() / POWER_CONFIG3_RESET_DIVIDER); 10 | return 0; 11 | } 12 | 13 | int power_ctrl(uint32_t device, OnOff on_off) { 14 | // only clock gates are used for the S5L8720 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /plat-s5l8900/SConscript: -------------------------------------------------------------------------------- 1 | Import("*") 2 | 3 | env = env.Clone() 4 | env.Append(CPPPATH = [Dir('includes')]) 5 | env.Append(CPPDEFINES = ['ARM11', 'CONFIG_S5L8900']) 6 | 7 | env.AddModules([ 8 | "acm", 9 | "usb-synopsys", 10 | ]) 11 | 12 | plat_s5l8900_src = arch_arm_src + base_src + env.Localize([ 13 | 's5l8900.c', 14 | 'accel.c', 15 | 'aes.c', 16 | 'buttons.c', 17 | 'chipid.c', 18 | 'clock.c', 19 | 'dma.c', 20 | 'event.c', 21 | 'gpio.c', 22 | 'i2c.c', 23 | 'interrupt.c', 24 | 'lcd.c', 25 | 'miu.c', 26 | 'mmu.c', 27 | 'nand.c', 28 | 'ftl.c', 29 | 'pmu.c', 30 | 'power.c', 31 | 'sdio.c', 32 | 'spi.c', 33 | 'timer.c', 34 | 'uart.c', 35 | 'usbphy.c', 36 | 'wdt.c', 37 | 'wlan.c', 38 | ]) + hfs_src 39 | Export('plat_s5l8900_src') 40 | 41 | env.SConscript('iPhone3G.SConscript', 'env') 42 | env.SConscript('iPhone2G.SConscript', 'env') 43 | env.SConscript('iPodTouch1G.SConscript', 'env') 44 | -------------------------------------------------------------------------------- /plat-s5l8900/accel.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "commands.h" 3 | #include "util.h" 4 | #include "i2c.h" 5 | #include "hardware/accel.h" 6 | 7 | int accel_get_reg(int reg) { 8 | uint8_t registers[1]; 9 | uint8_t out[1]; 10 | 11 | registers[0] = reg; 12 | 13 | i2c_rx(ACCEL_I2C_BUS, ACCEL_GETADDR, registers, 1, out, 1); 14 | return out[0]; 15 | } 16 | 17 | int accel_write_reg(int reg, int data, int verify) { 18 | uint8_t command[2]; 19 | 20 | command[0] = reg; 21 | command[1] = data; 22 | 23 | i2c_tx(ACCEL_I2C_BUS, ACCEL_SETADDR, command, sizeof(command)); 24 | 25 | if(!verify) 26 | return 0; 27 | 28 | uint8_t accelReg = reg; 29 | uint8_t buffer = 0; 30 | i2c_rx(ACCEL_I2C_BUS, ACCEL_GETADDR, &accelReg, 1, &buffer, 1); 31 | 32 | if(buffer == data) 33 | return 0; 34 | else 35 | return -1; 36 | } 37 | 38 | void accel_init() 39 | { 40 | int whoami = accel_get_reg(ACCEL_WHOAMI); 41 | if(whoami != ACCEL_WHOAMI_VALUE) 42 | { 43 | bufferPrintf("accel: incorrect whoami value\n"); 44 | return; 45 | } 46 | 47 | accel_write_reg(ACCEL_CTRL_REG2, ACCEL_CTRL_REG2_BOOT, FALSE); 48 | accel_write_reg(ACCEL_CTRL_REG1, ACCEL_CTRL_REG1_PD | ACCEL_CTRL_REG1_XEN | ACCEL_CTRL_REG1_YEN | ACCEL_CTRL_REG1_ZEN, FALSE); 49 | } 50 | MODULE_INIT(accel_init); 51 | 52 | int accel_get_x() 53 | { 54 | return (signed char)(accel_get_reg(ACCEL_OUTX)); 55 | } 56 | 57 | int accel_get_y() 58 | { 59 | return (signed char)(accel_get_reg(ACCEL_OUTY)); 60 | } 61 | 62 | int accel_get_z() 63 | { 64 | return (signed char)(accel_get_reg(ACCEL_OUTZ)); 65 | } 66 | 67 | static error_t cmd_accel(int argc, char** argv) 68 | { 69 | int x = accel_get_x(); 70 | int y = accel_get_y(); 71 | int z = accel_get_z(); 72 | 73 | bufferPrintf("x: %d, y: %d, z: %d\r\n", x, y, z); 74 | 75 | return 0; 76 | } 77 | COMMAND("accel", "display accelerometer data", cmd_accel); 78 | -------------------------------------------------------------------------------- /plat-s5l8900/buttons.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "buttons.h" 3 | #include "hardware/buttons.h" 4 | #include "pmu.h" 5 | #include "gpio.h" 6 | 7 | int buttons_is_pushed(int which) { 8 | if(gpio_pin_state(which) && pmu_get_reg(BUTTONS_IIC_STATE)) 9 | return TRUE; 10 | else 11 | return FALSE; 12 | } 13 | -------------------------------------------------------------------------------- /plat-s5l8900/camera.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static uint16_t camera_readw(uint16_t addr); 10 | 11 | int camera_setup() { 12 | gpio_custom_io(CAMERA_GPIO_CLOCK_ENABLE, 0x02); 13 | gpio_pin_output(CAMERA_GPIO_POWER_ON, 1); 14 | 15 | gpio_pin_output(CAMERA_GPIO_STANDBY, 1); 16 | gpio_pin_output(CAMERA_GPIO_RESET, 0); 17 | 18 | udelay(1000); 19 | 20 | gpio_pin_output(CAMERA_GPIO_STANDBY, 0); 21 | gpio_pin_output(CAMERA_GPIO_RESET, 1); 22 | 23 | udelay(1000); 24 | 25 | uint16_t modelID = camera_readw(0x3000); 26 | 27 | if(modelID != 0x1580) 28 | { 29 | bufferPrintf("camera: unrecognized sensor model ID = 0x%x!\r\n", modelID); 30 | return -1; 31 | } 32 | 33 | bufferPrintf("camera: sensor model ID = 0x%x\r\n", modelID); 34 | 35 | return 0; 36 | } 37 | 38 | static void camera_init() 39 | { 40 | camera_setup(); 41 | } 42 | MODULE_INIT(camera_init); 43 | 44 | static uint16_t camera_readw(uint16_t addr) 45 | { 46 | uint8_t registers[2]; 47 | uint8_t buffer[2]; 48 | 49 | registers[0] = (addr >> 8) & 0xFF; 50 | registers[1] = addr & 0xFF; 51 | buffer[0] = 0xDE; 52 | buffer[1] = 0xAD; 53 | 54 | i2c_rx(1, CAMERA_ADDR, registers, 2, buffer, 2); 55 | 56 | return (buffer[0] << 8) | buffer[1]; 57 | } 58 | -------------------------------------------------------------------------------- /plat-s5l8900/chipid.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "chipid.h" 3 | #include "hardware/chipid.h" 4 | 5 | int chipid_spi_clocktype() { 6 | return GET_SPICLOCKTYPE(GET_REG(CHIPID + SPICLOCKTYPE)); 7 | } 8 | 9 | unsigned int chipid_get_power_epoch() { 10 | return CHIPID_GET_POWER_EPOCH(GET_REG(CHIPID)); 11 | } 12 | 13 | unsigned int chipid_get_nand_epoch() 14 | { 15 | // TODO: This needs sorting out! -- Ricky26 16 | return chipid_get_power_epoch(); 17 | } 18 | -------------------------------------------------------------------------------- /plat-s5l8900/iPhone2G.SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | # 4 | # iPhone 2G 5 | # 6 | 7 | iphone_2g_src = [ 8 | plat_s5l8900_src, 9 | env.Localize([ 10 | 'camera.c', 11 | 'als-TSL2561.c', 12 | 'multitouch-z1.c', 13 | 'wm8958.c', 14 | 'vibrator-2G.c', 15 | ])] 16 | Export('iphone_2g_src') 17 | 18 | env = env.Clone() 19 | env.Append(CPPDEFINES=['OPENIBOOT_VERSION_CONFIG=\\" for iPhone 2G\\"', 'MACH_ID=3556']) 20 | 21 | env.AddModules([ 22 | "radio-pmb8876", 23 | "nor-cfi", 24 | ]) 25 | 26 | elf, bin, img3 = env.MenuEnv().OpenIBootTarget('iPhone2G', 'iphone_2g_openiboot', 'CONFIG_IPHONE_2G', iphone_2g_src, 'template') 27 | env.InstallerEnv().OpenIBootTarget('iPhone2G-Installer', 'iphone_2g_installer', 'CONFIG_IPHONE_2G', iphone_2g_src, 'template') 28 | Default(img3) 29 | -------------------------------------------------------------------------------- /plat-s5l8900/iPhone3G.SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | # 4 | # iPhone 3G 5 | # 6 | 7 | iphone_3g_src = [ 8 | plat_s5l8900_src, 9 | env.Localize([ 10 | 'camera.c', 11 | 'multitouch-z2.c', 12 | 'wm8991.c', 13 | 'als-ISL29003.c', 14 | 'vibrator-3G.c', 15 | ])] 16 | Export('iphone_3g_src') 17 | 18 | env = env.Clone() 19 | env.Append(CPPDEFINES=['OPENIBOOT_VERSION_CONFIG=\\" for iPhone 3G\\"', 'MACH_ID=3557']) 20 | 21 | env.AddModules([ 22 | "radio-pmb8878", 23 | "nor-spi", 24 | ]) 25 | 26 | elf, bin, img3 = env.MenuEnv().OpenIBootTarget('iPhone3G', 'iphone_3g_openiboot', 'CONFIG_IPHONE_3G', iphone_3g_src, 'template-3g') 27 | env.InstallerEnv().OpenIBootTarget('iPhone3G-Installer', 'iphone_3g_installer', 'CONFIG_IPHONE_3G', iphone_3g_src, 'template-3g') 28 | Default(img3) 29 | -------------------------------------------------------------------------------- /plat-s5l8900/iPodTouch1G.SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | # 4 | # iPod Touch 1G 5 | # 6 | 7 | ipt_1g_src = [ 8 | plat_s5l8900_src, 9 | env.Localize([ 10 | 'piezo.c', 11 | 'wm8958.c', 12 | 'multitouch-z2.c', 13 | ])] 14 | Export('ipt_1g_src') 15 | 16 | env = env.Clone() 17 | env.Append(CPPDEFINES=['OPENIBOOT_VERSION_CONFIG=\\" for iPod Touch 1G\\"', 'MACH_ID=3558']) 18 | 19 | env.AddModules([ 20 | "nor-cfi", 21 | ]) 22 | 23 | elf, bin, img3 = env.MenuEnv().OpenIBootTarget('iPodTouch1G', 'ipt_1g_openiboot', 'CONFIG_IPOD_TOUCH_1G', ipt_1g_src, 'template-ipt1g') 24 | env.InstallerEnv().OpenIBootTarget('iPodTouch1G-Installer', 'ipt_1g_installer', 'CONFIG_IPOD_TOUCH_1G', ipt_1g_src, 'template-ipt1g') 25 | Default(img3) 26 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/accel.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_ACCEL_H 2 | #define HW_ACCEL_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // See http://www.st.com/stonline/products/literature/ds/12726.pdf 7 | 8 | #define ACCEL_I2C_BUS 0 9 | 10 | // could be 0x72 and 0x73 as well 11 | #define ACCEL_SETADDR 0x3A 12 | #define ACCEL_GETADDR 0x3B 13 | 14 | #define ACCEL_WHOAMI 0x0F 15 | #define ACCEL_CTRL_REG1 0x20 16 | #define ACCEL_CTRL_REG2 0x21 17 | #define ACCEL_STATUS 0x27 18 | #define ACCEL_OUTX 0x29 19 | #define ACCEL_OUTY 0x2B 20 | #define ACCEL_OUTZ 0x2D 21 | 22 | #define ACCEL_WHOAMI_VALUE 0x3B 23 | 24 | #define ACCEL_CTRL_REG1_DR (1 << 7) 25 | #define ACCEL_CTRL_REG1_PD (1 << 6) 26 | #define ACCEL_CTRL_REG1_FS (1 << 5) 27 | #define ACCEL_CTRL_REG1_STP (1 << 4) 28 | #define ACCEL_CTRL_REG1_STM (1 << 3) 29 | #define ACCEL_CTRL_REG1_ZEN (1 << 2) 30 | #define ACCEL_CTRL_REG1_YEN (1 << 1) 31 | #define ACCEL_CTRL_REG1_XEN (1 << 0) 32 | 33 | #define ACCEL_CTRL_REG2_SIM (1 << 7) 34 | #define ACCEL_CTRL_REG2_BOOT (1 << 6) 35 | #define ACCEL_CTRL_REG2_FDS (1 << 4) 36 | #define ACCEL_CTRL_REG2_HPEN2 (1 << 3) 37 | #define ACCEL_CTRL_REG2_HPEN1 (1 << 2) 38 | #define ACCEL_CTRL_REG2_HP2 (1 << 1) 39 | #define ACCEL_CTRL_REG2_HP1 (1 << 0) 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/aes.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_AES_H 2 | #define HW_AES_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // Device 7 | #define AES 0x38C00000 8 | 9 | // Registers 10 | #define CONTROL 0x0 11 | #define GO 0x4 12 | #define UNKREG0 0x8 13 | #define STATUS 0xC 14 | #define UNKREG1 0x10 15 | #define KEYLEN 0x14 16 | #define INSIZE 0x18 17 | #define INADDR 0x20 18 | #define OUTSIZE 0x24 19 | #define OUTADDR 0x28 20 | #define AUXSIZE 0x2C 21 | #define AUXADDR 0x30 22 | #define SIZE3 0x34 23 | #define KEY 0x4C 24 | #define TYPE 0x6C 25 | #define IV 0x74 26 | 27 | // Values 28 | 29 | #define KEYSIZE 0x20 30 | #define IVSIZE 0x10 31 | 32 | #define AES_ENCRYPT 1 33 | #define AES_DECRYPT 0 34 | 35 | #define GET_KEYLEN(x) GET_BITS(x, 16, 2) 36 | 37 | #define AES_CLOCKGATE 0xA 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/als.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_ALS_H 2 | #define HW_ALS_H 3 | 4 | #define ALS_I2C 0 5 | 6 | #ifdef CONFIG_IPHONE_3G 7 | #define ALS_ADDR 0x88 8 | #else 9 | #define ALS_ADDR 0x92 10 | #endif 11 | #define ALS_INT 0x49 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/audiocodec.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_WM8958_H 2 | #define HW_WM8958_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | #ifdef CONFIG_IPOD_TOUCH_1G 7 | #define WMCODEC_I2C 1 8 | #endif 9 | 10 | #ifdef CONFIG_IPHONE_2G 11 | #define WMCODEC_I2C 0 12 | #endif 13 | 14 | #ifdef CONFIG_IPHONE_3G 15 | #define WMCODEC_I2C 0 16 | #define WMCODEC_I2C_SLAVE_ADDR 0x36 17 | #else 18 | #define WMCODEC_I2C_SLAVE_ADDR 0x34 19 | #endif 20 | 21 | #if defined(CONFIG_IPHONE_4) || defined(CONFIG_IPAD_1G) 22 | #define WMCODEC_I2C 0 23 | #endif 24 | 25 | #define WMCODEC_INT 0x2c 26 | #define WMCODEC_INT_GPIO 0x1604 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/buttons.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_BUTTONS_H 2 | #define HW_BUTTONS_H 3 | 4 | // Device 5 | #define BUTTONS_HOLD 0x1605 6 | 7 | #ifdef CONFIG_IPOD_TOUCH_1G 8 | #define BUTTONS_HOME 0x1606 9 | #define BUTTONS_HOME_IRQ 0x2E 10 | #else 11 | #define BUTTONS_HOME 0x1600 12 | #define BUTTONS_HOME_IRQ 0x28 13 | #define BUTTONS_VOLUP 0x1601 14 | #define BUTTONS_VOLDOWN 0x1602 15 | #define BUTTONS_RINGERAB 0x1603 16 | #endif 17 | 18 | #define BUTTONS_IIC_STATE 0x4B 19 | 20 | #define BUTTONS_HOLD_IRQ 0x2D 21 | #define BUTTONS_VOLUP_IRQ 0x29 22 | #define BUTTONS_VOLDOWN_IRQ 0x2A 23 | #define BUTTONS_RINGERAB_IRQ 0x2B 24 | 25 | #define BUTTONS_HOLD_IRQTYPE 1 26 | #define BUTTONS_HOME_IRQTYPE 1 27 | #define BUTTONS_VOLUP_IRQTYPE 1 28 | #define BUTTONS_VOLDOWN_IRQTYPE 1 29 | #define BUTTONS_RINGERAB_IRQTYPE 1 30 | 31 | #define BUTTONS_HOLD_IRQLEVEL 1 32 | #define BUTTONS_HOME_IRQLEVEL 1 33 | #define BUTTONS_VOLUP_IRQLEVEL 0 34 | #define BUTTONS_VOLDOWN_IRQLEVEL 0 35 | #define BUTTONS_RINGERAB_IRQLEVEL 1 36 | 37 | #define BUTTONS_HOLD_IRQAUTOFLIP 1 38 | #define BUTTONS_HOME_IRQAUTOFLIP 1 39 | #define BUTTONS_VOLUP_IRQAUTOFLIP 1 40 | #define BUTTONS_VOLDOWN_IRQAUTOFLIP 1 41 | #define BUTTONS_RINGERAB_IRQAUTOFLIP 1 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/camera.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_CAMERA_H 2 | #define HW_CAMERA_H 3 | 4 | #define CAMERA_I2C 1 5 | 6 | #define CAMERA_GPIO_POWER_ON 0x605 7 | #define CAMERA_GPIO_STANDBY 0xA01 8 | #define CAMERA_GPIO_RESET 0xA02 9 | #define CAMERA_GPIO_CLOCK_ENABLE 0xA00 10 | 11 | #define CAMERA_ADDR 0x78 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/chipid.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_CHIPID_H 2 | #define HW_CHIPID_H 3 | 4 | // Device 5 | #define CHIPID 0x3E500000 6 | 7 | // Registers 8 | #define SPICLOCKTYPE 0x4 9 | 10 | // Values 11 | #define GET_SPICLOCKTYPE(x) GET_BITS(x, 24, 4) 12 | #define CHIPID_GET_POWER_EPOCH(x) (0) 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/dma.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_DMA_H 2 | #define HW_DMA_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // This thing appears to be a PL080 7 | 8 | // Device 9 | #define DMAC0 0x38200000 10 | #define DMAC1 0x39900000 11 | 12 | // Registers 13 | #define DMACIntStatus 0 14 | #define DMACIntTCStatus 0x4 15 | #define DMACIntTCClear 0x8 16 | #define DMACConfiguration 0x30 17 | #define DMAC0SrcAddress 0x100 18 | #define DMAC0DestAddress 0x104 19 | #define DMAC0LLI 0x108 20 | #define DMAC0Control0 0x10C 21 | #define DMAC0Configuration 0x110 22 | 23 | // Values 24 | #define DMAC0_INTERRUPT 0x10 25 | #define DMAC1_INTERRUPT 0x11 26 | #define DMAC0_CLOCKGATE 0x19 27 | #define DMAC1_CLOCKGATE 0x1A 28 | 29 | #define DMA_NUMCHANNELS 8 30 | #define DMA_NUMCONTROLLERS 2 31 | 32 | #define DMAChannelRegSize 32 33 | #define DMACConfiguration_ENABLE 1 34 | #define DMAC0Control0_SWIDTHSHIFT 18 35 | #define DMAC0Control0_DWIDTHSHIFT 21 36 | #define DMAC0Control0_DWIDTH(x) GET_BITS(x, 21, 3) 37 | #define DMAC0Control0_WIDTHBYTE 0 38 | #define DMAC0Control0_WIDTHHALFWORD 1 39 | #define DMAC0Control0_WIDTHWORD 2 40 | #define DMAC0Control0_SBSIZESHIFT 12 41 | #define DMAC0Control0_DBSIZESHIFT 15 42 | #define DMAC0Control0_TERMINALCOUNTINTERRUPTENABLE 31 43 | #define DMAC0Control0_SOURCEAHBMASTERSELECT 24 44 | #define DMAC0Control0_SOURCEAHBMASTERSELECT 24 45 | #define DMAC0Control0_SOURCEINCREMENT 26 46 | #define DMAC0Control0_DESTINATIONINCREMENT 27 47 | #define DMAC0Control0_SIZEMASK 0xFFF 48 | 49 | #define DMAC0Configuration_SRCPERIPHERALSHIFT 1 50 | #define DMAC0Configuration_DESTPERIPHERALSHIFT 6 51 | #define DMAC0Configuration_FLOWCNTRLSHIFT 11 52 | #define DMAC0Configuration_FLOWCNTRLMASK 0x7 53 | #define DMAC0Configuration_FLOWCNTRL_M2M 0x0 54 | #define DMAC0Configuration_FLOWCNTRL_M2P 0x1 55 | #define DMAC0Configuration_FLOWCNTRL_P2M 0x2 56 | #define DMAC0Configuration_FLOWCNTRL_P2P 0x3 57 | #define DMAC0Configuration_CHANNELENABLED (1 << 0) 58 | #define DMAC0Configuration_TERMINALCOUNTINTERRUPTMASK (1 << 15) 59 | 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/gpio.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_GPIO_H 2 | #define HW_GPIO_H 3 | 4 | // gpioicBase 5 | // Device 6 | #define GPIOIC 0x39A00000 /* probably a part of the system controller */ 7 | 8 | // gpioBaseAddress 9 | #define GPIO 0x3E400000 10 | 11 | // Registers 12 | #define GPIO_INTLEVEL 0x80 13 | #define GPIO_INTSTAT 0xA0 14 | #define GPIO_INTEN 0xC0 15 | #define GPIO_INTTYPE 0xE0 16 | #define GPIO_FSEL 0x320 17 | 18 | // Values 19 | #define GPIO_NUMINTGROUPS 7 20 | #define GPIO_INTSTAT_RESET 0xFFFFFFFF 21 | #define GPIO_INTEN_RESET 0 22 | 23 | #define GPIO_FSEL_MAJSHIFT 16 24 | #define GPIO_FSEL_MAJMASK 0x1F 25 | #define GPIO_FSEL_MINSHIFT 8 26 | #define GPIO_FSEL_MINMASK 0x7 27 | #define GPIO_FSEL_USHIFT 0 28 | #define GPIO_FSEL_UMASK 0xF 29 | 30 | #define GPIO_CLOCKGATE 0x2C 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/i2c.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_I2C_H 2 | #define HW_I2C_H 3 | 4 | // Device 5 | #define I2C0 0x3C600000 6 | #define I2C1 0x3C900000 7 | 8 | // Registers 9 | #define IICCON 0x0 10 | #define IICSTAT 0x4 11 | #define IICADD 0x8 12 | #define IICDS 0xC 13 | #define IICLC 0x10 14 | #define IICREG14 0x14 15 | #define IICREG18 0x18 16 | #define IICREG1C 0x1C 17 | #define IICREG20 0x20 18 | 19 | // Values 20 | #define IICCON_INIT 0x3F00 21 | #define IICCON_ACKGEN (1 << 7) 22 | #define IICCON_TXCLKSRC_FPCLK16 (0 << 6) 23 | #define IICCON_TXCLKSRC_FPCLK512 (1 << 6) 24 | #define IICCON_INTENABLE (1 << 5) 25 | #define IICCON_INTPENDING (1 << 4) 26 | #define IICCON_TXCLKPRESCALEMASK 0xF 27 | 28 | #define IICSTAT_MODE_SLAVERX 0 29 | #define IICSTAT_MODE_SLAVETX 1 30 | #define IICSTAT_MODE_MASTERRX 2 31 | #define IICSTAT_MODE_MASTERTX 3 32 | #define IICSTAT_MODE_SHIFT 6 33 | #define IICSTAT_MODE_MASK 3 34 | #define IICSTAT_STARTSTOPGEN_START 1 35 | #define IICSTAT_STARTSTOPGEN_STOP 0 36 | #define IICSTAT_STARTSTOPGEN_MASK 1 37 | #define IICSTAT_STARTSTOPGEN_SHIFT 5 38 | #define IICSTAT_DATAOUTPUT_ENABLE_SHIFT 4 39 | #define IICSTAT_LASTRECEIVEDBIT (1 << 0) 40 | 41 | #define I2C0_SCL_GPIO 0xB02 42 | #define I2C0_SDA_GPIO 0xB03 43 | #define I2C1_SCL_GPIO 0x801 44 | #define I2C1_SDA_GPIO 0x802 45 | 46 | #define I2C0_CLOCKGATE 0x24 47 | #define I2C1_CLOCKGATE 0x26 48 | 49 | #define TXFREQ 25000 50 | 51 | #define OPERATION_SEND (1 << 8) 52 | #define OPERATION_CONDITIONCHANGE (1 << 13) 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/i2s.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_I2S_H 2 | #define HW_I2S_H 3 | 4 | #define I2S0_CLOCK 0x27 5 | #define I2S1_CLOCK 0x2A 6 | 7 | #define I2S0 0x3CA00000 8 | #define I2S1 0x3CD00000 9 | 10 | #define I2S_CLKCON 0 11 | #define I2S_TXCON 0x4 12 | #define I2S_TXCOM 0x8 13 | #define I2S_RXCON 0x30 14 | #define I2S_RXCOM 0x34 15 | #define I2S_STATUS 0x3C 16 | 17 | #ifdef CONFIG_IPOD_TOUCH_1G 18 | #define WM_I2S I2S1 19 | #define DMA_WM_I2S_TX DMA_I2S1_TX 20 | #define DMA_WM_I2S_RX DMA_I2S1_RX 21 | #else 22 | #define WM_I2S I2S0 23 | #define DMA_WM_I2S_TX DMA_I2S0_TX 24 | #define DMA_WM_I2S_RX DMA_I2S0_RX 25 | #define BB_I2S I2S1 26 | #define DMA_BB_I2S_TX DMA_I2S1_TX 27 | #define DMA_BB_I2S_RX DMA_I2S1_RX 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/interrupt.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_INTERRUPT_H 2 | #define HW_INTERRUPT_H 3 | 4 | // This appears to be a PL192 5 | 6 | // Constants 7 | 8 | #define VIC_MaxInterrupt 0x40 9 | #define VIC_InterruptSeparator 0x20 10 | 11 | // Devices 12 | 13 | #define VIC0 0x38E00000 14 | #define VIC1 0x38E01000 15 | 16 | // Registers 17 | 18 | #define VICIRQSTATUS 0x000 19 | #define VICRAWINTR 0x8 20 | #define VICINTSELECT 0xC 21 | #define VICINTENABLE 0x10 22 | #define VICINTENCLEAR 0x14 23 | #define VICSWPRIORITYMASK 0x24 24 | #define VICVECTADDRS 0x100 25 | #define VICADDRESS 0xF00 26 | #define VICPERIPHID0 0xFE0 27 | #define VICPERIPHID1 0xFE4 28 | #define VICPERIPHID2 0xFE8 29 | #define VICPERIPHID3 0xFEC 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/multitouch.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_MULTITOUCH_H 2 | #define HW_MULTITOUCH _H 3 | 4 | #include "hardware/spi.h" 5 | 6 | #ifdef CONFIG_IPHONE_2G 7 | #define MT_GPIO_POWER 0x804 8 | #define MT_ATN_INTERRUPT 0xa3 9 | #else 10 | #define MT_GPIO_POWER 0x701 11 | #define MT_ATN_INTERRUPT 0x9b 12 | #endif 13 | 14 | #ifdef CONFIG_IPHONE_3G 15 | #define MT_SPI 1 16 | #define MT_SPI_CS GPIO_SPI1_CS0 17 | #else 18 | #define MT_SPI 2 19 | #define MT_SPI_CS GPIO_SPI2_CS0 20 | #endif 21 | 22 | #define MT_INFO_FAMILYID 0xD1 23 | #define MT_INFO_SENSORINFO 0xD3 24 | #define MT_INFO_SENSORREGIONDESC 0xD0 25 | #define MT_INFO_SENSORREGIONPARAM 0xA1 26 | #define MT_INFO_SENSORDIM 0xD9 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/nand.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_NAND_H 2 | #define HW_NAND_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // Device 7 | #define NAND 0x38A00000 8 | #define NANDECC 0x38F00000 9 | #define NAND_CLOCK_GATE1 0x8 10 | #define NAND_CLOCK_GATE2 0xC 11 | #define NANDECC_INT 0x2B 12 | #define NAND_INT 0x14 13 | 14 | // Registers 15 | #define FMCTRL0 0x0 16 | #define FMCTRL1 0x4 17 | #define NAND_CMD 0x8 18 | #define FMADDR0 0xC 19 | #define FMANUM 0x2C 20 | #define FMADDR1 0x10 21 | #define FMDNUM 0x30 22 | #define NAND_REG_44 0x44 23 | #define FMCSTAT 0x48 24 | #define FMFIFO 0x80 25 | #define RSCTRL 0x100 26 | 27 | #define NANDECC_DATA 0x4 28 | #define NANDECC_ECC 0x8 29 | #define NANDECC_START 0xC 30 | #define NANDECC_STATUS 0x10 31 | #define NANDECC_SETUP 0x14 32 | #define NANDECC_CLEARINT 0x40 33 | 34 | // Values 35 | 36 | #define FMCTRL_TWH_SHIFT 12 37 | #define FMCTRL_TWP_SHIFT 16 38 | #define FMCTRL_TWH_MASK 0x7 39 | #define FMCTRL_TWP_MASK 0x7 40 | #define FMCTRL0_DMASETTINGSHIFT 10 41 | #define FMCTRL0_ON 1 42 | #define FMCTRL0_WPB 0x800 43 | 44 | #define NAND_CMD_RESET 0xFF 45 | #define NAND_CMD_ID 0x90 46 | #define NAND_CMD_READSTATUS 0x70 47 | #define NAND_CMD_READ 0x30 48 | 49 | #define FMANUM_TRANSFERSETTING 4 50 | 51 | #define FMCTRL1_DOTRANSADDR (1 << 0) 52 | #define FMCTRL1_CLEARALL (FMCTRL1_FLUSHFIFOS | 0x720) 53 | #define FMCTRL1_FLUSHFIFOS (FMCTRL1_FLUSHRXFIFO | FMCTRL1_FLUSHTXFIFO) 54 | #define FMCTRL1_FLUSHTXFIFO 0x40 55 | #define FMCTRL1_FLUSHRXFIFO 0x80 56 | #define FMCTRL1_DOREADDATA (1 << 1) 57 | 58 | #define FMCSTAT_READY 0x1 59 | 60 | #define NAND_NUM_BANKS 8 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/platform.h: -------------------------------------------------------------------------------- 1 | #include "hardware/s5l8900.h" 2 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/power.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_POWER_H 2 | #define HW_POWER_H 3 | 4 | // Device 5 | #define POWER 0x39A00000 /* probably a part of the system controller */ 6 | 7 | // Power 8 | #define POWER_DEFAULT_DEVICES 0xEC 9 | #define POWER_LCD 0x100 10 | #define POWER_USB 0x200 11 | #define POWER_VROM 0x1000 12 | 13 | // Registers 14 | #define POWER_CONFIG0 0x0 15 | #define POWER_CONFIG1 0x20 16 | #define POWER_CONFIG2 0x6C 17 | #define POWER_ONCTRL 0xC 18 | #define POWER_OFFCTRL 0x10 19 | #define POWER_SETSTATE 0x8 20 | #define POWER_STATE 0x14 21 | #define POWER_ID 0x44 22 | #define POWER_ID_EPOCH(x) ((x) >> 24) 23 | 24 | // Values 25 | #define POWER_CONFIG0_RESET 0x1123009 26 | #define POWER_CONFIG1_RESET 0x20 27 | #define POWER_CONFIG2_RESET 0x0 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/radio.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_RADIO_H 2 | #define HW_RADIO_H 3 | 4 | #ifdef CONFIG_IPHONE_3G 5 | #define RADIO_GPIO_BB_RESET 0x700 6 | #define RADIO_GPIO_RADIO_ON 0x1507 7 | #define RADIO_GPIO_BB_ON 0x3 8 | #define RADIO_GPIO_BB_USART0_RXD_CTRL 0x1706 9 | #define RADIO_GPIO_RESET_DETECT 0x1203 10 | #define RADIO_GPIO_UMTS_RXD_CTRL 0x1704 11 | #define RADIO_GPIO_DOCK_UART_CTRL 0x1 12 | #define RADIO_BB_PULLDOWN 0xC03 13 | #define RADIO_UART 4 14 | #else 15 | #define RADIO_GPIO_BB_ON 0x1807 16 | #define RADIO_GPIO_RADIO_ON 0x1507 17 | #define RADIO_GPIO_BB_RESET 0x700 18 | #define RADIO_GPIO_BB_DETECT 0x701 19 | #define RADIO_GPIO_BB_MUX_SEL 0x606 20 | #define RADIO_BB_PULLDOWN 0x1703 21 | #define RADIO_UART 1 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/s5l8900.h: -------------------------------------------------------------------------------- 1 | #ifndef S5L8900_H 2 | #define S5L8900_H 3 | 4 | /* 5 | * Constants 6 | */ 7 | 8 | #define MemoryStart 0x00000000 9 | #define MemoryEnd 0xFFFFFFFF 10 | #define LargeMemoryStart 0x08000000 /* FIXME: This is an ugly hack to get around iBoot's memory rearrangement. Linux boot will only work for installed openiboot! */ 11 | #define RAMStart 0 12 | #define RAMEnd 0x08000000 13 | #define MemoryHigher 0x80000000 14 | #define ExceptionVector MemoryStart 15 | #ifdef SMALL 16 | #define PageTable (OpenIBootLoad + 0x24000) 17 | #define HeapStart (PageTable + 0x4000) 18 | #else 19 | #define OpenIBootLoad 0x00000000 20 | #define GeneralStack ((PageTable - 4) + LargeMemoryStart) 21 | #define HeapStart (LargeMemoryStart + 0x02000000) 22 | #define PageTable (RAMEnd - 0x4000) 23 | #endif 24 | 25 | /* 26 | * Devices 27 | */ 28 | 29 | #define PeripheralPort 0x38000000 30 | #ifdef CONFIG_IPHONE_3G 31 | #define AMC0 0x38500000 32 | #define ROM 0x50000000 33 | #else 34 | #define AMC0 0x22000000 35 | #define ROM 0x20000000 36 | #endif 37 | 38 | #define WDT_CTRL 0x3E300000 39 | #define WDT_CNT 0x3E300004 40 | 41 | #define WDT_INT 0x33 42 | /* 43 | * Values 44 | */ 45 | 46 | #define EDRAM_CLOCKGATE 0x1B 47 | #define WDT_ENABLE 0x100000 48 | #define WDT_PRE_SHIFT 16 49 | #define WDT_PRE_MASK 0xF 50 | #define WDT_CS_SHIFT 12 51 | #define WDT_CS_MASK 0x7 52 | #define WDT_CLR 0xA00 53 | #define WDT_DIS 0xA5 54 | #define WDT_INT_EN 0x8000 55 | 56 | #define DMA_ALIGN 0x40 57 | 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/sdio.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_SDIO_H 2 | #define HW_SDIO_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | #define SDIO 0x38D00000 7 | #define SDIO_CLOCKGATE 0xB 8 | 9 | #ifdef CONFIG_IPOD_TOUCH_1G 10 | #define SDIO_GPIO_POWER 0x1701 11 | #endif 12 | 13 | #define SDIO_CTRL 0x0 14 | #define SDIO_DCTRL 0x4 15 | #define SDIO_CMD 0x8 16 | #define SDIO_ARGU 0xC 17 | #define SDIO_STATE 0x10 18 | #define SDIO_STAC 0x14 19 | #define SDIO_DSTA 0x18 20 | #define SDIO_FSTA 0x1C 21 | #define SDIO_RESP0 0x20 22 | #define SDIO_RESP1 0x24 23 | #define SDIO_RESP2 0x28 24 | #define SDIO_RESP3 0x2C 25 | #define SDIO_CLKDIV 0x30 26 | #define SDIO_CSR 0x34 27 | #define SDIO_IRQ 0x38 28 | #define SDIO_IRQMASK 0x3C 29 | #define SDIO_BADDR 0x44 30 | #define SDIO_BLKLEN 0x48 31 | #define SDIO_NUMBLK 0x4C 32 | #define SDIO_REMBLK 0x50 33 | 34 | #ifndef CONFIG_IPOD_TOUCH_1G 35 | #define SDIO_GPIO_DEVICE_RESET 0x607 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/spi.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_SPI_H 2 | #define HW_SPI_H 3 | 4 | // Device 5 | #define SPI0 0x3C300000 6 | #define SPI1 0x3CE00000 7 | #define SPI2 0x3D200000 8 | 9 | // Registers 10 | 11 | #define CONTROL 0x0 12 | #define SETUP 0x4 13 | #define STATUS 0x8 14 | #define PIN 0xC 15 | #define TXDATA 0x10 16 | #define RXDATA 0x20 17 | #define CLKDIVIDER 0x30 18 | #define SPCNT 0x34 19 | #define SPIDD 0x38 20 | 21 | // Values 22 | #define MAX_TX_BUFFER 8 23 | #define TX_BUFFER_LEFT(x) GET_BITS(status, 4, 4) 24 | #define RX_BUFFER_LEFT(x) GET_BITS(status, 8, 4) 25 | 26 | #define CLOCK_SHIFT 12 27 | #define MAX_DIVIDER 0x3FF 28 | 29 | #define SPI0_CLOCKGATE 0x22 30 | #define SPI1_CLOCKGATE 0x2B 31 | #define SPI2_CLOCKGATE 0x2F 32 | 33 | #define SPI0_IRQ 0x9 34 | #define SPI1_IRQ 0xA 35 | #define SPI2_IRQ 0xB 36 | 37 | #define GPIO_SPI0_CS0_IPHONE 0x400 38 | #define GPIO_SPI0_CS0_IPOD 0x700 39 | 40 | #ifdef CONFIG_IPOD_TOUCH_1G 41 | #define GPIO_SPI2_CS0 0x1804 42 | #define GPIO_SPI2_CS1 0x705 43 | #endif 44 | 45 | #ifdef CONFIG_IPHONE_2G 46 | #define GPIO_SPI2_CS0 0x705 47 | #endif 48 | 49 | #if defined(CONFIG_IPHONE_4) || defined(CONFIG_IPAD_1G) 50 | #define GPIO_SPI2_CS0 0x705 // No! 51 | #endif 52 | 53 | #ifdef CONFIG_IPOD_TOUCH_1G 54 | #define GPIO_SPI0_CS0 GPIO_SPI0_CS0_IPOD 55 | #else 56 | #define GPIO_SPI0_CS0 GPIO_SPI0_CS0_IPHONE 57 | #endif 58 | 59 | #define GPIO_SPI1_CS0 0x1800 60 | 61 | #ifdef CONFIG_IPHONE_3G 62 | #define GPIO_SPI0_CS1 0x705 63 | #define GPIO_SPI0_CS2 0x706 64 | #endif 65 | 66 | #define NUM_SPIPORTS 3 67 | 68 | typedef struct SPIRegister { 69 | uint32_t control; 70 | uint32_t setup; 71 | uint32_t status; 72 | uint32_t pin; 73 | uint32_t txData; 74 | uint32_t rxData; 75 | uint32_t clkDivider; 76 | uint32_t cnt; 77 | uint32_t idd; 78 | } SPIRegister; 79 | 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_TIMER_H 2 | #define HW_TIMER_H 3 | 4 | // Constants 5 | #define EventTimer 4 6 | #ifdef CONFIG_IPOD_TOUCH_1G 7 | #define PiezoTimer 1 8 | #endif 9 | #ifdef CONFIG_IPHONE_3G 10 | #define VibratorTimer 5 11 | #endif 12 | 13 | // Devices 14 | #define TIMER 0x3E200000 15 | 16 | // Registers 17 | 18 | #define TIMER_0 0x0 19 | #define TIMER_1 0x20 20 | #define TIMER_2 0x40 21 | #define TIMER_3 0x60 22 | #define TIMER_4 0xA0 23 | #define TIMER_5 0xC0 24 | #define TIMER_6 0xE0 25 | #define TIMER_CONFIG 0 26 | #define TIMER_STATE 0x4 27 | #define TIMER_COUNT_BUFFER 0x8 28 | #define TIMER_COUNT_BUFFER2 0xC 29 | #define TIMER_PRESCALER 0x10 30 | #define TIMER_UNKNOWN3 0x14 31 | #define TIMER_TICKSHIGH 0x80 32 | #define TIMER_TICKSLOW 0x84 33 | #define TIMER_UNKREG0 0x88 34 | #define TIMER_UNKREG1 0x8C 35 | #define TIMER_UNKREG2 0x90 36 | #define TIMER_UNKREG3 0x94 37 | #define TIMER_UNKREG4 0x98 38 | #define TIMER_IRQSTAT 0x10000 39 | #define TIMER_IRQLATCH 0xF8 40 | 41 | // Timer 42 | #define NUM_TIMERS 7 43 | #define TIMER_CLOCKGATE 0x25 44 | #define TIMER_IRQ 0x7 45 | #define TIMER_STATE_START 1 46 | #define TIMER_STATE_STOP 0 47 | #define TIMER_STATE_MANUALUPDATE 2 48 | #define TIMER_UNKREG0_RESET1 0xA 49 | #define TIMER_UNKREG0_RESET2 0x18010 50 | #define TIMER_UNKREG1_RESET 0xFFFFFFFF 51 | #define TIMER_UNKREG2_RESET 0xFFFFFFFF 52 | #define TIMER_UNKREG3_RESET 0xFFFFFFFF 53 | #define TIMER_UNKREG4_RESET 0xFFFFFFFF 54 | #define TIMER_DIVIDER1 4 55 | #define TIMER_DIVIDER2 0 56 | #define TIMER_DIVIDER4 1 57 | #define TIMER_DIVIDER16 2 58 | #define TIMER_DIVIDER64 3 59 | #define TIMER_SPECIALTIMER_BIT0 0x1000000 60 | #define TIMER_SPECIALTIMER_BIT1 0x2000000 61 | 62 | #define TIMER_Separator 4 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /plat-s5l8900/includes/hardware/usbphy.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_USBPHY_H 2 | #define HW_USBPHY_H 3 | 4 | #define USB_PHY 0x3C400000 5 | 6 | // Registers 7 | #define OPHYPWR 0 8 | #define OPHYCLK 0x4 9 | #define ORSTCON 0x8 10 | 11 | // Values 12 | #define OPHYPWR_FORCESUSPEND 0x1 13 | #define OPHYPWR_PLLPOWERDOWN 0x2 14 | #define OPHYPWR_XOPOWERDOWN 0x4 15 | #define OPHYPWR_ANALOGPOWERDOWN 0x8 16 | #define OPHYPWR_UNKNOWNPOWERDOWN 0x10 17 | #define OPHYPWR_POWERON 0x0 // all the previous flags are off 18 | 19 | #define OPHYCLK_CLKSEL_MASK 0x3 20 | 21 | #define OPHYCLK_SPEED_48MHZ 48000000 22 | #define OPHYCLK_SPEED_12MHZ 12000000 23 | #define OPHYCLK_SPEED_24MHZ 24000000 24 | 25 | // TODO: these values are off according to iboot 3.1.3. Look into this. (probably cancels out somehow) 26 | #define OPHYCLK_CLKSEL_48MHZ 0x0 27 | #define OPHYCLK_CLKSEL_12MHZ 0x2 28 | #define OPHYCLK_CLKSEL_24MHZ 0x3 29 | 30 | #define ORSTCON_PHYSWRESET 0x1 31 | #define ORSTCON_LINKSWRESET 0x2 32 | #define ORSTCON_PHYLINKSWRESET 0x4 33 | 34 | #define USB_PHYPWRPOWERON_DELAYUS 10 35 | #define USB_RESET2_DELAYUS 20 36 | #define USB_RESET_DELAYUS 1000 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /plat-s5l8900/miu.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "miu.h" 3 | #include "clock.h" 4 | #include "hardware/power.h" 5 | #include "util.h" 6 | 7 | int miu_setup() { 8 | if(POWER_ID_EPOCH(*((uint8_t*)(POWER + POWER_ID))) != 3) { 9 | // Epoch mismatch 10 | bufferPrintf("miu: epoch mismatch\r\n"); 11 | return -1; 12 | } 13 | 14 | clock_set_base_divisor(ClockDivisorCode1); 15 | 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /plat-s5l8900/power.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "power.h" 3 | #include "hardware/power.h" 4 | 5 | int power_setup() { 6 | // Deprecated in 2.x 7 | #if 0 8 | SET_REG(POWER + POWER_CONFIG0, POWER_CONFIG0_RESET); 9 | SET_REG(POWER + POWER_CONFIG1, POWER_CONFIG1_RESET); 10 | SET_REG(POWER + POWER_CONFIG2, POWER_CONFIG2_RESET); 11 | 12 | /* turn off everything */ 13 | int toReset = POWER_DEFAULT_DEVICES | POWER_VROM; 14 | SET_REG(POWER + POWER_OFFCTRL, toReset); 15 | 16 | /* wait for the new state to take effect */ 17 | while((GET_REG(POWER + POWER_SETSTATE) & toReset) != (GET_REG(POWER + POWER_STATE) & toReset)); 18 | #endif 19 | return 0; 20 | } 21 | 22 | int power_ctrl(uint32_t device, OnOff on_off) { 23 | if(on_off == ON) { 24 | SET_REG(POWER + POWER_ONCTRL, device); 25 | } else { 26 | SET_REG(POWER + POWER_OFFCTRL, device); 27 | } 28 | 29 | /* wait for the new state to take effect */ 30 | while((GET_REG(POWER + POWER_SETSTATE) & device) != (GET_REG(POWER + POWER_STATE) & device)); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /plat-s5l8900/s5l8900.c: -------------------------------------------------------------------------------- 1 | #include "aes.h" 2 | #include "arm/arm.h" 3 | #include "clock.h" 4 | #include "dma.h" 5 | #include "event.h" 6 | #include "framebuffer.h" 7 | #include "gpio.h" 8 | #include "interrupt.h" 9 | #include "i2c.h" 10 | #include "lcd.h" 11 | #include "miu.h" 12 | #include "mmu.h" 13 | #include "openiboot.h" 14 | #include "power.h" 15 | #include "spi.h" 16 | #include "tasks.h" 17 | #include "timer.h" 18 | #include "uart.h" 19 | #include "wdt.h" 20 | #include "audiocodec.h" 21 | 22 | void platform_init() 23 | { 24 | arm_setup(); 25 | mmu_setup(); 26 | tasks_setup(); 27 | 28 | // Basic prerequisites for everything else 29 | miu_setup(); 30 | power_setup(); 31 | 32 | clock_setup(); 33 | 34 | // Need interrupts for everything afterwards 35 | interrupt_setup(); 36 | 37 | gpio_setup(); 38 | 39 | // For scheduling/sleeping niceties 40 | timer_setup(); 41 | event_setup(); 42 | wdt_setup(); 43 | 44 | // Other devices 45 | uart_setup(); 46 | i2c_setup(); 47 | 48 | dma_setup(); 49 | 50 | spi_setup(); 51 | 52 | LeaveCriticalSection(); 53 | 54 | clock_set_sdiv(0); 55 | 56 | aes_setup(); 57 | 58 | lcd_setup(); 59 | framebuffer_setup(); 60 | 61 | audiohw_init(); 62 | 63 | framebuffer_setdisplaytext(TRUE); 64 | } 65 | 66 | void platform_shutdown() 67 | { 68 | dma_shutdown(); 69 | wdt_disable(); 70 | arm_disable_caches(); 71 | mmu_disable(); 72 | } 73 | -------------------------------------------------------------------------------- /plat-s5l8900/usbphy.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "usbphy.h" 3 | #include "hardware/usbphy.h" 4 | #include "timer.h" 5 | #include "clock.h" 6 | 7 | void usb_phy_init() { 8 | // power on PHY 9 | SET_REG(USB_PHY + OPHYPWR, OPHYPWR_POWERON); 10 | udelay(USB_PHYPWRPOWERON_DELAYUS); 11 | 12 | // select clock 13 | SET_REG(USB_PHY + OPHYCLK, (GET_REG(USB_PHY + OPHYCLK) & (~OPHYCLK_CLKSEL_MASK)) | OPHYCLK_CLKSEL_48MHZ); 14 | 15 | // reset phy 16 | SET_REG(USB_PHY + ORSTCON, GET_REG(USB_PHY + ORSTCON) | ORSTCON_PHYSWRESET); 17 | udelay(USB_RESET2_DELAYUS); 18 | SET_REG(USB_PHY + ORSTCON, GET_REG(USB_PHY + ORSTCON) & (~ORSTCON_PHYSWRESET)); 19 | udelay(USB_RESET_DELAYUS); 20 | } 21 | 22 | void usb_phy_shutdown() { 23 | SET_REG(USB_PHY + OPHYPWR, OPHYPWR_FORCESUSPEND | OPHYPWR_PLLPOWERDOWN 24 | | OPHYPWR_XOPOWERDOWN | OPHYPWR_ANALOGPOWERDOWN | OPHYPWR_UNKNOWNPOWERDOWN); // power down phy 25 | SET_REG(USB_PHY + ORSTCON, ORSTCON_PHYSWRESET | ORSTCON_LINKSWRESET | ORSTCON_PHYLINKSWRESET); // reset phy/link 26 | 27 | udelay(USB_RESET_DELAYUS); // wait a millisecond for the changes to stick 28 | } 29 | 30 | -------------------------------------------------------------------------------- /plat-s5l8920/SConscript: -------------------------------------------------------------------------------- 1 | Import("*") 2 | 3 | env = env.Clone() 4 | env.Append(CPPPATH = [Dir('includes')]) 5 | env.Append(CPPDEFINES = ['ARM_A8', 'CONFIG_S5L8920', 'MALLOC_NO_WDT']) 6 | 7 | env.AddModules([ 8 | "acm", 9 | "nor-spi", 10 | "usb-synopsys", 11 | "vfl-vfl", 12 | "vfl-vsvfl", 13 | "ftl-yaftl", 14 | ]) 15 | 16 | plat_s5l8920_src = arch_arm_src + base_src + env.Localize([ 17 | 's5l8920.c', 18 | 'usbphy.c', 19 | 'aes.c', 20 | 'buttons.c', 21 | 'chipid.c', 22 | 'clock.c', 23 | 'event.c', 24 | 'gpio.c', 25 | 'i2c.c', 26 | 'interrupt.c', 27 | 'clcd.c', 28 | 'mipi_dsim.c', 29 | 'miu.c', 30 | 'mmu.c', 31 | 'power.c', 32 | 'spi.c', 33 | 'timer.c', 34 | 'cdma.c', 35 | 'h2fmi.c', 36 | 'uart.c', 37 | ]) + hfs_src 38 | Export('plat_s5l8920_src') 39 | 40 | env.SConscript('iPhone3GS.SConscript', 'env') 41 | -------------------------------------------------------------------------------- /plat-s5l8920/buttons.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "buttons.h" 3 | #include "hardware/buttons.h" 4 | #include "gpio.h" 5 | 6 | int buttons_is_pushed(int which) { 7 | if(!gpio_pin_state(which)) 8 | return TRUE; 9 | else 10 | return FALSE; 11 | } 12 | -------------------------------------------------------------------------------- /plat-s5l8920/chipid.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "chipid.h" 3 | #include "hardware/chipid.h" 4 | 5 | int chipid_spi_clocktype() 6 | { 7 | return GET_SPICLOCKTYPE(GET_REG(CHIPID + SPICLOCKTYPE)); 8 | } 9 | 10 | unsigned int chipid_get_power_epoch() 11 | { 12 | return CHIPID_GET_POWER_EPOCH(GET_REG(CHIPID)); 13 | } 14 | 15 | unsigned int chipid_get_gpio_epoch() 16 | { 17 | return CHIPID_GET_GPIO(GET_REG(CHIPID)); 18 | } 19 | 20 | uint32_t chipid_get_nand_epoch() 21 | { 22 | uint32_t ret = chipid_get_power_epoch(); 23 | if(ret <= 2) 24 | return 3; 25 | 26 | return ret; 27 | } 28 | -------------------------------------------------------------------------------- /plat-s5l8920/iPhone3GS.SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | # 4 | # iPhone 3GS 5 | # 6 | 7 | iphone_3gs_src = [plat_s5l8920_src, 8 | #radio_pmb8878_src, # doesn't work -- Ricky26 9 | env.Localize([ 10 | '#audiohw-null.c', 11 | ])] 12 | Export('iphone_3gs_src') 13 | 14 | env = env.Clone() 15 | env.Append(CPPDEFINES=['OPENIBOOT_VERSION_CONFIG=\\" for iPhone 3GS\\"', 'MACH_ID=3562']) 16 | 17 | env.AddModules([ 18 | "radio-pmb8878", 19 | ]) 20 | 21 | env.OpenIBootTarget('iPhone3GS', 'iphone_3gs_openiboot', 'CONFIG_IPHONE_3GS', iphone_3gs_src, None) 22 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/cdma.h: -------------------------------------------------------------------------------- 1 | #ifndef _CDMA_H 2 | #define _CDMA_H 3 | 4 | typedef struct dmaAES { 5 | uint32_t inverse; 6 | uint32_t type; 7 | uint32_t *key; 8 | uint32_t dataSize; 9 | void (*ivGenerator)(uint32_t _param, uint32_t _segment, uint32_t* _iv); 10 | uint32_t ivParameter; 11 | } dmaAES; 12 | 13 | typedef struct DMASegmentInfo { 14 | uint32_t ptr; 15 | uint32_t size; 16 | } DMASegmentInfo; 17 | 18 | typedef struct dmaAES_CRYPTO { 19 | uint32_t *unkn0; 20 | uint32_t unkn1; 21 | uint32_t *buffer; 22 | uint32_t size; 23 | uint32_t unkn4; 24 | uint32_t unkn5; 25 | uint32_t unkn6; 26 | uint32_t unkn7; 27 | uint32_t unkn8; 28 | uint32_t unkn9; 29 | uint32_t unkn10; 30 | uint32_t unkn11; 31 | uint32_t unkn12; 32 | uint32_t unkn13; 33 | uint32_t unkn14; 34 | uint32_t unkn15; 35 | } __attribute__((packed)) dmaAES_CRYPTO; 36 | 37 | int dma_setup(); 38 | signed int dma_init_channel(uint8_t direction, uint32_t channel, DMASegmentInfo* segmentsInfo, 39 | uint32_t txrx_register, uint32_t size, uint32_t Setting1Index, uint32_t Setting2Index, void* handler); 40 | void dma_continue_async(int channel); 41 | int dma_set_aes(int channel, dmaAES* dmaAESInfo); 42 | int dma_cancel(int channel); 43 | uint32_t aes_crypto_cmd(uint32_t _encrypt, void *_inBuf, void *_outBuf, uint32_t _size, uint32_t _type, void *_key, void *_iv); 44 | 45 | #endif //_CDMA_H 46 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/buttons.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_BUTTONS_H 2 | #define HW_BUTTONS_H 3 | 4 | // Device 5 | 6 | #define BUTTONS_HOME 0x0 7 | #define BUTTONS_HOLD 0x1 8 | #define BUTTONS_VOLUP 0x2 9 | #define BUTTONS_VOLDOWN 0x3 10 | #define BUTTONS_RINGERAB 0x4 11 | 12 | #define BUTTONS_IIC_STATE 0x4B 13 | 14 | #define BUTTONS_HOLD_IRQ 0x2D 15 | #define BUTTONS_VOLUP_IRQ 0x29 16 | #define BUTTONS_VOLDOWN_IRQ 0x2A 17 | #define BUTTONS_RINGERAB_IRQ 0x2B 18 | 19 | #define BUTTONS_HOLD_IRQTYPE 1 20 | #define BUTTONS_HOME_IRQTYPE 1 21 | #define BUTTONS_VOLUP_IRQTYPE 1 22 | #define BUTTONS_VOLDOWN_IRQTYPE 1 23 | #define BUTTONS_RINGERAB_IRQTYPE 1 24 | 25 | #define BUTTONS_HOLD_IRQLEVEL 1 26 | #define BUTTONS_HOME_IRQLEVEL 1 27 | #define BUTTONS_VOLUP_IRQLEVEL 0 28 | #define BUTTONS_VOLDOWN_IRQLEVEL 0 29 | #define BUTTONS_RINGERAB_IRQLEVEL 1 30 | 31 | #define BUTTONS_HOLD_IRQAUTOFLIP 1 32 | #define BUTTONS_HOME_IRQAUTOFLIP 1 33 | #define BUTTONS_VOLUP_IRQAUTOFLIP 1 34 | #define BUTTONS_VOLDOWN_IRQAUTOFLIP 1 35 | #define BUTTONS_RINGERAB_IRQAUTOFLIP 1 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/chipid.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_CHIPID_H 2 | #define HW_CHIPID_H 3 | 4 | // Device 5 | #define CHIPID 0xBF500000 6 | #define POWERID 0xBF100158 7 | 8 | // Registers 9 | #define SPICLOCKTYPE 0x4 10 | 11 | // Values 12 | #define GET_SPICLOCKTYPE(x) GET_BITS(x, 24, 4) 13 | #define CHIPID_GET_GPIO(x) GET_BITS((x), 4, 2) 14 | #define CHIPID_GET_POWER_EPOCH(x) GET_BITS((x), 9, 7) 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/clcd.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_CLCD_H 2 | #define HW_CLCD_H 3 | 4 | #define CLCD_BASE 0x85400000 5 | #define CLCD_FRAMEBUFFER 0x4FD00000 6 | #define CLCD_CLOCKGATE_1 0x2F 7 | #define CLCD_CLOCKGATE_2 0x2B 8 | #define CLCD_CLOCKGATE_3 0x1B 9 | 10 | #define VIDCON1_IVCLKSHIFT 3 11 | #define VIDCON1_IHSYNCSHIFT 2 12 | #define VIDCON1_IVSYNCSHIFT 1 13 | #define VIDCON1_IVDENSHIFT 0 14 | 15 | #define VIDTCON_BACKPORCHSHIFT 16 16 | #define VIDTCON_BACKPORCHMASK 0xFF 17 | #define VIDTCON_FRONTPORCHSHIFT 8 18 | #define VIDTCON_FRONTPORCHMASK 0xFF 19 | #define VIDTCON_SYNCPULSEWIDTHSHIFT 0 20 | #define VIDTCON_SYNCPULSEWIDTHMASK 0xFF 21 | #define VIDTCON2_LINEVALMASK 0x3FF 22 | #define VIDTCON2_LINEVALSHIFT 0 23 | #define VIDTCON2_HOZVALMASK 0x3FF 24 | #define VIDTCON2_HOZVALSHIFT 16 25 | 26 | #define DISPLAYID 0 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/clock.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_CLOCKS5L8730_H 2 | #define HW_CLOCKS5L8730_H 3 | 4 | // Clock constants for the S5L8730. This device does not have a distinction 5 | // between clock0 and clock1 like the S5L8900 does. 6 | 7 | #define NUM_PLL 4 8 | #define PLL_FREQUENCIES {600000000, 162000000, 200000000, 24000000} 9 | 10 | #define NUM_CLOCK_REFERENCE 3 11 | #define CLOCK_REFERENCE0 0xBF100004 12 | #define CLOCK_REFERENCE1 0xBF100008 13 | #define CLOCK_REFERENCE2 0xBF10000C 14 | #define CLOCK_REFERENCE {CLOCK_REFERENCE0, CLOCK_REFERENCE1, CLOCK_REFERENCE2} 15 | 16 | #define NUM_PERIPHERAL_CLOCK 28 17 | #define NUM_DYNAMIC_CLOCKS 25 18 | #define DYNAMIC_CLOCK_BASE 0xBF100010 19 | 20 | #define CLOCK_USB_PHY 27 21 | #define CLOCK_CPU 15 22 | #define CLOCK_MEMORY 25 23 | #define CLOCK_BUS 1 24 | #define CLOCK_TIMEBASE 26 25 | #define CLOCK_PERIPHERAL 2 26 | #define CLOCK_FIXED 19 27 | #define CLOCK_NAND 3 28 | 29 | #define CLOCK_GATE_BASE 0xBF100078 30 | #define NUM_CLOCK_GATES 52 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/dma.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_DMA_H 2 | #define HW_DMA_H 3 | 4 | #include "hardware/s5l8920.h" 5 | 6 | // Device 7 | #define DMA 0x87000000 8 | 9 | // Registers 10 | #define DMA_OFF 0x8 11 | #define DMA_STATUS 0x10 12 | #define DMA_INTERRUPT_ERROR 0x18 13 | #define DMA_CHANNEL_INTERRUPT_BASE 0x2a 14 | 15 | // Channel Registers 16 | #define DMA_SETTINGS 0x4 17 | #define DMA_TXRX_REGISTER 0x8 18 | #define DMA_SIZE 0xC 19 | 20 | // AES Registers 21 | #define DMA_AES 0x800000 22 | #define DMA_AES_KEY_0 0x20 23 | #define DMA_AES_KEY_1 0x24 24 | #define DMA_AES_KEY_2 0x28 25 | #define DMA_AES_KEY_3 0x2C 26 | #define DMA_AES_KEY_4 0x30 27 | #define DMA_AES_KEY_5 0x34 28 | #define DMA_AES_KEY_6 0x38 29 | #define DMA_AES_KEY_7 0x3C 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/gpio.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_GPIO_H 2 | #define HW_GPIO_H 3 | 4 | // gpioicBase 5 | // Device 6 | #define GPIOIC 0x39A00000 /* probably a part of the system controller */ 7 | 8 | // gpioBaseAddress 9 | #define GPIO 0x83000000 10 | 11 | // Registers 12 | #define GPIO_INTLEVEL 0x80 13 | #define GPIO_INTSTAT 0xA0 14 | #define GPIO_INTEN 0xC0 15 | #define GPIO_INTTYPE 0xE0 16 | #define GPIO_FSEL 0x320 17 | 18 | // Values 19 | #define GPIO_NUMINTGROUPS 7 20 | #define GPIO_INTSTAT_RESET 0xFFFFFFFF 21 | #define GPIO_INTEN_RESET 0 22 | 23 | #define GPIO_FSEL_MAJSHIFT 16 24 | #define GPIO_FSEL_MAJMASK 0x1F 25 | #define GPIO_FSEL_MINSHIFT 8 26 | #define GPIO_FSEL_MINMASK 0x7 27 | #define GPIO_FSEL_USHIFT 0 28 | #define GPIO_FSEL_UMASK 0xF 29 | 30 | #define GPIO_CLOCKGATE 0x2C 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/h2fmi.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_H2FMI_H 2 | #define HW_H2FMI_H 3 | 4 | #define H2FMI0_BASE 0x81200000 5 | #define H2FMI1_BASE 0x81300000 6 | 7 | #define H2FMI0_CLOCK_GATE 0x26 8 | #define H2FMI1_CLOCK_GATE 0x27 9 | 10 | #define H2FMI_CHIP_COUNT 16 11 | #define H2FMI_CHIPID_LENGTH 8 12 | 13 | #define H2FMI_REG(x, y) (((x)->base_address)+(y)) 14 | #define H2FMI_UNKREG1(x) (H2FMI_REG(x, 0x408)) 15 | #define H2FMI_UNKREG2(x) (H2FMI_REG(x, 0x400)) 16 | #define H2FMI_UNKREG3(x) (H2FMI_REG(x, 0x814)) 17 | #define H2FMI_UNKREG4(x) (H2FMI_REG(x, 0x414)) 18 | #define H2FMI_UNKREG5(x) (H2FMI_REG(x, 0x410)) 19 | #define H2FMI_UNK440(x) (H2FMI_REG(x, 0x440)) 20 | #define H2FMI_UNKREG6(x) (H2FMI_REG(x, 0x444)) 21 | #define H2FMI_CHIP_MASK(x) (H2FMI_REG(x, 0x40c)) 22 | #define H2FMI_UNKREG8(x) (H2FMI_REG(x, 0x424)) 23 | #define H2FMI_DATA(x) (H2FMI_REG(x, 0x448)) 24 | #define H2FMI_UNK44C(x) (H2FMI_REG(x, 0x44C)) 25 | #define H2FMI_UNKREG9(x) (H2FMI_REG(x, 0x418)) 26 | #define H2FMI_UNKREG10(x) (H2FMI_REG(x, 0x420)) 27 | #define H2FMI_UNK80C(x) (H2FMI_REG(x, 0x80C)) 28 | #define H2FMI_UNK810(x) (H2FMI_REG(x, 0x810)) 29 | #define H2FMI_UNK10(x) (H2FMI_REG(x, 0x10)) 30 | #define H2FMI_UNK14(x) (H2FMI_REG(x, 0x14)) 31 | #define H2FMI_UNK18(x) (H2FMI_REG(x, 0x18)) 32 | #define H2FMI_UNKC(x) (H2FMI_REG(x, 0xC)) 33 | #define H2FMI_UNK8(x) (H2FMI_REG(x, 0x8)) 34 | #define H2FMI_UNK4(x) (H2FMI_REG(x, 0x4)) 35 | #define H2FMI_PAGE_SIZE(x) (H2FMI_REG(x, 0x0)) 36 | #define H2FMI_ECC_BITS(x) (H2FMI_REG(x, 0x808)) 37 | #define H2FMI_UNK41C(x) (H2FMI_REG(x, 0x41C)) 38 | 39 | #endif //HW_H2FMI_H 40 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/i2c.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_I2C_H 2 | #define HW_I2C_H 3 | 4 | // Device 5 | #define I2C0 0x83200000 6 | #define I2C1 0x83300000 7 | #define I2C2 0x83400000 8 | 9 | // Registers 10 | #define IICREG0 0x0 11 | #define IICREG8 0x8 12 | #define IICREGC 0xC 13 | #define IICREG10 0x10 14 | #define IICREG14 0x14 15 | #define IICREG18 0x18 16 | #define IICREG20 0x20 17 | #define IICREG24 0x24 18 | 19 | // Values 20 | #define IICCON_INIT 0x3F00 21 | #define IICCON_ACKGEN (1 << 7) 22 | #define IICCON_TXCLKSRC_FPCLK16 (0 << 6) 23 | #define IICCON_TXCLKSRC_FPCLK512 (1 << 6) 24 | #define IICCON_INTENABLE (1 << 5) 25 | #define IICCON_INTPENDING (1 << 4) 26 | #define IICCON_TXCLKPRESCALEMASK 0xF 27 | 28 | #define IICSTAT_MODE_SLAVERX 0 29 | #define IICSTAT_MODE_SLAVETX 1 30 | #define IICSTAT_MODE_MASTERRX 2 31 | #define IICSTAT_MODE_MASTERTX 3 32 | #define IICSTAT_MODE_SHIFT 6 33 | #define IICSTAT_MODE_MASK 3 34 | #define IICSTAT_STARTSTOPGEN_START 1 35 | #define IICSTAT_STARTSTOPGEN_STOP 0 36 | #define IICSTAT_STARTSTOPGEN_MASK 1 37 | #define IICSTAT_STARTSTOPGEN_SHIFT 5 38 | #define IICSTAT_DATAOUTPUT_ENABLE_SHIFT 4 39 | #define IICSTAT_LASTRECEIVEDBIT (1 << 0) 40 | 41 | #define I2C0_SCL_GPIO 0xB02 42 | #define I2C0_SDA_GPIO 0xB03 43 | #define I2C1_SCL_GPIO 0x801 44 | #define I2C1_SDA_GPIO 0x802 45 | 46 | #define I2C0_CLOCKGATE 0x24 47 | #define I2C1_CLOCKGATE 0x26 48 | 49 | #define TXFREQ 25000 50 | 51 | #define OPERATION_SEND (1 << 8) 52 | #define OPERATION_CONDITIONCHANGE (1 << 13) 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/interrupt.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_INTERRUPT_H 2 | #define HW_INTERRUPT_H 3 | 4 | // This appears to be a PL192 5 | 6 | // Constants 7 | 8 | #define VIC_MaxInterrupt 0x80 9 | #define VIC_InterruptSeparator 0x20 10 | 11 | // Devices 12 | 13 | #define VIC0 0xBF200000 14 | #define VIC1 0xBF210000 15 | #define VIC2 0xBF220000 16 | 17 | // Registers 18 | 19 | #define VICIRQSTATUS 0x000 20 | #define VICRAWINTR 0x8 21 | #define VICINTSELECT 0xC 22 | #define VICINTENABLE 0x10 23 | #define VICINTENCLEAR 0x14 24 | #define VICSWPRIORITYMASK 0x24 25 | #define VICVECTADDRS 0x100 26 | #define VICADDRESS 0xF00 27 | #define VICPERIPHID0 0xFE0 28 | #define VICPERIPHID1 0xFE4 29 | #define VICPERIPHID2 0xFE8 30 | #define VICPERIPHID3 0xFEC 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/platform.h: -------------------------------------------------------------------------------- 1 | #include "hardware/s5l8920.h" 2 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/power.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_POWER_H 2 | #define HW_POWER_H 3 | 4 | // No power control in S5L8920 5 | 6 | #endif 7 | 8 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/radio.h: -------------------------------------------------------------------------------- 1 | #ifndef __A4_HARDWARE_RADIO 2 | #define __A4_HARDWARE_RADIO 3 | 4 | #define RADIO_GPIO_BB_RESET 0x1405 5 | #define RADIO_GPIO_RADIO_ON 0x1407 6 | #define RADIO_GPIO_RESET_DETECT 0x603 7 | #define RADIO_UART 1 8 | #define RADIO_HIGH_IS_ZERO 9 | 10 | #endif //__A4_HARDWARE_RADIO 11 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/s5l8920.h: -------------------------------------------------------------------------------- 1 | #ifndef A4_H 2 | #define A4_H 3 | 4 | // LOL HAX 5 | #ifndef MMU_SECTION_SIZE 6 | #define MMU_SECTION_SIZE 0x100000 7 | #endif 8 | 9 | /* 10 | * Constants 11 | */ 12 | 13 | #define MemoryStart 0x00000000 14 | #define MemoryEnd 0xFFFFFFFF 15 | #define LargeMemoryStart 0x50000000 16 | 17 | #define RAMStart 0x40000000 18 | #define RAMSize (0x100*(MMU_SECTION_SIZE)) 19 | #define RAMEnd (RAMStart + RAMSize) 20 | #define HiMemStart 0xC0000000 21 | #define HiMemEnd (HiMemStart + (0x400*(MMU_SECTION_SIZE))) 22 | 23 | #define ExceptionVector MemoryStart 24 | #ifdef SMALL 25 | #define PageTable (OpenIBootLoad + 0x24000) 26 | #define HeapStart (PageTable + 0x4000) 27 | #else 28 | #define OpenIBootLoad 0x00000000 29 | #define GeneralStack (PageTable - 4) 30 | #define HeapStart (LargeMemoryStart + 0x02000000) 31 | #define PageTable (RAMEnd - 0x8000) 32 | #endif 33 | 34 | /* 35 | * Devices 36 | */ 37 | 38 | #define AMC0Map 0x84000000 39 | #define AMC0Start 0x84800000 40 | #define AMC0Size (0x8*(MMU_SECTION_SIZE)) 41 | #define AMC0End (AMC0Start + AMC0Size) 42 | 43 | #define WDT_CTRL 0x3E300000 44 | #define WDT_CNT 0x3E300004 45 | 46 | #define WDT_INT 0x33 47 | /* 48 | * Values 49 | */ 50 | 51 | #define EDRAM_CLOCKGATE 0x1B 52 | #define WDT_ENABLE 0x100000 53 | #define WDT_PRE_SHIFT 16 54 | #define WDT_PRE_MASK 0xF 55 | #define WDT_CS_SHIFT 12 56 | #define WDT_CS_MASK 0x7 57 | #define WDT_CLR 0xA00 58 | #define WDT_DIS 0xA5 59 | #define WDT_INT_EN 0x8000 60 | 61 | #define DMA_ALIGN 0x40 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/spi.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_SPI_H 2 | #define HW_SPI_H 3 | 4 | // Device 5 | #define SPI0 0x82000000 6 | #define SPI1 0x82100000 7 | #define SPI2 0x82200000 8 | #define SPI3 0x82300000 9 | #define SPI4 0x82400000 10 | 11 | #define SPI0_CLOCKGATE 0x9 12 | #define SPI1_CLOCKGATE 0xA 13 | #define SPI2_CLOCKGATE 0xB 14 | #define SPI3_CLOCKGATE 0xC 15 | #define SPI4_CLOCKGATE 0xD 16 | 17 | #define SPI0_IRQ 0x1D 18 | #define SPI1_IRQ 0x1C 19 | #define SPI2_IRQ 0x1B 20 | #define SPI3_IRQ 0x1A 21 | #define SPI4_IRQ 0x19 22 | 23 | #define NUM_SPIPORTS 5 24 | 25 | // Setup register 26 | #define SPISETUP_NO_TRANSMIT_JUNK (1 << 0) // 1 bit 27 | #define SPISETUP_LAST_CLOCK_EDGE_MISSING (1 << 1) // 1 bit 28 | #define SPISETUP_IS_ACTIVE_LOW (1 << 2) // 1 bit 29 | #define SPISETUP_IS_MASTER (1 << 3) // 2 bits 30 | #define SPISETUP_OPTION5 (1 << 5) // 2 bits 31 | #define SPISETUP_UNKN1 (1 << 7) // 1 bit 32 | #define SPISETUP_UNKN2 (1 << 8) // 1 bit 33 | #define SPISETUP_CLOCKSOURCE (1 << 14) // 1 bit 34 | #define SPISETUP_WORDSIZE_SHIFT 15 // 2 bits 35 | #define SPISETUP_UNKN3 (1 << 21) // 1 bit 36 | 37 | #define STATUS_RX 1 38 | 39 | #define TX_BUFFER_LEFT(x) (((x) >> 6) & 0x1f) 40 | #define RX_BUFFER_LEFT(x) (((x) >> 11) & 0x1f) 41 | 42 | #define MAX_TX_BUFFER 0x1f 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_TIMER_H 2 | #define HW_TIMER_H 3 | 4 | // Constants 5 | #define EventTimer 4 6 | #ifdef CONFIG_IPOD_TOUCH_1G 7 | #define PiezoTimer 1 8 | #endif 9 | #ifdef CONFIG_IPHONE_3G 10 | #define VibratorTimer 5 11 | #endif 12 | 13 | // Devices 14 | #define TIMER 0xBF100000 15 | 16 | // Registers 17 | 18 | #define TIMER_0 0x0 19 | #define TIMER_1 0x20 20 | #define TIMER_2 0x40 21 | #define TIMER_3 0x60 22 | #define TIMER_4 0xA0 23 | #define TIMER_5 0xC0 24 | #define TIMER_6 0xE0 25 | #define TIMER_CONFIG 0 26 | #define TIMER_STATE 0x4 27 | #define TIMER_COUNT_BUFFER 0x8 28 | #define TIMER_COUNT_BUFFER2 0xC 29 | #define TIMER_PRESCALER 0x10 30 | #define TIMER_UNKNOWN3 0x14 31 | #define TIMER_TICKSHIGH 0x204 32 | #define TIMER_TICKSLOW 0x200 33 | #define TIMER_UNKREG0 0x88 34 | #define TIMER_UNKREG1 0x8C 35 | #define TIMER_UNKREG2 0x90 36 | #define TIMER_UNKREG3 0x94 37 | #define TIMER_UNKREG4 0x98 38 | #define TIMER_IRQSTAT 0x10000 39 | #define TIMER_IRQLATCH 0xF8 40 | 41 | // Timer 42 | #define NUM_TIMERS 7 43 | #define TIMER_CLOCKGATE 0x25 44 | #define TIMER_IRQ 0x6 45 | #define TIMER_REGISTER 0xBF100208 46 | #define TIMER_REGISTER_TICK 0xBF100220 47 | /* Argument == 1 48 | #define TIMER_IRQ 0x5 49 | #define TIMER_REGISTER 0xBF10020C 50 | #define TIMER_REGISTER_TICK 0xBF100224 51 | */ 52 | #define TIMER_STATE_START 1 53 | #define TIMER_STATE_STOP 0 54 | #define TIMER_STATE_MANUALUPDATE 2 55 | #define TIMER_UNKREG0_RESET1 0xA 56 | #define TIMER_UNKREG0_RESET2 0x18010 57 | #define TIMER_UNKREG1_RESET 0xFFFFFFFF 58 | #define TIMER_UNKREG2_RESET 0xFFFFFFFF 59 | #define TIMER_UNKREG3_RESET 0xFFFFFFFF 60 | #define TIMER_UNKREG4_RESET 0xFFFFFFFF 61 | #define TIMER_DIVIDER1 4 62 | #define TIMER_DIVIDER2 0 63 | #define TIMER_DIVIDER4 1 64 | #define TIMER_DIVIDER16 2 65 | #define TIMER_DIVIDER64 3 66 | #define TIMER_SPECIALTIMER_BIT0 0x1000000 67 | #define TIMER_SPECIALTIMER_BIT1 0x2000000 68 | 69 | #define TIMER_Separator 4 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/hardware/usbphy.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_USBPHY_H 2 | #define HW_USBPHY_H 3 | 4 | #define USB_PHY 0x86000000 5 | 6 | // Registers 7 | #define OPHYPWR 0 8 | #define OPHYCLK 0x4 9 | #define ORSTCON 0x8 10 | #define OPHYUNK1 0x1C 11 | #define OPHYUNK2 0x44 12 | #define OPHYUNK3 0x48 13 | #define OPHYUNK4 0x60 14 | #define OPHYCON 0x28 15 | 16 | // Values 17 | #define OPHYPWR_FORCESUSPEND 0x1 18 | #define OPHYPWR_PLLPOWERDOWN 0x2 19 | #define OPHYPWR_XOPOWERDOWN 0x4 20 | #define OPHYPWR_ANALOGPOWERDOWN 0x8 21 | #define OPHYPWR_UNKNOWNPOWERDOWN 0x10 22 | #define OPHYPWR_POWERON 0x0 // all the previous flags are off 23 | 24 | #define OPHYCLK_CLKSEL_MASK 0x3 25 | 26 | #define OPHYCLK_SPEED_48MHZ 48000000 27 | #define OPHYCLK_SPEED_12MHZ 12000000 28 | #define OPHYCLK_SPEED_24MHZ 24000000 29 | 30 | #define OPHYCLK_CLKSEL_12MHZ 0x0 31 | #define OPHYCLK_CLKSEL_24MHZ 0x1 32 | #define OPHYCLK_CLKSEL_48MHZ 0x2 33 | #define OPHYCLK_CLKSEL_OTHER 0x3 34 | 35 | #define ORSTCON_PHYSWRESET 0x1 36 | #define ORSTCON_LINKSWRESET 0x2 37 | #define ORSTCON_PHYLINKSWRESET 0x4 38 | 39 | #define OPHYUNK1_START 0x6 40 | #define OPHYUNK1_STOP_MASK 0x2 41 | #define OPHYUNK2_START 0xE3F 42 | 43 | #define USB_PHYPWRPOWERON_DELAYUS 10 44 | #define USB_RESET2_DELAYUS 20 45 | #define USB_RESET_DELAYUS 1000 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /plat-s5l8920/includes/mipi_dsim.h: -------------------------------------------------------------------------------- 1 | #ifndef MIPIDSIM_H 2 | #define MIPIDSIM_H 3 | 4 | #include "openiboot.h" 5 | #include "lcd.h" 6 | 7 | typedef struct LCDInfo { 8 | char name[4]; 9 | uint32_t unkn1; 10 | uint32_t DrivingClockFrequency; 11 | uint32_t DotPitch; 12 | uint32_t width; 13 | uint32_t horizontalBackPorch; 14 | uint32_t horizontalFrontPorch; 15 | uint32_t horizontalSyncPulseWidth; 16 | uint32_t height; 17 | uint32_t verticalBackPorch; 18 | uint32_t verticalFrontPorch; 19 | uint32_t verticalSyncPulseWidth; 20 | uint32_t IVClk; 21 | uint32_t IHSync; 22 | uint32_t IVSync; 23 | uint32_t IVDen; 24 | uint32_t bitsPerPixel; 25 | uint32_t unkn17; 26 | uint32_t unkn18; 27 | } LCDInfo; 28 | 29 | int mipi_dsim_init(LCDInfo* LCDTable); 30 | void mipi_dsim_quiesce(); 31 | void mipi_dsim_framebuffer_on_off(OnOff on_off); 32 | int mipi_dsim_read_write(int a1, uint8_t* buffer, uint32_t* read); 33 | int mipi_dsim_write_data(uint8_t data_id, uint8_t data0, uint8_t data1); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /plat-s5l8920/miu.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "miu.h" 3 | #include "clock.h" 4 | #include "chipid.h" 5 | #include "hardware/chipid.h" 6 | #include "util.h" 7 | 8 | int miu_setup() { 9 | if(GET_REG(POWERID) != chipid_get_power_epoch()) { 10 | // Epoch mismatch 11 | bufferPrintf("miu: epoch mismatch\r\n"); 12 | return -1; 13 | } 14 | 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /plat-s5l8920/power.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "power.h" 3 | #include "hardware/power.h" 4 | 5 | // S5L8920 no longer has power_ctrl, just 6 | // lots of clock gates. -- Ricky26 7 | 8 | int power_setup() 9 | { 10 | return 0; 11 | } 12 | 13 | int power_ctrl(uint32_t device, OnOff on_off) 14 | { 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /plat-s5l8920/s5l8920.c: -------------------------------------------------------------------------------- 1 | #include "aes.h" 2 | #include "arm/arm.h" 3 | #include "clock.h" 4 | #include "dma.h" 5 | #include "event.h" 6 | #include "framebuffer.h" 7 | #include "gpio.h" 8 | #include "interrupt.h" 9 | #include "i2c.h" 10 | #include "lcd.h" 11 | #include "miu.h" 12 | #include "mmu.h" 13 | #include "openiboot.h" 14 | #include "power.h" 15 | #include "spi.h" 16 | #include "tasks.h" 17 | #include "timer.h" 18 | #include "uart.h" 19 | #include "wdt.h" 20 | #include "audiocodec.h" 21 | 22 | void platform_init() 23 | { 24 | arm_setup(); 25 | mmu_setup(); 26 | 27 | tasks_setup(); 28 | 29 | // Basic prerequisites for everything else 30 | miu_setup(); 31 | power_setup(); 32 | 33 | //framebuffer_hook(); // TODO: Remove once LCD implemented -- Ricky26 34 | //framebuffer_setdisplaytext(TRUE); 35 | 36 | clock_setup(); 37 | 38 | // Need interrupts for everything afterwards 39 | interrupt_setup(); 40 | 41 | gpio_setup(); 42 | 43 | // For scheduling/sleeping niceties 44 | timer_setup(); 45 | event_setup(); 46 | 47 | // Other devices 48 | dma_setup(); 49 | //usb_shutdown(); 50 | uart_setup(); 51 | i2c_setup(); 52 | spi_setup(); 53 | 54 | LeaveCriticalSection(); 55 | 56 | aes_setup(); 57 | } 58 | 59 | void platform_shutdown() 60 | { 61 | //dma_shutdown(); 62 | arm_disable_caches(); 63 | mmu_disable(); 64 | } 65 | 66 | // NYI -- Ricky26 67 | void pmu_set_iboot_stage(uint8_t stage) 68 | {} 69 | -------------------------------------------------------------------------------- /plat-s5l8920/usbphy.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "usbphy.h" 3 | #include "hardware/usbphy.h" 4 | #include "timer.h" 5 | #include "clock.h" 6 | #include "util.h" 7 | 8 | void usb_phy_init() 9 | { 10 | // power on PHY 11 | SET_REG(USB_PHY + OPHYPWR, OPHYPWR_PLLPOWERDOWN | OPHYPWR_XOPOWERDOWN); 12 | SET_REG(USB_PHY + OPHYUNK1, OPHYUNK1_START); 13 | SET_REG(USB_PHY + OPHYUNK2, OPHYUNK2_START); 14 | 15 | udelay(USB_PHYPWRPOWERON_DELAYUS); 16 | 17 | // select clock 18 | uint32_t phyClockBits; 19 | switch (clock_get_frequency(FrequencyBaseUsbPhy)) 20 | { 21 | case OPHYCLK_SPEED_12MHZ: 22 | phyClockBits = OPHYCLK_CLKSEL_12MHZ; 23 | break; 24 | 25 | case OPHYCLK_SPEED_24MHZ: 26 | phyClockBits = OPHYCLK_CLKSEL_24MHZ; 27 | break; 28 | 29 | case OPHYCLK_SPEED_48MHZ: 30 | phyClockBits = OPHYCLK_CLKSEL_48MHZ; 31 | break; 32 | 33 | default: 34 | phyClockBits = OPHYCLK_CLKSEL_OTHER; 35 | break; 36 | } 37 | SET_REG(USB_PHY + OPHYCLK, (GET_REG(USB_PHY + OPHYCLK) & ~OPHYCLK_CLKSEL_MASK) | phyClockBits); 38 | 39 | // reset phy 40 | SET_REG(USB_PHY + ORSTCON, GET_REG(USB_PHY + ORSTCON) | ORSTCON_PHYSWRESET); 41 | udelay(USB_RESET2_DELAYUS); 42 | SET_REG(USB_PHY + ORSTCON, GET_REG(USB_PHY + ORSTCON) & (~ORSTCON_PHYSWRESET)); 43 | udelay(USB_RESET_DELAYUS); 44 | } 45 | 46 | void usb_phy_shutdown() 47 | { 48 | SET_REG(USB_PHY + OPHYPWR, OPHYPWR_FORCESUSPEND | OPHYPWR_PLLPOWERDOWN 49 | | OPHYPWR_XOPOWERDOWN | OPHYPWR_ANALOGPOWERDOWN | OPHYPWR_UNKNOWNPOWERDOWN); // power down phy 50 | 51 | SET_REG(USB_PHY + ORSTCON, GET_REG(USB_PHY + ORSTCON) | ORSTCON_PHYSWRESET); 52 | 53 | udelay(USB_RESET_DELAYUS); // wait a millisecond for the changes to stick 54 | 55 | SET_REG(USB_PHY + OPHYUNK1, GET_REG(USB_PHY + OPHYUNK1) &~ OPHYUNK1_STOP_MASK); 56 | } 57 | 58 | 59 | -------------------------------------------------------------------------------- /radio-pmb8876/SConscript: -------------------------------------------------------------------------------- 1 | Import("*") 2 | 3 | radio_pmb8876_src = env.Localize([ 4 | 'radio.c' 5 | ]) 6 | 7 | radio_pmb8876 = env.CreateModule('radio-pmb8876', radio_pmb8876_src) 8 | radio_pmb8876.Append(CPPPATH=[Dir('includes')]) 9 | -------------------------------------------------------------------------------- /radio-pmb8878/SConscript: -------------------------------------------------------------------------------- 1 | Import("*") 2 | 3 | radio_pmb8878_src = env.Localize([ 4 | 'radio.c' 5 | ]) 6 | 7 | radio_pmb8878 = env.CreateModule('radio-pmb8878', radio_pmb8878_src) 8 | radio_pmb8878.Append(CPPPATH=[Dir('includes')]) 9 | -------------------------------------------------------------------------------- /radio-xgold618/SConscript: -------------------------------------------------------------------------------- 1 | Import("*") 2 | 3 | radio_xgold618_src = env.Localize([ 4 | 'radio.c' 5 | ]) 6 | 7 | radio_xgold618 = env.CreateModule('radio-xgold618', radio_xgold618_src) 8 | radio_xgold618.Append(CPPPATH=[Dir('includes')]) 9 | -------------------------------------------------------------------------------- /scons/ARMEnvironment.SConscript: -------------------------------------------------------------------------------- 1 | # 2 | # Setup our cross-compilation environment. 3 | # 4 | 5 | import os 6 | 7 | def ARMEnvironment(*a, **kw): 8 | env = Environment(tools=['gas', 'gcc', 'gnulink', 'ar'], ENV=os.environ, *a, **kw) 9 | plat_flags = ['-mlittle-endian', '-mfpu=vfp', '-mthumb', '-mthumb-interwork', '-fPIC'] 10 | env.Append(CPPPATH = ['#includes']) 11 | env.Append(CPPFLAGS = plat_flags+['-nostdlib']) 12 | env.Append(ASPPFLAGS = ['-xassembler-with-cpp']) 13 | env.Append(LINKFLAGS = plat_flags+['-nostdlib', '--nostdlib', '-Ttext=0x0']) 14 | env.Append(LIBS = ['gcc']) 15 | 16 | env['PROGSUFFIX'] = '' 17 | 18 | if not env.has_key("CROSS"): 19 | if env['ENV'].has_key("CROSS"): 20 | env['CROSS'] = env['ENV']['CROSS'] 21 | else: 22 | env["CROSS"] = 'arm-elf-' 23 | 24 | env["CC"] = env["CROSS"] + 'gcc' 25 | env["OBJCOPY"] = env["CROSS"] + 'objcopy' 26 | env["AR"] = env["CROSS"] + 'ar' 27 | 28 | return env 29 | Export('ARMEnvironment') 30 | -------------------------------------------------------------------------------- /scons/Git.SConscript: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | def GetGitCommit(): 4 | p = subprocess.Popen('git log | head -n1 | cut -b8-14', shell=True, stdout=subprocess.PIPE) 5 | ret,smth = p.communicate() 6 | return ret[:-1] 7 | Export('GetGitCommit') 8 | -------------------------------------------------------------------------------- /sentinel.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sentinel.c - OpeniBoot Menu 3 | * 4 | * Copyright 2010 iDroid Project 5 | * 6 | * This file is part of iDroid. An android distribution for Apple products. 7 | * For more information, please visit http://www.idroidproject.org/. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 3 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #include "openiboot.h" 25 | #include "commands.h" 26 | 27 | initfn_t init_boot_sentinal __attribute__ ((section(BOOT_MODULE_INIT_SECTION))) = NULL; 28 | initfn_t init_sentinal __attribute__ ((section(MODULE_INIT_SECTION))) = NULL; 29 | exitfn_t exit_sentinal __attribute__ ((section(MODULE_EXIT_SECTION))) = NULL; 30 | OPIBCommand *command_sentinal __attribute__ ((section(".commands"))) = NULL; 31 | -------------------------------------------------------------------------------- /usb-synopsys/SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | usb_synopsys_src = env.Localize([ 4 | 'usb.c', 5 | ]) 6 | 7 | usb_synopsys = env.CreateModule('usb-synopsys', usb_synopsys_src) 8 | usb_synopsys.Append(CPPPATH = [Dir('includes')]) 9 | -------------------------------------------------------------------------------- /vfl-vfl/SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | vfl_vfl_src = env.Localize([ 4 | 'vfl.c', 5 | ]) 6 | 7 | vfl_vfl = env.CreateModule('vfl-vfl', vfl_vfl_src) 8 | vfl_vfl.Append(CPPPATH = [Dir('includes')]) 9 | vfl_vfl.Append(CPPDEFINES = ['CONFIG_VFL_VFL']) 10 | -------------------------------------------------------------------------------- /vfl-vfl/includes/vfl/vfl.h: -------------------------------------------------------------------------------- 1 | #ifndef VFL_VFL_H 2 | #define VFL_VFL_H 3 | 4 | #include "../../includes/vfl.h" 5 | #include "nand.h" 6 | 7 | /** 8 | * @file 9 | * 10 | * This file is where the VFL-VFL VFL implementation is defined. 11 | * 12 | * VFL-VFL is the standard VFL implementation, which is 13 | * compatible with the VFL from older Apple devices, 14 | * including upto the iPhone 3G. 15 | */ 16 | 17 | typedef struct _vfl_vfl_geometry 18 | { 19 | uint16_t pages_per_block; 20 | uint16_t pages_per_sublk; 21 | uint32_t pages_total; 22 | uint32_t some_page_mask; 23 | uint32_t some_sublk_mask; 24 | uint16_t blocks_per_ce; 25 | uint16_t bytes_per_page; 26 | uint32_t num_ecc_bytes; 27 | uint32_t bytes_per_spare; 28 | uint32_t one; 29 | uint16_t num_ce; 30 | uint16_t ecc_bits; 31 | uint16_t reserved_blocks; 32 | uint16_t vfl_blocks; 33 | uint16_t some_crazy_val; 34 | uint16_t fs_start_block; 35 | uint32_t unk; 36 | } vfl_vfl_geometry_t; 37 | 38 | struct _vfl_vfl_context; 39 | 40 | // VFL-VFL Device Struct 41 | 42 | /** 43 | * The VFL-VFL device structure. 44 | * 45 | * This is the device structure for 46 | * the standard VFL implementation, VFL-VFL. 47 | * 48 | * @implements _vfl_device 49 | * @ingroup VFL 50 | */ 51 | typedef struct _vfl_vfl_device 52 | { 53 | vfl_device_t vfl; 54 | 55 | uint32_t current_version; 56 | struct _vfl_vfl_context *contexts; 57 | nand_device_t *device; 58 | vfl_vfl_geometry_t geometry; 59 | uint8_t *bbt; 60 | 61 | uint32_t *pageBuffer; 62 | uint16_t *chipBuffer; 63 | } vfl_vfl_device_t; 64 | 65 | // VFL-VFL Functions 66 | error_t vfl_vfl_device_init(vfl_vfl_device_t *_vfl); 67 | void vfl_vfl_device_cleanup(vfl_vfl_device_t *_vfl); 68 | 69 | vfl_vfl_device_t *vfl_vfl_device_allocate(); 70 | 71 | #endif //VFL_VFL_H 72 | -------------------------------------------------------------------------------- /vfl-vsvfl/SConscript: -------------------------------------------------------------------------------- 1 | Import('*') 2 | 3 | vfl_vsvfl_src = env.Localize([ 4 | 'vsvfl.c', 5 | ]) 6 | 7 | vfl_vsvfl = env.CreateModule('vfl-vsvfl', vfl_vsvfl_src) 8 | vfl_vsvfl.Append(CPPPATH = [Dir('includes')]) 9 | vfl_vsvfl.Append(CPPDEFINES = ['CONFIG_VFL_VSVFL']) 10 | --------------------------------------------------------------------------------