SlideShare a Scribd company logo
1 of 40
資科工所
0786030
陳柏宇
 正常模式
 恢復模式 – Recovery Mode
 韌體更新模式 – DFU Mode
2
 Boot ROM
 LLB (Low Level Bootloader)
 iBoot
 Kernel
 iOS launchd
3
4
5
Application Processor
Boot ROM
Apple Public Key Low-Level
Bootloader
(LLB)
iBoot Kernel iOS
 iOS 啟動過程中,均會驗證每個元件是否經過 Apple 加密簽名
 Boot ROM 包含 Apple Root CA Public Key
 除了 Boot ROM 沒有加密以外,其他元件都有加密
 iBoot
 LLB
 Kernel
 Filesystem
 Baseband
6
 如果啟動失敗則切換到 DFU Mode
 A5 之前有漏洞,可繞過簽名檢查安裝客製化的 LLB
 使用 A5 的裝置
 Apple iPad 2
 Apple iPhone 4S
 Apple Apple TV 第三代
 Apple iPod touch 5
 Apple iPad mini
7
 受影響的處理器 S5L8720 / S5L8920
 當時 LLB 從 NOR 載入到 RAM 時沒有進行簽名檢查以及長度檢查
 在恢復模式更新 LLB 也沒有進行檢查
 Boot Rom 放在 0x0 ~ 0x100000,搬移到 0x20000000 ~ 0x20100000
 SRAM 映射到 0x22000000 ~ 0x22100000 以及 0x84000000 ~
0x84100000
 SRAM ~ SRAM+0x24000 用來存放 LLB
 SRAM+0x24000 用來存放 Boot ROM 需要用到的 variables、heap 和
stack
 因此 LLB 只要長度大於 0x24000 byte 就可以產生溢位,覆蓋 Boot
Rom 的簽名檢查
8
 S5L8720 – iPod Touch 2G
 0x220240D4 - SHA1 accelerator register table
 0x22024200 - Block Device List
 0x220250A0 - Permissions Flags
 0x220254E0 - Interrupt Table
 0x2202C000 - Page table
9
 負責載入 iBoot,若載入失敗,進入到 DFU Mode
 格式為加密的 IMG3 / IMG4 檔案
 Firmware/all_flash.xxxlp.production/LLB.xxx.RELEASE.img3
 Firmware/all_flash/LLB.d42.RELEASE.im4p
10
 iBSS (iBoot Single Stage)
 負責底層初始化以及準備載入 iBEC
 iOS 10 之後改名為 iBootStage1
 iBEC (iBoot Epoch Change)
 負責 iTunes 通過 USB 升級 iOS 的過程
 iOS 10 之後改名為 iBootStage2
11
 主要的 Loader
 負責載入 OS Kernel
 在 iOS5 時,iBoot 會被載入到 0x5FF00000 執行
 內建 HFS+ / APFS Driver,可直接存取 iOS 檔案系統,並支援多
執行緒
 main
 顯示啟動的蘋果 logo
 根據 auto-boot 和 boot-command(fsboot) 進行啟動環境的設定
 uart reader
 Debug 測試用
12
 fsboot()
 掛載檔案系統
 定位kernel
 準備裝置
 若啟動失敗,則進入恢復模式
 idleoff
 idle超過一定時間則關閉設備
 poweoff
 電量不足時關閉設備
 usb-req
 處理iTunes的USB連接
 usb-high-current / usb-no-current
 處理USB充電
 command
 啟動shell
13
14
15
16
 基於 iOS 9.3 的 iBoot 原始碼,在 2018 年 2 月被洩露到 github 上
 包含以下裝置的 iBoot 原始碼
 iBoot for A5 targets (s5l8940x, s5l8942x, s5l8945x, s5l8947x) and
s5l8747x (used in Haywire)
 iBoot for A6 targets (both s5l8950x and s5l8955x)
 iBoot for A7 (s5l8960x), A8 (t7000, t7001), A9 (s8000, s8003, s8001),
S1 (s7002) and S1P/S2 (t8002)
18
 /apps # SecureROM, iBoot, EmbeddedIOP
 /arch # Platform architecture-specific code
 /docs
 /drivers # apple, nand, nor, power, usb, etc
 /include # Header and libs
 /lib # Support library
 /makefiles
 /platform # SoC-specific code, drivers, startup code, etc
 /sys # Core OS services.
 /target # Target-specific code, fpga, sim, etc
19
20
 main.c 主要函式
 _main
 boot_selected
 lookup_image_in_bdev
 load_selected_image
 boot_loaded_image
21
22
23
 arm_invalidate_dcache()
 arm_invalidate_icache()
 aux_cr = arm_read_aux_cr();
 arm_write_aux_cr(aux_cr);
 cr = arm_read_cr();
 arm_write_cr(cr);
 arm_mmu_init(resume);
24
25
 Initialise the heap.
 security_init(false);
 sys_setup_default_environment();
 task_init();
26
 platform_setup_default_en
vironment()
 target_setup_default_envir
onment()
27
 platform_setup_default_environment()
 env_set("boot-device", "nvme_nand0", 0);
 target_setup_default_environment()
 env_set("boot-args", " debug=0x14e serial=3 amfi=3 amfi_get_out_of_my_way=1
cs_enforcement_disable=1 fips_mode=0", 0);
 env_set("display-color-space","RGB888", 0);
 env_set("display-timing", "fpga-wsvga", 0);
 env_set("ramdisk-delay", "60000000", 0); /* This tells PurpleRestore to slow down;
rdar://6345846 */
 env_set("idle-off", "false", 0);
 env_set("bootdelay", "3", 0);
 env_set("debug-uarts", "3", 0);
28
 platform_enable_boot_interface(true, boot_device, boot_arg);
 security_init(true);
29
30
31
32
33
 do_ll_init();
 sys_init();
 platform_early_init();
 platform_init_mainmem(resume);
 platform_init();
 check_enter_dfu();
 find_boot_images();
 boot_iboot();
 security_init(false);
 main_dfu();
34
 platform_power_init();
 miu_init(); /* CIF, SCU, remap setup */
 clocks_init();
 interrupt_init();
 timer_init(0);
 boot_set_stage(kPowerNVRAMiBootStageProductStart);
35
 platform_enable_error_handler();
 spi_init();
 pci_init();
 apcie_set_s3e_mode(true);
 nvme_init(0, apcie_get_port_bridge(0), 0);
 target_init(); //flash_nor_init(SPI_NOR0);
36
37
38
 bootfile = (char *)malloc(FS_MAXPATHLEN);
 err = mount_bootfs();
 err = load_kernelcache_file(bootfile,
IMAGE_TYPE_KERNELCACHE, &entry, &boot_args);
 boot_darwin((void *)entry, (void *)boot_args);
39
iOS Bootloader

More Related Content

What's hot

C/C++プログラマのための開発ツール
C/C++プログラマのための開発ツールC/C++プログラマのための開発ツール
C/C++プログラマのための開発ツールMITSUNARI Shigeo
 
車載組み込み用ディープラーニング・エンジン NVIDIA DRIVE PX
車載組み込み用ディープラーニング・エンジン NVIDIA DRIVE PX車載組み込み用ディープラーニング・エンジン NVIDIA DRIVE PX
車載組み込み用ディープラーニング・エンジン NVIDIA DRIVE PXNVIDIA Japan
 
Starc RTL設計スタイルガイドの検査道具spyglassの使い方
Starc RTL設計スタイルガイドの検査道具spyglassの使い方Starc RTL設計スタイルガイドの検査道具spyglassの使い方
Starc RTL設計スタイルガイドの検査道具spyglassの使い方Kiyoshi Ogawa
 
Hybrid Public Key Encryption (HPKE)
Hybrid Public Key Encryption (HPKE)Hybrid Public Key Encryption (HPKE)
Hybrid Public Key Encryption (HPKE)Jun Kurihara
 
C++ マルチスレッドプログラミング
C++ マルチスレッドプログラミングC++ マルチスレッドプログラミング
C++ マルチスレッドプログラミングKohsuke Yuasa
 
Simplivity 4.0 with storeonce catalyst
Simplivity 4.0 with storeonce catalystSimplivity 4.0 with storeonce catalyst
Simplivity 4.0 with storeonce catalyst裝機安 Angelo
 
Proxmox VE 企業應用經驗分享 [2017/07/29] @台中資策會
Proxmox VE 企業應用經驗分享 [2017/07/29] @台中資策會Proxmox VE 企業應用經驗分享 [2017/07/29] @台中資策會
Proxmox VE 企業應用經驗分享 [2017/07/29] @台中資策會Jason Cheng
 
Arduino in TinyML with Edge Impulse
Arduino in TinyML with Edge ImpulseArduino in TinyML with Edge Impulse
Arduino in TinyML with Edge ImpulseRobocraze
 
Machine Learning - Breast Cancer Diagnosis
Machine Learning - Breast Cancer DiagnosisMachine Learning - Breast Cancer Diagnosis
Machine Learning - Breast Cancer DiagnosisPramod Sharma
 
Dci vs aggregate_dddtw_2021-0.3-16-9
Dci vs aggregate_dddtw_2021-0.3-16-9Dci vs aggregate_dddtw_2021-0.3-16-9
Dci vs aggregate_dddtw_2021-0.3-16-9teddysoft
 
OpenCVを用いた画像処理入門
OpenCVを用いた画像処理入門OpenCVを用いた画像処理入門
OpenCVを用いた画像処理入門uranishi
 
MySQLからPostgreSQLへのマイグレーションのハマリ所
MySQLからPostgreSQLへのマイグレーションのハマリ所MySQLからPostgreSQLへのマイグレーションのハマリ所
MySQLからPostgreSQLへのマイグレーションのハマリ所Makoto Kaga
 
Object classification using CNN & VGG16 Model (Keras and Tensorflow)
Object classification using CNN & VGG16 Model (Keras and Tensorflow) Object classification using CNN & VGG16 Model (Keras and Tensorflow)
Object classification using CNN & VGG16 Model (Keras and Tensorflow) Lalit Jain
 
VMware Overview
VMware OverviewVMware Overview
VMware OverviewMadhu Bala
 
作業系統祕笈(張逸)
作業系統祕笈(張逸)作業系統祕笈(張逸)
作業系統祕笈(張逸)逸 張
 
開源 x 節流:企業導入實例分享 (二) [2015/09/19] 軟體自由日研討會
開源 x 節流:企業導入實例分享 (二)  [2015/09/19] 軟體自由日研討會開源 x 節流:企業導入實例分享 (二)  [2015/09/19] 軟體自由日研討會
開源 x 節流:企業導入實例分享 (二) [2015/09/19] 軟體自由日研討會Jason Cheng
 
Spresense Study meeting#1 How to use the Camera board
Spresense Study meeting#1 How to use the Camera boardSpresense Study meeting#1 How to use the Camera board
Spresense Study meeting#1 How to use the Camera board義則 太田
 
TEE (Trusted Execution Environment)は第二の仮想化技術になるか?
TEE (Trusted Execution Environment)は第二の仮想化技術になるか?TEE (Trusted Execution Environment)は第二の仮想化技術になるか?
TEE (Trusted Execution Environment)は第二の仮想化技術になるか?Kuniyasu Suzaki
 

What's hot (20)

C/C++プログラマのための開発ツール
C/C++プログラマのための開発ツールC/C++プログラマのための開発ツール
C/C++プログラマのための開発ツール
 
車載組み込み用ディープラーニング・エンジン NVIDIA DRIVE PX
車載組み込み用ディープラーニング・エンジン NVIDIA DRIVE PX車載組み込み用ディープラーニング・エンジン NVIDIA DRIVE PX
車載組み込み用ディープラーニング・エンジン NVIDIA DRIVE PX
 
Cloud security ppt
Cloud security pptCloud security ppt
Cloud security ppt
 
Starc RTL設計スタイルガイドの検査道具spyglassの使い方
Starc RTL設計スタイルガイドの検査道具spyglassの使い方Starc RTL設計スタイルガイドの検査道具spyglassの使い方
Starc RTL設計スタイルガイドの検査道具spyglassの使い方
 
Hybrid Public Key Encryption (HPKE)
Hybrid Public Key Encryption (HPKE)Hybrid Public Key Encryption (HPKE)
Hybrid Public Key Encryption (HPKE)
 
C++ マルチスレッドプログラミング
C++ マルチスレッドプログラミングC++ マルチスレッドプログラミング
C++ マルチスレッドプログラミング
 
Simplivity 4.0 with storeonce catalyst
Simplivity 4.0 with storeonce catalystSimplivity 4.0 with storeonce catalyst
Simplivity 4.0 with storeonce catalyst
 
Proxmox VE 企業應用經驗分享 [2017/07/29] @台中資策會
Proxmox VE 企業應用經驗分享 [2017/07/29] @台中資策會Proxmox VE 企業應用經驗分享 [2017/07/29] @台中資策會
Proxmox VE 企業應用經驗分享 [2017/07/29] @台中資策會
 
Arduino in TinyML with Edge Impulse
Arduino in TinyML with Edge ImpulseArduino in TinyML with Edge Impulse
Arduino in TinyML with Edge Impulse
 
Machine Learning - Breast Cancer Diagnosis
Machine Learning - Breast Cancer DiagnosisMachine Learning - Breast Cancer Diagnosis
Machine Learning - Breast Cancer Diagnosis
 
Xen Hypervisor
Xen HypervisorXen Hypervisor
Xen Hypervisor
 
Dci vs aggregate_dddtw_2021-0.3-16-9
Dci vs aggregate_dddtw_2021-0.3-16-9Dci vs aggregate_dddtw_2021-0.3-16-9
Dci vs aggregate_dddtw_2021-0.3-16-9
 
OpenCVを用いた画像処理入門
OpenCVを用いた画像処理入門OpenCVを用いた画像処理入門
OpenCVを用いた画像処理入門
 
MySQLからPostgreSQLへのマイグレーションのハマリ所
MySQLからPostgreSQLへのマイグレーションのハマリ所MySQLからPostgreSQLへのマイグレーションのハマリ所
MySQLからPostgreSQLへのマイグレーションのハマリ所
 
Object classification using CNN & VGG16 Model (Keras and Tensorflow)
Object classification using CNN & VGG16 Model (Keras and Tensorflow) Object classification using CNN & VGG16 Model (Keras and Tensorflow)
Object classification using CNN & VGG16 Model (Keras and Tensorflow)
 
VMware Overview
VMware OverviewVMware Overview
VMware Overview
 
作業系統祕笈(張逸)
作業系統祕笈(張逸)作業系統祕笈(張逸)
作業系統祕笈(張逸)
 
開源 x 節流:企業導入實例分享 (二) [2015/09/19] 軟體自由日研討會
開源 x 節流:企業導入實例分享 (二)  [2015/09/19] 軟體自由日研討會開源 x 節流:企業導入實例分享 (二)  [2015/09/19] 軟體自由日研討會
開源 x 節流:企業導入實例分享 (二) [2015/09/19] 軟體自由日研討會
 
Spresense Study meeting#1 How to use the Camera board
Spresense Study meeting#1 How to use the Camera boardSpresense Study meeting#1 How to use the Camera board
Spresense Study meeting#1 How to use the Camera board
 
TEE (Trusted Execution Environment)は第二の仮想化技術になるか?
TEE (Trusted Execution Environment)は第二の仮想化技術になるか?TEE (Trusted Execution Environment)は第二の仮想化技術になるか?
TEE (Trusted Execution Environment)は第二の仮想化技術になるか?
 

Similar to iOS Bootloader

iOS 逆向工程及越獄開發 - iPlayground 2018
iOS 逆向工程及越獄開發 - iPlayground 2018iOS 逆向工程及越獄開發 - iPlayground 2018
iOS 逆向工程及越獄開發 - iPlayground 2018Lin Gary
 
Linux期末 效能調教(kernel trnning)
Linux期末 效能調教(kernel trnning)Linux期末 效能調教(kernel trnning)
Linux期末 效能調教(kernel trnning)米米 林
 
Raspberry pi 基本操作
Raspberry pi 基本操作Raspberry pi 基本操作
Raspberry pi 基本操作艾鍗科技
 
Mobile app security
Mobile app securityMobile app security
Mobile app securitydrewz lin
 
Tiptop gp 5.1 setup_instructions
Tiptop gp 5.1 setup_instructionsTiptop gp 5.1 setup_instructions
Tiptop gp 5.1 setup_instructionsguest994aeb5
 
Arduino 底層原始碼解析心得
Arduino 底層原始碼解析心得Arduino 底層原始碼解析心得
Arduino 底層原始碼解析心得roboard
 
Coscup2011: porting android to brand-new cpu architecture
Coscup2011: porting android to brand-new cpu architecture Coscup2011: porting android to brand-new cpu architecture
Coscup2011: porting android to brand-new cpu architecture lusecheng
 
20201024_aigo_lab2_fruit_classification_omnixri
20201024_aigo_lab2_fruit_classification_omnixri20201024_aigo_lab2_fruit_classification_omnixri
20201024_aigo_lab2_fruit_classification_omnixriOmniXRI Studio
 
Core ML Sessions in WWDC 18
Core ML Sessions in WWDC 18Core ML Sessions in WWDC 18
Core ML Sessions in WWDC 18Marvin Lin
 
Raspberry pi 基本操作
Raspberry pi 基本操作Raspberry pi 基本操作
Raspberry pi 基本操作艾鍗科技
 
嵌入式平台移植技巧概說
嵌入式平台移植技巧概說嵌入式平台移植技巧概說
嵌入式平台移植技巧概說Joseph Lu
 
運用 Docker 整合 Laravel 提升團隊開發效率
運用 Docker 整合 Laravel 提升團隊開發效率運用 Docker 整合 Laravel 提升團隊開發效率
運用 Docker 整合 Laravel 提升團隊開發效率Bo-Yi Wu
 
U boot 程式碼打掃計畫
U boot 程式碼打掃計畫U boot 程式碼打掃計畫
U boot 程式碼打掃計畫Macpaul Lin
 
New i pad
New i padNew i pad
New i padyo9889
 
容器與 Gitlab CI 應用
容器與 Gitlab CI 應用容器與 Gitlab CI 應用
容器與 Gitlab CI 應用Philip Zheng
 
有想法才有追求
有想法才有追求有想法才有追求
有想法才有追求luke007
 
Raspberry pi3 基本操作
Raspberry pi3 基本操作Raspberry pi3 基本操作
Raspberry pi3 基本操作學院 艾鍗
 
Swift girls to_codeforgender20171111
Swift girls to_codeforgender20171111Swift girls to_codeforgender20171111
Swift girls to_codeforgender20171111雅方 鄭
 

Similar to iOS Bootloader (20)

Translation
TranslationTranslation
Translation
 
iOS 逆向工程及越獄開發 - iPlayground 2018
iOS 逆向工程及越獄開發 - iPlayground 2018iOS 逆向工程及越獄開發 - iPlayground 2018
iOS 逆向工程及越獄開發 - iPlayground 2018
 
Linux期末 效能調教(kernel trnning)
Linux期末 效能調教(kernel trnning)Linux期末 效能調教(kernel trnning)
Linux期末 效能調教(kernel trnning)
 
02 86 duino_簡介
02 86 duino_簡介02 86 duino_簡介
02 86 duino_簡介
 
Raspberry pi 基本操作
Raspberry pi 基本操作Raspberry pi 基本操作
Raspberry pi 基本操作
 
Mobile app security
Mobile app securityMobile app security
Mobile app security
 
Tiptop gp 5.1 setup_instructions
Tiptop gp 5.1 setup_instructionsTiptop gp 5.1 setup_instructions
Tiptop gp 5.1 setup_instructions
 
Arduino 底層原始碼解析心得
Arduino 底層原始碼解析心得Arduino 底層原始碼解析心得
Arduino 底層原始碼解析心得
 
Coscup2011: porting android to brand-new cpu architecture
Coscup2011: porting android to brand-new cpu architecture Coscup2011: porting android to brand-new cpu architecture
Coscup2011: porting android to brand-new cpu architecture
 
20201024_aigo_lab2_fruit_classification_omnixri
20201024_aigo_lab2_fruit_classification_omnixri20201024_aigo_lab2_fruit_classification_omnixri
20201024_aigo_lab2_fruit_classification_omnixri
 
Core ML Sessions in WWDC 18
Core ML Sessions in WWDC 18Core ML Sessions in WWDC 18
Core ML Sessions in WWDC 18
 
Raspberry pi 基本操作
Raspberry pi 基本操作Raspberry pi 基本操作
Raspberry pi 基本操作
 
嵌入式平台移植技巧概說
嵌入式平台移植技巧概說嵌入式平台移植技巧概說
嵌入式平台移植技巧概說
 
運用 Docker 整合 Laravel 提升團隊開發效率
運用 Docker 整合 Laravel 提升團隊開發效率運用 Docker 整合 Laravel 提升團隊開發效率
運用 Docker 整合 Laravel 提升團隊開發效率
 
U boot 程式碼打掃計畫
U boot 程式碼打掃計畫U boot 程式碼打掃計畫
U boot 程式碼打掃計畫
 
New i pad
New i padNew i pad
New i pad
 
容器與 Gitlab CI 應用
容器與 Gitlab CI 應用容器與 Gitlab CI 應用
容器與 Gitlab CI 應用
 
有想法才有追求
有想法才有追求有想法才有追求
有想法才有追求
 
Raspberry pi3 基本操作
Raspberry pi3 基本操作Raspberry pi3 基本操作
Raspberry pi3 基本操作
 
Swift girls to_codeforgender20171111
Swift girls to_codeforgender20171111Swift girls to_codeforgender20171111
Swift girls to_codeforgender20171111
 

iOS Bootloader

  • 2.  正常模式  恢復模式 – Recovery Mode  韌體更新模式 – DFU Mode 2
  • 3.  Boot ROM  LLB (Low Level Bootloader)  iBoot  Kernel  iOS launchd 3
  • 4. 4
  • 5. 5 Application Processor Boot ROM Apple Public Key Low-Level Bootloader (LLB) iBoot Kernel iOS
  • 6.  iOS 啟動過程中,均會驗證每個元件是否經過 Apple 加密簽名  Boot ROM 包含 Apple Root CA Public Key  除了 Boot ROM 沒有加密以外,其他元件都有加密  iBoot  LLB  Kernel  Filesystem  Baseband 6
  • 7.  如果啟動失敗則切換到 DFU Mode  A5 之前有漏洞,可繞過簽名檢查安裝客製化的 LLB  使用 A5 的裝置  Apple iPad 2  Apple iPhone 4S  Apple Apple TV 第三代  Apple iPod touch 5  Apple iPad mini 7
  • 8.  受影響的處理器 S5L8720 / S5L8920  當時 LLB 從 NOR 載入到 RAM 時沒有進行簽名檢查以及長度檢查  在恢復模式更新 LLB 也沒有進行檢查  Boot Rom 放在 0x0 ~ 0x100000,搬移到 0x20000000 ~ 0x20100000  SRAM 映射到 0x22000000 ~ 0x22100000 以及 0x84000000 ~ 0x84100000  SRAM ~ SRAM+0x24000 用來存放 LLB  SRAM+0x24000 用來存放 Boot ROM 需要用到的 variables、heap 和 stack  因此 LLB 只要長度大於 0x24000 byte 就可以產生溢位,覆蓋 Boot Rom 的簽名檢查 8
  • 9.  S5L8720 – iPod Touch 2G  0x220240D4 - SHA1 accelerator register table  0x22024200 - Block Device List  0x220250A0 - Permissions Flags  0x220254E0 - Interrupt Table  0x2202C000 - Page table 9
  • 10.  負責載入 iBoot,若載入失敗,進入到 DFU Mode  格式為加密的 IMG3 / IMG4 檔案  Firmware/all_flash.xxxlp.production/LLB.xxx.RELEASE.img3  Firmware/all_flash/LLB.d42.RELEASE.im4p 10
  • 11.  iBSS (iBoot Single Stage)  負責底層初始化以及準備載入 iBEC  iOS 10 之後改名為 iBootStage1  iBEC (iBoot Epoch Change)  負責 iTunes 通過 USB 升級 iOS 的過程  iOS 10 之後改名為 iBootStage2 11
  • 12.  主要的 Loader  負責載入 OS Kernel  在 iOS5 時,iBoot 會被載入到 0x5FF00000 執行  內建 HFS+ / APFS Driver,可直接存取 iOS 檔案系統,並支援多 執行緒  main  顯示啟動的蘋果 logo  根據 auto-boot 和 boot-command(fsboot) 進行啟動環境的設定  uart reader  Debug 測試用 12
  • 13.  fsboot()  掛載檔案系統  定位kernel  準備裝置  若啟動失敗,則進入恢復模式  idleoff  idle超過一定時間則關閉設備  poweoff  電量不足時關閉設備  usb-req  處理iTunes的USB連接  usb-high-current / usb-no-current  處理USB充電  command  啟動shell 13
  • 14. 14
  • 15. 15
  • 16. 16
  • 17.
  • 18.  基於 iOS 9.3 的 iBoot 原始碼,在 2018 年 2 月被洩露到 github 上  包含以下裝置的 iBoot 原始碼  iBoot for A5 targets (s5l8940x, s5l8942x, s5l8945x, s5l8947x) and s5l8747x (used in Haywire)  iBoot for A6 targets (both s5l8950x and s5l8955x)  iBoot for A7 (s5l8960x), A8 (t7000, t7001), A9 (s8000, s8003, s8001), S1 (s7002) and S1P/S2 (t8002) 18
  • 19.  /apps # SecureROM, iBoot, EmbeddedIOP  /arch # Platform architecture-specific code  /docs  /drivers # apple, nand, nor, power, usb, etc  /include # Header and libs  /lib # Support library  /makefiles  /platform # SoC-specific code, drivers, startup code, etc  /sys # Core OS services.  /target # Target-specific code, fpga, sim, etc 19
  • 20. 20
  • 21.  main.c 主要函式  _main  boot_selected  lookup_image_in_bdev  load_selected_image  boot_loaded_image 21
  • 22. 22
  • 23. 23
  • 24.  arm_invalidate_dcache()  arm_invalidate_icache()  aux_cr = arm_read_aux_cr();  arm_write_aux_cr(aux_cr);  cr = arm_read_cr();  arm_write_cr(cr);  arm_mmu_init(resume); 24
  • 25. 25
  • 26.  Initialise the heap.  security_init(false);  sys_setup_default_environment();  task_init(); 26
  • 28.  platform_setup_default_environment()  env_set("boot-device", "nvme_nand0", 0);  target_setup_default_environment()  env_set("boot-args", " debug=0x14e serial=3 amfi=3 amfi_get_out_of_my_way=1 cs_enforcement_disable=1 fips_mode=0", 0);  env_set("display-color-space","RGB888", 0);  env_set("display-timing", "fpga-wsvga", 0);  env_set("ramdisk-delay", "60000000", 0); /* This tells PurpleRestore to slow down; rdar://6345846 */  env_set("idle-off", "false", 0);  env_set("bootdelay", "3", 0);  env_set("debug-uarts", "3", 0); 28
  • 29.  platform_enable_boot_interface(true, boot_device, boot_arg);  security_init(true); 29
  • 30. 30
  • 31. 31
  • 32. 32
  • 33. 33
  • 34.  do_ll_init();  sys_init();  platform_early_init();  platform_init_mainmem(resume);  platform_init();  check_enter_dfu();  find_boot_images();  boot_iboot();  security_init(false);  main_dfu(); 34
  • 35.  platform_power_init();  miu_init(); /* CIF, SCU, remap setup */  clocks_init();  interrupt_init();  timer_init(0);  boot_set_stage(kPowerNVRAMiBootStageProductStart); 35
  • 36.  platform_enable_error_handler();  spi_init();  pci_init();  apcie_set_s3e_mode(true);  nvme_init(0, apcie_get_port_bridge(0), 0);  target_init(); //flash_nor_init(SPI_NOR0); 36
  • 37. 37
  • 38. 38
  • 39.  bootfile = (char *)malloc(FS_MAXPATHLEN);  err = mount_bootfs();  err = load_kernelcache_file(bootfile, IMAGE_TYPE_KERNELCACHE, &entry, &boot_args);  boot_darwin((void *)entry, (void *)boot_args); 39