├── .gitignore ├── Dripwn ├── C Tool │ ├── dripwn.c │ ├── includes │ │ ├── abstractfile.h │ │ ├── common.h │ │ ├── dmg │ │ │ ├── dmg.h │ │ │ ├── dmgfile.h │ │ │ ├── dmglib.h │ │ │ └── filevault.h │ │ ├── hfs │ │ │ ├── hfscompress.h │ │ │ ├── hfslib.h │ │ │ └── hfsplus.h │ │ ├── partial │ │ │ ├── firmwaremaster.h │ │ │ └── partial.h │ │ └── xpwn │ │ │ ├── 8900.h │ │ │ ├── ibootim.h │ │ │ ├── img2.h │ │ │ ├── img3.h │ │ │ ├── libxpwn.h │ │ │ ├── lzss.h │ │ │ ├── lzssfile.h │ │ │ ├── nor_files.h │ │ │ ├── outputstate.h │ │ │ ├── plist.h │ │ │ └── pwnutil.h │ ├── makefile │ └── minizip │ │ ├── crypt.h │ │ ├── ioapi.c │ │ ├── ioapi.h │ │ ├── iowin32.c │ │ ├── iowin32.h │ │ ├── miniunz.c │ │ ├── minizip.c │ │ ├── mztools.c │ │ ├── mztools.h │ │ ├── unzip.c │ │ ├── unzip.h │ │ ├── zip.c │ │ └── zip.h ├── CocoaCryptoHashing.h ├── CocoaCryptoHashing.m ├── Dripwn-Info.plist ├── Dripwn.xcodeproj │ ├── James.mode1v3 │ ├── James.pbxuser │ └── project.pbxproj ├── DripwnAppDelegate.h ├── DripwnAppDelegate.m ├── Dripwn_Prefix.pch ├── English.lproj │ ├── InfoPlist.strings │ └── MainMenu.xib ├── Firmwares │ ├── iPhone1,1_3.1.2_7D11_Restore.ipsw.plist │ ├── iPhone1,1_3.1.3_7E18_Restore.ipsw.plist │ ├── iPhone1,1_3.1_7C144_Restore.ipsw.plist │ ├── iPhone1,2_3.1.3_7E18_Restore.ipsw.plist │ ├── iPhone1,2_3.1_2_7D11_Restore.ipsw.plist │ ├── iPhone2,1_3.1.2_7D11_Restore.ipsw.plist │ └── iPhone2,1_3.1.3_7E18_Restore.ipsw.plist ├── IPSW.h ├── IPSW.m ├── Icon.icns ├── NSData+Base64.h ├── NSData+Base64.m ├── build │ ├── Dripwn.build │ │ ├── Debug │ │ │ └── Dripwn.build │ │ │ │ ├── Dripwn.dep │ │ │ │ └── build-state.dat │ │ └── Dripwn.pbxindex │ │ │ ├── categories.pbxbtree │ │ │ ├── cdecls.pbxbtree │ │ │ ├── decls.pbxbtree │ │ │ ├── files.pbxbtree │ │ │ ├── imports.pbxbtree │ │ │ ├── pbxindex.header │ │ │ ├── protocols.pbxbtree │ │ │ ├── refs.pbxbtree │ │ │ ├── strings.pbxstrings │ │ │ ├── control │ │ │ └── strings │ │ │ ├── subclasses.pbxbtree │ │ │ └── symbols0.pbxsymbols │ └── Release │ │ └── README.txt ├── dripwn ├── main.m ├── vfdecrypt └── xpwn │ └── crypto │ └── aescmd ├── WISHLIST ├── branches └── libibooter-1.0 │ ├── LICENCE │ ├── Makefile │ ├── README │ ├── include │ └── libibooter.h │ └── src │ ├── example.cpp │ └── libibooter.cpp ├── img3unpack ├── img3.c └── img3.h ├── libibooter ├── LICENCE ├── Makefile ├── README ├── include │ └── libibooter.h └── src │ ├── example.cpp │ └── libibooter.cpp ├── openiboot ├── Makefile ├── RUNNING ├── SCRIPTING.txt ├── accel.c ├── actions.c ├── aes.c ├── als.c ├── alsISL29003.c ├── arm.c ├── buttons.c ├── camera.c ├── chipid.c ├── client │ ├── Makefile │ ├── linux.c │ ├── loadibec.c │ └── oibc.c ├── clock.c ├── commands.c ├── dma.c ├── entry.S ├── event.c ├── framebuffer.c ├── ftl.c ├── gpio.c ├── hfs │ ├── bdev.c │ ├── btree.c │ ├── catalog.c │ ├── extents.c │ ├── fastunicodecompare.c │ ├── fs.c │ ├── rawfile.c │ ├── utility.c │ └── volume.c ├── i2c.c ├── images.c ├── images │ ├── AndroidOS.png │ ├── AndroidOSPNG.h │ ├── AndroidOSSelected.png │ ├── AndroidOSSelectedPNG.h │ ├── Console.png │ ├── ConsolePNG.h │ ├── ConsoleSelected.png │ ├── ConsoleSelectedPNG.h │ ├── Header.png │ ├── HeaderPNG.h │ ├── Makefile │ ├── README │ ├── bin2c.c │ ├── iPhoneOS.png │ ├── iPhoneOSPNG.h │ ├── iPhoneOSSelected.png │ └── iPhoneOSSelectedPNG.h ├── includes │ ├── accel.h │ ├── actions.h │ ├── aes.h │ ├── als.h │ ├── arm.h │ ├── buttons.h │ ├── camera.h │ ├── chipid.h │ ├── clock.h │ ├── commands.h │ ├── dma.h │ ├── event.h │ ├── framebuffer.h │ ├── ftl.h │ ├── gpio.h │ ├── hardware │ │ ├── accel.h │ │ ├── aes.h │ │ ├── als.h │ │ ├── arm.h │ │ ├── buttons.h │ │ ├── camera.h │ │ ├── chipid.h │ │ ├── clock0.h │ │ ├── clock1.h │ │ ├── dma.h │ │ ├── edgeic.h │ │ ├── gpio.h │ │ ├── i2c.h │ │ ├── i2s.h │ │ ├── interrupt.h │ │ ├── lcd.h │ │ ├── multitouch.h │ │ ├── nand.h │ │ ├── nor.h │ │ ├── pmu.h │ │ ├── power.h │ │ ├── radio.h │ │ ├── s5l8900.h │ │ ├── sdio.h │ │ ├── spi.h │ │ ├── timer.h │ │ ├── uart.h │ │ ├── usb.h │ │ └── wmcodec.h │ ├── hfs │ │ ├── bdev.h │ │ ├── common.h │ │ ├── fs.h │ │ ├── hfslib.h │ │ └── hfsplus.h │ ├── i2c.h │ ├── images.h │ ├── interrupt.h │ ├── lcd.h │ ├── malloc-2.8.3.h │ ├── menu.h │ ├── miu.h │ ├── mmu.h │ ├── multitouch.h │ ├── nand.h │ ├── nor.h │ ├── nvram.h │ ├── openiboot-asmhelpers.h │ ├── openiboot.h │ ├── piezo.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 │ ├── util.h │ ├── wdt.h │ ├── wlan.h │ └── wmcodec.h ├── interrupt.c ├── lcd.c ├── malloc.c ├── menu.c ├── miu.c ├── mk8900image │ ├── 8900.h │ ├── Makefile │ ├── abstractfile.h │ ├── blank │ ├── common.h │ ├── iboot-template.img2 │ ├── ibootim.h │ ├── img2.h │ ├── iphonelinux.der │ ├── lzss.h │ ├── lzssfile.h │ ├── mk8900image.c │ ├── nor_files.h │ ├── template-3g.img3 │ ├── template-ipod.img3 │ ├── template-wtf.img2 │ ├── template.img2 │ ├── template.img3 │ ├── x86 │ │ ├── libcommon.a │ │ └── libxpwn.a │ └── x86_64 │ │ ├── libcommon.a │ │ └── libxpwn.a ├── mmu.c ├── multitouch-z2.c ├── multitouch.c ├── nand.c ├── nor.c ├── nvram.c ├── openiboot-asmhelpers.S ├── openiboot.S.h ├── openiboot.c ├── pcf │ ├── 6x10.h │ ├── Makefile │ ├── README │ ├── bin2.c │ ├── oif.c │ └── pcf.c ├── piezo.c ├── pmu.c ├── power.c ├── printf.c ├── radio.c ├── scripting.c ├── sdio.c ├── sha1.c ├── spi.c ├── stb_image.c ├── syscfg.c ├── tasks.c ├── timer.c ├── uart.c ├── ultrasn0w.h ├── usb.c ├── util.c ├── wdt.c ├── wlan.c ├── wm8958.c └── wm8991.c ├── toolchain ├── README ├── TOOLCHAIN ├── build-toolchain.sh ├── newlib-1.14.0-missing-makeinfo.patch └── t-arm-elf.patch └── tools ├── Makefile ├── bitset.c └── dumpnandinfo.c /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE! Don't add files that are generated in specific 3 | # subdirectories here. Add them in the ".gitignore" file 4 | # in that subdirectory instead. 5 | # 6 | # NOTE! Please use 'git-ls-files -i --exclude-standard' 7 | # command after changing this file, to see if there are 8 | # any tracked files which get ignored after the change. 9 | # 10 | # Normal rules 11 | # 12 | .* 13 | *.o 14 | *.o.* 15 | *.a 16 | *.s 17 | *.ko 18 | *.so 19 | *.so.dbg 20 | *.mod.c 21 | *.i 22 | *.lst 23 | *.symtypes 24 | *.order 25 | *.elf 26 | *.bin 27 | *.gz 28 | *.dump 29 | 30 | !.gitignore 31 | 32 | openiboot/*.img3 33 | openiboot/*.img2 34 | openiboot/openiboot 35 | openiboot/client/oibc 36 | openiboot/client/loadibec 37 | openiboot/client/linux 38 | openiboot/mk8900image/mk8900image 39 | 40 | openiboot/images/bin2c 41 | 42 | *.orig 43 | *~ 44 | \#*# 45 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/abstractfile.h: -------------------------------------------------------------------------------- 1 | #ifndef ABSTRACTFILE_H 2 | #define ABSTRACTFILE_H 3 | 4 | #include "common.h" 5 | #include 6 | 7 | typedef struct AbstractFile AbstractFile; 8 | typedef struct AbstractFile2 AbstractFile2; 9 | 10 | typedef size_t (*WriteFunc)(AbstractFile* file, const void* data, size_t len); 11 | typedef size_t (*ReadFunc)(AbstractFile* file, void* data, size_t len); 12 | typedef int (*SeekFunc)(AbstractFile* file, off_t offset); 13 | typedef off_t (*TellFunc)(AbstractFile* file); 14 | typedef void (*CloseFunc)(AbstractFile* file); 15 | typedef off_t (*GetLengthFunc)(AbstractFile* file); 16 | typedef void (*SetKeyFunc)(AbstractFile2* file, const unsigned int* key, const unsigned int* iv); 17 | 18 | typedef enum AbstractFileType { 19 | AbstractFileTypeFile, 20 | AbstractFileType8900, 21 | AbstractFileTypeImg2, 22 | AbstractFileTypeImg3, 23 | AbstractFileTypeLZSS, 24 | AbstractFileTypeIBootIM, 25 | AbstractFileTypeMem, 26 | AbstractFileTypeMemFile, 27 | AbstractFileTypeDummy 28 | } AbstractFileType; 29 | 30 | struct AbstractFile { 31 | void* data; 32 | WriteFunc write; 33 | ReadFunc read; 34 | SeekFunc seek; 35 | TellFunc tell; 36 | GetLengthFunc getLength; 37 | CloseFunc close; 38 | AbstractFileType type; 39 | }; 40 | 41 | struct AbstractFile2 { 42 | AbstractFile super; 43 | SetKeyFunc setKey; 44 | }; 45 | 46 | 47 | typedef struct { 48 | size_t offset; 49 | void** buffer; 50 | size_t bufferSize; 51 | } MemWrapperInfo; 52 | 53 | typedef struct { 54 | size_t offset; 55 | void** buffer; 56 | size_t* bufferSize; 57 | size_t actualBufferSize; 58 | } MemFileWrapperInfo; 59 | 60 | #ifdef __cplusplus 61 | extern "C" { 62 | #endif 63 | AbstractFile* createAbstractFileFromFile(FILE* file); 64 | AbstractFile* createAbstractFileFromDummy(); 65 | AbstractFile* createAbstractFileFromMemory(void** buffer, size_t size); 66 | AbstractFile* createAbstractFileFromMemoryFile(void** buffer, size_t* size); 67 | AbstractFile* createAbstractFileFromMemoryFileBuffer(void** buffer, size_t* size, size_t actualBufferSize); 68 | void abstractFilePrint(AbstractFile* file, const char* format, ...); 69 | io_func* IOFuncFromAbstractFile(AbstractFile* file); 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/common.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_H 2 | #define COMMON_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #ifdef WIN32 11 | #define fseeko fseeko64 12 | #define ftello ftello64 13 | #define off_t off64_t 14 | #define mkdir(x, y) mkdir(x) 15 | #define PATH_SEPARATOR "\\" 16 | #else 17 | #define PATH_SEPARATOR "/" 18 | #endif 19 | 20 | #define TRUE 1 21 | #define FALSE 0 22 | 23 | #define FLIPENDIAN(x) flipEndian((unsigned char *)(&(x)), sizeof(x)) 24 | #define FLIPENDIANLE(x) flipEndianLE((unsigned char *)(&(x)), sizeof(x)) 25 | 26 | #define IS_BIG_ENDIAN 0 27 | #define IS_LITTLE_ENDIAN 1 28 | 29 | #define TIME_OFFSET_FROM_UNIX 2082844800L 30 | #define APPLE_TO_UNIX_TIME(x) ((x) - TIME_OFFSET_FROM_UNIX) 31 | #define UNIX_TO_APPLE_TIME(x) ((x) + TIME_OFFSET_FROM_UNIX) 32 | 33 | #define ASSERT(x, m) if(!(x)) { fflush(stdout); fprintf(stderr, "error: %s\n", m); perror("error"); fflush(stderr); exit(1); } 34 | 35 | extern char endianness; 36 | 37 | static inline void flipEndian(unsigned char* x, int length) { 38 | int i; 39 | unsigned char tmp; 40 | 41 | if(endianness == IS_BIG_ENDIAN) { 42 | return; 43 | } else { 44 | for(i = 0; i < (length / 2); i++) { 45 | tmp = x[i]; 46 | x[i] = x[length - i - 1]; 47 | x[length - i - 1] = tmp; 48 | } 49 | } 50 | } 51 | 52 | static inline void flipEndianLE(unsigned char* x, int length) { 53 | int i; 54 | unsigned char tmp; 55 | 56 | if(endianness == IS_LITTLE_ENDIAN) { 57 | return; 58 | } else { 59 | for(i = 0; i < (length / 2); i++) { 60 | tmp = x[i]; 61 | x[i] = x[length - i - 1]; 62 | x[length - i - 1] = tmp; 63 | } 64 | } 65 | } 66 | 67 | static inline void hexToBytes(const char* hex, uint8_t** buffer, size_t* bytes) { 68 | *bytes = strlen(hex) / 2; 69 | *buffer = (uint8_t*) malloc(*bytes); 70 | size_t i; 71 | for(i = 0; i < *bytes; i++) { 72 | uint32_t byte; 73 | sscanf(hex, "%2x", &byte); 74 | (*buffer)[i] = byte; 75 | hex += 2; 76 | } 77 | } 78 | 79 | static inline void hexToInts(const char* hex, unsigned int** buffer, size_t* bytes) { 80 | *bytes = strlen(hex) / 2; 81 | *buffer = (unsigned int*) malloc((*bytes) * sizeof(int)); 82 | size_t i; 83 | for(i = 0; i < *bytes; i++) { 84 | sscanf(hex, "%2x", &((*buffer)[i])); 85 | hex += 2; 86 | } 87 | } 88 | 89 | struct io_func_struct; 90 | 91 | typedef int (*readFunc)(struct io_func_struct* io, off_t location, size_t size, void *buffer); 92 | typedef int (*writeFunc)(struct io_func_struct* io, off_t location, size_t size, void *buffer); 93 | typedef void (*closeFunc)(struct io_func_struct* io); 94 | 95 | typedef struct io_func_struct { 96 | void* data; 97 | readFunc read; 98 | writeFunc write; 99 | closeFunc close; 100 | } io_func; 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/dmg/dmgfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * dmgfile.h 3 | * libdmg-hfsplus 4 | * 5 | */ 6 | 7 | #include 8 | 9 | io_func* openDmgFile(AbstractFile* dmg); 10 | io_func* openDmgFilePartition(AbstractFile* dmg, int partition); 11 | 12 | typedef struct DMG { 13 | AbstractFile* dmg; 14 | ResourceKey* resources; 15 | uint32_t numBLKX; 16 | BLKXTable** blkx; 17 | void* runData; 18 | uint64_t runStart; 19 | uint64_t runEnd; 20 | uint64_t offset; 21 | } DMG; 22 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/dmg/dmglib.h: -------------------------------------------------------------------------------- 1 | #ifndef DMGLIB_H 2 | #define DMGLIB_H 3 | 4 | #include 5 | #include "abstractfile.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | int extractDmg(AbstractFile* abstractIn, AbstractFile* abstractOut, int partNum); 11 | int buildDmg(AbstractFile* abstractIn, AbstractFile* abstractOut, unsigned int BlockSize); 12 | 13 | int convertToDMG(AbstractFile* abstractIn, AbstractFile* abstractOut); 14 | int convertToISO(AbstractFile* abstractIn, AbstractFile* abstractOut); 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/dmg/filevault.h: -------------------------------------------------------------------------------- 1 | #ifndef FILEVAULT_H 2 | #define FILEVAULT_H 3 | 4 | #include 5 | #include "dmg.h" 6 | 7 | #ifdef HAVE_CRYPT 8 | 9 | #include 10 | #include 11 | 12 | #define FILEVAULT_CIPHER_KEY_LENGTH 16 13 | #define FILEVAULT_CIPHER_BLOCKSIZE 16 14 | #define FILEVAULT_CHUNK_SIZE 4096 15 | #define FILEVAULT_PBKDF2_ITER_COUNT 1000 16 | #define FILEVAULT_MSGDGST_LENGTH 20 17 | 18 | /* 19 | * Information about the FileVault format was yoinked from vfdecrypt, which was written by Ralf-Philipp Weinmann , 20 | * Jacob Appelbaum , and Christian Fromme 21 | */ 22 | 23 | #define FILEVAULT_V2_SIGNATURE 0x656e637263647361ULL 24 | 25 | typedef struct FileVaultV1Header { 26 | uint8_t padding1[48]; 27 | uint32_t kdfIterationCount; 28 | uint32_t kdfSaltLen; 29 | uint8_t kdfSalt[48]; 30 | uint8_t unwrapIV[0x20]; 31 | uint32_t wrappedAESKeyLen; 32 | uint8_t wrappedAESKey[296]; 33 | uint32_t wrappedHMACSHA1KeyLen; 34 | uint8_t wrappedHMACSHA1Key[300]; 35 | uint32_t integrityKeyLen; 36 | uint8_t integrityKey[48]; 37 | uint8_t padding2[484]; 38 | } __attribute__((__packed__)) FileVaultV1Header; 39 | 40 | typedef struct FileVaultV2Header { 41 | uint64_t signature; 42 | uint32_t version; 43 | uint32_t encIVSize; 44 | uint32_t unk1; 45 | uint32_t unk2; 46 | uint32_t unk3; 47 | uint32_t unk4; 48 | uint32_t unk5; 49 | UDIFID uuid; 50 | uint32_t blockSize; 51 | uint64_t dataSize; 52 | uint64_t dataOffset; 53 | uint8_t padding[0x260]; 54 | uint32_t kdfAlgorithm; 55 | uint32_t kdfPRNGAlgorithm; 56 | uint32_t kdfIterationCount; 57 | uint32_t kdfSaltLen; 58 | uint8_t kdfSalt[0x20]; 59 | uint32_t blobEncIVSize; 60 | uint8_t blobEncIV[0x20]; 61 | uint32_t blobEncKeyBits; 62 | uint32_t blobEncAlgorithm; 63 | uint32_t blobEncPadding; 64 | uint32_t blobEncMode; 65 | uint32_t encryptedKeyblobSize; 66 | uint8_t encryptedKeyblob[0x30]; 67 | } __attribute__((__packed__)) FileVaultV2Header; 68 | 69 | typedef struct FileVaultInfo { 70 | union { 71 | FileVaultV1Header v1; 72 | FileVaultV2Header v2; 73 | } header; 74 | 75 | uint8_t version; 76 | uint64_t dataOffset; 77 | uint64_t dataSize; 78 | uint32_t blockSize; 79 | 80 | AbstractFile* file; 81 | 82 | HMAC_CTX hmacCTX; 83 | AES_KEY aesKey; 84 | AES_KEY aesEncKey; 85 | 86 | off_t offset; 87 | 88 | uint32_t curChunk; 89 | unsigned char chunk[FILEVAULT_CHUNK_SIZE]; 90 | 91 | char dirty; 92 | char headerDirty; 93 | } FileVaultInfo; 94 | #endif 95 | 96 | AbstractFile* createAbstractFileFromFileVault(AbstractFile* file, const char* key); 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/hfs/hfscompress.h: -------------------------------------------------------------------------------- 1 | #ifndef HFSCOMPRESS_H 2 | #define HFSCOMPRESS_H 3 | 4 | #include 5 | #include "common.h" 6 | 7 | #define CMPFS_MAGIC 0x636D7066 8 | 9 | typedef struct HFSPlusDecmpfs { 10 | uint32_t magic; 11 | uint32_t flags; 12 | uint64_t size; 13 | uint8_t data[0]; 14 | } __attribute__ ((packed)) HFSPlusDecmpfs; 15 | 16 | typedef struct HFSPlusCmpfRsrcHead { 17 | uint32_t headerSize; 18 | uint32_t totalSize; 19 | uint32_t dataSize; 20 | uint32_t flags; 21 | } __attribute__ ((packed)) HFSPlusCmpfRsrcHead; 22 | 23 | typedef struct HFSPlusCmpfRsrcBlock { 24 | uint32_t offset; 25 | uint32_t size; 26 | } __attribute__ ((packed)) HFSPlusCmpfRsrcBlock; 27 | 28 | typedef struct HFSPlusCmpfRsrcBlockHead { 29 | uint32_t dataSize; 30 | uint32_t numBlocks; 31 | HFSPlusCmpfRsrcBlock blocks[0]; 32 | } __attribute__ ((packed)) HFSPlusCmpfRsrcBlockHead; 33 | 34 | typedef struct HFSPlusCmpfEnd { 35 | uint32_t pad[6]; 36 | uint16_t unk1; 37 | uint16_t unk2; 38 | uint16_t unk3; 39 | uint32_t magic; 40 | uint32_t flags; 41 | uint64_t size; 42 | uint32_t unk4; 43 | } __attribute__ ((packed)) HFSPlusCmpfEnd; 44 | 45 | typedef struct HFSPlusCompressed { 46 | Volume* volume; 47 | HFSPlusCatalogFile* file; 48 | io_func* io; 49 | size_t decmpfsSize; 50 | HFSPlusDecmpfs* decmpfs; 51 | 52 | HFSPlusCmpfRsrcHead rsrcHead; 53 | HFSPlusCmpfRsrcBlockHead* blocks; 54 | 55 | int dirty; 56 | 57 | uint8_t* cached; 58 | uint32_t cachedStart; 59 | uint32_t cachedEnd; 60 | } HFSPlusCompressed; 61 | 62 | #ifdef __cplusplus 63 | extern "C" { 64 | #endif 65 | void flipHFSPlusDecmpfs(HFSPlusDecmpfs* compressData); 66 | io_func* openHFSPlusCompressed(Volume* volume, HFSPlusCatalogFile* file); 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/hfs/hfslib.h: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "hfsplus.h" 3 | #include "abstractfile.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | void writeToFile(HFSPlusCatalogFile* file, AbstractFile* output, Volume* volume); 9 | void writeToHFSFile(HFSPlusCatalogFile* file, AbstractFile* input, Volume* volume); 10 | void get_hfs(Volume* volume, const char* inFileName, AbstractFile* output); 11 | int add_hfs(Volume* volume, AbstractFile* inFile, const char* outFileName); 12 | void grow_hfs(Volume* volume, uint64_t newSize); 13 | void removeAllInFolder(HFSCatalogNodeID folderID, Volume* volume, const char* parentName); 14 | void addAllInFolder(HFSCatalogNodeID folderID, Volume* volume, const char* parentName); 15 | void addall_hfs(Volume* volume, const char* dirToMerge, const char* dest); 16 | void extractAllInFolder(HFSCatalogNodeID folderID, Volume* volume); 17 | int copyAcrossVolumes(Volume* volume1, Volume* volume2, char* path1, char* path2); 18 | 19 | void hfs_untar(Volume* volume, AbstractFile* tarFile); 20 | void hfs_ls(Volume* volume, const char* path); 21 | void hfs_setsilence(int s); 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/partial/firmwaremaster.h: -------------------------------------------------------------------------------- 1 | const char* FirmwareGetHardwareID(const char* platform); 2 | char* FirmwareGetURL(const char* platform, const char* version); 3 | 4 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/partial/partial.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | typedef struct EndOfCD { 5 | uint32_t signature; 6 | uint16_t diskNo; 7 | uint16_t CDDiskNo; 8 | uint16_t CDDiskEntries; 9 | uint16_t CDEntries; 10 | uint32_t CDSize; 11 | uint32_t CDOffset; 12 | uint16_t lenComment; 13 | } __attribute__ ((packed)) EndOfCD; 14 | 15 | typedef struct CDFile { 16 | uint32_t signature; 17 | uint16_t version; 18 | uint16_t versionExtract; 19 | uint16_t flags; 20 | uint16_t method; 21 | uint16_t modTime; 22 | uint16_t modDate; 23 | uint32_t crc32; 24 | uint32_t compressedSize; 25 | uint32_t size; 26 | uint16_t lenFileName; 27 | uint16_t lenExtra; 28 | uint16_t lenComment; 29 | uint16_t diskStart; 30 | uint16_t internalAttr; 31 | uint32_t externalAttr; 32 | uint32_t offset; 33 | } __attribute__ ((packed)) CDFile; 34 | 35 | typedef struct LocalFile { 36 | uint32_t signature; 37 | uint16_t versionExtract; 38 | uint16_t flags; 39 | uint16_t method; 40 | uint16_t modTime; 41 | uint16_t modDate; 42 | uint32_t crc32; 43 | uint32_t compressedSize; 44 | uint32_t size; 45 | uint16_t lenFileName; 46 | uint16_t lenExtra; 47 | } __attribute__ ((packed)) LocalFile; 48 | 49 | typedef struct ZipInfo ZipInfo; 50 | 51 | typedef void (*PartialZipProgressCallback)(ZipInfo* info, CDFile* file, size_t progress); 52 | 53 | struct ZipInfo { 54 | char* url; 55 | uint64_t length; 56 | CURL* hIPSW; 57 | char* centralDirectory; 58 | size_t centralDirectoryRecvd; 59 | EndOfCD* centralDirectoryDesc; 60 | char centralDirectoryEnd[0xffff + sizeof(EndOfCD)]; 61 | size_t centralDirectoryEndRecvd; 62 | PartialZipProgressCallback progressCallback; 63 | }; 64 | 65 | #ifdef __cplusplus 66 | extern "C" { 67 | #endif 68 | 69 | ZipInfo* PartialZipInit(const char* url); 70 | 71 | CDFile* PartialZipFindFile(ZipInfo* info, const char* fileName); 72 | 73 | CDFile* PartialZipListFiles(ZipInfo* info); 74 | 75 | unsigned char* PartialZipGetFile(ZipInfo* info, CDFile* file); 76 | 77 | void PartialZipRelease(ZipInfo* info); 78 | 79 | void PartialZipSetProgressCallback(ZipInfo* info, PartialZipProgressCallback progressCallback); 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/xpwn/8900.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 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 | #define key_0x837 ((uint8_t[]){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 | char exploit; 43 | } Info8900; 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | AbstractFile* createAbstractFileFrom8900(AbstractFile* file); 49 | AbstractFile* duplicate8900File(AbstractFile* file, AbstractFile* backing); 50 | void replaceCertificate8900(AbstractFile* file, AbstractFile* certificate); 51 | void exploit8900(AbstractFile* file); 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/xpwn/ibootim.h: -------------------------------------------------------------------------------- 1 | #ifndef IBOOTIM_H 2 | #define IBOOTIM_H 3 | 4 | #include 5 | #include 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, const unsigned int* key, const unsigned int* iv, AbstractFile* png, size_t *fileSize); 41 | int convertToPNG(AbstractFile* imageWrapper, const unsigned int* key, const unsigned int* iv, const char* png); 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/xpwn/img2.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 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 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/xpwn/img3.h: -------------------------------------------------------------------------------- 1 | #ifndef IMG3_H 2 | #define IMG3_H 3 | 4 | #include 5 | #include "common.h" 6 | #include 7 | #include 8 | 9 | #define IMG3_MAGIC 0x496d6733 10 | #define IMG3_DATA_MAGIC 0x44415441 11 | #define IMG3_VERS_MAGIC 0x56455253 12 | #define IMG3_SEPO_MAGIC 0x5345504f 13 | #define IMG3_SCEP_MAGIC 0x53434550 14 | #define IMG3_BORD_MAGIC 0x424f5244 15 | #define IMG3_BDID_MAGIC 0x42444944 16 | #define IMG3_SHSH_MAGIC 0x53485348 17 | #define IMG3_CERT_MAGIC 0x43455254 18 | #define IMG3_KBAG_MAGIC 0x4B424147 19 | #define IMG3_TYPE_MAGIC 0x54595045 20 | 21 | #define IMG3_SIGNATURE IMG3_MAGIC 22 | 23 | typedef struct Img3Element Img3Element; 24 | typedef struct Img3Info Img3Info; 25 | 26 | typedef void (*WriteImg3)(AbstractFile* file, Img3Element* element, Img3Info* info); 27 | typedef void (*FreeImg3)(Img3Element* element); 28 | 29 | typedef struct AppleImg3Header { 30 | uint32_t magic; 31 | uint32_t size; 32 | uint32_t dataSize; 33 | }__attribute__((__packed__)) AppleImg3Header; 34 | 35 | typedef struct AppleImg3RootExtra { 36 | uint32_t shshOffset; 37 | uint32_t name; 38 | }__attribute__((__packed__)) AppleImg3RootExtra; 39 | 40 | typedef struct AppleImg3RootHeader { 41 | AppleImg3Header base; 42 | AppleImg3RootExtra extra; 43 | }__attribute__((__packed__)) AppleImg3RootHeader; 44 | 45 | typedef struct AppleImg3KBAGHeader { 46 | 47 | uint32_t key_modifier; // key modifier, can be 0 or 1 48 | uint32_t key_bits; // number of bits in the key, can be 128, 192 or 256 (it seems only 128 is supported in current iBoot) 49 | } AppleImg3KBAGHeader; 50 | 51 | struct Img3Element 52 | { 53 | AppleImg3Header* header; 54 | WriteImg3 write; 55 | FreeImg3 free; 56 | void* data; 57 | struct Img3Element* next; 58 | }; 59 | 60 | struct Img3Info { 61 | AbstractFile* file; 62 | Img3Element* root; 63 | Img3Element* data; 64 | Img3Element* cert; 65 | Img3Element* kbag; 66 | Img3Element* type; 67 | int encrypted; 68 | AES_KEY encryptKey; 69 | AES_KEY decryptKey; 70 | uint8_t iv[16]; 71 | size_t offset; 72 | uint32_t replaceDWord; 73 | char dirty; 74 | char exploit24k; 75 | char exploitN8824k; 76 | }; 77 | 78 | #ifdef __cplusplus 79 | extern "C" { 80 | #endif 81 | AbstractFile* createAbstractFileFromImg3(AbstractFile* file); 82 | AbstractFile* duplicateImg3File(AbstractFile* file, AbstractFile* backing); 83 | void replaceCertificateImg3(AbstractFile* file, AbstractFile* certificate); 84 | void exploit24kpwn(AbstractFile* file); 85 | void exploitN8824kpwn(AbstractFile* file); 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | 91 | #endif 92 | 93 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/xpwn/libxpwn.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBXPWN_H 2 | #define LIBXPWN_H 3 | 4 | typedef void (*LogMessageCallback) (const char * Message); 5 | 6 | extern LogMessageCallback logCallback; 7 | 8 | #if __STDC_VERSION__ < 199901L 9 | # if __GNUC__ >= 2 10 | # define __func__ __FUNCTION__ 11 | # else 12 | # define __func__ "" 13 | # endif 14 | #endif 15 | 16 | #define XLOG(level, format, ...) Log(level, __FILE__, __LINE__, __func__, format, ## __VA_ARGS__) 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | void init_libxpwn(); 22 | void libxpwn_log(LogMessageCallback callback); 23 | void libxpwn_loglevel(int logLevel); 24 | void Log(int level, const char* file, unsigned int line, const char* function, const char* format, ...); 25 | void TestByteOrder(); 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/xpwn/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 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/xpwn/lzssfile.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 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 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/xpwn/nor_files.h: -------------------------------------------------------------------------------- 1 | #ifndef NOR_FILES_H 2 | #define NOR_FILES_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 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 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/xpwn/outputstate.h: -------------------------------------------------------------------------------- 1 | #ifndef OUTPUTSTATE_H 2 | #define OUTPUTSTATE_H 3 | 4 | #include 5 | 6 | typedef struct OutputState { 7 | char* fileName; 8 | void* buffer; 9 | size_t bufferSize; 10 | char* tmpFileName; 11 | struct OutputState* next; 12 | struct OutputState* prev; 13 | } OutputState; 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | char* createTempFile(); 19 | void addToOutput2(OutputState** state, const char* fileName, void* buffer, const size_t bufferSize, char* tmpFileName); 20 | void addToOutput(OutputState** state, const char* fileName, void* buffer, const size_t bufferSize); 21 | void removeFileFromOutputState(OutputState** state, const char* fileName); 22 | AbstractFile* getFileFromOutputState(OutputState** state, const char* fileName); 23 | AbstractFile* getFileFromOutputStateForOverwrite(OutputState** state, const char* fileName); 24 | AbstractFile* getFileFromOutputStateForReplace(OutputState** state, const char* fileName); 25 | void writeOutput(OutputState** state, char* ipsw); 26 | void releaseOutput(OutputState** state); 27 | OutputState* loadZip2(const char* ipsw, int useMemory); 28 | void loadZipFile2(const char* ipsw, OutputState** output, const char* file, int useMemory); 29 | OutputState* loadZip(const char* ipsw); 30 | void loadZipFile(const char* ipsw, OutputState** output, const char* file); 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/xpwn/plist.h: -------------------------------------------------------------------------------- 1 | #ifndef PLIST_H 2 | #define PLIST_H 3 | 4 | enum DictTypes { 5 | DictionaryType = 1, 6 | ArrayType, 7 | StringType, 8 | IntegerType, 9 | BoolType 10 | }; 11 | 12 | typedef struct DictValue { 13 | int type; 14 | char* key; 15 | struct DictValue* next; 16 | struct DictValue* prev; 17 | } DictValue; 18 | 19 | typedef struct StringValue { 20 | DictValue dValue; 21 | char* value; 22 | } StringValue; 23 | 24 | typedef struct IntegerValue { 25 | DictValue dValue; 26 | int value; 27 | } IntegerValue; 28 | 29 | typedef struct BoolValue { 30 | DictValue dValue; 31 | char value; 32 | } BoolValue; 33 | 34 | typedef struct ArrayValue { 35 | DictValue dValue; 36 | int size; 37 | DictValue** values; 38 | } ArrayValue; 39 | 40 | typedef struct Dictionary { 41 | DictValue dValue; 42 | DictValue* values; 43 | } Dictionary; 44 | 45 | typedef struct Tag { 46 | char* name; 47 | char* xml; 48 | } Tag; 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | void createArray(ArrayValue* myself, char* xml); 54 | void createDictionary(Dictionary* myself, char* xml); 55 | void releaseArray(ArrayValue* myself); 56 | void releaseDictionary(Dictionary* myself); 57 | char* getXmlFromArrayValue(ArrayValue* myself, int tabsCount); 58 | char* getXmlFromDictionary(Dictionary* myself, int tabsCount); 59 | Dictionary* createRoot(char* xml); 60 | char* getXmlFromRoot(Dictionary* root); 61 | char* getXmlFromRoot(Dictionary* root); 62 | DictValue* getValueByKey(Dictionary* myself, const char* key); 63 | void addStringToArray(ArrayValue* array, char* str); 64 | void removeKey(Dictionary* dict, char* key); 65 | void addBoolToDictionary(Dictionary* dict, const char* key, int value); 66 | void addIntegerToDictionary(Dictionary* dict, const char* key, int value); 67 | void addValueToDictionary(Dictionary* dict, const char* key, DictValue* value); 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif 73 | 74 | -------------------------------------------------------------------------------- /Dripwn/C Tool/includes/xpwn/pwnutil.h: -------------------------------------------------------------------------------- 1 | #ifndef PWNUTIL_H 2 | #define PWNUTIL_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | typedef int (*PatchFunction)(AbstractFile* file); 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | int patch(AbstractFile* in, AbstractFile* out, AbstractFile* patch); 14 | Dictionary* parseIPSW(const char* inputIPSW, const char* bundleRoot, char** bundlePath, OutputState** state); 15 | Dictionary* parseIPSW2(const char* inputIPSW, const char* bundleRoot, char** bundlePath, OutputState** state, int useMemory); 16 | int doPatch(StringValue* patchValue, StringValue* fileValue, const char* bundlePath, OutputState** state, unsigned int* key, unsigned int* iv, int useMemory); 17 | void doPatchInPlace(Volume* volume, const char* filePath, const char* patchPath); 18 | void doPatchInPlaceMemoryPatch(Volume* volume, const char* filePath, void** patch, size_t* patchSize); 19 | void fixupBootNeuterArgs(Volume* volume, char unlockBaseband, char selfDestruct, char use39, char use46); 20 | void createRestoreOptions(Volume* volume, int SystemPartitionSize, int UpdateBaseband); 21 | 22 | int patchSigCheck(AbstractFile* file); 23 | int patchKernel(AbstractFile* file); 24 | int patchDeviceTree(AbstractFile* file); 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /Dripwn/C Tool/makefile: -------------------------------------------------------------------------------- 1 | dripwn : dripwn.o 2 | gcc ./dripwn.o ./libdmg.a ./libhfs.a ./libcommon.a ./libminizip.a -lz -lcrypto -o ./dripwn 3 | 4 | dripwn.o : dripwn.c 5 | gcc ./dripwn.c -L./minizip/ -I./minizip/ -L./includes/ -I./includes -c -------------------------------------------------------------------------------- /Dripwn/C Tool/minizip/ioapi.h: -------------------------------------------------------------------------------- 1 | /* ioapi.h -- IO base function header for compress/uncompress .zip 2 | files using zlib + zip or unzip API 3 | 4 | Version 1.01e, February 12th, 2005 5 | 6 | Copyright (C) 1998-2005 Gilles Vollant 7 | */ 8 | 9 | #ifndef _ZLIBIOAPI_H 10 | #define _ZLIBIOAPI_H 11 | 12 | 13 | #define ZLIB_FILEFUNC_SEEK_CUR (1) 14 | #define ZLIB_FILEFUNC_SEEK_END (2) 15 | #define ZLIB_FILEFUNC_SEEK_SET (0) 16 | 17 | #define ZLIB_FILEFUNC_MODE_READ (1) 18 | #define ZLIB_FILEFUNC_MODE_WRITE (2) 19 | #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) 20 | 21 | #define ZLIB_FILEFUNC_MODE_EXISTING (4) 22 | #define ZLIB_FILEFUNC_MODE_CREATE (8) 23 | 24 | 25 | #ifndef ZCALLBACK 26 | 27 | #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) 28 | #define ZCALLBACK CALLBACK 29 | #else 30 | #define ZCALLBACK 31 | #endif 32 | #endif 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); 39 | typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); 40 | typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); 41 | typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); 42 | typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); 43 | typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); 44 | typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); 45 | 46 | typedef struct zlib_filefunc_def_s 47 | { 48 | open_file_func zopen_file; 49 | read_file_func zread_file; 50 | write_file_func zwrite_file; 51 | tell_file_func ztell_file; 52 | seek_file_func zseek_file; 53 | close_file_func zclose_file; 54 | testerror_file_func zerror_file; 55 | voidpf opaque; 56 | } zlib_filefunc_def; 57 | 58 | 59 | 60 | void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 61 | 62 | #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) 63 | #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) 64 | #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) 65 | #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) 66 | #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) 67 | #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) 68 | 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /Dripwn/C Tool/minizip/iowin32.h: -------------------------------------------------------------------------------- 1 | /* iowin32.h -- IO base function header for compress/uncompress .zip 2 | files using zlib + zip or unzip API 3 | This IO API version uses the Win32 API (for Microsoft Windows) 4 | 5 | Version 1.01e, February 12th, 2005 6 | 7 | Copyright (C) 1998-2005 Gilles Vollant 8 | */ 9 | 10 | #include 11 | 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /Dripwn/C Tool/minizip/mztools.h: -------------------------------------------------------------------------------- 1 | /* 2 | Additional tools for Minizip 3 | Code: Xavier Roche '2004 4 | License: Same as ZLIB (www.gzip.org) 5 | */ 6 | 7 | #ifndef _zip_tools_H 8 | #define _zip_tools_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #ifndef _ZLIB_H 15 | #include "zlib.h" 16 | #endif 17 | 18 | #include "unzip.h" 19 | 20 | /* Repair a ZIP file (missing central directory) 21 | file: file to recover 22 | fileOut: output file after recovery 23 | fileOutTmp: temporary file name used for recovery 24 | */ 25 | extern int ZEXPORT unzRepair(const char* file, 26 | const char* fileOut, 27 | const char* fileOutTmp, 28 | uLong* nRecovered, 29 | uLong* bytesRecovered); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Dripwn/CocoaCryptoHashing.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CocoaCryptoHashing.h 3 | * CocoaCryptoHashing 4 | */ 5 | 6 | #import 7 | 8 | @interface NSString (CocoaCryptoHashing) 9 | 10 | /*! 11 | * @method md5Hash 12 | * @abstract Calculates the MD5 hash from the UTF-8 representation of the specified string and returns the binary representation 13 | * @result A NSData object containing the binary representation of the MD5 hash 14 | */ 15 | - (NSData *)md5Hash; 16 | 17 | /*! 18 | * @method md5HexHash 19 | * @abstract Calculates the MD5 hash from the UTF-8 representation of the specified string and returns the hexadecimal representation 20 | * @result A NSString object containing the hexadecimal representation of the MD5 hash 21 | */ 22 | - (NSString *)md5HexHash; 23 | 24 | /*! 25 | * @method sha1Hash 26 | * @abstract Calculates the SHA-1 hash from the UTF-8 representation of the specified string and returns the binary representation 27 | * @result A NSData object containing the binary representation of the SHA-1 hash 28 | */ 29 | - (NSData *)sha1Hash; 30 | 31 | /*! 32 | * @method sha1HexHash 33 | * @abstract Calculates the SHA-1 hash from the UTF-8 representation of the specified string and returns the hexadecimal representation 34 | * @result A NSString object containing the hexadecimal representation of the SHA-1 hash 35 | */ 36 | - (NSString *)sha1HexHash; 37 | 38 | @end 39 | 40 | @interface NSData (CocoaCryptoHashing) 41 | 42 | /*! 43 | * @method md5Hash 44 | * @abstract Calculates the MD5 hash from the data in the specified NSData object and returns the binary representation 45 | * @result A NSData object containing the binary representation of the MD5 hash 46 | */ 47 | - (NSData *)md5Hash; 48 | 49 | /*! 50 | * @method md5HexHash 51 | * @abstract Calculates the MD5 hash from the data in the specified NSData object and returns the hexadecimal representation 52 | * @result A NSString object containing the hexadecimal representation of the MD5 hash 53 | */ 54 | - (NSString *)md5HexHash; 55 | 56 | /*! 57 | * @method sha1Hash 58 | * @abstract Calculates the SHA-1 hash from the data in the specified NSData object and returns the binary representation 59 | * @result A NSData object containing the binary representation of the SHA-1 hash 60 | */ 61 | - (NSData *)sha1Hash; 62 | 63 | /*! 64 | * @method sha1HexHash 65 | * @abstract Calculates the SHA-1 hash from the data in the specified NSData object and returns the hexadecimal representation 66 | * @result A NSString object containing the hexadecimal representation of the SHA-1 hash 67 | */ 68 | - (NSString *)sha1HexHash; 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /Dripwn/CocoaCryptoHashing.m: -------------------------------------------------------------------------------- 1 | /* 2 | * CocoaCryptoHashing.m 3 | * CocoaCryptoHashing 4 | */ 5 | 6 | #import "CocoaCryptoHashing.h" 7 | 8 | #if TARGET_OS_MAC && (TARGET_OS_IPHONE || MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4) 9 | 10 | #define COMMON_DIGEST_FOR_OPENSSL 11 | #import 12 | 13 | #define MD5(data, len, md) CC_MD5(data, len, md) 14 | #define SHA1(data, len, md) CC_SHA1(data, len, md) 15 | 16 | #else 17 | 18 | #import 19 | #import 20 | 21 | #endif 22 | 23 | @implementation NSString (CocoaCryptoHashing) 24 | 25 | - (NSData *)md5Hash 26 | { 27 | return [[self dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO] md5Hash]; 28 | } 29 | 30 | - (NSString *)md5HexHash 31 | { 32 | return [[self dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO] md5HexHash]; 33 | } 34 | 35 | - (NSData *)sha1Hash 36 | { 37 | return [[self dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO] sha1Hash]; 38 | } 39 | 40 | - (NSString *)sha1HexHash 41 | { 42 | return [[self dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO] sha1HexHash]; 43 | } 44 | 45 | @end 46 | 47 | @implementation NSData (CocoaCryptoHashing) 48 | 49 | - (NSString *)md5HexHash 50 | { 51 | unsigned char digest[MD5_DIGEST_LENGTH]; 52 | char finaldigest[2*MD5_DIGEST_LENGTH]; 53 | int i; 54 | 55 | MD5([self bytes],[self length],digest); 56 | for(i=0;i 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | Icon.icns 11 | CFBundleIdentifier 12 | uk.co.jamware.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleSignature 20 | ???? 21 | CFBundleShortVersionString 22 | 1.1 23 | LSMinimumSystemVersion 24 | ${MACOSX_DEPLOYMENT_TARGET} 25 | CFBundleVersion 26 | 1 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /Dripwn/DripwnAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // DripwnAppDelegate.h 3 | // Dripwn 4 | // 5 | // Created by James Munnelly on 23/04/2010. 6 | // Copyright 2010 JamWare. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "IPSW.h" 11 | 12 | @interface DripwnAppDelegate : NSObject { 13 | NSWindow *window; 14 | IPSW *ipsw; 15 | } 16 | 17 | @property (assign) IBOutlet NSWindow *window; 18 | - (IBAction) startExtraction:(id) sender; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Dripwn/DripwnAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // DripwnAppDelegate.m 3 | // Dripwn 4 | // 5 | // Created by James Munnelly on 23/04/2010. 6 | // Copyright 2010 JamWare. All rights reserved. 7 | // 8 | 9 | #import "DripwnAppDelegate.h" 10 | #import "IPSW.h" 11 | 12 | @implementation DripwnAppDelegate 13 | 14 | @synthesize window; 15 | 16 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 17 | // Insert code here to initialize your application 18 | } 19 | 20 | - (IBAction) startExtraction:(id) sender { 21 | ipsw = [[IPSW alloc] init]; 22 | [ipsw startExtraction:sender]; 23 | [ipsw release]; 24 | } 25 | 26 | - (void) dealloc { 27 | if(ipsw) 28 | [ipsw release]; 29 | [super dealloc]; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Dripwn/Dripwn_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Dripwn' target in the 'Dripwn' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Dripwn/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Dripwn/Firmwares/iPhone1,1_3.1.2_7D11_Restore.ipsw.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Filename 6 | iPhone1,1_3.1.2_7D11_Restore.ipsw 7 | Name 8 | iPhone1,1_3.1.2_7D11 9 | RootFilesystem 10 | 018-6028-014.dmg 11 | RootFilesystemKey 12 | FE431A1E436E5298D3C871359768AAB43189FD5E7375A2CED3405DD8A223879A4D64A28E 13 | RootFilesystemMountVolume 14 | Northstar7D11.iPhoneOS 15 | SHA1 16 | e4a1171542dbbd3093516d9c02047b9f7e143050 17 | 18 | 19 | -------------------------------------------------------------------------------- /Dripwn/Firmwares/iPhone1,1_3.1_7C144_Restore.ipsw.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Filename 6 | iPhone1,1_3.1_7C144_Restore.ipsw 7 | Name 8 | iPhone1,1_3.1_7C144 9 | RootFilesystem 10 | 018-5343-086.dmg 11 | RootFilesystemKey 12 | DBE476ED0D8C1ECF7CD514463F2CA5A6F71B6F244D98EBAA9203FD527C1ECBF2BB5F143F 13 | RootFilesystemMountVolume 14 | Northstar7C144.iPhoneOS 15 | SHA1 16 | b7b5f436f81c6f855410e8b44a3d432ccaacd6fc 17 | 18 | 19 | -------------------------------------------------------------------------------- /Dripwn/Firmwares/iPhone1,2_3.1.3_7E18_Restore.ipsw.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Filename 6 | iPhone1,2_3.1.3_7E18_Restore.ipsw 7 | Name 8 | iPhone1,2_3.1.3_7E18 9 | RootFilesystem 10 | 018-6482-014.dmg 11 | RootFilesystemKey 12 | BF5EB72CD65E9C37CF9920707CB6B4F7ECC10B38CFEC6B167002AC9FD6A3AB6643E45005 13 | RootFilesystemMountVolume 14 | SUNorthstarTwo7E18.iPhoneOS 15 | SHA1 16 | f5950afca546f93e281ba3cdb08bc0cfed7f0896 17 | 18 | 19 | -------------------------------------------------------------------------------- /Dripwn/Firmwares/iPhone1,2_3.1_2_7D11_Restore.ipsw.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Filename 6 | iPhone1,2_3.1.2_7D11_Restore.ipsw 7 | Name 8 | iPhone1,2_3.1.2_7D11 9 | RootFilesystem 10 | 018-6028-014.dmg 11 | RootFilesystemKey 12 | A8A886D56011D2D98B190D0A498F6FCAC719467047639CD601FD53A4A1D93C24E1B2DDC6 13 | RootFilesystemMountVolume 14 | Northstar7D11.iPhoneOS 15 | SHA1 16 | b1a6ab2771bb5da372ba75a8fa3e1d72b71359d0 17 | 18 | 19 | -------------------------------------------------------------------------------- /Dripwn/Firmwares/iPhone2,1_3.1.2_7D11_Restore.ipsw.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Filename 6 | iPhone2,1_3.1.2_7D11_Restore.ipsw 7 | Name 8 | iPhone2,1_3.1.2_7D11 9 | RootFilesystem 10 | 018-6029-014.dmg 11 | RootFilesystemKey 12 | 47D76295817F74953F8E557B4917FE2201E9778A9900E43FBF311A83F176FE521B996A4B 13 | RootFilesystemMountVolume 14 | Northstar7D11.N88OS 15 | SHA1 16 | 6998bb7d9e869b2d89a08853312f9457d070fb1f 17 | 18 | 19 | -------------------------------------------------------------------------------- /Dripwn/Firmwares/iPhone2,1_3.1.3_7E18_Restore.ipsw.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Filename 6 | iPhone2,1_3.1.3_7E18_Restore.ipsw 7 | Name 8 | iPhone2,1_3.1.3_7E18 9 | RootFilesystem 10 | 018-6483-022.dmg 11 | RootFilesystemKey 12 | 9B3FD35BAD7D5307D85CE4B38B8E56BD680EF5A72A8F3B615F8D4F16C14BDCF3C3B24C6C 13 | RootFilesystemMountVolume 14 | SUNorthstarTwo7E18.N88OS 15 | SHA1 16 | 8cb3775e62c6f72059a962bf891b4e145b965052 17 | 18 | 19 | -------------------------------------------------------------------------------- /Dripwn/IPSW.h: -------------------------------------------------------------------------------- 1 | // 2 | // IPSW.h 3 | // Dripwn 4 | // 5 | // Created by James Munnelly on 25/04/2010. 6 | // Copyright 2010 JamWare. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface IPSW : NSObject { 13 | 14 | } 15 | 16 | - (BOOL) startExtraction:(id) sender; 17 | - (NSString *) selectIPSW; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Dripwn/IPSW.m: -------------------------------------------------------------------------------- 1 | // 2 | // IPSW.m 3 | // Dripwn 4 | // 5 | // Created by James Munnelly on 25/04/2010. 6 | // Copyright 2010 JamWare. All rights reserved. 7 | // 8 | 9 | #import "IPSW.h" 10 | #import "CocoaCryptoHashing.h" 11 | 12 | @implementation IPSW 13 | 14 | 15 | - (BOOL) startExtraction:(id) sender { 16 | NSString *ipsw = [self selectIPSW]; 17 | if(!ipsw) 18 | return NO; 19 | NSString *resourceBundle = [[NSBundle mainBundle] pathForResource:[ipsw lastPathComponent] ofType:@"plist"]; 20 | if(!resourceBundle) { 21 | NSLog(@"Invalid file"); 22 | NSAlert *alert = [NSAlert alertWithMessageText:@"Invalid file" defaultButton:@"Okay" alternateButton:nil otherButton:nil informativeTextWithFormat:@"Invalid file selected. You must use an iPhone IPSW firmware version 3.1 or above."]; 23 | [alert runModal]; 24 | return NO; 25 | } 26 | NSString *saveFolder = [self chooseFolder]; 27 | NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:resourceBundle]; 28 | NSTask *cmnd=[[NSTask alloc] init]; 29 | [cmnd setLaunchPath:[[NSBundle mainBundle] pathForResource:@"dripwn" ofType:@""]]; 30 | [cmnd setArguments:[NSArray arrayWithObjects:ipsw,[dict objectForKey:@"RootFilesystemKey"],[dict objectForKey:@"RootFilesystem"],nil]]; 31 | [cmnd setCurrentDirectoryPath:saveFolder]; 32 | [cmnd launch]; 33 | [cmnd waitUntilExit]; 34 | 35 | if ([cmnd terminationStatus] != 0) 36 | { 37 | return NO; 38 | } 39 | [cmnd release]; 40 | 41 | NSAlert *alert = [NSAlert alertWithMessageText:@"Complete" defaultButton:@"Okay" alternateButton:nil otherButton:nil informativeTextWithFormat:@"Succesfully extracted Zephyr firmware files."]; 42 | [alert runModal]; 43 | return YES; 44 | } 45 | 46 | - (NSString *) selectIPSW { 47 | NSOpenPanel* openDlg = [NSOpenPanel openPanel]; 48 | [openDlg setCanChooseFiles:YES]; 49 | [openDlg setCanChooseDirectories:NO]; 50 | [openDlg setAllowsMultipleSelection:NO]; 51 | 52 | if ([openDlg runModalForDirectory:nil file:nil] == NSOKButton) 53 | { 54 | NSArray* files = [openDlg filenames]; 55 | return [files objectAtIndex:0]; 56 | } 57 | return nil; 58 | } 59 | 60 | - (NSString *) chooseFolder { 61 | NSOpenPanel* saveDlg = [NSOpenPanel openPanel]; 62 | [saveDlg setTitle:@"Save to..."]; 63 | [saveDlg setMessage:@"Select where to save the Zephyr firmware files."]; 64 | [saveDlg setCanChooseDirectories:YES]; 65 | [saveDlg setAllowsMultipleSelection:NO]; 66 | 67 | if ([saveDlg runModalForDirectory:nil file:nil] == NSOKButton) 68 | { 69 | NSArray* files = [saveDlg filenames]; 70 | return [files objectAtIndex:0]; 71 | } 72 | return nil; 73 | } 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /Dripwn/Icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/Dripwn/Icon.icns -------------------------------------------------------------------------------- /Dripwn/NSData+Base64.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+Base64.m 3 | // 4 | // Derived from http://colloquy.info/project/browser/trunk/NSDataAdditions.h?rev=1576 5 | // Created by khammond on Mon Oct 29 2001. 6 | // Formatted by Timothy Hatcher on Sun Jul 4 2004. 7 | // Copyright (c) 2001 Kyle Hammond. All rights reserved. 8 | // Original development by Dave Winer. 9 | // 10 | 11 | @interface NSData (Base64) 12 | 13 | + (NSData *) dataWithBase64EncodedData:(NSData *) data; 14 | - (id) initWithBase64EncodedData:(NSData *) dta; 15 | /*! @function +dataWithBase64EncodedString: 16 | @discussion This method returns an autoreleased NSData object. The NSData object is initialized with the 17 | contents of the Base 64 encoded string. This is a convenience method. 18 | @param inBase64String An NSString object that contains only Base 64 encoded data. 19 | @result The NSData object. */ 20 | + (NSData *) dataWithBase64EncodedString:(NSString *) string; 21 | 22 | /*! @function -initWithBase64EncodedString: 23 | @discussion The NSData object is initialized with the contents of the Base 64 encoded string. 24 | This method returns self as a convenience. 25 | @param inBase64String An NSString object that contains only Base 64 encoded data. 26 | @result This method returns self. */ 27 | - (id) initWithBase64EncodedString:(NSString *) string; 28 | 29 | /*! @function -base64EncodingWithLineLength: 30 | @discussion This method returns a Base 64 encoded string representation of the data object. 31 | @param inLineLength A value of zero means no line breaks. This is crunched to a multiple of 4 (the next 32 | one greater than inLineLength). 33 | @result The base 64 encoded data. */ 34 | - (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength; 35 | 36 | @end -------------------------------------------------------------------------------- /Dripwn/build/Dripwn.build/Dripwn.pbxindex/categories.pbxbtree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/Dripwn/build/Dripwn.build/Dripwn.pbxindex/categories.pbxbtree -------------------------------------------------------------------------------- /Dripwn/build/Dripwn.build/Dripwn.pbxindex/cdecls.pbxbtree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/Dripwn/build/Dripwn.build/Dripwn.pbxindex/cdecls.pbxbtree -------------------------------------------------------------------------------- /Dripwn/build/Dripwn.build/Dripwn.pbxindex/decls.pbxbtree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/Dripwn/build/Dripwn.build/Dripwn.pbxindex/decls.pbxbtree -------------------------------------------------------------------------------- /Dripwn/build/Dripwn.build/Dripwn.pbxindex/files.pbxbtree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/Dripwn/build/Dripwn.build/Dripwn.pbxindex/files.pbxbtree -------------------------------------------------------------------------------- /Dripwn/build/Dripwn.build/Dripwn.pbxindex/imports.pbxbtree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/Dripwn/build/Dripwn.build/Dripwn.pbxindex/imports.pbxbtree -------------------------------------------------------------------------------- /Dripwn/build/Dripwn.build/Dripwn.pbxindex/pbxindex.header: -------------------------------------------------------------------------------- 1 | xnip!ry   -------------------------------------------------------------------------------- /Dripwn/build/Dripwn.build/Dripwn.pbxindex/protocols.pbxbtree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/Dripwn/build/Dripwn.build/Dripwn.pbxindex/protocols.pbxbtree -------------------------------------------------------------------------------- /Dripwn/build/Dripwn.build/Dripwn.pbxindex/refs.pbxbtree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/Dripwn/build/Dripwn.build/Dripwn.pbxindex/refs.pbxbtree -------------------------------------------------------------------------------- /Dripwn/build/Dripwn.build/Dripwn.pbxindex/strings.pbxstrings/control: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/Dripwn/build/Dripwn.build/Dripwn.pbxindex/strings.pbxstrings/control -------------------------------------------------------------------------------- /Dripwn/build/Dripwn.build/Dripwn.pbxindex/strings.pbxstrings/strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/Dripwn/build/Dripwn.build/Dripwn.pbxindex/strings.pbxstrings/strings -------------------------------------------------------------------------------- /Dripwn/build/Dripwn.build/Dripwn.pbxindex/subclasses.pbxbtree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/Dripwn/build/Dripwn.build/Dripwn.pbxindex/subclasses.pbxbtree -------------------------------------------------------------------------------- /Dripwn/build/Dripwn.build/Dripwn.pbxindex/symbols0.pbxsymbols: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/Dripwn/build/Dripwn.build/Dripwn.pbxindex/symbols0.pbxsymbols -------------------------------------------------------------------------------- /Dripwn/build/Release/README.txt: -------------------------------------------------------------------------------- 1 | To use Dripwn, simply click 'Extract firmware' and select your iPhone 3.1 (or above) IPSW. Wait approx. 10 seconds and you will have the two firmware files sitting on your desktop waiting for you! 2 | 3 | Enjoy! 4 | 5 | Munnerz -------------------------------------------------------------------------------- /Dripwn/dripwn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/Dripwn/dripwn -------------------------------------------------------------------------------- /Dripwn/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Dripwn 4 | // 5 | // Created by James Munnelly on 23/04/2010. 6 | // Copyright 2010 JamWare. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /Dripwn/vfdecrypt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/Dripwn/vfdecrypt -------------------------------------------------------------------------------- /Dripwn/xpwn/crypto/aescmd: -------------------------------------------------------------------------------- 1 | aes -------------------------------------------------------------------------------- /branches/libibooter-1.0/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Simple make for ibooter/libibooter 3 | # 4 | CC=g++ 5 | 6 | CFLAGS=-g 7 | INC=-I./include/ 8 | 9 | SRCDIR=src 10 | OBJDIR=build 11 | 12 | LDFLAGS_SO=-lusb -shared 13 | LDFLAGS=-L../$(OBJDIR) -libooter 14 | 15 | OBJS=example.o 16 | LIBOBJS=libibooter.o 17 | 18 | 19 | all: prepare libibooter.so example 20 | 21 | VPATH=$(SRCDIR) 22 | 23 | .cpp.o: 24 | $(CC) $(CFLAGS) -c $< $(INC) -o $(OBJDIR)/$@ 25 | 26 | libibooter.so: $(LIBOBJS) 27 | cd $(OBJDIR); $(CC) $(LDFLAGS_SO) $^ -o $@ 28 | 29 | example: $(OBJS) libibooter.so 30 | cd $(OBJDIR); $(CC) $(LDFLAGS) $^ -o $@ 31 | 32 | prepare: 33 | mkdir -p $(OBJDIR) 34 | 35 | clean: 36 | rm -rf $(OBJDIR) 37 | -------------------------------------------------------------------------------- /branches/libibooter-1.0/README: -------------------------------------------------------------------------------- 1 | IBooter lib version 1.0 2 | 3 | This code is released under GPL. Please make sure to include credit to cmw/dre if you use it. 4 | 5 | Credits 6 | Cmw & Dre 7 | Geohot 8 | 9 | Greets 10 | planetbeing 11 | Wizdaz 12 | Pumpkin 13 | Roxfan 14 | Nightwatch 15 | -------------------------------------------------------------------------------- /branches/libibooter-1.0/include/libibooter.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace ibooter 5 | { 6 | typedef enum { 7 | IB_SUCCESS = 0, 8 | IB_FAIL, 9 | IB_DEVICE_NOT_FOUND, 10 | IB_FAILED_TO_OPEN, 11 | IB_FAILED_TO_CONFIGURE, 12 | IB_FAILED_TO_CLAIM, 13 | IB_FILE_NOT_FOUND, 14 | IB_CONNECTION_LOST, 15 | IB_COMMAND_NOT_ACK, 16 | IB_DUMPING_BUFFER, 17 | } ERR_CODE; 18 | 19 | const char *errcode_to_str(ERR_CODE code) 20 | { 21 | switch (code) 22 | { 23 | case IB_SUCCESS: 24 | return "Success"; 25 | case IB_FAIL: 26 | return "Failed"; 27 | case IB_DEVICE_NOT_FOUND: 28 | return "iPhone/iTouch not found in recovery"; 29 | case IB_FAILED_TO_OPEN: 30 | return "Failed to connect to iPhone/iTouch"; 31 | case IB_FAILED_TO_CONFIGURE: 32 | return "You do not have adequate system privileges"; 33 | case IB_FAILED_TO_CLAIM: 34 | return "Unable to claim USB device, possibly due to multiple instances running"; 35 | case IB_FILE_NOT_FOUND: 36 | return "Cannot open specified file"; 37 | case IB_CONNECTION_LOST: 38 | return "I/O with device failed, connection lost?"; 39 | case IB_COMMAND_NOT_ACK: 40 | return "Command not acked"; 41 | case IB_DUMPING_BUFFER: 42 | return "Processing reply buffer"; 43 | default: 44 | return "Unknown error code"; 45 | } 46 | } 47 | 48 | class CIBootConn 49 | { 50 | public: 51 | 52 | public: 53 | CIBootConn(int nVendor = USB_VENDOR_ID, int nProduct = USB_PRODUCT_ID); 54 | ~CIBootConn(); 55 | 56 | ERR_CODE Connect(); 57 | ERR_CODE Disconnect(); 58 | ERR_CODE GetFile(const char *szFile, unsigned long lLoadAddr, int nLen); 59 | ERR_CODE SendFile(const char *szFile, unsigned long lLoadAddr); 60 | ERR_CODE SendCommand(const char *szCmd); 61 | ERR_CODE GetResponse(const char *&ppBuffer); 62 | 63 | private: 64 | 65 | typedef struct SMessage 66 | { 67 | short int cmdcode; 68 | short int constant; 69 | int size; 70 | int unknown; 71 | } SMessage; 72 | 73 | static const short int MSG_ECHO = 0x801; 74 | static const short int MSG_DUMP_BUFFER = 0x802; 75 | static const short int MSG_SEND_COMMAND = 0x803; 76 | static const short int MSG_READ_FILE = 0x804; 77 | static const short int MSG_SEND_FILE = 0x805; 78 | static const short int MSG_CRC = 0x807; 79 | static const short int MSG_ACK = 0x808; 80 | static const short int MSG_REJECT = 0x809; 81 | 82 | private: 83 | 84 | void CloseUsb(); 85 | 86 | ERR_CODE RequestInitial(SMessage *pSend, SMessage *pRcv); 87 | ERR_CODE RequestSendCommand(SMessage *pSend, SMessage *pRcv, int nLen); 88 | ERR_CODE RequestSendFile(SMessage *pSend, SMessage *pRcv, int nLen, unsigned long lLoadAddr); 89 | ERR_CODE RequestReadFile(SMessage *pSend, SMessage *pRcv, int nLen, unsigned long lLoadAddr); 90 | ERR_CODE RequestDumpBuffer(SMessage *pSend, SMessage *pRcv); 91 | 92 | ERR_CODE SendControl(SMessage *pSend, SMessage *pRcv); 93 | ERR_CODE WriteControl(SMessage *pCtrl); 94 | ERR_CODE ReadControl(SMessage *pCtrl); 95 | 96 | ERR_CODE WriteFile(char *pBuffer, int &nLength); 97 | ERR_CODE ReadFile(char *pBuffer, int &nLength); 98 | 99 | ERR_CODE WriteSerial(char *pBuffer, int &nLength); 100 | ERR_CODE ReadSerial(char *pBuffer, int &nLength); 101 | 102 | struct usb_device *FindDevice(int nVendor, int nProduct) const; 103 | 104 | static int const USB_VENDOR_ID = 0x05ac; 105 | static int const USB_PRODUCT_ID = 0x1280; 106 | 107 | static int const USB_WFILE_EP = 0x05; // Write file EP 108 | static int const USB_RFILE_EP = 0x85; // Read file EP 109 | static int const USB_WCONTROL_EP = 0x04; // Write control EP 110 | static int const USB_RCONTROL_EP = 0x83; // Read control EP 111 | static int const USB_WSERIAL_EP = 0x02; // Write serial EP 112 | static int const USB_RSERIAL_EP = 0x81; // Read serial EP 113 | 114 | static int const USB_TIMEOUT = 1000; 115 | 116 | private: 117 | int m_nVendorId; 118 | int m_nProductId; 119 | struct usb_dev_handle *m_pDevice; 120 | SMessage *m_pSend, *m_pRecv; 121 | std::string m_sResponse; 122 | 123 | }; // end class CIBootConn 124 | 125 | }; // end namespace 126 | 127 | -------------------------------------------------------------------------------- /branches/libibooter-1.0/src/example.cpp: -------------------------------------------------------------------------------- 1 | #include "libibooter.h" 2 | #include 3 | 4 | using namespace ibooter; 5 | using namespace std; 6 | 7 | int main(int argv, char **argc) 8 | { 9 | CIBootConn conn; 10 | ERR_CODE code; 11 | cout << "Connecting..." << endl; 12 | if ((code = conn.Connect()) != IB_SUCCESS) 13 | { 14 | cout << errcode_to_str(code) << endl; 15 | return 1; 16 | } 17 | 18 | cout << "Sending command..." << endl; 19 | if ((code = conn.SendCommand("printenv\n")) != IB_SUCCESS) 20 | { 21 | cout << errcode_to_str(code) << endl; 22 | conn.Disconnect(); 23 | return 1; 24 | } 25 | 26 | const char *pResponse = NULL; 27 | if ((code = conn.GetResponse(pResponse)) != IB_SUCCESS) 28 | { 29 | cout << errcode_to_str(code) << endl; 30 | conn.Disconnect(); 31 | return 1; 32 | } 33 | 34 | cout << "Response: " << pResponse << endl; 35 | conn.Disconnect(); 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /img3unpack/img3.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct Img3 { 4 | unsigned int magic; 5 | unsigned int dataLenPad; 6 | unsigned int u1; // offSet to 20 byte footer 7 | unsigned int certOffset; 8 | unsigned int name; 9 | unsigned int type; 10 | unsigned int nameOffset; 11 | unsigned int dataLen; 12 | } typedef Img3; 13 | 14 | #define IMG3_MAGIC_UC 0x496d6733 15 | #define IMG3_MAGIC_LC 0x696D6733 16 | 17 | struct Img3_footer1 { 18 | unsigned int magic; 19 | unsigned int u1; 20 | unsigned int u2; 21 | unsigned int name_len; 22 | } typedef Img3_footer1; 23 | 24 | struct dataFlag { 25 | unsigned int name; 26 | unsigned int u5; 27 | unsigned int u6; 28 | unsigned int u7; 29 | } typedef dataFlag; 30 | 31 | struct Img3_footer2 { 32 | unsigned int name; 33 | unsigned int blockSize; 34 | unsigned int sigLen; 35 | unsigned char sig[0x80]; 36 | unsigned int cert_magic; 37 | unsigned int cert_size; 38 | unsigned char cert[0xc18]; 39 | } typedef Img3_footer2; 40 | 41 | #define IMG3_FOOTER_MAGIC 0x56455253 42 | #define START_FLAG_SEPO 0x5345504f 43 | #define OPTION_BORD 0x424f5244 44 | #define END_FLAG_HSHS 0x53485348 45 | -------------------------------------------------------------------------------- /libibooter/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Simple make for ibooter/libibooter 3 | # 4 | CC=g++ 5 | 6 | CFLAGS=-g 7 | INC=-I./include/ 8 | 9 | SRCDIR=src 10 | OBJDIR=build 11 | 12 | LDFLAGS_SO=-lusb -shared 13 | LDFLAGS=-L../$(OBJDIR) -libooter 14 | 15 | OBJS=example.o 16 | LIBOBJS=libibooter.o 17 | 18 | 19 | all: prepare libibooter.so example 20 | 21 | VPATH=$(SRCDIR) 22 | 23 | .cpp.o: 24 | $(CC) $(CFLAGS) -c $< $(INC) -o $(OBJDIR)/$@ 25 | 26 | libibooter.so: $(LIBOBJS) 27 | cd $(OBJDIR); $(CC) $(LDFLAGS_SO) $^ -o $@ 28 | 29 | example: $(OBJS) libibooter.so 30 | cd $(OBJDIR); $(CC) $(LDFLAGS) $^ -o $@ 31 | 32 | prepare: 33 | mkdir -p $(OBJDIR) 34 | 35 | clean: 36 | rm -rf $(OBJDIR) 37 | -------------------------------------------------------------------------------- /libibooter/README: -------------------------------------------------------------------------------- 1 | IBooter lib version 1.0 2 | 3 | This code is released under GPL. Please make sure to include credit to cmw/dre if you use it. 4 | 5 | Credits 6 | Cmw & Dre 7 | Geohot 8 | 9 | Greets 10 | planetbeing 11 | Wizdaz 12 | Pumpkin 13 | Roxfan 14 | Nightwatch 15 | -------------------------------------------------------------------------------- /libibooter/include/libibooter.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace ibooter 5 | { 6 | typedef enum { 7 | IB_SUCCESS = 0, 8 | IB_FAIL, 9 | IB_DEVICE_NOT_FOUND, 10 | IB_FAILED_TO_OPEN, 11 | IB_FAILED_TO_CONFIGURE, 12 | IB_FAILED_TO_CLAIM, 13 | IB_FILE_NOT_FOUND, 14 | IB_CONNECTION_LOST, 15 | IB_COMMAND_NOT_ACK, 16 | IB_DUMPING_BUFFER, 17 | } ERR_CODE; 18 | 19 | const char *errcode_to_str(ERR_CODE code) 20 | { 21 | switch (code) 22 | { 23 | case IB_SUCCESS: 24 | return "Success"; 25 | case IB_FAIL: 26 | return "Failed"; 27 | case IB_DEVICE_NOT_FOUND: 28 | return "iPhone/iTouch not found in recovery"; 29 | case IB_FAILED_TO_OPEN: 30 | return "Failed to connect to iPhone/iTouch"; 31 | case IB_FAILED_TO_CONFIGURE: 32 | return "You do not have adequate system privileges"; 33 | case IB_FAILED_TO_CLAIM: 34 | return "Unable to claim USB device, possibly due to multiple instances running"; 35 | case IB_FILE_NOT_FOUND: 36 | return "Cannot open specified file"; 37 | case IB_CONNECTION_LOST: 38 | return "I/O with device failed, connection lost?"; 39 | case IB_COMMAND_NOT_ACK: 40 | return "Command not acked"; 41 | case IB_DUMPING_BUFFER: 42 | return "Processing reply buffer"; 43 | default: 44 | return "Unknown error code"; 45 | } 46 | } 47 | 48 | class CIBootConn 49 | { 50 | public: 51 | 52 | public: 53 | CIBootConn(int nVendor = USB_VENDOR_ID, int nProduct = USB_PRODUCT_ID); 54 | ~CIBootConn(); 55 | 56 | ERR_CODE Connect(); 57 | ERR_CODE Disconnect(); 58 | ERR_CODE GetFile(const char *szFile, unsigned long lLoadAddr, int nLen); 59 | ERR_CODE SendFile(const char *szFile, unsigned long lLoadAddr); 60 | ERR_CODE SendCommand(const char *szCmd); 61 | ERR_CODE GetResponse(const char *&ppBuffer); 62 | 63 | private: 64 | 65 | typedef struct SMessage 66 | { 67 | short int cmdcode; 68 | short int constant; 69 | int size; 70 | int unknown; 71 | } SMessage; 72 | 73 | static const short int MSG_ECHO = 0x801; 74 | static const short int MSG_DUMP_BUFFER = 0x802; 75 | static const short int MSG_SEND_COMMAND = 0x803; 76 | static const short int MSG_READ_FILE = 0x804; 77 | static const short int MSG_SEND_FILE = 0x805; 78 | static const short int MSG_CRC = 0x807; 79 | static const short int MSG_ACK = 0x808; 80 | static const short int MSG_REJECT = 0x809; 81 | 82 | private: 83 | 84 | void CloseUsb(); 85 | 86 | ERR_CODE RequestInitial(SMessage *pSend, SMessage *pRcv); 87 | ERR_CODE RequestSendCommand(SMessage *pSend, SMessage *pRcv, int nLen); 88 | ERR_CODE RequestSendFile(SMessage *pSend, SMessage *pRcv, int nLen, unsigned long lLoadAddr); 89 | ERR_CODE RequestReadFile(SMessage *pSend, SMessage *pRcv, int nLen, unsigned long lLoadAddr); 90 | ERR_CODE RequestDumpBuffer(SMessage *pSend, SMessage *pRcv); 91 | 92 | ERR_CODE SendControl(SMessage *pSend, SMessage *pRcv); 93 | ERR_CODE WriteControl(SMessage *pCtrl); 94 | ERR_CODE ReadControl(SMessage *pCtrl); 95 | 96 | ERR_CODE WriteFile(char *pBuffer, int &nLength); 97 | ERR_CODE ReadFile(char *pBuffer, int &nLength); 98 | 99 | ERR_CODE WriteSerial(char *pBuffer, int &nLength); 100 | ERR_CODE ReadSerial(char *pBuffer, int &nLength); 101 | 102 | struct usb_device *FindDevice(int nVendor, int nProduct) const; 103 | 104 | static int const USB_VENDOR_ID = 0x05ac; 105 | static int const USB_PRODUCT_ID = 0x1280; 106 | 107 | static int const USB_WFILE_EP = 0x05; // Write file EP 108 | static int const USB_RFILE_EP = 0x85; // Read file EP 109 | static int const USB_WCONTROL_EP = 0x04; // Write control EP 110 | static int const USB_RCONTROL_EP = 0x83; // Read control EP 111 | static int const USB_WSERIAL_EP = 0x02; // Write serial EP 112 | static int const USB_RSERIAL_EP = 0x81; // Read serial EP 113 | 114 | static int const USB_TIMEOUT = 1000; 115 | 116 | private: 117 | int m_nVendorId; 118 | int m_nProductId; 119 | struct usb_dev_handle *m_pDevice; 120 | SMessage *m_pSend, *m_pRecv; 121 | std::string m_sResponse; 122 | 123 | }; // end class CIBootConn 124 | 125 | }; // end namespace 126 | 127 | -------------------------------------------------------------------------------- /libibooter/src/example.cpp: -------------------------------------------------------------------------------- 1 | #include "libibooter.h" 2 | #include 3 | 4 | using namespace ibooter; 5 | using namespace std; 6 | 7 | int main(int argv, char **argc) 8 | { 9 | CIBootConn conn; 10 | ERR_CODE code; 11 | cout << "Connecting..." << endl; 12 | if ((code = conn.Connect()) != IB_SUCCESS) 13 | { 14 | cout << errcode_to_str(code) << endl; 15 | return 1; 16 | } 17 | 18 | cout << "Sending command..." << endl; 19 | if ((code = conn.SendCommand("printenv\n")) != IB_SUCCESS) 20 | { 21 | cout << errcode_to_str(code) << endl; 22 | conn.Disconnect(); 23 | return 1; 24 | } 25 | 26 | const char *pResponse = NULL; 27 | if ((code = conn.GetResponse(pResponse)) != IB_SUCCESS) 28 | { 29 | cout << errcode_to_str(code) << endl; 30 | conn.Disconnect(); 31 | return 1; 32 | } 33 | 34 | cout << "Response: " << pResponse << endl; 35 | conn.Disconnect(); 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /openiboot/RUNNING: -------------------------------------------------------------------------------- 1 | For the first time: 2 | 0. Build an ARM toolchain (see the toolchain folder); will take a while (but you don't have to repeat that step, unless the toolchain is updated) 3 | Then: 4 | 1. Compile OpeniBoot: 5 | A. To run openiboot from the recovery mode (a.K.a iboot), you'll need to create an img3 image. 6 | a. A system capable of running x86 Linux binaries is required. 7 | b. For iPod touch: PLATFORM=IPOD make openiboot.img3 8 | c. For iPhone 2G: PLATFORM=IPHONE make openiboot.img3 9 | d. For iPhone 3G: PLATFORM=3G make openiboot.img3 10 | 2. Compile all in client/ : cd client && make all && cd .. (requires libusb, libreadline and pthread) 11 | 3. sudo client/loadibec openiboot.img3 12 | 4. Run the client: sudo client/oibc 13 | To install openiboot in the NOR (optional): run "install" in openiboot client (to uninstall, restore/update/run QuickPwn) 14 | 15 | To update openiboot: 16 | 0. Pull the new code from Git: ("git pull" if you downloaded the code using Git) 17 | 1. Compile openiboot, but this time you don't have to make an img3 image. 18 | a. For iPod touch: PLATFORM=IPOD make 19 | b. For iPhone 2G: PLATFORM=IPHONE make 20 | c. For iPhone 3G: PLATFORM=3G make 21 | 2. Compile all in client/: cd client && make all && cd .. (requires libusb, libreadline and pthread) 22 | 3. Launch openiboot 23 | 4. Run the client: sudo client/oibc 24 | 5. Copy the openiboot binary in the device memory: !openiboot.bin 25 | 6. Jump to it: go 0x09000000 26 | 7. Relaunch openiboot console 27 | 8. Relaunch the client: sudo client/oibc 28 | 9. Install the new version: install 29 | -------------------------------------------------------------------------------- /openiboot/SCRIPTING.txt: -------------------------------------------------------------------------------- 1 | scripting support in openiboot 2 | script can be launched before openiboot launch the shell or load the kernel (for automatic boot). 3 | scripting uses 4 environment variables (NVRAM values) and a file in the NAND. 4 | NVRAM values: 5 | - partition-script : 6 | tells in which partition the file script is stored (openiboot format, so currently 0 corresponds to / and 1 to /private/var in iPhoneOS) 7 | - file-script : 8 | tells the path to the file script from the root of the partition (for a file like /private/var/script in iPhoneOS, set partition-script to 1 and file-script to /script ) 9 | - scripting-openiboot : 10 | tells if the script is launched before droping the openiboot shell. Accepted values are true or 1 , anything else is considered as false. 11 | -scripting-linux : 12 | tells if the script is launched before lauching the linux kernel in automated boot. Accepted values are true or 1 , anything else is considered as false. 13 | ATTENTION : after setting NVRAM values, you need to commit the changes by using the command saveenv 14 | 15 | How to change NVRAM values? 16 | it can be done either with iboot or openiboot with the same syntax : 17 | setenv variableName VariableValue 18 | And to commit the changes : simply saveenv (the variable will be erased after next reboot, or if you load an image, so save it!) 19 | 20 | script file: 21 | it is a text file (ASCII), the separation of lines are new lines. Don't add extras lines. 22 | It handle \n end-of-line (and should also handle the windows \r\n end-of-line as \r is ignored) 23 | 24 | What instructions works? 25 | all internal openiboot command line. 26 | Communication with computer doesn't work (so don't try to send or receive a file). oibc need changes to receive instructions from USB. 27 | 28 | example of script for updating openiboot automatically. 29 | 3 files stored in /private/var : 30 | - openiboot.bin (in binary format, not packed as img3) 31 | - update-openiboot-part1 32 | - update-openiboot-part2 33 | 34 | the content of these texts files: 35 | update-openiboot-part1 : 36 | uninstall 37 | setenv file-script /update-openiboot-part2 38 | setenv opib-hide-menu true 39 | saveenv 40 | fs_extract 1 /openiboot.bin 0x09000000 41 | go 42 | 43 | 44 | update-openiboot-part2 : 45 | install 46 | setenv opib-hide-menu false 47 | setenv scripting-openiboot false 48 | setenv scripting-linux false (chose one of these 2 lines depending how the script was launched it the first place) 49 | saveenv 50 | reboot 51 | 52 | 53 | Note : you can install your script/kernel/images (if not too big) with openiboot. 54 | The command tu use is fs_add: 55 | usage: fs_add 56 | First step upload the file to openiboot : 57 | !myFile 58 | openiboot will tell you the size of the file. The address is by default 0x09000000 unless you specifed something different. 59 | you now have the location (address) and the size of the file. 60 | the file is the path to the on the device from the root of the partition. 61 | partition is which partition to use. 62 | -------------------------------------------------------------------------------- /openiboot/accel.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "util.h" 3 | #include "accel.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 | int accel_setup() 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 -1; 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 | return 0; 50 | } 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 | 68 | -------------------------------------------------------------------------------- /openiboot/alsISL29003.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "als.h" 3 | #include "hardware/als.h" 4 | #include "i2c.h" 5 | #include "timer.h" 6 | #include "multitouch.h" 7 | #include "util.h" 8 | #include "gpio.h" 9 | 10 | #define COMMAND 0x0 11 | #define CONTROL 0x1 12 | #define INTTHRESHHIGH 0x2 13 | #define INTTHRESHLOW 0x3 14 | #define SENSORLOW 0x4 15 | #define SENSORHIGH 0x5 16 | #define TIMERLOW 0x6 17 | #define TIMERHIGH 0x7 18 | 19 | static void als_writeb(uint8_t addr, uint8_t b); 20 | static uint8_t als_readb(uint8_t addr); 21 | static uint16_t als_readw(uint8_t addr); 22 | static void als_clearint(); 23 | static void als_int(uint32_t token); 24 | 25 | static int use_channel; 26 | 27 | int als_setup() 28 | { 29 | multitouch_on(); 30 | 31 | // disable ADC-core 32 | als_writeb(COMMAND, 0<<7); 33 | udelay(1000); 34 | // powerdown chip 35 | als_writeb(COMMAND, 1<<6); 36 | udelay(1000); 37 | // power up chip 38 | als_writeb(COMMAND, 0<<6); 39 | udelay(1000); 40 | als_setchannel(0); 41 | 42 | if(als_readb(COMMAND) != (1 << 7 | 0 << 5 | (use_channel == 0 ? 0 : 1) << 2)) 43 | { 44 | bufferPrint("als: error initializing\r\n"); 45 | return -1; 46 | } 47 | 48 | gpio_register_interrupt(ALS_INT, 1, 0, 0, als_int, 0); 49 | 50 | bufferPrintf("als: initialized\r\n"); 51 | 52 | return 0; 53 | } 54 | 55 | void als_setchannel(int channel) 56 | { 57 | use_channel = channel; 58 | als_writeb(COMMAND, 1 << 7 | 0 << 5 | (channel == 0 ? 0 : 1) << 2); 59 | udelay(1000); 60 | } 61 | 62 | void als_enable_interrupt() 63 | { 64 | uint16_t sensordata = als_data(); 65 | 66 | als_setlowthreshold(sensordata >> 8); 67 | als_sethighthreshold(sensordata >> 8); 68 | 69 | // Gain : 0-62272 lux, trigger if out of range for every consecutive integration cycles 70 | als_writeb(CONTROL, (3 << 2) | 0); 71 | als_clearint(); 72 | 73 | gpio_interrupt_enable(ALS_INT); 74 | } 75 | 76 | void als_disable_interrupt() 77 | { 78 | gpio_interrupt_disable(ALS_INT); 79 | als_clearint(); 80 | } 81 | 82 | static void als_int(uint32_t token) 83 | { 84 | // this is needed because there's no way to avoid repeated interrupts at the boundaries (0 and 0xFFFF) 85 | static uint16_t lastData0 = 0xFFFF; 86 | 87 | uint16_t sensordata = als_data(); 88 | 89 | als_setlowthreshold(sensordata >> 8); 90 | als_sethighthreshold(sensordata >> 8); 91 | 92 | if(lastData0 != sensordata) 93 | bufferPrintf("als: data = %d\r\n", sensordata); 94 | 95 | lastData0 = sensordata; 96 | 97 | als_clearint(); 98 | } 99 | 100 | void als_setlowthreshold(uint16_t value) 101 | { 102 | als_writeb(INTTHRESHHIGH, value); 103 | } 104 | 105 | void als_sethighthreshold(uint16_t value) 106 | { 107 | als_writeb(INTTHRESHLOW, value); 108 | } 109 | 110 | uint16_t als_data() 111 | { 112 | return als_readw(SENSORLOW); 113 | } 114 | 115 | static void als_writeb(uint8_t addr, uint8_t b) 116 | { 117 | uint8_t buf[2]; 118 | buf[0] = addr | (1 << 6); 119 | buf[1] = b; 120 | i2c_tx(ALS_I2C, ALS_ADDR, buf, sizeof(buf)); 121 | } 122 | 123 | static uint8_t als_readb(uint8_t addr) 124 | { 125 | uint8_t registers[1]; 126 | uint8_t ret[1]; 127 | 128 | registers[0] = addr | (1 << 6); 129 | 130 | ret[0] = 0; 131 | 132 | i2c_rx(ALS_I2C, ALS_ADDR, registers, 1, ret, sizeof(ret)); 133 | 134 | return ret[0]; 135 | } 136 | 137 | static uint16_t als_readw(uint8_t addr) 138 | { 139 | uint8_t registers; 140 | uint16_t ret; 141 | 142 | registers = addr | (1 << 6); 143 | ret = 0; 144 | 145 | i2c_rx(ALS_I2C, ALS_ADDR, ®isters, 1, &ret, sizeof(ret)); 146 | 147 | return ret; 148 | } 149 | 150 | static void als_clearint() 151 | { 152 | als_setchannel(use_channel); 153 | } 154 | -------------------------------------------------------------------------------- /openiboot/arm.c: -------------------------------------------------------------------------------- 1 | #include "hardware/arm.h" 2 | #include "arm.h" 3 | #include "openiboot-asmhelpers.h" 4 | 5 | int arm_setup() { 6 | 7 | CleanAndInvalidateCPUDataCache(); 8 | ClearCPUInstructionCache(); 9 | 10 | WriteControlRegisterConfigData(ReadControlRegisterConfigData() & ~(ARM11_Control_INSTRUCTIONCACHE)); // Disable instruction cache 11 | WriteControlRegisterConfigData(ReadControlRegisterConfigData() & ~(ARM11_Control_DATACACHE)); // Disable data cache 12 | 13 | GiveFullAccessCP10CP11(); 14 | EnableVFP(); 15 | 16 | // Map the peripheral port of size 128 MB to 0x38000000 17 | WritePeripheralPortMemoryRemapRegister(PeripheralPort | ARM11_PeripheralPortSize128MB); 18 | InvalidateCPUDataCache(); 19 | ClearCPUInstructionCache(); 20 | 21 | WriteControlRegisterConfigData(ReadControlRegisterConfigData() | ARM11_Control_INSTRUCTIONCACHE); // Enable instruction cache 22 | WriteControlRegisterConfigData(ReadControlRegisterConfigData() | ARM11_Control_DATACACHE); // Enable data cache 23 | 24 | WriteControlRegisterConfigData((ReadControlRegisterConfigData() 25 | & ~(ARM11_Control_STRICTALIGNMENTCHECKING)) // Disable strict alignment fault checking 26 | | ARM11_Control_UNALIGNEDDATAACCESS); // Enable unaligned data access operations 27 | 28 | 29 | WriteControlRegisterConfigData(ReadControlRegisterConfigData() | ARM11_Control_BRANCHPREDICTION); // Enable branch prediction 30 | 31 | // Enable return stack, dynamic branch prediction, static branch prediction 32 | WriteAuxiliaryControlRegister(ReadAuxiliaryControlRegister() 33 | | ARM11_AuxControl_RETURNSTACK 34 | | ARM11_AuxControl_DYNAMICBRANCHPREDICTION 35 | | ARM11_AuxControl_STATICBRANCHPREDICTION); 36 | 37 | return 0; 38 | } 39 | 40 | void arm_disable_caches() { 41 | CleanAndInvalidateCPUDataCache(); 42 | ClearCPUInstructionCache(); 43 | WriteControlRegisterConfigData(ReadControlRegisterConfigData() & ~ARM11_Control_INSTRUCTIONCACHE); // Disable instruction cache 44 | WriteControlRegisterConfigData(ReadControlRegisterConfigData() & ~ARM11_Control_DATACACHE); // Disable data cache 45 | } 46 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/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 | 28 | if(modelID != 0x1580) 29 | { 30 | bufferPrintf("camera: unrecognized sensor model ID = 0x%x!\r\n", modelID); 31 | return -1; 32 | } 33 | 34 | bufferPrintf("camera: sensor model ID = 0x%x\r\n", modelID); 35 | 36 | return 0; 37 | } 38 | 39 | static uint16_t camera_readw(uint16_t addr) 40 | { 41 | uint8_t registers[2]; 42 | uint8_t buffer[2]; 43 | 44 | registers[0] = (addr >> 8) & 0xFF; 45 | registers[1] = addr & 0xFF; 46 | buffer[0] = 0xDE; 47 | buffer[1] = 0xAD; 48 | 49 | i2c_rx(1, CAMERA_ADDR, registers, 2, buffer, 2); 50 | 51 | return (buffer[0] << 8) | buffer[1]; 52 | } 53 | -------------------------------------------------------------------------------- /openiboot/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 | 10 | -------------------------------------------------------------------------------- /openiboot/client/Makefile: -------------------------------------------------------------------------------- 1 | OIBC_OBJS = oibc.o 2 | LOADIBEC_OBJS = loadibec.o 3 | LINUX_OBJS = linux.o 4 | LIBRARIES = -L/opt/local-universal-10.4/lib -lusb -lpthread -lreadline 5 | LOADIBEC_LIBS = -L/opt/local-universal-10.4/lib -lusb-1.0 6 | CFLAGS += -DHAVE_GETEUID -I/opt/local-universal-10.4/include 7 | 8 | %.o: %.c 9 | $(CC) $(CFLAGS) -c $< -o $@ 10 | 11 | 12 | all: oibc loadibec linux 13 | 14 | oibc: $(OIBC_OBJS) 15 | $(CC) $(CFLAGS) $(OIBC_OBJS) $(LIBRARIES) -o $@ 16 | 17 | loadibec: ${LOADIBEC_OBJS} 18 | $(CC) $(CFLAGS) $(LOADIBEC_OBJS) $(LOADIBEC_LIBS) -o $@ 19 | 20 | linux: $(LINUX_OBJS) 21 | $(CC) $(CFLAGS) $(LINUX_OBJS) -lusb -lpthread -lncurses -o $@ 22 | 23 | clean: 24 | -rm *.o 25 | -rm oibc 26 | -rm loadibec 27 | 28 | -------------------------------------------------------------------------------- /openiboot/hfs/bdev.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "hfs/common.h" 3 | #include "hfs/bdev.h" 4 | #include "ftl.h" 5 | #include "util.h" 6 | #include "nand.h" 7 | 8 | int HasBDevInit = FALSE; 9 | 10 | static MBR MBRData; 11 | 12 | unsigned int BLOCK_SIZE = 0; 13 | 14 | int bdev_setup() { 15 | if(HasBDevInit) 16 | return 0; 17 | 18 | ftl_setup(); 19 | 20 | NANDData* Data = nand_get_geometry(); 21 | BLOCK_SIZE = Data->bytesPerPage; 22 | 23 | ftl_read(&MBRData, 0, sizeof(MBRData)); 24 | MBRPartitionRecord* record = MBRData.partitions; 25 | 26 | int id = 0; 27 | while(record->type != 0) { 28 | bufferPrintf("bdev: partition id: %d, type: %x, sectors: %d - %d\r\n", id, record->type, record->beginLBA, record->beginLBA + record->numSectors); 29 | record++; 30 | id++; 31 | } 32 | 33 | HasBDevInit = TRUE; 34 | 35 | return 0; 36 | } 37 | 38 | int bdevRead(io_func* io, off_t location, size_t size, void *buffer) { 39 | MBRPartitionRecord* record = (MBRPartitionRecord*) io->data; 40 | //bufferPrintf("bdev: attempt to read %d sectors from partition %d, sector %Ld to 0x%x\r\n", size, ((uint32_t)record - (uint32_t)MBRData.partitions)/sizeof(MBRPartitionRecord), location, buffer); 41 | return ftl_read(buffer, location + record->beginLBA * BLOCK_SIZE, size); 42 | } 43 | 44 | static int bdevWrite(io_func* io, off_t location, size_t size, void *buffer) { 45 | MBRPartitionRecord* record = (MBRPartitionRecord*) io->data; 46 | //bufferPrintf("bdev: attempt to write %d sectors to partition %d, sector %d!\r\n", size, ((uint32_t)record - (uint32_t)MBRData.partitions)/sizeof(MBRPartitionRecord), location); 47 | return ftl_write(buffer, location + record->beginLBA * BLOCK_SIZE, size); 48 | } 49 | 50 | static void bdevClose(io_func* io) { 51 | free(io); 52 | } 53 | 54 | unsigned int bdev_get_start(int partition) 55 | { 56 | return MBRData.partitions[partition].beginLBA; 57 | } 58 | 59 | io_func* bdev_open(int partition) { 60 | io_func* io; 61 | 62 | if(MBRData.partitions[partition].type != 0xAF) 63 | return NULL; 64 | 65 | io = (io_func*) malloc(sizeof(io_func)); 66 | io->data = &MBRData.partitions[partition]; 67 | io->read = &bdevRead; 68 | io->write = &bdevWrite; 69 | io->close = &bdevClose; 70 | 71 | return io; 72 | } 73 | 74 | -------------------------------------------------------------------------------- /openiboot/hfs/extents.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static inline void flipExtentDescriptor(HFSPlusExtentDescriptor* extentDescriptor) { 4 | FLIPENDIAN(extentDescriptor->startBlock); 5 | FLIPENDIAN(extentDescriptor->blockCount); 6 | } 7 | 8 | void flipExtentRecord(HFSPlusExtentRecord* extentRecord) { 9 | HFSPlusExtentDescriptor *extentDescriptor; 10 | extentDescriptor = (HFSPlusExtentDescriptor*)extentRecord; 11 | 12 | flipExtentDescriptor(&extentDescriptor[0]); 13 | flipExtentDescriptor(&extentDescriptor[1]); 14 | flipExtentDescriptor(&extentDescriptor[2]); 15 | flipExtentDescriptor(&extentDescriptor[3]); 16 | flipExtentDescriptor(&extentDescriptor[4]); 17 | flipExtentDescriptor(&extentDescriptor[5]); 18 | flipExtentDescriptor(&extentDescriptor[6]); 19 | flipExtentDescriptor(&extentDescriptor[7]); 20 | } 21 | 22 | static int extentCompare(BTKey* vLeft, BTKey* vRight) { 23 | HFSPlusExtentKey* left; 24 | HFSPlusExtentKey* right; 25 | 26 | left = (HFSPlusExtentKey*) vLeft; 27 | right =(HFSPlusExtentKey*) vRight; 28 | 29 | if(left->forkType < right->forkType) { 30 | return -1; 31 | } else if(left->forkType > right->forkType) { 32 | return 1; 33 | } else { 34 | if(left->fileID < right->fileID) { 35 | return -1; 36 | } else if(left->fileID > right->fileID) { 37 | return 1; 38 | } else { 39 | if(left->startBlock < right->startBlock) { 40 | return -1; 41 | } else if(left->startBlock > right->startBlock) { 42 | return 1; 43 | } else { 44 | /* do a safety check on key length. Otherwise, bad things may happen later on when we try to add or remove with this key */ 45 | if(left->keyLength == right->keyLength) { 46 | return 0; 47 | } else if(left->keyLength < right->keyLength) { 48 | return -1; 49 | } else { 50 | return 1; 51 | } 52 | return 0; 53 | } 54 | } 55 | } 56 | } 57 | 58 | static BTKey* extentKeyRead(off_t offset, io_func* io) { 59 | HFSPlusExtentKey* key; 60 | 61 | key = (HFSPlusExtentKey*) malloc(sizeof(HFSPlusExtentKey)); 62 | 63 | if(!READ(io, offset, sizeof(HFSPlusExtentKey), key)) 64 | return NULL; 65 | 66 | FLIPENDIAN(key->keyLength); 67 | FLIPENDIAN(key->forkType); 68 | FLIPENDIAN(key->fileID); 69 | FLIPENDIAN(key->startBlock); 70 | 71 | return (BTKey*)key; 72 | } 73 | 74 | static int extentKeyWrite(off_t offset, BTKey* toWrite, io_func* io) { 75 | HFSPlusExtentKey* key; 76 | 77 | key = (HFSPlusExtentKey*) malloc(sizeof(HFSPlusExtentKey)); 78 | 79 | memcpy(key, toWrite, sizeof(HFSPlusExtentKey)); 80 | 81 | FLIPENDIAN(key->keyLength); 82 | FLIPENDIAN(key->forkType); 83 | FLIPENDIAN(key->fileID); 84 | FLIPENDIAN(key->startBlock); 85 | 86 | if(!WRITE(io, offset, sizeof(HFSPlusExtentKey), key)) 87 | return FALSE; 88 | 89 | free(key); 90 | 91 | return TRUE; 92 | } 93 | 94 | static void extentKeyPrint(BTKey* toPrint) { 95 | HFSPlusExtentKey* key; 96 | 97 | key = (HFSPlusExtentKey*)toPrint; 98 | 99 | printf("extent%d:%d:%d", (int)key->forkType, (int)key->fileID, (int)key->startBlock); 100 | } 101 | 102 | static BTKey* extentDataRead(off_t offset, io_func* io) { 103 | HFSPlusExtentRecord* record; 104 | 105 | record = (HFSPlusExtentRecord*) malloc(sizeof(HFSPlusExtentRecord)); 106 | 107 | if(!READ(io, offset, sizeof(HFSPlusExtentRecord), record)) 108 | return NULL; 109 | 110 | flipExtentRecord(record); 111 | 112 | return (BTKey*)record; 113 | } 114 | 115 | BTree* openExtentsTree(io_func* file) { 116 | return openBTree(file, &extentCompare, &extentKeyRead, &extentKeyWrite, &extentKeyPrint, &extentDataRead); 117 | } 118 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/images/AndroidOS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/images/AndroidOS.png -------------------------------------------------------------------------------- /openiboot/images/AndroidOSSelected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/images/AndroidOSSelected.png -------------------------------------------------------------------------------- /openiboot/images/Console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/images/Console.png -------------------------------------------------------------------------------- /openiboot/images/ConsoleSelected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/images/ConsoleSelected.png -------------------------------------------------------------------------------- /openiboot/images/Header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/images/Header.png -------------------------------------------------------------------------------- /openiboot/images/Makefile: -------------------------------------------------------------------------------- 1 | all: ConsolePNG.h ConsoleSelectedPNG.h HeaderPNG.h iPhoneOSPNG.h iPhoneOSSelectedPNG.h AndroidOSSelectedPNG.h AndroidOSPNG.h 2 | 3 | bin2c: bin2c.c 4 | $(CC) bin2c.c -o $@ 5 | 6 | %PNG.h: %.png bin2c 7 | ./bin2c data$*PNG < $< > $@ 8 | 9 | clean: 10 | -rm *.o 11 | -rm bin2c 12 | -rm *.h 13 | -------------------------------------------------------------------------------- /openiboot/images/README: -------------------------------------------------------------------------------- 1 | openiboot image resources 2 | ------------------------- 3 | 4 | Images currently used by openiboot are grayscale PNGs linked into the binary 5 | via bin2c. The graphics are provided by poorlad and modified by galiaxy. 6 | 7 | The Apple logo is a trademark of Apple Inc., and is included for proper 8 | identification of Apple software on the device, and is believed to be 9 | necessary to avoid tarnishing or misrepresenting its image. It does not imply 10 | any association with or endorsement by the company, and its inclusion is 11 | believed to be fair use under United States copyright law. 12 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/images/iPhoneOS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/images/iPhoneOS.png -------------------------------------------------------------------------------- /openiboot/images/iPhoneOSSelected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/images/iPhoneOSSelected.png -------------------------------------------------------------------------------- /openiboot/includes/accel.h: -------------------------------------------------------------------------------- 1 | #ifndef ACCEL_H 2 | #define ACCEL_H 3 | 4 | #include "openiboot.h" 5 | 6 | int accel_setup(); 7 | 8 | int accel_get_x(); 9 | int accel_get_y(); 10 | int accel_get_z(); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /openiboot/includes/actions.h: -------------------------------------------------------------------------------- 1 | #ifndef ACTIONS_H 2 | #define ACTIONS_H 3 | 4 | #include "openiboot.h" 5 | 6 | void chainload(uint32_t address); 7 | void set_kernel(void* location, int size); 8 | void set_ramdisk(void* location, int size); 9 | void set_rootfs(int partition, const char* fileName); 10 | void boot_linux(const char* args); 11 | 12 | #ifndef NO_HFS 13 | void boot_linux_from_files(); 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /openiboot/includes/aes.h: -------------------------------------------------------------------------------- 1 | #ifndef AES_H 2 | #define AES_H 3 | 4 | #include "openiboot.h" 5 | 6 | #define AES_128_CBC_IV_SIZE 16 7 | #define AES_128_CBC_BLOCK_SIZE 64 8 | 9 | typedef enum AESKeyType { 10 | AESCustom = 0, 11 | AESGID = 1, 12 | AESUID = 2 13 | } AESKeyType; 14 | 15 | typedef enum AESKeyLen { 16 | AES128 = 0, 17 | AES192 = 1, 18 | AES256 = 2 19 | } AESKeyLen; 20 | 21 | int aes_setup(); 22 | void aes_836_encrypt(void* data, int size, const void* iv); 23 | void aes_836_decrypt(void* data, int size, const void* iv); 24 | void aes_838_encrypt(void* data, int size, const void* iv); 25 | void aes_838_decrypt(void* data, int size, const void* iv); 26 | void aes_img2verify_encrypt(void* data, int size, const void* iv); 27 | void aes_img2verify_decrypt(void* data, int size, const void* iv); 28 | 29 | void aes_encrypt(void* data, int size, AESKeyType keyType, const void* key, const void* iv); 30 | void aes_decrypt(void* data, int size, AESKeyType keyType, const void* key, const void* iv); 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /openiboot/includes/als.h: -------------------------------------------------------------------------------- 1 | #ifndef ALS_H 2 | #define ALS_H 3 | 4 | int als_setup(); 5 | void als_sethighthreshold(uint16_t value); 6 | void als_setlowthreshold(uint16_t value); 7 | uint16_t als_data(); 8 | void als_setchannel(int channel); 9 | void als_enable_interrupt(); 10 | void als_disable_interrupt(); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /openiboot/includes/arm.h: -------------------------------------------------------------------------------- 1 | #ifndef ARM_H 2 | #define ARM_H 3 | 4 | #include "openiboot.h" 5 | 6 | int arm_setup(); 7 | void arm_disable_caches(); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /openiboot/includes/buttons.h: -------------------------------------------------------------------------------- 1 | #ifndef BUTTONS_H 2 | #define BUTTONS_H 3 | 4 | #include "openiboot.h" 5 | #include "hardware/buttons.h" 6 | 7 | int buttons_is_pushed(int); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /openiboot/includes/camera.h: -------------------------------------------------------------------------------- 1 | #ifndef CAMERA_H 2 | #define CAMERA_H 3 | 4 | int camera_setup(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /openiboot/includes/chipid.h: -------------------------------------------------------------------------------- 1 | #ifndef CHIPID_H 2 | #define CHIPID_H 3 | 4 | #include "openiboot.h" 5 | 6 | int chipid_spi_clocktype(); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /openiboot/includes/clock.h: -------------------------------------------------------------------------------- 1 | #ifndef CLOCK_H 2 | #define CLOCK_H 3 | 4 | #include "openiboot.h" 5 | #include "hardware/clock1.h" 6 | 7 | typedef enum Clock0ConfigCode { 8 | Clock0ConfigCode0 = 0, 9 | Clock0ConfigCode1 = 1, 10 | Clock0ConfigCode2 = 2, 11 | Clock0ConfigCode3 = 3 12 | } Clock0ConfigCode; 13 | 14 | extern uint32_t ClockPLL; 15 | extern uint32_t PLLFrequencies[NUM_PLL]; 16 | 17 | extern uint32_t ClockFrequency; 18 | extern uint32_t MemoryFrequency; 19 | extern uint32_t BusFrequency; 20 | extern uint32_t PeripheralFrequency; 21 | extern uint32_t UnknownFrequency; 22 | extern uint32_t DisplayFrequency; 23 | extern uint32_t FixedFrequency; 24 | extern uint32_t TimebaseFrequency; 25 | 26 | extern uint32_t ClockSDiv; 27 | 28 | extern uint32_t TicksPerSec; 29 | 30 | typedef enum FrequencyBase { 31 | FrequencyBaseClock, 32 | FrequencyBaseMemory, 33 | FrequencyBaseBus, 34 | FrequencyBasePeripheral, 35 | FrequencyBaseUnknown, 36 | FrequencyBaseDisplay, 37 | FrequencyBaseFixed, 38 | FrequencyBaseTimebase 39 | } FrequencyBase; 40 | 41 | int clock_set_bottom_bits_38100000(Clock0ConfigCode code); 42 | int clock_setup(); 43 | void clock_gate_switch(uint32_t gate, OnOff on_off); 44 | uint32_t clock_get_frequency(FrequencyBase freqBase); 45 | uint32_t clock_calculate_frequency(uint32_t pdiv, uint32_t mdiv, FrequencyBase freqBase); 46 | void clock_set_sdiv(int sdiv); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /openiboot/includes/commands.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMANDS_H 2 | #define COMMANDS_H 3 | 4 | #include "openiboot.h" 5 | 6 | typedef void (*OPIBCommandRoutine)(int argc, char** argv); 7 | 8 | typedef struct OPIBCommand { 9 | char* name; 10 | char* description; 11 | OPIBCommandRoutine routine; 12 | } OPIBCommand; 13 | 14 | extern OPIBCommand CommandList[]; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /openiboot/includes/dma.h: -------------------------------------------------------------------------------- 1 | #ifndef DMA_H 2 | #define DMA_H 3 | 4 | #define ERROR_DMA 0x13 5 | #define ERROR_BUSY 0x15 6 | #define ERROR_ALIGN 0x9 7 | 8 | typedef void (*DMAHandler)(int status, int controller, int channel); 9 | 10 | typedef struct DMARequest { 11 | int started; 12 | int done; 13 | DMAHandler handler; 14 | // TODO: fill this thing out 15 | } DMARequest; 16 | 17 | typedef struct DMALinkedList { 18 | uint32_t source; 19 | uint32_t destination; 20 | struct DMALinkedList* next; 21 | uint32_t control; 22 | } DMALinkedList; 23 | 24 | #define DMA_I2S0_RX 19 25 | #define DMA_I2S0_TX 20 26 | #define DMA_I2S1_RX 14 27 | #define DMA_I2S1_TX 15 28 | #define DMA_MEMORY 25 29 | #define DMA_NAND 8 30 | 31 | int dma_setup(); 32 | int dma_shutdown(); 33 | int dma_request(int Source, int SourceTransferWidth, int SourceBurstSize, int Destination, int DestinationTransferWidth, int DestinationBurstSize, int* controller, int* channel, DMAHandler handler); 34 | int dma_perform(uint32_t Source, uint32_t Destination, int size, int continueList, int* controller, int* channel); 35 | int dma_finish(int controller, int channel, int timeout); 36 | uint32_t dma_dstpos(int controller, int channel); 37 | uint32_t dma_srcpos(int controller, int channel); 38 | void dma_pause(int controller, int channel); 39 | void dma_resume(int controller, int channel); 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /openiboot/includes/event.h: -------------------------------------------------------------------------------- 1 | #ifndef EVENT_H 2 | #define EVENT_H 3 | 4 | #include "openiboot.h" 5 | 6 | extern Event EventList; 7 | 8 | int event_setup(); 9 | int event_add(Event* newEvent, uint64_t timeout, EventHandler handler, void* opaque); 10 | int event_readd(Event* event, uint64_t new_interval); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /openiboot/includes/framebuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef FRAMEBUFFER_H 2 | #define FRAMEBUFFER_H 3 | 4 | #include "openiboot.h" 5 | 6 | #define COLOR_WHITE 0xffffff 7 | #define COLOR_BLACK 0x0 8 | 9 | typedef struct OpenIBootFont { 10 | uint32_t width; 11 | uint32_t height; 12 | uint8_t data[]; 13 | } OpenIBootFont; 14 | 15 | extern int FramebufferHasInit; 16 | 17 | int framebuffer_setup(); 18 | void framebuffer_setdisplaytext(int onoff); 19 | int framebuffer_width(); 20 | int framebuffer_height(); 21 | int framebuffer_x(); 22 | int framebuffer_y(); 23 | void framebuffer_putc(int c); 24 | void framebuffer_print(const char* str); 25 | void framebuffer_print_force(const char* str); 26 | void framebuffer_setloc(int x, int y); 27 | void framebuffer_clear(); 28 | uint32_t* framebuffer_load_image(const char* data, int len, int* width, int* height, int alpha); 29 | void framebuffer_blend_image(uint32_t* dst, int dstWidth, int dstHeight, uint32_t* src, int srcWidth, int srcHeight, int x, int y); 30 | void framebuffer_draw_image(uint32_t* image, int x, int y, int width, int height); 31 | void framebuffer_capture_image(uint32_t* image, int x, int y, int width, int height); 32 | void framebuffer_draw_rect(uint32_t color, int x, int y, int width, int height); 33 | void framebuffer_draw_rect_hgradient(int starting, int ending, int x, int y, int width, int height); 34 | void framebuffer_setcolors(uint32_t fore, uint32_t back); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /openiboot/includes/gpio.h: -------------------------------------------------------------------------------- 1 | #ifndef GPIO_H 2 | #define GPIO_H 3 | 4 | #include "openiboot.h" 5 | #include "interrupt.h" 6 | 7 | typedef enum 8 | { 9 | GPIOPDDisabled, 10 | GPIOPDUp, 11 | GPIOPDDown 12 | } GPIOPDSetting; 13 | 14 | typedef struct GPIORegisters { 15 | volatile uint32_t CON; 16 | volatile uint32_t DAT; 17 | volatile uint32_t PUD1; // (PUD1[x], PUD2[x]): (0, 0) = pull up/down for x disabled, (0, 1) = pull down, (1, 0) = pull up 18 | volatile uint32_t PUD2; 19 | volatile uint32_t CONSLP1; 20 | volatile uint32_t CONSLP2; 21 | volatile uint32_t PUDSLP1; 22 | volatile uint32_t PUDSLP2; 23 | } GPIORegisters; 24 | 25 | int gpio_setup(); 26 | int gpio_pin_state(int port); 27 | void gpio_custom_io(int port, int bits); 28 | void gpio_pin_use_as_input(int port); 29 | void gpio_pin_output(int port, int bit); 30 | 31 | void gpio_register_interrupt(uint32_t interrupt, int type, int level, int autoflip, InterruptServiceRoutine handler, uint32_t token); 32 | void gpio_interrupt_enable(uint32_t interrupt); 33 | void gpio_interrupt_disable(uint32_t interrupt); 34 | 35 | void gpio_pulldown_configure(int port, GPIOPDSetting setting); 36 | 37 | int pmu_gpio(int gpio, int is_output, int value); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/als.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_ALS_H 2 | #define HW_ALS_H 3 | 4 | #define ALS_I2C 0 5 | 6 | #ifdef CONFIG_3G 7 | #define ALS_ADDR 0x88 8 | #else 9 | #define ALS_ADDR 0x92 10 | #endif 11 | #define ALS_INT 0x49 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/buttons.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_BUTTONS_H 2 | #define HW_BUTTONS_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // Device 7 | 8 | #define BUTTONS_HOME_IPHONE 0x1600 9 | #define BUTTONS_VOLUP 0x1601 10 | #define BUTTONS_VOLDOWN 0x1602 11 | #define BUTTONS_RINGERAB 0x1603 12 | #define BUTTONS_HOLD 0x1605 13 | #define BUTTONS_HOME_IPOD 0x1606 14 | 15 | #ifdef CONFIG_IPOD 16 | #define BUTTONS_HOME BUTTONS_HOME_IPOD 17 | #define BUTTONS_HOME_IRQ 0x2E 18 | #else 19 | #define BUTTONS_HOME BUTTONS_HOME_IPHONE 20 | #define BUTTONS_HOME_IRQ 0x28 21 | #endif 22 | 23 | #define BUTTONS_IIC_STATE 0x4B 24 | 25 | #define BUTTONS_HOLD_IRQ 0x2D 26 | #define BUTTONS_VOLUP_IRQ 0x29 27 | #define BUTTONS_VOLDOWN_IRQ 0x2A 28 | #define BUTTONS_RINGERAB_IRQ 0x2B 29 | 30 | #define BUTTONS_HOLD_IRQTYPE 1 31 | #define BUTTONS_HOME_IRQTYPE 1 32 | #define BUTTONS_VOLUP_IRQTYPE 1 33 | #define BUTTONS_VOLDOWN_IRQTYPE 1 34 | #define BUTTONS_RINGERAB_IRQTYPE 1 35 | 36 | #define BUTTONS_HOLD_IRQLEVEL 1 37 | #define BUTTONS_HOME_IRQLEVEL 1 38 | #define BUTTONS_VOLUP_IRQLEVEL 0 39 | #define BUTTONS_VOLDOWN_IRQLEVEL 0 40 | #define BUTTONS_RINGERAB_IRQLEVEL 1 41 | 42 | #define BUTTONS_HOLD_IRQAUTOFLIP 1 43 | #define BUTTONS_HOME_IRQAUTOFLIP 1 44 | #define BUTTONS_VOLUP_IRQAUTOFLIP 1 45 | #define BUTTONS_VOLDOWN_IRQAUTOFLIP 1 46 | #define BUTTONS_RINGERAB_IRQAUTOFLIP 1 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/chipid.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_CHIPID_H 2 | #define HW_CHIPID_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // Device 7 | #define CHIPID 0x3E500000 8 | 9 | // Registers 10 | #define SPICLOCKTYPE 0x4 11 | 12 | // Values 13 | #define GET_SPICLOCKTYPE(x) GET_BITS(x, 24, 4) 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/clock0.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_CLOCK0_H 2 | #define HW_CLOCK0_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | #define CLOCK0 0x38100000 /* the clocks are probably also parts of the system controller */ 7 | 8 | // Registers 9 | #define CLOCK0_CONFIG 0x0 10 | #define CLOCK0_ADJ1 0x8 11 | #define CLOCK0_ADJ2 0x404 12 | 13 | // Values 14 | #define CLOCK0_ADJ_MASK 0xFFFFF000 15 | 16 | #define CLOCK0_CONFIG_BOTTOMMASK 0x7 17 | #define CLOCK0_CONFIG_C0VALUE 0x1 18 | #define CLOCK0_CONFIG_C1VALUE 0x3 19 | #define CLOCK0_CONFIG_C2VALUE 0x5 20 | #define CLOCK0_CONFIG_C3VALUE 0 21 | 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/clock1.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_CLOCK1_H 2 | #define HW_CLOCK1_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // Constants 7 | #define NUM_PLL 4 8 | #define FREQUENCY_BASE 12000000 9 | #define PLL0_INFREQ_DIV FREQUENCY_BASE /* 12 MHz */ 10 | #define PLL1_INFREQ_DIV FREQUENCY_BASE /* 12 MHz */ 11 | #define PLL2_INFREQ_DIV FREQUENCY_BASE /* 12 MHz */ 12 | #define PLL3_INFREQ_DIV 13500000 /* 13.5 MHz */ 13 | #define PLL0_INFREQ_MULT 0x4000 14 | #define PLL1_INFREQ_MULT 0x4000 15 | #define PLL2_INFREQ_MULT 0x4000 16 | #define PLL3_INFREQ_MULT FREQUENCY_BASE 17 | 18 | // Devices 19 | #define CLOCK1 0x3C500000 20 | 21 | // Registers 22 | #define CLOCK1_CONFIG0 0x0 23 | #define CLOCK1_CONFIG1 0x4 24 | #define CLOCK1_CONFIG2 0x8 25 | #define CLOCK1_PLL0CON 0x20 26 | #define CLOCK1_PLL1CON 0x24 27 | #define CLOCK1_PLL2CON 0x28 28 | #define CLOCK1_PLL3CON 0x2C 29 | #define CLOCK1_PLL0LCNT 0x30 30 | #define CLOCK1_PLL1LCNT 0x34 31 | #define CLOCK1_PLL2LCNT 0x38 32 | #define CLOCK1_PLL3LCNT 0x3C 33 | #define CLOCK1_PLLLOCK 0x40 34 | #define CLOCK1_PLLMODE 0x44 35 | #define CLOCK1_CL2_GATES 0x48 36 | #define CLOCK1_CL3_GATES 0x4C 37 | 38 | // Values 39 | #define CLOCK1_Separator 0x20 40 | 41 | #define CLOCK1_CLOCKPLL(x) GET_BITS((x), 12, 2) 42 | #define CLOCK1_CLOCKDIVIDER(x) (GET_BITS((x), 0, 4) + 1) 43 | #define CLOCK1_CLOCKHASDIVIDER(x) GET_BITS((x), 8, 1) 44 | 45 | #define CLOCK1_MEMORYPLL(x) GET_BITS((x), 12, 2) 46 | #define CLOCK1_MEMORYDIVIDER(x) (GET_BITS((x), 16, 4) + 1) 47 | #define CLOCK1_MEMORYHASDIVIDER(x) GET_BITS((x), 24, 1) 48 | 49 | #define CLOCK1_BUSPLL(x) GET_BITS((x), 12, 2) 50 | #define CLOCK1_BUSDIVIDER(x) (GET_BITS((x), 16, 4) + 1) 51 | #define CLOCK1_BUSHASDIVIDER(x) GET_BITS((x), 24, 1) 52 | 53 | #define CLOCK1_UNKNOWNPLL(x) GET_BITS((x), 12, 2) 54 | #define CLOCK1_UNKNOWNDIVIDER1(x) (GET_BITS((x), 0, 4) + 1) 55 | #define CLOCK1_UNKNOWNDIVIDER2(x) (GET_BITS((x), 4, 4) + 1) 56 | #define CLOCK1_UNKNOWNDIVIDER(x) (CLOCK1_UNKNOWNDIVIDER1(x) * CLOCK1_UNKNOWNDIVIDER2(x)) 57 | #define CLOCK1_UNKNOWNHASDIVIDER(x) GET_BITS((x), 8, 1) 58 | 59 | #define CLOCK1_PERIPHERALDIVIDER(x) GET_BITS((x), 20, 2) 60 | 61 | #define CLOCK1_DISPLAYPLL(x) GET_BITS((x), 28, 2) 62 | #define CLOCK1_DISPLAYDIVIDER(x) GET_BITS((x), 16, 4) 63 | #define CLOCK1_DISPLAYHASDIVIDER(x) GET_BITS((x), 24, 1) 64 | 65 | #define CLOCK1_PLLMODE_ONOFF(x, y) (((x) >> (y)) & 0x1) 66 | #define CLOCK1_PLLMODE_DIVIDERMODE(x, y) (((x) >> (y + 4)) & 0x1) 67 | #define CLOCK1_PLLMODE_DIVIDE 1 68 | #define CLOCK1_PLLMODE_MULTIPLY 0 69 | 70 | #define CLOCK1_MDIV(x) (((x) >> 8) & 0x3FF) 71 | #define CLOCK1_PDIV(x) (((x) >> 24) & 0x3F) 72 | #define CLOCK1_SDIV(x) ((x) & 0x3) 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/edgeic.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_EDGEIC_H 2 | #define HW_EDGEIC_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // Devices 7 | #define EDGEIC 0x38E02000 8 | 9 | // Registers 10 | #define EDGEICCONFIG0 0x0 11 | #define EDGEICCONFIG1 0x4 12 | #define EDGEICLOWSTATUS 0x8 13 | #define EDGEICHIGHSTATUS 0xC 14 | 15 | // Values 16 | #define EDGEIC_CONFIG0RESET 0 17 | #define EDGEIC_CONFIG1RESET 0 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/gpio.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_GPIO_H 2 | #define HW_GPIO_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // gpioicBase 7 | // Device 8 | #define GPIOIC 0x39A00000 /* probably a part of the system controller */ 9 | 10 | // gpioBaseAddress 11 | #define GPIO 0x3E400000 12 | 13 | // Registers 14 | #define GPIO_INTLEVEL 0x80 15 | #define GPIO_INTSTAT 0xA0 16 | #define GPIO_INTEN 0xC0 17 | #define GPIO_INTTYPE 0xE0 18 | #define GPIO_FSEL 0x320 19 | 20 | // Values 21 | #define GPIO_NUMINTGROUPS 7 22 | #define GPIO_INTSTAT_RESET 0xFFFFFFFF 23 | #define GPIO_INTEN_RESET 0 24 | 25 | #define GPIO_FSEL_MAJSHIFT 16 26 | #define GPIO_FSEL_MAJMASK 0x1F 27 | #define GPIO_FSEL_MINSHIFT 8 28 | #define GPIO_FSEL_MINMASK 0x7 29 | #define GPIO_FSEL_USHIFT 0 30 | #define GPIO_FSEL_UMASK 0xF 31 | 32 | #define GPIO_CLOCKGATE 0x2C 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/i2c.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_I2C_H 2 | #define HW_I2C_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // Device 7 | #define I2C0 0x3C600000 8 | #define I2C1 0x3C900000 9 | 10 | // Registers 11 | #define IICCON 0x0 12 | #define IICSTAT 0x4 13 | #define IICADD 0x8 14 | #define IICDS 0xC 15 | #define IICLC 0x10 16 | #define IICREG14 0x14 17 | #define IICREG18 0x18 18 | #define IICREG1C 0x1C 19 | #define IICREG20 0x20 20 | 21 | // Values 22 | #define IICCON_INIT 0x3F00 23 | #define IICCON_ACKGEN (1 << 7) 24 | #define IICCON_TXCLKSRC_FPCLK16 (0 << 6) 25 | #define IICCON_TXCLKSRC_FPCLK512 (1 << 6) 26 | #define IICCON_INTENABLE (1 << 5) 27 | #define IICCON_INTPENDING (1 << 4) 28 | #define IICCON_TXCLKPRESCALEMASK 0xF 29 | 30 | #define IICSTAT_MODE_SLAVERX 0 31 | #define IICSTAT_MODE_SLAVETX 1 32 | #define IICSTAT_MODE_MASTERRX 2 33 | #define IICSTAT_MODE_MASTERTX 3 34 | #define IICSTAT_MODE_SHIFT 6 35 | #define IICSTAT_MODE_MASK 3 36 | #define IICSTAT_STARTSTOPGEN_START 1 37 | #define IICSTAT_STARTSTOPGEN_STOP 0 38 | #define IICSTAT_STARTSTOPGEN_MASK 1 39 | #define IICSTAT_STARTSTOPGEN_SHIFT 5 40 | #define IICSTAT_DATAOUTPUT_ENABLE_SHIFT 4 41 | #define IICSTAT_LASTRECEIVEDBIT (1 << 0) 42 | 43 | #define I2C0_SCL_GPIO 0xB02 44 | #define I2C0_SDA_GPIO 0xB03 45 | #define I2C1_SCL_GPIO 0x801 46 | #define I2C1_SDA_GPIO 0x802 47 | 48 | #define I2C0_CLOCKGATE 0x24 49 | #define I2C1_CLOCKGATE 0x26 50 | 51 | #define TXFREQ 25000 52 | 53 | #define OPERATION_SEND (1 << 8) 54 | #define OPERATION_CONDITIONCHANGE (1 << 13) 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /openiboot/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 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 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/interrupt.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_INTERRUPT_H 2 | #define HW_INTERRUPT_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // This appears to be a PL192 7 | 8 | // Constants 9 | 10 | #define VIC_MaxInterrupt 0x40 11 | #define VIC_InterruptSeparator 0x20 12 | 13 | // Devices 14 | 15 | #define VIC0 0x38E00000 16 | #define VIC1 0x38E01000 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 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/lcd.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_LCD_H 2 | #define HW_LCD_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // Device 7 | #define LCD 0x38900000 8 | //#define LCD_I2C_BUS 0 9 | 10 | // Registers 11 | #define LCD_0 0x0 12 | #define LCD_CON 0x4 13 | #define LCD_CON2 0x8 14 | #define WND_CON 0x20 15 | #define VIDCON0 0x200 16 | #define VIDCON1 0x204 17 | #define VIDTCON0 0x20C 18 | #define VIDTCON1 0x210 19 | #define VIDTCON2 0x214 20 | #define VIDTCON3 0x218 21 | 22 | // Values 23 | #define VIDCON0_INTERNALCLOCK 0 24 | #define VIDCON0_DISPLAYCLOCK 1 25 | #define VIDCON0_BUSCLOCK 2 26 | #define VIDCON0_CLOCKMASK 0x3 27 | #define VIDCON0_CLOCKSHIFT 6 28 | #define VIDCON0_OPTION4MASK 0x3 29 | #define VIDCON0_OPTION4SHIFT 4 30 | #define VIDCON0_OTFCLOCKDIVISORMASK 0xF 31 | #define VIDCON0_OTFCLOCKDIVISORSHIFT 8 32 | #define VIDCON0_ENVID_F 1 33 | #define VIDCON1_IVCLKSHIFT 3 34 | #define VIDCON1_IHSYNCSHIFT 2 35 | #define VIDCON1_IVSYNCSHIFT 1 36 | #define VIDCON1_IVDENSHIFT 0 37 | #define VIDTCON_BACKPORCHSHIFT 16 38 | #define VIDTCON_BACKPORCHMASK 0xFF 39 | #define VIDTCON_FRONTPORCHSHIFT 8 40 | #define VIDTCON_FRONTPORCHMASK 0xFF 41 | #define VIDTCON_SYNCPULSEWIDTHSHIFT 0 42 | #define VIDTCON_SYNCPULSEWIDTHMASK 0xFF 43 | #define VIDTCON2_LINEVALMASK 0x3FF 44 | #define VIDTCON2_LINEVALSHIFT 0 45 | #define VIDTCON2_HOZVALMASK 0x3FF 46 | #define VIDTCON2_HOZVALSHIFT 16 47 | 48 | #define GET_HSTATUS(x) GET_BITS(x, 4, 2); 49 | #define GET_VSTATUS(x) GET_BITS(x, 6, 2); 50 | #define GET_LINECNT(x) GET_BITS(x, 8, 9); 51 | #define LCD_CLOCKGATE1 0x7 52 | #define LCD_CLOCKGATE2 0x1D 53 | 54 | #define LCD_GPIO_MPL_RX_ENABLE_IPHONE 0x1804 55 | #define LCD_GPIO_MPL_RX_ENABLE_IPOD 0x607 56 | #define LCD_GPIO_MPL_RX_ENABLE_3G 0x0 57 | 58 | #define LCD_GPIO_RESET 0x1 59 | #define LCD_GPIO_POWER_ENABLE 0x2 60 | #define LCD_GPIO_PIXEL_CLOCK_ENABLE 0x3 61 | #define LCD_GPIO_CONTROL_ENABLE 0x304 62 | 63 | #define LCD_GPIO_CONFIG1 0xE04 64 | #define LCD_GPIO_CONFIG2 0xE05 65 | #define LCD_GPIO_CONFIG3 0xE06 66 | 67 | #ifdef CONFIG_IPOD 68 | #define LCD_GPIO_MPL_RX_ENABLE LCD_GPIO_MPL_RX_ENABLE_IPOD 69 | #endif 70 | #ifdef CONFIG_IPHONE 71 | #define LCD_GPIO_MPL_RX_ENABLE LCD_GPIO_MPL_RX_ENABLE_IPHONE 72 | #endif 73 | #ifdef CONFIG_3G 74 | #define LCD_GPIO_MPL_RX_ENABLE LCD_GPIO_MPL_RX_ENABLE_3G 75 | #endif 76 | 77 | #define LCD_GPIO_3G_ENABLE 0xE01 78 | 79 | #ifdef CONFIG_3G 80 | #define LCD_PANEL_SPI 0 81 | #define LCD_PANEL_CS GPIO_SPI0_CS1 82 | #define LCD_SPI 0 83 | #define LCD_CS GPIO_SPI0_CS2 84 | #else 85 | #define LCD_PANEL_SPI 1 86 | #define LCD_PANEL_CS GPIO_SPI1_CS0 87 | #define LCD_SPI 0 88 | #define LCD_CS GPIO_SPI0_CS0 89 | #endif 90 | 91 | #define LCD_I2C_COMMAND 0x31 92 | #define LCD_I2C_COMMANDMODE_ON 0x35 93 | #define LCD_I2C_COMMANDMODE_OFF 0x15 94 | 95 | #define NUM_WINDOWS 3 96 | 97 | #define LCD_MAX_BACKLIGHT 45 98 | #define LCD_BACKLIGHT_REG 0x28 99 | #define LCD_BACKLIGHT_REGMASK 0x3F 100 | 101 | #endif 102 | 103 | -------------------------------------------------------------------------------- /openiboot/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 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_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 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/nor.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_NOR_H 2 | #define HW_NOR_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // Device 7 | //#define NOR 0x54000000 8 | #define NOR 0x24000000 9 | 10 | // Registers 11 | #define COMMAND 0xAAAA 12 | #define LOCK 0x5554 13 | #define VENDOR 0 14 | #define DEVICE 2 15 | 16 | // Values 17 | #define DATA_MODE 0xFFFF 18 | #define COMMAND_UNLOCK 0xAAAA 19 | #define COMMAND_LOCK 0xF0F0 20 | #define COMMAND_IDENTIFY 0x9090 21 | #define COMMAND_WRITE 0xA0A0 22 | #define COMMAND_ERASE 0x8080 23 | #define ERASE_DATA 0x3030 24 | #define LOCK_UNLOCK 0x5555 25 | 26 | #define NOR_SPI_READ 0x03 27 | #define NOR_SPI_WREN 0x06 28 | #define NOR_SPI_WRDI 0x04 29 | #define NOR_SPI_PRGM 0x02 30 | #define NOR_SPI_RDSR 0x05 31 | #define NOR_SPI_WRSR 0x01 32 | #define NOR_SPI_EWSR 0x50 33 | #define NOR_SPI_AIPG 0xAD 34 | #define NOR_SPI_ERSE_4KB 0x20 35 | #define NOR_SPI_JEDECID 0x9F 36 | 37 | #define NOR_SPI_SR_BUSY 0 38 | #define NOR_SPI_SR_WEL 1 39 | #define NOR_SPI_SR_BP0 2 40 | #define NOR_SPI_SR_BP1 3 41 | #define NOR_SPI_SR_BP2 4 42 | #define NOR_SPI_SR_BP3 5 43 | #define NOR_SPI_SR_AAI 6 44 | #define NOR_SPI_SR_BPL 7 45 | 46 | #define NOR_T_BP 10000 47 | #define NOR_T_SE 25000 48 | 49 | #define NOR_CLOCKGATE 0x1E 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/pmu.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_PMU_H 2 | #define HW_PMU_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | #ifdef CONFIG_IPOD 7 | #define PMU_I2C_BUS 1 8 | #else 9 | #define PMU_I2C_BUS 0 10 | #endif 11 | 12 | // Power 13 | #define PMU_SETADDR 0xE6 14 | #define PMU_GETADDR 0xE7 15 | // Registers 16 | #define PMU_MAXREG 0xF 17 | 18 | // Values 19 | 20 | #define PMU_GPIO_CHARGER_IDENTIFY_DN_IPHONE 0x1404 21 | #define PMU_GPIO_CHARGER_IDENTIFY_DP_IPHONE 0x1405 22 | #define PMU_GPIO_CHARGER_IDENTIFY_DN_IPOD 0x1603 23 | #define PMU_GPIO_CHARGER_IDENTIFY_DP_IPOD 0x1604 24 | 25 | #ifdef CONFIG_IPOD 26 | #define PMU_GPIO_CHARGER_IDENTIFY_DN PMU_GPIO_CHARGER_IDENTIFY_DN_IPOD 27 | #define PMU_GPIO_CHARGER_IDENTIFY_DP PMU_GPIO_CHARGER_IDENTIFY_DN_IPOD 28 | #else 29 | #define PMU_GPIO_CHARGER_IDENTIFY_DN PMU_GPIO_CHARGER_IDENTIFY_DN_IPHONE 30 | #define PMU_GPIO_CHARGER_IDENTIFY_DP PMU_GPIO_CHARGER_IDENTIFY_DN_IPHONE 31 | #endif 32 | 33 | #define PMU_GPIO_CHARGER_USB_SUSPEND 0x1704 34 | #define PMU_GPIO_CHARGER_SUSPEND 0x1706 35 | #define PMU_GPIO_CHARGER_SHUTDOWN 0x1707 36 | #define PMU_GPIO_CHARGER_USB_500_1000 0x1705 37 | #define PMU_GPIO_CHARGER_USB_1000 0x704 38 | 39 | #define PMU_OOCSHDWN 0xC 40 | #define PMU_GPIOCTL 0x13 41 | #define PMU_GPIO1CFG 0x14 42 | #define PMU_ADCC3 0x52 43 | #define PMU_ADCC2 0x53 44 | #define PMU_ADCC1 0x54 45 | #define PMU_ADCS3 0x57 46 | #define PMU_ADCS1 0x55 47 | #define PMU_MBCS1 0x4B 48 | #define PMU_RTCSC 0x59 49 | #define PMU_RTCMN 0x5A 50 | #define PMU_RTCHR 0x5B 51 | #define PMU_RTCWD 0x5C 52 | #define PMU_RTCDT 0x5D 53 | #define PMU_RTCMT 0x5E 54 | #define PMU_RTCYR 0x5F 55 | 56 | #define PMU_RTCSC_MASK 0x7F 57 | #define PMU_RTCMN_MASK 0x7F 58 | #define PMU_RTCHR_MASK 0x3F 59 | #define PMU_RTCWD_MASK 0x07 60 | #define PMU_RTCDT_MASK 0x3F 61 | #define PMU_RTCMT_MASK 0x1F 62 | #define PMU_RTCYR_MASK 0xFF 63 | 64 | #define PMU_OOCSHDWN_GOSTBY (1 << 0) 65 | 66 | #define PMU_MBCS1_ADAPTPRES (1 << 2) 67 | #define PMU_MBCS1_USBOK (1 << 0) 68 | 69 | #define PMU_ADCC1_ADCINMUX_SHIFT 4 70 | #define PMU_ADCC1_ADCINMUX_MASK 0xF 71 | #define PMU_ADCC1_ADC_AV_SHIFT 2 72 | #define PMU_ADCC1_ADCSTART 0x1 73 | #define PMU_ADCC1_ADCRES 0x2 74 | 75 | #define PMU_ADCC1_ADC_AV_1 0x0 76 | #define PMU_ADCC1_ADC_AV_4 0x1 77 | #define PMU_ADCC1_ADC_AV_8 0x2 78 | #define PMU_ADCC1_ADC_AV_16 0x3 79 | 80 | #define PMU_ADCC1_ADCINMUX_BATSNS_DIV 0x0 81 | #define PMU_ADCC1_ADCINMUX_BATSNS_SUB 0x1 82 | #define PMU_ADCC1_ADCINMUX_ADCIN2_DIV 0x2 83 | #define PMU_ADCC1_ADCINMUX_ADCIN2_SUB 0x3 84 | #define PMU_ADCC1_ADCINMUX_BATTEMP 0x6 85 | #define PMU_ADCC1_ADCINMUX_ADCIN1 0x7 86 | 87 | #endif 88 | 89 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/power.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_POWER_H 2 | #define HW_POWER_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // Device 7 | #define POWER 0x39A00000 /* probably a part of the system controller */ 8 | 9 | // Power 10 | #define POWER_DEFAULT_DEVICES 0xEC 11 | #define POWER_LCD 0x100 12 | #define POWER_USB 0x200 13 | #define POWER_VROM 0x1000 14 | 15 | // Registers 16 | #define POWER_CONFIG0 0x0 17 | #define POWER_CONFIG1 0x20 18 | #define POWER_CONFIG2 0x6C 19 | #define POWER_ONCTRL 0xC 20 | #define POWER_OFFCTRL 0x10 21 | #define POWER_SETSTATE 0x8 22 | #define POWER_STATE 0x14 23 | #define POWER_ID 0x44 24 | #define POWER_ID_EPOCH(x) ((x) >> 24) 25 | 26 | // Values 27 | #define POWER_CONFIG0_RESET 0x1123009 28 | #define POWER_CONFIG1_RESET 0x20 29 | #define POWER_CONFIG2_RESET 0x0 30 | 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/radio.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_RADIO_H 2 | #define HW_RADIO_H 3 | 4 | #ifdef CONFIG_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 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/s5l8900.h: -------------------------------------------------------------------------------- 1 | #ifndef S5L8900_H 2 | #define S5L8900_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | /* 7 | * Constants 8 | */ 9 | 10 | #define MemoryStart 0x00000000 11 | #define MemoryEnd 0xFFFFFFFF 12 | #define LargeMemoryStart 0x08000000 /* FIXME: This is an ugly hack to get around iBoot's memory rearrangement. Linux boot will only work for installed openiboot! */ 13 | #define RAMEnd 0x08000000 14 | #define MemoryHigher 0x80000000 15 | #define ExceptionVector MemoryStart 16 | #ifdef SMALL 17 | #define PageTable (OpenIBootLoad + 0x24000) 18 | #define HeapStart (PageTable + 0x4000) 19 | #else 20 | #define OpenIBootLoad 0x00000000 21 | #define GeneralStack ((PageTable - 4) + LargeMemoryStart) 22 | #define HeapStart (LargeMemoryStart + 0x02000000) 23 | #define PageTable (RAMEnd - 0x4000) 24 | #endif 25 | 26 | /* 27 | * Devices 28 | */ 29 | 30 | #define PeripheralPort 0x38000000 31 | #ifdef CONFIG_3G 32 | #define AMC0 0x38500000 33 | #define ROM 0x50000000 34 | #else 35 | #define AMC0 0x22000000 36 | #define ROM 0x20000000 37 | #endif 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 | -------------------------------------------------------------------------------- /openiboot/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 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 35 | #define SDIO_GPIO_DEVICE_RESET 0x607 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/spi.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_SPI_H 2 | #define HW_SPI_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // Device 7 | #define SPI0 0x3C300000 8 | #define SPI1 0x3CE00000 9 | #define SPI2 0x3D200000 10 | 11 | // Registers 12 | 13 | #define CONTROL 0x0 14 | #define SETUP 0x4 15 | #define STATUS 0x8 16 | #define UNKREG1 0xC 17 | #define TXDATA 0x10 18 | #define RXDATA 0x20 19 | #define CLKDIVIDER 0x30 20 | #define UNKREG2 0x34 21 | #define UNKREG3 0x38 22 | 23 | // Values 24 | #define MAX_TX_BUFFER 8 25 | #define TX_BUFFER_LEFT(x) GET_BITS(status, 4, 4) 26 | #define RX_BUFFER_LEFT(x) GET_BITS(status, 8, 4) 27 | 28 | #define CLOCK_SHIFT 12 29 | #define MAX_DIVIDER 0x3FF 30 | 31 | #define SPI0_CLOCKGATE 0x22 32 | #define SPI1_CLOCKGATE 0x2B 33 | #define SPI2_CLOCKGATE 0x2F 34 | 35 | #define SPI0_IRQ 0x9 36 | #define SPI1_IRQ 0xA 37 | #define SPI2_IRQ 0xB 38 | 39 | #define GPIO_SPI0_CS0_IPHONE 0x400 40 | #define GPIO_SPI0_CS0_IPOD 0x700 41 | 42 | #ifdef CONFIG_IPOD 43 | #define GPIO_SPI2_CS0 0x1804 44 | #define GPIO_SPI2_CS1 0x705 45 | #endif 46 | 47 | #ifdef CONFIG_IPHONE 48 | #define GPIO_SPI2_CS0 0x705 49 | #endif 50 | 51 | #ifdef CONFIG_IPOD 52 | #define GPIO_SPI0_CS0 GPIO_SPI0_CS0_IPOD 53 | #else 54 | #define GPIO_SPI0_CS0 GPIO_SPI0_CS0_IPHONE 55 | #endif 56 | 57 | #define GPIO_SPI1_CS0 0x1800 58 | 59 | #ifdef CONFIG_3G 60 | #define GPIO_SPI0_CS1 0x705 61 | #define GPIO_SPI0_CS2 0x706 62 | #endif 63 | 64 | #define NUM_SPIPORTS 3 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_TIMER_H 2 | #define HW_TIMER_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // Constants 7 | #define EventTimer 4 8 | #define PiezoTimer 1 9 | 10 | // Devices 11 | 12 | #define TIMER 0x3E200000 13 | 14 | // Registers 15 | 16 | #define TIMER_0 0x0 17 | #define TIMER_1 0x20 18 | #define TIMER_2 0x40 19 | #define TIMER_3 0x60 20 | #define TIMER_4 0xA0 21 | #define TIMER_5 0xC0 22 | #define TIMER_6 0xE0 23 | #define TIMER_CONFIG 0 24 | #define TIMER_STATE 0x4 25 | #define TIMER_COUNT_BUFFER 0x8 26 | #define TIMER_COUNT_BUFFER2 0xC 27 | #define TIMER_PRESCALER 0x10 28 | #define TIMER_UNKNOWN3 0x14 29 | #define TIMER_TICKSHIGH 0x80 30 | #define TIMER_TICKSLOW 0x84 31 | #define TIMER_UNKREG0 0x88 32 | #define TIMER_UNKREG1 0x8C 33 | #define TIMER_UNKREG2 0x90 34 | #define TIMER_UNKREG3 0x94 35 | #define TIMER_UNKREG4 0x98 36 | #define TIMER_IRQSTAT 0x10000 37 | #define TIMER_IRQLATCH 0xF8 38 | 39 | // Timer 40 | #define NUM_TIMERS 7 41 | #define TIMER_CLOCKGATE 0x25 42 | #define TIMER_IRQ 0x7 43 | #define TIMER_STATE_START 1 44 | #define TIMER_STATE_STOP 0 45 | #define TIMER_STATE_MANUALUPDATE 2 46 | #define TIMER_UNKREG0_RESET1 0xA 47 | #define TIMER_UNKREG0_RESET2 0x18010 48 | #define TIMER_UNKREG1_RESET 0xFFFFFFFF 49 | #define TIMER_UNKREG2_RESET 0xFFFFFFFF 50 | #define TIMER_UNKREG3_RESET 0xFFFFFFFF 51 | #define TIMER_UNKREG4_RESET 0xFFFFFFFF 52 | #define TIMER_DIVIDER1 4 53 | #define TIMER_DIVIDER2 0 54 | #define TIMER_DIVIDER4 1 55 | #define TIMER_DIVIDER16 2 56 | #define TIMER_DIVIDER64 3 57 | #define TIMER_SPECIALTIMER_BIT0 0x1000000 58 | #define TIMER_SPECIALTIMER_BIT1 0x2000000 59 | 60 | #define TIMER_Separator 4 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/uart.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_UART_H 2 | #define HW_UART_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | // Devices 7 | #define UART 0x3CC00000 8 | 9 | // Registers 10 | #define UART0 0x0 11 | #define UART1 0x4000 12 | #define UART2 0x8000 13 | #define UART3 0xC000 14 | #define UART4 0x10000 15 | 16 | #define UART_ULCON 0x0 17 | #define UART_UCON 0x4 18 | #define UART_UFCON 0x8 19 | #define UART_UMCON 0xC 20 | #define UART_UTRSTAT 0x10 21 | #define UART_UERSTAT 0x14 22 | #define UART_UFSTAT 0x18 23 | #define UART_UMSTAT 0x1C 24 | #define UART_UTXH 0x20 25 | #define UART_URXH 0x24 26 | #define UART_UBAUD 0x28 27 | #define UART_UDIVSLOT 0x2C 28 | 29 | // Values 30 | #define NUM_UARTS 5 31 | #define UART_CLOCKGATE 0x29 32 | 33 | #define UART_CLOCK_SELECTION_MASK (0x3 << 10) // Bit 10-11 34 | #define UART_CLOCK_SELECTION_SHIFT 10 // Bit 10-11 35 | #define UART_UCON_UNKMASK 0x7000 36 | #define UART_UCON_LOOPBACKMODE (0x1 << 5) 37 | #define UART_UCON_RXMODE_SHIFT 0 38 | #define UART_UCON_RXMODE_MASK (0x3 << UART_UCON_RXMODE_SHIFT) 39 | #define UART_UCON_TXMODE_SHIFT 2 40 | #define UART_UCON_TXMODE_MASK (0x3 << UART_UCON_TXMODE_SHIFT) 41 | 42 | #define UART_FIFO_RESET_TX 0x4 43 | #define UART_FIFO_RESET_RX 0x2 44 | #define UART_FIFO_ENABLE 0x1 45 | 46 | #define UART_DIVVAL_MASK 0x0000FFFF 47 | #define UART_SAMPLERATE_MASK 0x00030000 // Bit 16-17 48 | #define UART_SAMPLERATE_SHIFT 16 49 | 50 | #define UART_UCON_MODE_DISABLE 0 51 | #define UART_UCON_MODE_IRQORPOLL 1 52 | #define UART_UCON_MODE_DMA0 2 53 | #define UART_UCON_MODE_DMA1 3 54 | 55 | #define UART_CLOCK_PCLK 0 56 | #define UART_CLOCK_EXT_UCLK0 1 57 | #define UART_CLOCK_EXT_UCLK1 3 58 | 59 | #define UART_SAMPLERATE_4 2 60 | #define UART_SAMPLERATE_8 1 61 | #define UART_SAMPLERATE_16 0 62 | 63 | #define UART_UMCON_AFC_BIT 0x10 64 | #define UART_UMCON_NRTS_BIT 0x1 65 | 66 | #define UART_UTRSTAT_TRANSMITTEREMPTY 0x4 67 | #define UART_UTRSTAT_RECEIVEDATAREADY 0x1 68 | 69 | #define UART_UMSTAT_CTS 0x1 70 | 71 | #define UART_UFSTAT_TXFIFO_FULL (0x1 << 9) 72 | #define UART_UFSTAT_RXFIFO_FULL (0x1 << 8) 73 | #define UART_UFSTAT_TXCOUNT_SHIFT 4 74 | #define UART_UFSTAT_TXCOUNT_MASK (0xF << UART_UFSTAT_TXCOUNT_SHIFT) 75 | #define UART_UFSTAT_RXCOUNT_MASK 0xF 76 | 77 | #define UART_5BITS 0 78 | #define UART_6BITS 1 79 | #define UART_7BITS 2 80 | #define UART_8BITS 3 81 | 82 | #endif 83 | 84 | -------------------------------------------------------------------------------- /openiboot/includes/hardware/wmcodec.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_WM8958_H 2 | #define HW_WM8958_H 3 | 4 | #include "hardware/s5l8900.h" 5 | 6 | #ifdef CONFIG_IPOD 7 | #define WMCODEC_I2C 1 8 | #endif 9 | 10 | #ifdef CONFIG_IPHONE 11 | #define WMCODEC_I2C 0 12 | #endif 13 | 14 | #ifdef CONFIG_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 | #define WMCODEC_INT 0x2c 22 | #define WMCODEC_INT_GPIO 0x1604 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /openiboot/includes/hfs/bdev.h: -------------------------------------------------------------------------------- 1 | #ifndef BDEV_H 2 | #define BDEV_H 3 | 4 | #include "openiboot.h" 5 | #include "hfs/common.h" 6 | 7 | typedef struct MBRPartitionRecord { 8 | uint8_t status; 9 | uint8_t beginHead; 10 | uint8_t beginSectorCyl; 11 | uint8_t beginCyl; 12 | uint8_t type; 13 | uint8_t endHead; 14 | uint8_t endSectorCyl; 15 | uint8_t endCyl; 16 | uint32_t beginLBA; 17 | uint32_t numSectors; 18 | } MBRPartitionRecord; 19 | 20 | typedef struct MBR { 21 | uint8_t code[0x1B8]; 22 | uint32_t signature; 23 | uint16_t padding; 24 | MBRPartitionRecord partitions[4]; 25 | uint16_t magic; 26 | } __attribute__ ((packed)) MBR; 27 | 28 | extern int HasBDevInit; 29 | 30 | int bdev_setup(); 31 | unsigned int bdev_get_start(int partition); 32 | io_func* bdev_open(int partition); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /openiboot/includes/hfs/common.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_H 2 | #define COMMON_H 3 | 4 | #include "openiboot.h" 5 | #include "util.h" 6 | 7 | #define FLIPENDIAN(x) flipEndian((unsigned char *)(&(x)), sizeof(x)) 8 | #define FLIPENDIANLE(x) flipEndianLE((unsigned char *)(&(x)), sizeof(x)) 9 | 10 | #define TRUE 1 11 | #define FALSE 0 12 | 13 | #define IS_BIG_ENDIAN 0 14 | #define IS_LITTLE_ENDIAN 1 15 | 16 | #define TIME_OFFSET_FROM_UNIX 2082844800L 17 | #define APPLE_TO_UNIX_TIME(x) ((x) - TIME_OFFSET_FROM_UNIX) 18 | #define UNIX_TO_APPLE_TIME(x) ((x) + TIME_OFFSET_FROM_UNIX) 19 | 20 | #define ASSERT(x, m) if(!(x)) { bufferPrintf("error: %s\n", m); } 21 | 22 | typedef uint64_t off_t; 23 | 24 | #define endianness IS_LITTLE_ENDIAN 25 | 26 | static inline int time(void* unused) { 27 | return 0; 28 | } 29 | 30 | static inline void flipEndian(unsigned char* x, int length) { 31 | int i; 32 | unsigned char tmp; 33 | 34 | if(endianness == IS_BIG_ENDIAN) { 35 | return; 36 | } else { 37 | for(i = 0; i < (length / 2); i++) { 38 | tmp = x[i]; 39 | x[i] = x[length - i - 1]; 40 | x[length - i - 1] = tmp; 41 | } 42 | } 43 | } 44 | 45 | static inline void flipEndianLE(unsigned char* x, int length) { 46 | int i; 47 | unsigned char tmp; 48 | 49 | if(endianness == IS_LITTLE_ENDIAN) { 50 | return; 51 | } else { 52 | for(i = 0; i < (length / 2); i++) { 53 | tmp = x[i]; 54 | x[i] = x[length - i - 1]; 55 | x[length - i - 1] = tmp; 56 | } 57 | } 58 | } 59 | struct io_func_struct; 60 | 61 | typedef int (*readFunc)(struct io_func_struct* io, off_t location, size_t size, void *buffer); 62 | typedef int (*writeFunc)(struct io_func_struct* io, off_t location, size_t size, void *buffer); 63 | typedef void (*closeFunc)(struct io_func_struct* io); 64 | 65 | typedef struct io_func_struct { 66 | void* data; 67 | readFunc read; 68 | writeFunc write; 69 | closeFunc close; 70 | } io_func; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /openiboot/includes/hfs/fs.h: -------------------------------------------------------------------------------- 1 | #ifndef FS_H 2 | #define FS_H 3 | 4 | #include "openiboot.h" 5 | #include "hfs/hfsplus.h" 6 | 7 | typedef struct ExtentListItem { 8 | uint32_t startBlock; 9 | uint32_t blockCount; 10 | } ExtentListItem; 11 | 12 | typedef struct ExtentList { 13 | uint32_t numExtents; 14 | ExtentListItem extents[16]; 15 | } ExtentList; 16 | 17 | extern int HasFSInit; 18 | 19 | uint32_t readHFSFile(HFSPlusCatalogFile* file, uint8_t** buffer, Volume* volume); 20 | 21 | int fs_setup(); 22 | ExtentList* fs_get_extents(int partition, const char* fileName); 23 | void fs_cmd_ls(int argc, char** argv); 24 | void fs_cmd_cat(int argc, char** argv); 25 | void fs_cmd_extract(int argc, char** argv); 26 | void fs_cmd_add(int argc, char** argv); 27 | int fs_extract(int partition, const char* file, void* location); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /openiboot/includes/hfs/hfslib.h: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "hfsplus.h" 3 | #include "abstractfile.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | void writeToFile(HFSPlusCatalogFile* file, AbstractFile* output, Volume* volume); 9 | void writeToHFSFile(HFSPlusCatalogFile* file, AbstractFile* input, Volume* volume); 10 | void get_hfs(Volume* volume, const char* inFileName, AbstractFile* output); 11 | int add_hfs(Volume* volume, AbstractFile* inFile, const char* outFileName); 12 | void grow_hfs(Volume* volume, uint64_t newSize); 13 | void removeAllInFolder(HFSCatalogNodeID folderID, Volume* volume, const char* parentName); 14 | void addAllInFolder(HFSCatalogNodeID folderID, Volume* volume, const char* parentName); 15 | void addall_hfs(Volume* volume, const char* dirToMerge, const char* dest); 16 | void extractAllInFolder(HFSCatalogNodeID folderID, Volume* volume); 17 | int copyAcrossVolumes(Volume* volume1, Volume* volume2, char* path1, char* path2); 18 | 19 | void hfs_untar(Volume* volume, AbstractFile* tarFile); 20 | void hfs_ls(Volume* volume, const char* path); 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /openiboot/includes/i2c.h: -------------------------------------------------------------------------------- 1 | #ifndef I2C_H 2 | #define I2C_H 3 | 4 | #include "openiboot.h" 5 | #include "clock.h" 6 | 7 | typedef enum I2CError { 8 | I2CNoError = 0 9 | } I2CError; 10 | 11 | typedef enum I2CState { 12 | I2CDone = 0, 13 | I2CStart = 1, 14 | I2CSendRegister = 2, 15 | I2CRegistersDone = 3, 16 | I2CSetup = 4, 17 | I2CTx = 5, 18 | I2CRx = 6, 19 | I2CRxSetup = 7, 20 | I2CFinish = 8 21 | } I2CState; 22 | 23 | 24 | typedef struct I2CInfo { 25 | uint32_t field_0; 26 | uint32_t frequency; 27 | I2CError error_code; 28 | int is_write; 29 | int cursor; 30 | I2CState state; 31 | int operation_result; 32 | uint32_t address; 33 | uint32_t iiccon_settings; 34 | uint32_t current_iicstat; 35 | int num_regs; 36 | const uint8_t* registers; 37 | int bufferLen; 38 | uint8_t* buffer; 39 | uint32_t iic_scl_gpio; 40 | uint32_t iic_sda_gpio; 41 | uint32_t register_IICCON; 42 | uint32_t register_IICSTAT; 43 | uint32_t register_IICADD; 44 | uint32_t register_IICDS; 45 | uint32_t register_IICLC; 46 | uint32_t register_14; 47 | uint32_t register_18; 48 | uint32_t register_1C; 49 | uint32_t register_20; 50 | } I2CInfo; 51 | 52 | int i2c_setup(); 53 | I2CError i2c_rx(int bus, int iicaddr, const uint8_t* registers, int num_regs, void* buffer, int len); 54 | I2CError i2c_tx(int bus, int iicaddr, void* buffer, int len); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /openiboot/includes/interrupt.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERRUPT_H 2 | #define INTERRUPT_H 3 | 4 | #include "openiboot.h" 5 | #include "hardware/interrupt.h" 6 | 7 | typedef void (*InterruptServiceRoutine)(uint32_t token); 8 | 9 | typedef struct InterruptHandler { 10 | InterruptServiceRoutine handler; 11 | uint32_t token; 12 | uint32_t useEdgeIC; 13 | } InterruptHandler; 14 | 15 | extern InterruptHandler InterruptHandlerTable[VIC_MaxInterrupt]; 16 | 17 | int interrupt_setup(); 18 | int interrupt_install(int irq_no, InterruptServiceRoutine handler, uint32_t token); 19 | int interrupt_enable(int irq_no); 20 | int interrupt_disable(int irq_no); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /openiboot/includes/lcd.h: -------------------------------------------------------------------------------- 1 | #ifndef LCD_H 2 | #define LCD_H 3 | 4 | #include "openiboot.h" 5 | #include "clock.h" 6 | 7 | typedef enum ColorSpace { 8 | RGB565 = 3, 9 | RGB888 = 6 10 | } ColorSpace; 11 | 12 | typedef struct LCDInfo { 13 | FrequencyBase freqBase; 14 | uint32_t pixelsPerSecond; 15 | uint32_t width; 16 | uint32_t horizontalBackPorch; 17 | uint32_t horizontalFrontPorch; 18 | uint32_t horizontalSyncPulseWidth; 19 | uint32_t height; 20 | uint32_t verticalBackPorch; 21 | uint32_t verticalFrontPorch; 22 | uint32_t verticalSyncPulseWidth; 23 | uint32_t IVClk; 24 | uint32_t IHSync; 25 | uint32_t IVSync; 26 | uint32_t IVDen; 27 | uint32_t OTFClockDivisor; 28 | } LCDInfo; 29 | 30 | struct Framebuffer; 31 | 32 | typedef void (*HLineFunc)(struct Framebuffer* framebuffer, int start, int line_no, int length, int fill); 33 | typedef void (*VLineFunc)(struct Framebuffer* framebuffer, int start, int line_no, int length, int fill); 34 | 35 | typedef struct Framebuffer { 36 | volatile uint32_t* buffer; 37 | uint32_t width; 38 | uint32_t height; 39 | uint32_t lineWidth; 40 | ColorSpace colorSpace; 41 | HLineFunc hline; 42 | VLineFunc vline; 43 | } Framebuffer; 44 | 45 | typedef struct Window { 46 | int created; 47 | int width; 48 | int height; 49 | uint32_t lineBytes; 50 | Framebuffer framebuffer; 51 | uint32_t* lcdConPtr; 52 | uint32_t lcdCon[2]; 53 | } Window; 54 | 55 | typedef struct GammaTable { 56 | uint32_t data[18]; 57 | } GammaTable; 58 | 59 | typedef struct GammaTableDescriptor { 60 | uint32_t panelIDMatch; 61 | uint32_t panelIDMask; 62 | GammaTable table0; 63 | GammaTable table1; 64 | GammaTable table2; 65 | } GammaTableDescriptor; 66 | 67 | extern int LCDInitRegisterCount; 68 | extern const uint16_t* LCDInitRegisters; 69 | extern uint32_t LCDPanelID; 70 | 71 | extern Window* currentWindow; 72 | extern volatile uint32_t* CurFramebuffer; 73 | extern uint32_t NextFramebuffer; 74 | 75 | int lcd_setup(); 76 | void lcd_fill(uint32_t color); 77 | void lcd_shutdown(); 78 | void lcd_set_backlight_level(int level); 79 | void lcd_window_address(int window, uint32_t framebuffer); 80 | 81 | #endif 82 | 83 | -------------------------------------------------------------------------------- /openiboot/includes/menu.h: -------------------------------------------------------------------------------- 1 | #ifndef MENU_H 2 | #define MENU_H 3 | 4 | #include "openiboot.h" 5 | 6 | int menu_setup(int timeout); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /openiboot/includes/miu.h: -------------------------------------------------------------------------------- 1 | #ifndef MIU_H 2 | #define MIU_H 3 | 4 | #include "openiboot.h" 5 | 6 | int miu_setup(); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /openiboot/includes/mmu.h: -------------------------------------------------------------------------------- 1 | #ifndef MMU_H 2 | #define MMU_H 3 | 4 | #include "openiboot.h" 5 | 6 | #define MMU_SECTION_SIZE 0x100000 7 | #define MMU_SECTION_MASK 0xFFF00000 8 | 9 | #define MMU_SECTION 0x2 10 | #define MMU_AP_NOACCESS 0x0 11 | #define MMU_AP_PRIVILEGEDONLY 0xA00 12 | #define MMU_AP_BOTH 0xB00 13 | #define MMU_AP_BOTHWRITE 0xC00 14 | #define MMU_EXECUTENEVER 0x10 15 | #define MMU_CACHEABLE 0x8 16 | #define MMU_BUFFERABLE 0x4 17 | 18 | extern uint32_t* CurrentPageTable; 19 | 20 | int mmu_setup(); 21 | void mmu_enable(); 22 | void mmu_disable(); 23 | void mmu_map_section(uint32_t section, uint32_t target, Boolean cacheable, Boolean bufferable); 24 | void mmu_map_section_range(uint32_t rangeStart, uint32_t rangeEnd, uint32_t target, Boolean cacheable, Boolean bufferable); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /openiboot/includes/multitouch.h: -------------------------------------------------------------------------------- 1 | #ifndef MULTITOUCH_H 2 | #define MULTITOUCH_H 3 | 4 | #include "openiboot.h" 5 | 6 | typedef struct MTFrameHeader 7 | { 8 | uint8_t type; 9 | uint8_t frameNum; 10 | uint8_t headerLen; 11 | uint8_t unk_3; 12 | uint32_t timestamp; 13 | uint8_t unk_8; 14 | uint8_t unk_9; 15 | uint8_t unk_A; 16 | uint8_t unk_B; 17 | uint16_t unk_C; 18 | uint16_t isImage; 19 | 20 | uint8_t numFingers; 21 | uint8_t fingerDataLen; 22 | uint16_t unk_12; 23 | uint16_t unk_14; 24 | uint16_t unk_16; 25 | } MTFrameHeader; 26 | 27 | typedef struct FingerData 28 | { 29 | uint8_t id; 30 | uint8_t event; 31 | uint8_t unk_2; 32 | uint8_t unk_3; 33 | int16_t x; 34 | int16_t y; 35 | int16_t velX; 36 | int16_t velY; 37 | uint16_t radius2; 38 | uint16_t radius3; 39 | uint16_t angle; 40 | uint16_t radius1; 41 | uint16_t contactDensity; 42 | uint16_t unk_16; 43 | uint16_t unk_18; 44 | uint16_t unk_1A; 45 | } FingerData; 46 | 47 | #ifdef CONFIG_IPHONE 48 | int multitouch_setup(const uint8_t* ASpeedFirmware, int ASpeedFirmwareLen, const uint8_t* mainFirmware, int mainFirmwareLen); 49 | #else 50 | int multitouch_setup(const uint8_t* constructedFirmware, int constructedFirmwareLen); 51 | #endif 52 | 53 | void multitouch_on(); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /openiboot/includes/nand.h: -------------------------------------------------------------------------------- 1 | #ifndef NAND_H 2 | #define NAND_H 3 | 4 | #include "openiboot.h" 5 | 6 | #define ERROR_ARG 0x80010000 7 | #define ERROR_NAND 0x80020000 8 | #define ERROR_TIMEOUT 0x1F 9 | #define ERROR_ECC 0x17 10 | #define ERROR_EMPTYBLOCK 0x1 11 | 12 | typedef struct NANDDeviceType { 13 | uint32_t id; 14 | uint16_t blocksPerBank; 15 | uint16_t pagesPerBlock; 16 | uint16_t sectorsPerPage; 17 | uint16_t bytesPerSpare; 18 | uint8_t WPPulseTime; 19 | uint8_t WEHighHoldTime; 20 | uint8_t NANDSetting3; 21 | uint8_t NANDSetting4; 22 | uint32_t userSuBlksTotal; 23 | uint32_t ecc1; 24 | uint32_t ecc2; 25 | } NANDDeviceType; 26 | 27 | typedef struct NANDFTLData { 28 | uint16_t sysSuBlks; 29 | uint16_t field_2; 30 | uint16_t field_4; // reservoir blocks? 31 | uint16_t field_6; 32 | uint16_t field_8; 33 | } NANDFTLData; 34 | 35 | typedef struct SpareData { 36 | union { 37 | struct { 38 | uint32_t logicalPageNumber; 39 | uint32_t usn; 40 | } __attribute__ ((packed)) user; 41 | 42 | struct { 43 | uint32_t usnDec; 44 | uint16_t idx; 45 | uint8_t field_6; 46 | uint8_t field_7; 47 | } __attribute__ ((packed)) meta; 48 | }; 49 | 50 | uint8_t type2; 51 | uint8_t type1; 52 | uint8_t eccMark; 53 | uint8_t field_B; 54 | 55 | } __attribute__ ((packed)) SpareData; 56 | 57 | typedef struct NANDData { 58 | uint32_t field_0; 59 | uint16_t field_4; 60 | uint16_t sectorsPerPage; 61 | uint16_t pagesPerBlock; 62 | uint16_t pagesPerSuBlk; 63 | uint32_t pagesPerBank; 64 | uint32_t pagesTotal; 65 | uint16_t suBlksTotal; 66 | uint16_t userSuBlksTotal; 67 | uint32_t userPagesTotal; 68 | uint16_t blocksPerBank; 69 | uint16_t bytesPerPage; 70 | uint16_t bytesPerSpare; 71 | uint16_t field_22; 72 | uint32_t field_24; 73 | uint32_t DeviceID; 74 | uint16_t banksTotal; 75 | uint8_t field_2E; 76 | uint8_t field_2F; 77 | int* banksTable; 78 | } NANDData; 79 | 80 | extern int HasNANDInit; 81 | 82 | int nand_setup(); 83 | int nand_bank_reset(int bank, int timeout); 84 | int nand_read(int bank, int page, uint8_t* buffer, uint8_t* spare, int doECC, int checkBadBlocks); 85 | int nand_read_multiple(uint16_t* bank, uint32_t* pages, uint8_t* main, SpareData* spare, int pagesCount); 86 | int nand_read_alternate_ecc(int bank, int page, uint8_t* buffer); 87 | int nand_erase(int bank, int block); 88 | int nand_write(int bank, int page, uint8_t* buffer, uint8_t* spare, int doECC); 89 | int nand_read_status(); 90 | int nand_calculate_ecc(uint8_t* data, uint8_t* ecc); 91 | NANDData* nand_get_geometry(); 92 | NANDFTLData* nand_get_ftl_data(); 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /openiboot/includes/nor.h: -------------------------------------------------------------------------------- 1 | #ifndef NOR_H 2 | #define NOR_H 3 | 4 | #include "openiboot.h" 5 | 6 | int nor_setup(); 7 | 8 | typedef struct NorInfo { 9 | 10 | } NorInfo; 11 | 12 | int nor_write_word(uint32_t offset, uint16_t data); 13 | uint16_t nor_read_word(uint32_t offset); 14 | int nor_erase_sector(uint32_t offset); 15 | 16 | void nor_read(void* buffer, int offset, int len); 17 | int nor_write(void* buffer, int offset, int len); 18 | 19 | int getNORSectorSize(); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /openiboot/includes/nvram.h: -------------------------------------------------------------------------------- 1 | #ifndef NVRAM_H 2 | #define NVRAM_H 3 | 4 | #include "openiboot.h" 5 | 6 | #define NVRAM_START 0xFC000 7 | #define NVRAM_SIZE 0x2000 8 | 9 | typedef struct NVRamInfo { 10 | uint8_t ckByteSeed; 11 | uint8_t ckByte; 12 | uint16_t size; 13 | char type[12]; 14 | } __attribute__ ((packed)) NVRamInfo; 15 | 16 | typedef struct NVRamData { 17 | uint32_t adler; 18 | uint32_t epoch; 19 | } NVRamData; 20 | 21 | typedef struct NVRamAtom { 22 | NVRamInfo* info; 23 | uint32_t size; 24 | struct NVRamAtom* next; 25 | uint8_t* data; 26 | } NVRamAtom; 27 | 28 | typedef struct EnvironmentVar { 29 | char* name; 30 | char* value; 31 | struct EnvironmentVar* next; 32 | } EnvironmentVar; 33 | 34 | int nvram_setup(); 35 | void nvram_listvars(); 36 | const char* nvram_getvar(const char* name); 37 | void nvram_setvar(const char* name, const char* value); 38 | void nvram_save(); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /openiboot/includes/openiboot-asmhelpers.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENIBOOT_ASMHELPERS_H 2 | #define OPENIBOOT_ASMHELPERS_H 3 | 4 | void IncrementCriticalLock(); 5 | void DecrementCriticalLock(); 6 | void EnterCriticalSection(); 7 | void LeaveCriticalSection(); 8 | 9 | void EnableCPUIRQ(); 10 | void EnableCPUFIQ(); 11 | void DisableCPUIRQ(); 12 | void DisableCPUFIQ(); 13 | 14 | uint32_t ReadAuxiliaryControlRegister(); 15 | void ClearCPUInstructionCache(); 16 | uint32_t ReadControlRegisterConfigData(); 17 | 18 | uint32_t ReadControlRegisterConfigData(); 19 | void WriteControlRegisterConfigData(uint32_t regData); 20 | uint32_t ReadAuxiliaryControlRegister(); 21 | void WriteAuxiliaryControlRegister(uint32_t regData); 22 | void WriteDomainAccessControlRegister(uint32_t regData); 23 | uint32_t ReadDataFaultStatusRegister(); 24 | uint32_t ReadFaultAddressRegister(); 25 | void WritePeripheralPortMemoryRemapRegister(uint32_t regData); 26 | void GiveFullAccessCP10CP11(); 27 | void EnableVFP(); 28 | void WaitForInterrupt(); 29 | void WriteTranslationTableBaseRegister0(void* translationTableBase); 30 | uint32_t ReadTranslationTableBaseRegister0(); 31 | 32 | void InvalidateUnifiedTLBUnlockedEntries(); 33 | void ClearCPUInstructionCache(); 34 | void CleanDataCacheLineMVA(); 35 | void CleanCPUDataCache(); 36 | void InvalidateCPUDataCache(); 37 | void CleanAndInvalidateCPUDataCache(); 38 | void ClearCPUCaches(); 39 | 40 | void CallArm(uint32_t address); 41 | void CallThumb(uint32_t address); 42 | 43 | void Reboot(); 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /openiboot/includes/openiboot.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENIBOOT_H 2 | #define OPENIBOOT_H 3 | 4 | typedef unsigned long long uint64_t; 5 | typedef unsigned int uint32_t; 6 | typedef unsigned short uint16_t; 7 | typedef unsigned char uint8_t; 8 | typedef signed long long int64_t; 9 | typedef signed int int32_t; 10 | typedef signed short int16_t; 11 | typedef signed char int8_t; 12 | typedef long unsigned int size_t; 13 | typedef signed int intptr_t; 14 | 15 | #ifdef DEBUG 16 | #define OPENIBOOT_VERSION_DEBUG " (DEBUG)" 17 | #else 18 | #define OPENIBOOT_VERSION_DEBUG "" 19 | #endif 20 | 21 | #ifdef CONFIG_IPHONE 22 | #define OPENIBOOT_VERSION_CONFIG " for iPhone 2G" 23 | #endif 24 | #ifdef CONFIG_IPOD 25 | #define OPENIBOOT_VERSION_CONFIG " for iPod touch 1G" 26 | #endif 27 | #ifdef CONFIG_3G 28 | #define OPENIBOOT_VERSION_CONFIG " for iPhone 3G" 29 | #endif 30 | 31 | #define XSTRINGIFY(s) STRINGIFY(s) 32 | #define STRINGIFY(s) #s 33 | #define OPENIBOOT_VERSION_STR "openiboot " XSTRINGIFY(OPENIBOOT_VERSION) " commit " XSTRINGIFY(OPENIBOOT_VERSION_BUILD) OPENIBOOT_VERSION_DEBUG OPENIBOOT_VERSION_CONFIG 34 | 35 | extern void* _start; 36 | extern void* OpenIBootEnd; 37 | extern int received_file_size; 38 | 39 | typedef enum Boolean { 40 | FALSE = 0, 41 | TRUE = 1 42 | } Boolean; 43 | 44 | typedef enum OnOff { 45 | OFF = 0, 46 | ON = 1 47 | } OnOff; 48 | 49 | #ifndef NULL 50 | #define NULL 0 51 | #endif 52 | #define uSecPerSec 1000000 53 | 54 | typedef struct Event Event; 55 | 56 | typedef void (*TaskRoutineFunction)(void* opaque); 57 | typedef void (*EventHandler)(Event* event, void* opaque); 58 | 59 | typedef struct LinkedList { 60 | void* prev; 61 | void* next; 62 | } __attribute__ ((packed)) LinkedList; 63 | 64 | typedef struct TaskRegisterState { 65 | uint32_t r4; 66 | uint32_t r5; 67 | uint32_t r6; 68 | uint32_t r7; 69 | uint32_t r8; 70 | uint32_t r9; 71 | uint32_t r10; 72 | uint32_t r11; 73 | uint32_t sp; 74 | uint32_t lr; 75 | } __attribute__ ((packed)) TaskRegisterState; 76 | 77 | typedef enum TaskState { 78 | TASK_READY = 1, 79 | TASK_RUNNING = 2, 80 | TASK_SLEEPING = 4, 81 | TASK_STOPPED = 5 82 | } TaskState; 83 | 84 | #define TaskDescriptorIdentifier1 0x7461736b 85 | #define TaskDescriptorIdentifier2 0x74736b32 86 | 87 | struct Event { 88 | LinkedList list; 89 | uint64_t deadline; 90 | uint64_t interval; 91 | EventHandler handler; 92 | void* opaque; 93 | }; 94 | 95 | typedef struct TaskDescriptor { 96 | uint32_t identifier1; 97 | LinkedList taskList; 98 | LinkedList runqueueList; 99 | TaskState state; 100 | uint32_t criticalSectionNestCount; 101 | TaskRegisterState savedRegisters; 102 | Event sleepEvent; 103 | LinkedList linked_list_3; 104 | uint32_t exitState; 105 | TaskRoutineFunction taskRoutine; 106 | void* unknown_passed_value; 107 | void* storage; 108 | uint32_t storageSize; 109 | char taskName[16]; 110 | uint32_t identifier2; 111 | } __attribute__ ((packed)) TaskDescriptor; 112 | 113 | extern TaskDescriptor* CurrentRunning; 114 | 115 | /* 116 | * Macros 117 | */ 118 | 119 | #define GET_REG(x) (*((volatile uint32_t*)(x))) 120 | #define SET_REG(x, y) (*((volatile uint32_t*)(x)) = (y)) 121 | #define GET_REG32(x) GET_REG(x) 122 | #define SET_REG32(x, y) SET_REG(x, y) 123 | #define GET_REG16(x) (*((volatile uint16_t*)(x))) 124 | #define SET_REG16(x, y) (*((volatile uint16_t*)(x)) = (y)) 125 | #define GET_REG8(x) (*((volatile uint8_t*)(x))) 126 | #define SET_REG8(x, y) (*((volatile uint8_t*)(x)) = (y)) 127 | #define GET_BITS(x, start, length) ((((uint32_t)(x)) << (32 - ((start) + (length)))) >> (32 - (length))) 128 | 129 | #endif 130 | -------------------------------------------------------------------------------- /openiboot/includes/piezo.h: -------------------------------------------------------------------------------- 1 | #ifndef PIEZO_H 2 | #define PIEZO_H 3 | 4 | void piezo_buzz(int hertz, unsigned int microseconds); 5 | void piezo_play(const char* command); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /openiboot/includes/pmu.h: -------------------------------------------------------------------------------- 1 | #ifndef PMU_H 2 | #define PMU_H 3 | 4 | #include "openiboot.h" 5 | 6 | typedef struct PMURegisterData { 7 | uint8_t reg; 8 | uint8_t data; 9 | } PMURegisterData; 10 | 11 | typedef enum PowerSupplyType { 12 | PowerSupplyTypeError, 13 | PowerSupplyTypeBattery, 14 | PowerSupplyTypeFirewire, 15 | PowerSupplyTypeUSBHost, 16 | PowerSupplyTypeUSBBrick500mA, 17 | PowerSupplyTypeUSBBrick1000mA 18 | } PowerSupplyType; 19 | 20 | #define PMU_IBOOTSTATE 0xF 21 | #define PMU_IBOOTDEBUG 0x0 22 | #define PMU_IBOOTSTAGE 0x1 23 | #define PMU_IBOOTERRORCOUNT 0x2 24 | #define PMU_IBOOTERRORSTAGE 0x3 25 | 26 | int pmu_setup(); 27 | void pmu_poweroff(); 28 | void pmu_set_iboot_stage(uint8_t stage); 29 | int pmu_get_gpmem_reg(int reg, uint8_t* out); 30 | int pmu_set_gpmem_reg(int reg, uint8_t data); 31 | int pmu_get_reg(int reg); 32 | int pmu_get_regs(int reg, uint8_t* out, int count); 33 | int pmu_write_reg(int reg, int data, int verify); 34 | int pmu_write_regs(const PMURegisterData* regs, int num); 35 | int pmu_get_battery_voltage(); 36 | PowerSupplyType pmu_get_power_supply(); 37 | void pmu_charge_settings(int UseUSB, int SuspendUSB, int StopCharger); 38 | uint64_t pmu_get_epoch(); 39 | void epoch_to_date(uint64_t epoch, int* year, int* month, int* day, int* day_of_week, int* hour, int* minute, int* second); 40 | void pmu_date(int* year, int* month, int* day, int* day_of_week, int* hour, int* minute, int* second); 41 | const char* get_dayofweek_str(int day); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /openiboot/includes/power.h: -------------------------------------------------------------------------------- 1 | #ifndef POWER_H 2 | #define POWER_H 3 | 4 | #include "openiboot.h" 5 | 6 | int power_setup(); 7 | int power_ctrl(uint32_t device, OnOff on_off); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /openiboot/includes/printf.h: -------------------------------------------------------------------------------- 1 | #ifndef PRINTF_H 2 | #define PRINTF_H 3 | 4 | int vsprintf(char *buf, const char *fmt, va_list args); 5 | int sprintf(char *buf, const char *fmt, ...); 6 | int vprintf(const char *fmt, va_list args); 7 | int printf(const char *fmt, ...); 8 | int puts(const char *str); 9 | #endif 10 | -------------------------------------------------------------------------------- /openiboot/includes/radio.h: -------------------------------------------------------------------------------- 1 | #ifndef RADIO_H 2 | 3 | int radio_setup(); 4 | int radio_write(const char* str); 5 | int radio_read(char* buf, int len); 6 | int radio_wait_for_ok(int tries); 7 | int radio_cmd(const char* cmd, int tries); 8 | 9 | void radio_nvram_list(); 10 | 11 | void vibrator_loop(int frequency, int period, int timeOn); 12 | void vibrator_once(int frequency, int time); 13 | void vibrator_off(); 14 | 15 | int speaker_setup(); 16 | void loudspeaker_vol(int vol); 17 | void speaker_vol(int vol); 18 | int radio_register(int timeout); 19 | void radio_call(const char* number); 20 | void radio_hangup(); 21 | int radio_nvram_get(int type_in, uint8_t** data_out); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /openiboot/includes/scripting.h: -------------------------------------------------------------------------------- 1 | #ifndef SCRIPTING_H 2 | #define SCRIPTING_H 3 | 4 | #include "openiboot.h" 5 | 6 | void startScripting(); 7 | 8 | //static void processCommand(char*); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /openiboot/includes/sdio.h: -------------------------------------------------------------------------------- 1 | #ifndef SDIO_H 2 | #define SDIO_H 3 | 4 | #include "openiboot.h" 5 | #include "interrupt.h" 6 | 7 | int sdio_setup(); 8 | 9 | void sdio_status(); 10 | 11 | int sdio_set_block_size(int function, int blocksize); 12 | int sdio_claim_irq(int function, InterruptServiceRoutine handler, uint32_t token); 13 | int sdio_enable_func(int function); 14 | uint8_t sdio_readb(int function, uint32_t address, int* err_ret); 15 | void sdio_writeb(int function, uint8_t val, uint32_t address, int* err_ret); 16 | int sdio_writesb(int function, uint32_t address, void* src, int count); 17 | int sdio_readsb(int function, void* dst, uint32_t address, int count); 18 | int sdio_memcpy_toio(int function, uint32_t address, void* src, int count); 19 | int sdio_memcpy_fromio(int function, void* dst, uint32_t address, int count); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /openiboot/includes/sha1.h: -------------------------------------------------------------------------------- 1 | #ifndef SHA1_H 2 | 3 | #include "openiboot.h" 4 | 5 | typedef struct { 6 | unsigned long state[5]; 7 | unsigned long count[2]; 8 | unsigned char buffer[64]; 9 | } SHA1_CTX; 10 | 11 | void SHA1Transform(unsigned long state[5], unsigned char buffer[64]); 12 | void SHA1Init(SHA1_CTX* context); 13 | void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len); 14 | void SHA1Final(unsigned char digest[20], SHA1_CTX* context); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /openiboot/includes/spi.h: -------------------------------------------------------------------------------- 1 | #ifndef SPI_H 2 | #define SPI_H 3 | 4 | #include "openiboot.h" 5 | 6 | typedef struct SPIRegister { 7 | uint32_t control; 8 | uint32_t setup; 9 | uint32_t status; 10 | uint32_t unkReg1; 11 | uint32_t txData; 12 | uint32_t rxData; 13 | uint32_t clkDivider; 14 | uint32_t unkReg2; 15 | uint32_t unkReg3; 16 | } SPIRegister; 17 | 18 | typedef enum SPIClockSource { 19 | PCLK = 0, 20 | NCLK = 1 21 | } SPIClockSource; 22 | 23 | typedef enum SPIOption13 { 24 | SPIOption13Setting0 = 8, 25 | SPIOption13Setting1 = 16, 26 | SPIOption13Setting2 = 32 27 | } SPIOption13; 28 | 29 | typedef struct SPIInfo { 30 | int option13; 31 | int isActiveLow; 32 | int lastClockEdgeMissing; 33 | SPIClockSource clockSource; 34 | int baud; 35 | int isMaster; 36 | int option5; 37 | const volatile uint8_t* txBuffer; 38 | volatile int txCurrentLen; 39 | volatile int txTotalLen; 40 | volatile uint8_t* rxBuffer; 41 | volatile int rxCurrentLen; 42 | volatile int rxTotalLen; 43 | volatile int counter; 44 | volatile int txDone; 45 | volatile int rxDone; 46 | } SPIInfo; 47 | 48 | int spi_setup(); 49 | int spi_tx(int port, const uint8_t* buffer, int len, int block, int unknown); 50 | int spi_rx(int port, uint8_t* buffer, int len, int block, int noTransmitJunk); 51 | int spi_txrx(int port, const uint8_t* outBuffer, int outLen, uint8_t* inBuffer, int inLen, int block); 52 | void spi_set_baud(int port, int baud, SPIOption13 option13, int isMaster, int isActiveLow, int lastClockEdgeMissing); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /openiboot/includes/syscfg.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSCFG_H 2 | 3 | #include "openiboot.h" 4 | 5 | #define SCFG_PxCl 0x5078436C 6 | #define SCFG_MtCl 0x4D74436C 7 | 8 | int syscfg_setup(); 9 | uint8_t* syscfg_get_entry(uint32_t type, int* size); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /openiboot/includes/tasks.h: -------------------------------------------------------------------------------- 1 | #ifndef TASKS_H 2 | #define TASKS_H 3 | 4 | #include "openiboot.h" 5 | 6 | int tasks_setup(); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /openiboot/includes/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMER_H 2 | #define TIMER_H 3 | 4 | #include "openiboot.h" 5 | 6 | typedef void (*TimerHandler)(void); 7 | 8 | typedef struct TimerRegisters { 9 | uint32_t config; 10 | uint32_t state; 11 | uint32_t count_buffer; 12 | uint32_t count_buffer2; 13 | uint32_t prescaler; 14 | uint32_t cur_count; 15 | } TimerRegisters; 16 | 17 | typedef struct TimerInfo { 18 | Boolean option6; 19 | uint32_t divider; 20 | uint32_t unknown1; 21 | TimerHandler handler1; 22 | TimerHandler handler2; 23 | TimerHandler handler3; 24 | } TimerInfo; 25 | 26 | extern const TimerRegisters HWTimers[]; 27 | extern TimerInfo Timers[7]; 28 | 29 | int timer_setup(); 30 | int timer_stop_all(); 31 | int timer_on_off(int timer_id, OnOff on_off); 32 | int timer_setup_clk(int timer_id, int type, int divider, uint32_t unknown1); 33 | int timer_init(int timer_id, uint32_t interval, uint32_t interval2, uint32_t prescaler, uint32_t z, Boolean option24, Boolean option28, Boolean option11, Boolean interrupts); 34 | 35 | uint64_t timer_get_system_microtime(); 36 | void timer_get_rtc_ticks(uint64_t* ticks, uint64_t* sec_divisor); 37 | 38 | void udelay(uint64_t delay); 39 | int has_elapsed(uint64_t startTime, uint64_t elapsedTime); 40 | 41 | extern int RTCHasInit; 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /openiboot/includes/uart.h: -------------------------------------------------------------------------------- 1 | #ifndef UART_H 2 | #define UART_H 3 | 4 | #include "openiboot.h" 5 | 6 | #define UART_POLL_MODE 0 7 | 8 | typedef struct UARTSettings { 9 | uint32_t ureg; 10 | uint32_t baud; 11 | uint32_t sample_rate; 12 | OnOff flow_control; 13 | OnOff fifo; 14 | uint32_t mode; 15 | uint32_t clock; 16 | } UARTSettings; 17 | 18 | typedef struct UARTRegisters { 19 | uint32_t ULCON; 20 | uint32_t UCON; 21 | uint32_t UFCON; 22 | uint32_t UMCON; 23 | 24 | uint32_t UTRSTAT; 25 | uint32_t UERSTAT; 26 | uint32_t UFSTAT; 27 | uint32_t UMSTAT; 28 | 29 | uint32_t UTXH; 30 | uint32_t URXH; 31 | uint32_t UBAUD; 32 | uint32_t UDIVSLOT; 33 | } UARTRegisters; 34 | 35 | int uart_setup(); 36 | int uart_set_clk(int ureg, int clock); 37 | int uart_set_sample_rate(int ureg, int rate); 38 | int uart_set_flow_control(int ureg, OnOff flow_control); 39 | int uart_set_mode(int ureg, uint32_t mode); 40 | int uart_set_baud_rate(int ureg, uint32_t baud); 41 | 42 | int uart_write(int ureg, const char *buffer, uint32_t length); 43 | int uart_read(int ureg, char *buffer, uint32_t length, uint64_t timeout); 44 | 45 | extern int UartHasInit; 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /openiboot/includes/util.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_H 2 | #define UTIL_H 3 | 4 | #include "openiboot.h" 5 | #include 6 | 7 | #ifdef DEBUG 8 | #define DebugPrintf bufferPrintf 9 | #else 10 | #define DebugPrintf(...) 11 | #endif 12 | 13 | void panic(); 14 | 15 | void __assert(const char* file, int line, const char* m); 16 | void* memset(void* x, int fill, uint32_t size); 17 | void* memcpy(void* dest, const void* src, uint32_t size); 18 | int strcmp(const char* s1, const char* s2); 19 | char* strchr(const char* s1, int s2); 20 | char* strstr(const char* s1, const char* s2); 21 | char* strdup(const char* str); 22 | char* strcpy(char* dst, const char* src); 23 | int memcmp(const void* s1, const void* s2, uint32_t size); 24 | void* memmove(void *dest, const void* src, size_t length); 25 | size_t strlen(const char* str); 26 | int tolower(int c); 27 | int putchar(int c); 28 | unsigned long int parseNumber(const char* str); 29 | unsigned long int strtoul(const char* str, char** endptr, int base); 30 | char** tokenize(char* commandline, int* argc); 31 | void dump_memory(uint32_t start, int length); 32 | void buffer_dump_memory(uint32_t start, int length); 33 | void hexdump(uint32_t start, int length); 34 | void buffer_dump_memory2(uint32_t start, int length, int width); 35 | int addToBuffer(const char* toBuffer, int len); 36 | void bufferPrint(const char* toBuffer); 37 | void bufferPrintf(const char* format, ...); 38 | void uartPrint(const char* toBuffer); 39 | void uartPrintf(const char* format, ...); 40 | void fbPrintf(const char* format, ...); 41 | void bufferFlush(char* destination, size_t length); 42 | char* getScrollback(); 43 | size_t getScrollbackLen(); 44 | 45 | void hexToBytes(const char* hex, uint8_t** buffer, int* bytes); 46 | void bytesToHex(const uint8_t* buffer, int bytes); 47 | 48 | uint32_t crc32(uint32_t* ckSum, const void *buffer, size_t len); 49 | uint32_t adler32(uint8_t *buf, int32_t len); 50 | 51 | #include "printf.h" 52 | #include "malloc-2.8.3.h" 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /openiboot/includes/wdt.h: -------------------------------------------------------------------------------- 1 | #ifndef WDT_H 2 | #define WDT_H 3 | 4 | #include "openiboot.h" 5 | 6 | int wdt_setup(); 7 | int wdt_counter(); 8 | void wdt_enable(); 9 | void wdt_disable(); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /openiboot/includes/wlan.h: -------------------------------------------------------------------------------- 1 | #ifndef WLAN_H 2 | #define WLAN_H 3 | 4 | int wlan_setup(); 5 | int wlan_prog_helper(const uint8_t * firmware, int size); 6 | int wlan_prog_real(const uint8_t* firmware, size_t size); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /openiboot/includes/wmcodec.h: -------------------------------------------------------------------------------- 1 | struct sound_settings_info { 2 | const char *unit; 3 | char numdecimals; 4 | char steps; 5 | short minval; 6 | short maxval; 7 | short defaultval; 8 | }; 9 | 10 | enum { 11 | SOUND_VOLUME = 0, 12 | SOUND_BASS, 13 | SOUND_TREBLE, 14 | SOUND_BALANCE, 15 | SOUND_CHANNELS, 16 | SOUND_STEREO_WIDTH, 17 | #if defined(HAVE_RECORDING) 18 | SOUND_LEFT_GAIN, 19 | SOUND_RIGHT_GAIN, 20 | SOUND_MIC_GAIN, 21 | #endif 22 | SOUND_BASS_CUTOFF, 23 | SOUND_TREBLE_CUTOFF, 24 | SOUND_LAST_SETTING, /* Keep this last */ 25 | }; 26 | 27 | void audiohw_init(); 28 | void audiohw_postinit(); 29 | void audiohw_play_pcm(const void* addr_in, uint32_t size, int use_speaker); 30 | void audiohw_set_headphone_vol(int vol_l, int vol_r); 31 | void audiohw_set_lineout_vol(int vol_l, int vol_r); 32 | void audiohw_set_aux_vol(int vol_l, int vol_r); 33 | int audiohw_transfers_done(); 34 | void audiohw_pause(); 35 | void audiohw_resume(); 36 | uint32_t audiohw_get_position(); 37 | uint32_t audiohw_get_total(); 38 | void audiohw_mute(int mute); 39 | 40 | void audiohw_switch_normal_call(int in_call); 41 | 42 | #ifdef CONFIG_3G 43 | void audiohw_set_speaker_vol(int vol); 44 | #endif 45 | 46 | 47 | extern const struct sound_settings_info audiohw_settings[]; 48 | -------------------------------------------------------------------------------- /openiboot/interrupt.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "interrupt.h" 3 | #include "hardware/interrupt.h" 4 | #include "hardware/edgeic.h" 5 | #include "util.h" 6 | #include "openiboot-asmhelpers.h" 7 | 8 | int interrupt_setup() { 9 | if((0xfff & (GET_REG(VIC0 + VICPERIPHID0) | (GET_REG(VIC0 + VICPERIPHID1) << 8) | (GET_REG(VIC0 + VICPERIPHID2) << 16) | (GET_REG(VIC0 + VICPERIPHID3) << 24))) != 0x192) { 10 | /* peripheral ID for vic0 doesn't match PL 192, which is the VIC we are expecting */ 11 | return -1; 12 | } 13 | 14 | if((0xfff & (GET_REG(VIC1 + VICPERIPHID0) | (GET_REG(VIC1 + VICPERIPHID1) << 8) | (GET_REG(VIC1 + VICPERIPHID2) << 16) | (GET_REG(VIC1 + VICPERIPHID3) << 24))) != 0x192) { 15 | /* peripheral ID for vic1 doesn't match PL 192, which is the VIC we are expecting */ 16 | return -1; 17 | } 18 | 19 | SET_REG(EDGEIC + EDGEICCONFIG0, EDGEIC_CONFIG0RESET); 20 | SET_REG(EDGEIC + EDGEICCONFIG1, EDGEIC_CONFIG1RESET); 21 | 22 | SET_REG(VIC0 + VICINTENCLEAR, 0xFFFFFFFF); // disable all interrupts 23 | SET_REG(VIC1 + VICINTENCLEAR, 0xFFFFFFFF); 24 | 25 | SET_REG(VIC0 + VICINTSELECT, 0); // 0 means to use IRQs, 1 means to use FIQs, so use all IRQs 26 | SET_REG(VIC1 + VICINTSELECT, 0); 27 | 28 | SET_REG(VIC0 + VICSWPRIORITYMASK, 0xffff); // unmask all 16 interrupt levels 29 | SET_REG(VIC1 + VICSWPRIORITYMASK, 0xffff); 30 | 31 | // Set interrupt vector addresses to the interrupt number. This will signal the interrupt handler to consult the handler tables 32 | int i; 33 | for(i = 0; i < VIC_InterruptSeparator; i++) { 34 | SET_REG(VIC0 + VICVECTADDRS + (i * 4), i); 35 | SET_REG(VIC1 + VICVECTADDRS + (i * 4), VIC_InterruptSeparator + i); 36 | } 37 | 38 | memset(InterruptHandlerTable, 0, sizeof(InterruptHandlerTable)); 39 | 40 | return 0; 41 | } 42 | 43 | int interrupt_install(int irq_no, InterruptServiceRoutine handler, uint32_t token) { 44 | if(irq_no >= VIC_MaxInterrupt) { 45 | return -1; 46 | } 47 | 48 | EnterCriticalSection(); 49 | InterruptHandlerTable[irq_no].handler = handler; 50 | InterruptHandlerTable[irq_no].token = token; 51 | InterruptHandlerTable[irq_no].useEdgeIC = 0; 52 | LeaveCriticalSection(); 53 | 54 | return 0; 55 | } 56 | 57 | int interrupt_enable(int irq_no) { 58 | if(irq_no >= VIC_MaxInterrupt) { 59 | return -1; 60 | } 61 | 62 | EnterCriticalSection(); 63 | if(irq_no < VIC_InterruptSeparator) { 64 | SET_REG(VIC0 + VICINTENABLE, GET_REG(VIC0 + VICINTENABLE) | (1 << irq_no)); 65 | } else { 66 | SET_REG(VIC1 + VICINTENABLE, GET_REG(VIC1 + VICINTENABLE) | (1 << (irq_no - VIC_InterruptSeparator))); 67 | } 68 | LeaveCriticalSection(); 69 | 70 | return 0; 71 | } 72 | 73 | int interrupt_disable(int irq_no) { 74 | if(irq_no >= VIC_MaxInterrupt) { 75 | return -1; 76 | } 77 | 78 | EnterCriticalSection(); 79 | if(irq_no < VIC_InterruptSeparator) { 80 | SET_REG(VIC0 + VICINTENABLE, GET_REG(VIC0 + VICINTENABLE) & ~(1 << irq_no)); 81 | } else { 82 | SET_REG(VIC1 + VICINTENABLE, GET_REG(VIC1 + VICINTENABLE) & ~(1 << (irq_no - VIC_InterruptSeparator))); 83 | } 84 | LeaveCriticalSection(); 85 | 86 | return 0; 87 | } 88 | 89 | -------------------------------------------------------------------------------- /openiboot/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_bottom_bits_38100000(1); 15 | 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/mk8900image/Makefile: -------------------------------------------------------------------------------- 1 | MKIMAGEOBJS=mk8900image.o 2 | LIBRARIES=-L/usr/lib -lm -ldl -lpng -lcrypto -lz 3 | CFLAGS += 4 | 5 | ifeq ($(ARCH), x86_64) 6 | LIBXPWN=x86_64/libxpwn.a x86_64/libcommon.a 7 | else 8 | LIBXPWN=x86/libxpwn.a x86/libcommon.a 9 | endif 10 | 11 | %.o: %.c 12 | @echo "Compiling $@" 13 | @$(CC) $(CFLAGS) -c $< -o $@ 14 | 15 | mk8900image: $(MKIMAGEOBJS) $(LIBXPWN) 16 | @echo "Building $@" 17 | @$(CC) $(CFLAGS) $(MKIMAGEOBJS) $(LIBXPWN) $(LIBRARIES) -o $@ 18 | 19 | clean: 20 | @rm -f *.o 21 | @rm -f mk8900image 22 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/mk8900image/blank: -------------------------------------------------------------------------------- 1 | This file is intentionally left blank. 2 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/mk8900image/iboot-template.img2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/mk8900image/iboot-template.img2 -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/mk8900image/iphonelinux.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/mk8900image/iphonelinux.der -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/mk8900image/mk8900image.c: -------------------------------------------------------------------------------- 1 | #include "nor_files.h" 2 | #include 3 | #include 4 | #define BUFFERSIZE (1024*1024) 5 | 6 | #include 7 | 8 | char createImage(char* inElf, size_t inElfSize, char** outImage, size_t* outImageSize) { 9 | Elf32_Ehdr* elf_hdr = (Elf32_Ehdr*) inElf; 10 | size_t maxmem; 11 | 12 | if(strncmp(elf_hdr->e_ident, ELFMAG, 4) != 0 ) { 13 | return 0; 14 | } 15 | 16 | Elf32_Phdr* phdrs = (Elf32_Phdr*) (inElf + elf_hdr->e_phoff); 17 | int i; 18 | 19 | maxmem = 0; 20 | for(i = 0; i < elf_hdr->e_phnum; i++) { 21 | int memExtent = phdrs[i].p_vaddr + phdrs[i].p_memsz - elf_hdr->e_entry; 22 | if(maxmem < memExtent) { 23 | maxmem = memExtent; 24 | } 25 | } 26 | 27 | *outImageSize = maxmem; 28 | *outImage = (char*) malloc(*outImageSize); 29 | memset(*outImage, 0, *outImageSize); 30 | for(i = 0; i < elf_hdr->e_phnum; i++) { 31 | memcpy(*outImage + phdrs[i].p_vaddr - elf_hdr->e_entry, inElf + phdrs[i].p_offset, phdrs[i].p_filesz); 32 | } 33 | 34 | return 1; 35 | } 36 | 37 | int main(int argc, char* argv[]) { 38 | char* inElf; 39 | size_t inElfSize; 40 | char* outImage; 41 | size_t outImageSize; 42 | init_libxpwn(); 43 | 44 | if(argc < 3) { 45 | printf("usage: %s [template] [certificate]\n", argv[0]); 46 | return 0; 47 | } 48 | 49 | AbstractFile* template = NULL; 50 | if(argc >= 4) { 51 | template = createAbstractFileFromFile(fopen(argv[3], "rb")); 52 | if(!template) { 53 | fprintf(stderr, "error: cannot open template\n"); 54 | return 1; 55 | } 56 | } 57 | 58 | AbstractFile* certificate = NULL; 59 | if(argc >= 5) { 60 | certificate = createAbstractFileFromFile(fopen(argv[4], "rb")); 61 | if(!certificate) { 62 | fprintf(stderr, "error: cannot open certificate\n"); 63 | return 5; 64 | } 65 | } 66 | 67 | AbstractFile* inFile = openAbstractFile(createAbstractFileFromFile(fopen(argv[1], "rb"))); 68 | if(!inFile) { 69 | fprintf(stderr, "error: cannot open infile\n"); 70 | return 2; 71 | } 72 | 73 | AbstractFile* outFile = createAbstractFileFromFile(fopen(argv[2], "wb")); 74 | if(!outFile) { 75 | fprintf(stderr, "error: cannot open outfile\n"); 76 | return 3; 77 | } 78 | 79 | AbstractFile* newFile; 80 | 81 | if(template) { 82 | if(certificate != NULL) { 83 | newFile = duplicateAbstractFile2(template, outFile, NULL, NULL, certificate); 84 | } else { 85 | newFile = duplicateAbstractFile(template, outFile); 86 | } 87 | if(!newFile) { 88 | fprintf(stderr, "error: cannot duplicate file from provided template\n"); 89 | return 4; 90 | } 91 | } else { 92 | newFile = outFile; 93 | } 94 | 95 | inElfSize = (size_t) inFile->getLength(inFile); 96 | inElf = (char*) malloc(inElfSize); 97 | inFile->read(inFile, inElf, inElfSize); 98 | inFile->close(inFile); 99 | 100 | if(!createImage(inElf, inElfSize, &outImage, &outImageSize)) { 101 | outImage = inElf; 102 | outImageSize = inElfSize; 103 | } else { 104 | free(inElf); 105 | } 106 | 107 | newFile->write(newFile, outImage, outImageSize); 108 | newFile->close(newFile); 109 | 110 | 111 | 112 | free(outImage); 113 | 114 | return 0; 115 | } 116 | 117 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/mk8900image/template-3g.img3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/mk8900image/template-3g.img3 -------------------------------------------------------------------------------- /openiboot/mk8900image/template-ipod.img3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/mk8900image/template-ipod.img3 -------------------------------------------------------------------------------- /openiboot/mk8900image/template-wtf.img2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/mk8900image/template-wtf.img2 -------------------------------------------------------------------------------- /openiboot/mk8900image/template.img2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/mk8900image/template.img2 -------------------------------------------------------------------------------- /openiboot/mk8900image/template.img3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/mk8900image/template.img3 -------------------------------------------------------------------------------- /openiboot/mk8900image/x86/libcommon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/mk8900image/x86/libcommon.a -------------------------------------------------------------------------------- /openiboot/mk8900image/x86/libxpwn.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/mk8900image/x86/libxpwn.a -------------------------------------------------------------------------------- /openiboot/mk8900image/x86_64/libcommon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/mk8900image/x86_64/libcommon.a -------------------------------------------------------------------------------- /openiboot/mk8900image/x86_64/libxpwn.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/planetbeing/iphonelinux/4f5978c271d9bf913c94870380e305992f23bfb8/openiboot/mk8900image/x86_64/libxpwn.a -------------------------------------------------------------------------------- /openiboot/mmu.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "mmu.h" 3 | #include "hardware/s5l8900.h" 4 | #include "hardware/arm.h" 5 | #include "openiboot-asmhelpers.h" 6 | 7 | uint32_t* CurrentPageTable; 8 | 9 | static void initialize_pagetable(); 10 | 11 | int mmu_setup() { 12 | CurrentPageTable = (uint32_t*) PageTable; 13 | 14 | // Initialize the page table 15 | 16 | initialize_pagetable(); 17 | 18 | // Implement the page table 19 | 20 | // Disable checking TLB permissions for domain 0, which is the only domain we're using so anyone can access 21 | // anywhere in memory, since we trust ourselves. 22 | WriteDomainAccessControlRegister(ARM11_DomainAccessControl_D0_ALL); 23 | 24 | WriteTranslationTableBaseRegister0(CurrentPageTable); 25 | InvalidateUnifiedTLBUnlockedEntries(); 26 | mmu_enable(); 27 | InvalidateUnifiedTLBUnlockedEntries(); 28 | 29 | return 0; 30 | } 31 | 32 | void mmu_enable() { 33 | WriteControlRegisterConfigData(ReadControlRegisterConfigData() | 0x1); 34 | } 35 | 36 | void mmu_disable() { 37 | WriteControlRegisterConfigData(ReadControlRegisterConfigData() & ~0x4); 38 | WriteControlRegisterConfigData(ReadControlRegisterConfigData() & ~0x1); 39 | } 40 | 41 | void initialize_pagetable() { 42 | // Initialize the page table with a default identity mapping 43 | mmu_map_section_range(MemoryStart, MemoryEnd, MemoryStart, FALSE, FALSE); 44 | 45 | // Now we get to setup default mappings that we will need 46 | mmu_map_section_range(0x08000000, 0x10000000, 0x08000000, TRUE, TRUE); // unknown, but mapped by iPhone 47 | mmu_map_section(AMC0, AMC0, TRUE, TRUE); 48 | 49 | // Make our own code cacheable and bufferable 50 | //mmu_map_section_range(OpenIBootLoad, (uint32_t) &OpenIBootEnd, OpenIBootLoad, TRUE, TRUE); 51 | 52 | // Make ROM buffer cacheable and bufferable 53 | mmu_map_section(ROM, ROM, TRUE, TRUE); 54 | 55 | // Remap exception vector so we can actually get interrupts 56 | //mmu_map_section(ExceptionVector, OpenIBootLoad, TRUE, TRUE); 57 | 58 | // Remap upper half of memory to the lower half 59 | mmu_map_section_range(MemoryHigher, MemoryEnd, MemoryStart, FALSE, FALSE); 60 | } 61 | 62 | void mmu_map_section(uint32_t section, uint32_t target, Boolean cacheable, Boolean bufferable) { 63 | uint32_t* sectionEntry = &CurrentPageTable[section >> 20]; 64 | 65 | *sectionEntry = 66 | (target & MMU_SECTION_MASK) 67 | | (cacheable ? MMU_CACHEABLE : 0x0) 68 | | (bufferable ? MMU_BUFFERABLE : 0x0) 69 | | MMU_AP_BOTHWRITE // set AP to 11 (APX is always 0, so this means R/W for everyone) 70 | | MMU_EXECUTENEVER 71 | | MMU_SECTION; // this is a section 72 | 73 | //bufferPrintf("map section (%x): %x -> %x, %d %d (%x)\r\n", sectionEntry, section, target, cacheable, bufferable, *sectionEntry); 74 | 75 | CleanDataCacheLineMVA(sectionEntry); 76 | InvalidateUnifiedTLBUnlockedEntries(); 77 | } 78 | 79 | void mmu_map_section_range(uint32_t rangeStart, uint32_t rangeEnd, uint32_t target, Boolean bufferable, Boolean cacheable) { 80 | uint32_t currentSection; 81 | uint32_t curTargetSection = target; 82 | Boolean started = FALSE; 83 | 84 | for(currentSection = rangeStart; currentSection < rangeEnd; currentSection += MMU_SECTION_SIZE) { 85 | if(started && currentSection == 0) { 86 | // We need this check because if rangeEnd is 0xFFFFFFFF, currentSection 87 | // will always be < rangeEnd, since we overflow the uint32. 88 | break; 89 | } 90 | started = TRUE; 91 | mmu_map_section(currentSection, curTargetSection, bufferable, cacheable); 92 | curTargetSection += MMU_SECTION_SIZE; 93 | } 94 | } 95 | 96 | -------------------------------------------------------------------------------- /openiboot/openiboot.S.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENIBOOT_S_H 2 | #define OPENIBOOT_S_H 3 | 4 | # 5 | # Structures 6 | # 7 | 8 | # InterruptHandler 9 | .equ InterruptHandler.handler, 0x0 10 | .equ InterruptHandler.token, (InterruptHandler.handler + 0x4) 11 | .equ InterruptHandler.useEdgeIC, (InterruptHandler.token + 0x4) 12 | 13 | # TaskDescriptor 14 | .equ TaskDescriptor.identifier1, 0x0 15 | .equ TaskDescriptor.taskList, (TaskDescriptor.identifier1 + 0x4) 16 | .equ TaskDescriptor.runqueueList, (TaskDescriptor.taskList + 0x8) 17 | .equ TaskDescriptor.state, (TaskDescriptor.runqueueList + 0x8) 18 | .equ TaskDescriptor.criticalSectionNestCount, (TaskDescriptor.state + 0x4) 19 | .equ TaskDescriptor.savedRegisters, (TaskDescriptor.criticalSectionNestCount + 0x4) 20 | .equ TaskDescriptor.sleepEvent, (TaskDescriptor.savedRegisters + 0x28) 21 | .equ TaskDescriptor.linked_list_3, (TaskDescriptor.sleepEvent + 0x20) 22 | .equ TaskDescriptor.exitState, (TaskDescriptor.linked_list_3 + 0x8) 23 | .equ TaskDescriptor.taskRoutine, (TaskDescriptor.exitState + 0x4) 24 | .equ TaskDescriptor.unknown_passed_value, (TaskDescriptor.taskRoutine + 0x4) 25 | .equ TaskDescriptor.storage, (TaskDescriptor.unknown_passed_value + 0x4) 26 | .equ TaskDescriptor.storageSize, (TaskDescriptor.storage + 0x4) 27 | .equ TaskDescriptor.taskName, (TaskDescriptor.storageSize + 0x4) 28 | .equ TaskDescriptor.identifier2, (TaskDescriptor.taskName + 0x10) 29 | .equ TaskDescriptorIdentifier1, 0x7461736b 30 | .equ TaskDescriptorIdentifier2, 0x74736b32 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/pcf/bin2.c: -------------------------------------------------------------------------------- 1 | // bin2c.c 2 | // 3 | // convert a binary file into a C source vector 4 | // 5 | // THE "BEER-WARE LICENSE" (Revision 3.1415): 6 | // sandro AT sigala DOT it wrote this file. As long as you retain this notice you can do 7 | // whatever you want with this stuff. If we meet some day, and you think this stuff is 8 | // worth it, you can buy me a beer in return. Sandro Sigala 9 | // 10 | // syntax: bin2c [-c] [-z] 11 | // 12 | // -c add the "const" keyword to definition 13 | // -z terminate the array with a zero (useful for embedded C strings) 14 | // 15 | // examples: 16 | // bin2c -c myimage.png myimage_png.cpp 17 | // bin2c -z sometext.txt sometext_txt.cpp 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #ifndef PATH_MAX 25 | #define PATH_MAX 1024 26 | #endif 27 | 28 | int useconst = 0; 29 | int zeroterminated = 0; 30 | 31 | int myfgetc(FILE *f) 32 | { 33 | int c = fgetc(f); 34 | if (c == EOF && zeroterminated) { 35 | zeroterminated = 0; 36 | return 0; 37 | } 38 | return c; 39 | } 40 | 41 | void process(const char *ifname, const char *ofname) 42 | { 43 | FILE *ifile, *ofile; 44 | ifile = fopen(ifname, "rb"); 45 | if (ifile == NULL) { 46 | fprintf(stderr, "cannot open %s for reading\n", ifname); 47 | exit(1); 48 | } 49 | ofile = fopen(ofname, "wb"); 50 | if (ofile == NULL) { 51 | fprintf(stderr, "cannot open %s for writing\n", ofname); 52 | exit(1); 53 | } 54 | char buf[PATH_MAX], *p; 55 | const char *cp; 56 | if ((cp = strrchr(ifname, '/')) != NULL) 57 | ++cp; 58 | else { 59 | if ((cp = strrchr(ifname, '\\')) != NULL) 60 | ++cp; 61 | else 62 | cp = ifname; 63 | } 64 | strcpy(buf, cp); 65 | for (p = buf; *p != '\0'; ++p) 66 | if (!isalnum(*p)) 67 | *p = '_'; 68 | fprintf(ofile, "static %sunsigned char %s[] = {\n", useconst ? "const " : "", buf); 69 | int c, col = 1; 70 | while ((c = myfgetc(ifile)) != EOF) { 71 | if (col >= 78 - 6) { 72 | fputc('\n', ofile); 73 | col = 1; 74 | } 75 | fprintf(ofile, "0x%.2x, ", c); 76 | col += 6; 77 | 78 | } 79 | fprintf(ofile, "\n};\n"); 80 | 81 | fclose(ifile); 82 | fclose(ofile); 83 | } 84 | 85 | void usage(void) 86 | { 87 | fprintf(stderr, "usage: bin2c [-cz] \n"); 88 | exit(1); 89 | } 90 | 91 | int main(int argc, char **argv) 92 | { 93 | while (argc > 3) { 94 | if (!strcmp(argv[1], "-c")) { 95 | useconst = 1; 96 | --argc; 97 | ++argv; 98 | } else if (!strcmp(argv[1], "-z")) { 99 | zeroterminated = 1; 100 | --argc; 101 | ++argv; 102 | } else { 103 | usage(); 104 | } 105 | } 106 | if (argc != 3) { 107 | usage(); 108 | } 109 | process(argv[1], argv[2]); 110 | return 0; 111 | } 112 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/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 | -------------------------------------------------------------------------------- /openiboot/syscfg.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "syscfg.h" 3 | #include "nor.h" 4 | #include "util.h" 5 | 6 | #define SCFG_MAGIC 0x53436667 7 | #define CNTB_MAGIC 0x434e5442 8 | #define SCFG_LOCATION 0x4000 9 | 10 | typedef struct SCfgHeader 11 | { 12 | uint32_t magic; 13 | uint32_t bytes_used; 14 | uint32_t bytes_total; 15 | uint32_t version; 16 | uint32_t unknown; 17 | uint32_t entries; 18 | } SCfgHeader; 19 | 20 | typedef struct SCfgEntry 21 | { 22 | uint32_t magic; 23 | union { 24 | uint8_t data[16]; 25 | struct { 26 | uint32_t type; 27 | uint32_t size; 28 | uint32_t offset; 29 | } cntb; 30 | }; 31 | } SCfgEntry; 32 | 33 | typedef struct OIBSyscfgEntry 34 | { 35 | int type; 36 | uint32_t size; 37 | uint8_t* data; 38 | } OIBSyscfgEntry; 39 | 40 | static SCfgHeader header; 41 | static OIBSyscfgEntry* entries; 42 | 43 | int syscfg_setup() 44 | { 45 | int i; 46 | SCfgEntry curEntry; 47 | uint32_t cursor; 48 | 49 | nor_read(&header, SCFG_LOCATION, sizeof(header)); 50 | if(header.magic != SCFG_MAGIC) 51 | { 52 | bufferPrintf("syscfg: cannot find readable syscfg partition!\r\n"); 53 | return -1; 54 | } 55 | 56 | bufferPrintf("syscfg: found version 0x%08x with %d entries using %d of %d bytes\r\n", header.version, header.entries, header.bytes_used, header.bytes_total); 57 | 58 | entries = (OIBSyscfgEntry*) malloc(sizeof(OIBSyscfgEntry) * header.entries); 59 | 60 | cursor = SCFG_LOCATION + sizeof(header); 61 | for(i = 0; i < header.entries; ++i) 62 | { 63 | nor_read(&curEntry, cursor, sizeof(curEntry)); 64 | 65 | if(curEntry.magic != CNTB_MAGIC) 66 | { 67 | entries[i].type = curEntry.magic; 68 | entries[i].size = 16; 69 | entries[i].data = (uint8_t*) malloc(16); 70 | memcpy(entries[i].data, curEntry.data, 16); 71 | } else 72 | { 73 | entries[i].type = curEntry.cntb.type; 74 | entries[i].size = curEntry.cntb.size; 75 | entries[i].data = (uint8_t*) malloc(curEntry.cntb.size); 76 | nor_read(entries[i].data, SCFG_LOCATION + curEntry.cntb.offset, curEntry.cntb.size); 77 | } 78 | 79 | cursor += sizeof(curEntry); 80 | } 81 | 82 | return 0; 83 | } 84 | 85 | uint8_t* syscfg_get_entry(uint32_t type, int* size) 86 | { 87 | int i; 88 | 89 | for(i = 0; i < header.entries; ++i) 90 | { 91 | if(entries[i].type == type) 92 | { 93 | *size = entries[i].size; 94 | return entries[i].data; 95 | } 96 | } 97 | 98 | return NULL; 99 | } 100 | -------------------------------------------------------------------------------- /openiboot/tasks.c: -------------------------------------------------------------------------------- 1 | #include "tasks.h" 2 | #include "util.h" 3 | 4 | const TaskDescriptor bootstrapTaskInit = { 5 | TaskDescriptorIdentifier1, 6 | {0, 0}, 7 | {0, 0}, 8 | TASK_RUNNING, 9 | 1, 10 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 11 | {{0, 0}, 0, 0, 0, 0}, 12 | {0, 0}, 13 | 0, 14 | 0, 15 | 0, 16 | 0, 17 | 0, 18 | "bootstrap", 19 | TaskDescriptorIdentifier2 20 | }; 21 | 22 | TaskDescriptor bootstrapTask; 23 | 24 | int tasks_setup() { 25 | memcpy(&bootstrapTask, &bootstrapTaskInit, sizeof(TaskDescriptor)); 26 | CurrentRunning = &bootstrapTask; 27 | return 0; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /openiboot/wdt.c: -------------------------------------------------------------------------------- 1 | #include "openiboot.h" 2 | #include "openiboot-asmhelpers.h" 3 | #include "wdt.h" 4 | #include "interrupt.h" 5 | #include "hardware/s5l8900.h" 6 | #include "util.h" 7 | #include "event.h" 8 | #include "clock.h" 9 | 10 | #define PRESCALE 15 11 | #define CLOCK_CS 4 12 | #define CLOCK_DIV 2048 13 | 14 | static int count; 15 | static int period; 16 | 17 | static Event WDTEvent; 18 | 19 | static volatile int wdt_enabled; 20 | static volatile int wdt_disabled; 21 | static int wdt_init = FALSE; 22 | 23 | static void wdt_handler(Event* event, void* opaque) 24 | { 25 | EnterCriticalSection(); 26 | if(wdt_enabled) 27 | { 28 | SET_REG(WDT_CTRL, WDT_CLR | WDT_ENABLE | ((PRESCALE & WDT_PRE_MASK) << WDT_PRE_SHIFT) | ((CLOCK_CS & WDT_CS_MASK) << WDT_CS_SHIFT)); 29 | event_readd(event, period); 30 | ++count; 31 | } 32 | else 33 | { 34 | // shouldn't be necessary 35 | wdt_disable(); 36 | wdt_disabled = TRUE; 37 | } 38 | LeaveCriticalSection(); 39 | } 40 | 41 | int wdt_setup() 42 | { 43 | wdt_init = TRUE; 44 | wdt_disabled = TRUE; 45 | wdt_enabled = FALSE; 46 | wdt_enable(); 47 | return 0; 48 | } 49 | 50 | void wdt_enable() 51 | { 52 | if(!wdt_init) 53 | return; 54 | 55 | EnterCriticalSection(); 56 | if(wdt_disabled) 57 | { 58 | period = 1000000 * 2048 / PeripheralFrequency * (PRESCALE + 1) * CLOCK_DIV / 4; 59 | count = 0; 60 | event_add(&WDTEvent, period, wdt_handler, NULL); 61 | SET_REG(WDT_CTRL, WDT_CLR | WDT_ENABLE | ((PRESCALE & WDT_PRE_MASK) << WDT_PRE_SHIFT) | ((CLOCK_CS & WDT_CS_MASK) << WDT_CS_SHIFT)); 62 | } 63 | 64 | wdt_enabled = TRUE; 65 | LeaveCriticalSection(); 66 | } 67 | 68 | void wdt_disable() 69 | { 70 | if(!wdt_init) 71 | return; 72 | 73 | EnterCriticalSection(); 74 | if(wdt_enabled) 75 | { 76 | SET_REG(WDT_CTRL, WDT_CLR | WDT_DIS); 77 | wdt_enabled = FALSE; 78 | } 79 | LeaveCriticalSection(); 80 | } 81 | 82 | int wdt_counter() 83 | { 84 | return count; 85 | } 86 | -------------------------------------------------------------------------------- /toolchain/README: -------------------------------------------------------------------------------- 1 | Using build-toolchain 2 | -------------------------- 3 | 4 | This script will build the GNU ARM toolchain from scratch. It must be ran as root 5 | due to the fact that it installs the bins in /usr/local. 6 | 7 | It will use /tmp/ipl-toolchain for temporary storage. If you would like to override 8 | this path you can set the environment variable $TOOLCHAIN_PATH to the location of 9 | your temporary storage directory. 10 | 11 | It's important to note that the files are not cleaned up after the install. You will 12 | have to run clean for it to cleanup the packages/src directories. 13 | 14 | The commands are as follows: 15 | 16 | ## Make toolchain 17 | ./build-toolchain.sh make 18 | ## Clean toolchain 19 | ./build-toolchain.sh clean 20 | 21 | Logs are stored in $TOOLCHAIN_PATH/build.log ( by default /tmp/ipl-toolchain/build.log ) 22 | -------------------------------------------------------------------------------- /toolchain/newlib-1.14.0-missing-makeinfo.patch: -------------------------------------------------------------------------------- 1 | --- newlib-1.14.0-bak/configure 2008-06-10 20:49:16.918036351 +0200 2 | +++ newlib-1.14.0/configure 2008-06-10 21:21:35.750035824 +0200 3 | @@ -3542,7 +3542,7 @@ 4 | # For an installed makeinfo, we require it to be from texinfo 4.2 or 5 | # higher, else we use the "missing" dummy. 6 | if ${MAKEINFO} --version \ 7 | - | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[2-9]|[5-9])' >/dev/null 2>&1; then 8 | + | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.([2-9]|[1-9][0-9])|[5-9])' >/dev/null 2>&1; then 9 | : 10 | else 11 | MAKEINFO="$MISSING makeinfo" 12 | -------------------------------------------------------------------------------- /toolchain/t-arm-elf.patch: -------------------------------------------------------------------------------- 1 | --- gcc-4.1.1/gcc/config/arm/t-arm-elf.old 2010-02-27 13:02:07.785435756 +0100 2 | +++ gcc-4.1.1/gcc/config/arm/t-arm-elf 2010-02-27 16:22:30.085894247 +0100 3 | @@ -6,7 +6,7 @@ 4 | _truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \ 5 | _fixsfsi _fixunssfsi _floatdidf _floatdisf 6 | 7 | -MULTILIB_OPTIONS = marm/mthumb 8 | +MULTILIB_OPTIONS = marm/mthumb mthumb-interwork 9 | -MULTILIB_DIRNAMES = arm thumb 10 | +MULTILIB_DIRNAMES = arm thumb interwork 11 | MULTILIB_EXCEPTIONS = 12 | MULTILIB_MATCHES = 13 | -------------------------------------------------------------------------------- /tools/Makefile: -------------------------------------------------------------------------------- 1 | all: bitset 2 | 3 | bitset: bitset.o 4 | gcc bitset.o -o bitset 5 | 6 | clean: 7 | rm -f bitset 8 | rm -f *.o 9 | -------------------------------------------------------------------------------- /tools/bitset.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main(int argc, char* argv[]) 7 | { 8 | if(argc < 2) 9 | { 10 | printf("Usage: %s \n", argv[0]); 11 | return 0; 12 | } 13 | 14 | uint64_t number = strtoll(argv[1], NULL, 0); 15 | 16 | int i; 17 | for(i = 31; i >= 0; --i) 18 | { 19 | printf("%02d ", i); 20 | } 21 | 22 | printf("\n"); 23 | 24 | for(i = 31; i >= 0; --i) 25 | { 26 | if((number & (1 << i)) != 0) 27 | printf(" 1 "); 28 | else 29 | printf(" 0 "); 30 | } 31 | 32 | printf("\n"); 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /tools/dumpnandinfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | typedef struct NANDDeviceType { 6 | uint32_t id; 7 | uint16_t blocksPerBank; 8 | uint16_t pagesPerBlock; 9 | uint16_t sectorsPerPage; 10 | uint16_t bytesPerSpare; 11 | uint8_t WPPulseTime; 12 | uint8_t WEHighHoldTime; 13 | uint8_t NANDSetting3; 14 | uint8_t NANDSetting4; 15 | uint32_t userSubBlksTotal; 16 | uint32_t ecc1; 17 | uint32_t ecc2; 18 | } NANDDeviceType; 19 | 20 | int main(int argc, char* argv[]) 21 | { 22 | if(argc < 3) 23 | { 24 | printf("Spit out a struct openiboot can use to configure NAND parameters from the similar table in iBoot.\n\n"); 25 | printf("Usage: %s \n", argv[0]); 26 | return 0; 27 | } 28 | 29 | printf("static const NANDDeviceType SupportedDevices[] = {\n"); 30 | uint32_t offset = strtol(argv[2], NULL, 0); 31 | FILE* f = fopen(argv[1], "rb"); 32 | 33 | fseek(f, offset, SEEK_SET); 34 | while(1) 35 | { 36 | NANDDeviceType entry; 37 | fread(&entry, 1, sizeof(entry), f); 38 | if(entry.id == 0) 39 | break; 40 | 41 | printf("\t{0x%X, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d},\n", 42 | entry.id, entry.blocksPerBank, entry.pagesPerBlock, entry.sectorsPerPage, entry.bytesPerSpare, 43 | entry.WPPulseTime, entry.WEHighHoldTime, entry.NANDSetting3, entry.NANDSetting4, 44 | entry.userSubBlksTotal, entry.ecc1, entry.ecc2); 45 | } 46 | 47 | printf("\t{0}\n};\n"); 48 | 49 | fclose(f); 50 | } 51 | --------------------------------------------------------------------------------