diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a049001 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,63 @@ +name: Build & Release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install ARM toolchain + run: | + sudo apt-get update + sudo apt-get install -y gcc-arm-none-eabi + + - name: Install mk8900image dependencies + run: | + sudo apt-get install -y libpng-dev libssl-dev zlib1g-dev + + - name: Build all release targets + run: | + RELEASE_TARGETS="iPhone2G iPhone3G iPodTouch1G iPodTouch2G iPhone3GS iPhone4 iPad1G iPodTouch4G aTV2G" + for target in $RELEASE_TARGETS; do + echo "::group::Building $target" + make "$target" + echo "::endgroup::" + done + + - name: Build installer targets + run: | + INSTALLER_TARGETS="iPhone2G-Installer iPhone3G-Installer iPodTouch1G-Installer" + for target in $INSTALLER_TARGETS; do + echo "::group::Building $target" + make "$target" + echo "::endgroup::" + done + + - name: Collect artifacts + run: | + mkdir -p dist + cp *.img3 *.bin dist/ 2>/dev/null || true + ls -la dist/ + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: openiboot-images + path: dist/ + + - name: Create GitHub Release + if: startsWith(github.ref, 'refs/tags/') + uses: softprops/action-gh-release@v2 + with: + files: dist/* + generate_release_notes: true diff --git a/.gitignore b/.gitignore index ac3d143..60e0d5b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -.sconsign.dblite +build/ *.img3 *.img2 *.bin diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..9dd19b6 --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,475 @@ +# openiBoot GNUmakefile +# Usage: make iPhone2G | iPhone3G | iPodTouch1G | iPodTouch2G | +# iPhone3GS | iPhone4 | iPad1G | iPodTouch4G | aTV2G + +CROSS ?= arm-none-eabi- +CC := $(CROSS)gcc +OBJCOPY := $(CROSS)objcopy +HOST_CC := cc + +VERSION := 0.3 +GIT_COMMIT := $(shell git log --format=%h -1) + +BUILD := build + +# ── ARM compiler flags ──────────────────────────────────────────────────────── + +PLAT_FLAGS := \ + -mlittle-endian -mfpu=vfp -mthumb -mthumb-interwork -std=gnu11 + +CFLAGS := $(PLAT_FLAGS) -nostdlib -Wall -O1 -fcommon \ + -DOPENIBOOT_VERSION=$(VERSION) \ + -DOPENIBOOT_VERSION_BUILD=$(GIT_COMMIT) \ + -DCONFIG_ARM + +ASFLAGS := $(PLAT_FLAGS) -nostdlib -xassembler-with-cpp + +LDFLAGS := $(PLAT_FLAGS) -nostdlib -Ttext=0x0 + +INCLUDES := -Iincludes -Iarch-arm/includes + +# ── Host tools ──────────────────────────────────────────────────────────────── + +BIN2C := images/bin2c +MK8900IMG := mk8900image/mk8900image + +$(BIN2C): images/bin2c.c + $(HOST_CC) -o $@ $< + +# On Darwin arm64 the pre-built x86_64 binary runs via Rosetta. +# On other platforms, build from source. +UNAME_S := $(shell uname -s) +UNAME_M := $(shell uname -m) +ifeq ($(UNAME_S) $(UNAME_M),Darwin arm64) +$(MK8900IMG): + @test -f $@ || (echo "ERROR: mk8900image binary missing from mk8900image/"; exit 1) +else +MK8900_LIBS_Darwin := mk8900image/mac-x86/libxpwn.a mk8900image/mac-x86/libcommon.a +MK8900_LIBS_Linux_x86_64 := mk8900image/x86_64/libxpwn.a mk8900image/x86_64/libcommon.a +MK8900_LIBS_Linux := mk8900image/x86/libxpwn.a mk8900image/x86/libcommon.a +MK8900_LIBS := $(or $(MK8900_LIBS_$(UNAME_S)_$(UNAME_M)),$(MK8900_LIBS_$(UNAME_S))) +$(MK8900IMG): mk8900image/mk8900image.c $(MK8900_LIBS) + $(HOST_CC) -no-pie -o $@ $< $(MK8900_LIBS) -L/usr/X11/lib -lm -ldl -lpng -lcrypto -lz +endif + +# ── Source groups ───────────────────────────────────────────────────────────── + +ARCH_ARM_SRC := \ + arch-arm/entry.sx \ + arch-arm/asmhelpers.sx \ + arch-arm/arm.c + +BASE_SRC := \ + device.c mtd.c bdev.c nand.c vfl.c ftl.c audiohw.c actions.c \ + commands.c framebuffer.c images.c malloc.c nvram.c openiboot.c \ + printf.c scripting.c sha1.c stb_image.c syscfg.c tasks.c \ + util.c aes_wrap.c + +# s5l8720 uses a subset of base_src (no audiohw, nand, vfl, ftl, aes_wrap) +S5L8720_BASE_SRC := \ + device.c mtd.c bdev.c actions.c commands.c framebuffer.c images.c \ + malloc.c nvram.c openiboot.c printf.c scripting.c sha1.c stb_image.c \ + syscfg.c tasks.c util.c + +HFS_SRC := \ + hfs/bdev.c hfs/btree.c hfs/catalog.c hfs/extents.c \ + hfs/fastunicodecompare.c hfs/fs.c hfs/rawfile.c hfs/utility.c \ + hfs/volume.c hfs/xattr.c hfs/hfscompress.c + +# ── Module sources and flags ────────────────────────────────────────────────── + +ACM_SRC := acm/acm.c +ACM_INC := -Iacm/includes + +USB_SRC := usb-synopsys/usb.c +USB_INC := -Iusb-synopsys/includes + +NOR_CFI_SRC := nor-cfi/nor.c +NOR_CFI_INC := -Inor-cfi/includes + +NOR_SPI_SRC := nor-spi/nor.c +NOR_SPI_INC := -Inor-spi/includes + +VFL_VFL_SRC := vfl-vfl/vfl.c +VFL_VFL_INC := -Ivfl-vfl/includes -DCONFIG_VFL_VFL + +VFL_VSVFL_SRC := vfl-vsvfl/vsvfl.c +VFL_VSVFL_INC := -Ivfl-vsvfl/includes -DCONFIG_VFL_VSVFL + +FTL_YAFTL_SRC := ftl-yaftl/yaftl_mem.c ftl-yaftl/yaftl_common.c \ + ftl-yaftl/yaftl.c ftl-yaftl/yaftl_gc.c ftl-yaftl/l2v.c +FTL_YAFTL_INC := -Iftl-yaftl/includes -DCONFIG_FTL_YAFTL + +PMB8876_SRC := radio-pmb8876/radio.c +PMB8876_INC := -Iradio-pmb8876/includes + +PMB8878_SRC := radio-pmb8878/radio.c +PMB8878_INC := -Iradio-pmb8878/includes + +XGOLD618_SRC := radio-xgold618/radio.c +XGOLD618_INC := -Iradio-xgold618/includes + +MENU_SRC := menu/menu.c +MENU_INC := -Imenu/includes -Imenu + +INSTALLER_SRC := installer/installer.c +INSTALLER_INC := -Iinstaller + +INSTALLER_IMGS := \ + installer/images/installerLogoPNG.h \ + installer/images/installerBarEmptyPNG.h \ + installer/images/installerBarFullPNG.h + +# ── Platform sources and flags ──────────────────────────────────────────────── + +S5L8900_SRC := \ + plat-s5l8900/s5l8900.c plat-s5l8900/accel.c plat-s5l8900/aes.c \ + plat-s5l8900/buttons.c plat-s5l8900/chipid.c plat-s5l8900/clock.c \ + plat-s5l8900/dma.c plat-s5l8900/event.c plat-s5l8900/gpio.c \ + plat-s5l8900/i2c.c plat-s5l8900/interrupt.c plat-s5l8900/lcd.c \ + plat-s5l8900/miu.c plat-s5l8900/mmu.c plat-s5l8900/nand.c \ + plat-s5l8900/ftl.c plat-s5l8900/pmu.c plat-s5l8900/power.c \ + plat-s5l8900/sdio.c plat-s5l8900/spi.c plat-s5l8900/timer.c \ + plat-s5l8900/uart.c plat-s5l8900/usbphy.c plat-s5l8900/wdt.c \ + plat-s5l8900/wlan.c +S5L8900_INC := -Iplat-s5l8900/includes +S5L8900_DEFS := -DARM11 -DCONFIG_S5L8900 -mcpu=arm1176jzf-s + +S5L8720_SRC := \ + plat-s5l8720/s5l8720.c plat-s5l8720/accel.c plat-s5l8720/aes.c \ + plat-s5l8720/buttons.c plat-s5l8720/chipid.c plat-s5l8720/clcd.c \ + plat-s5l8720/clock.c plat-s5l8720/dma.c plat-s5l8720/event.c \ + plat-s5l8720/gpio.c plat-s5l8720/i2c.c plat-s5l8720/interrupt.c \ + plat-s5l8720/mipi_dsim.c plat-s5l8720/miu.c plat-s5l8720/mmu.c \ + plat-s5l8720/pmu.c plat-s5l8720/power.c plat-s5l8720/spi.c \ + plat-s5l8720/timer.c plat-s5l8720/uart.c plat-s5l8720/usbphy.c \ + plat-s5l8720/wdt.c +S5L8720_INC := -Iplat-s5l8720/includes +S5L8720_DEFS := -DARM11 -DCONFIG_S5L8720 -mcpu=arm1176jzf-s + +S5L8920_SRC := \ + plat-s5l8920/s5l8920.c plat-s5l8920/usbphy.c plat-s5l8920/aes.c \ + plat-s5l8920/buttons.c plat-s5l8920/chipid.c plat-s5l8920/clock.c \ + plat-s5l8920/event.c plat-s5l8920/gpio.c plat-s5l8920/i2c.c \ + plat-s5l8920/interrupt.c plat-s5l8920/clcd.c plat-s5l8920/mipi_dsim.c \ + plat-s5l8920/miu.c plat-s5l8920/mmu.c plat-s5l8920/power.c \ + plat-s5l8920/spi.c plat-s5l8920/timer.c plat-s5l8920/cdma.c \ + plat-s5l8920/h2fmi.c plat-s5l8920/uart.c +S5L8920_INC := -Iplat-s5l8920/includes +S5L8920_DEFS := -DARM_A8 -DCONFIG_S5L8920 -DMALLOC_NO_WDT -mcpu=cortex-a8 + +A4_SRC := \ + plat-a4/a4.c plat-a4/aes.c plat-a4/buttons.c plat-a4/chipid.c \ + plat-a4/clock.c plat-a4/event.c plat-a4/gpio.c plat-a4/i2c.c \ + plat-a4/interrupt.c plat-a4/mipi_dsim.c plat-a4/clcd.c plat-a4/miu.c \ + plat-a4/mmu.c plat-a4/pmu.c plat-a4/power.c plat-a4/spi.c \ + plat-a4/timer.c plat-a4/uart.c plat-a4/cdma.c plat-a4/usbphy.c \ + plat-a4/h2fmi.c plat-a4/sdio.c +A4_INC := -Iplat-a4/includes +A4_DEFS := -DARM_A8 -DCONFIG_A4 -DMALLOC_NO_WDT -DBIG_FONT -mcpu=cortex-a8 + +# ── Target definitions ──────────────────────────────────────────────────────── +# _SRC all source files +# _FLAGS extra compiler flags, defines, includes +# _OUT output base name (no extension) +# _TEMPLATE img3 template path (empty = .bin output only) + +iPhone2G_SRC := \ + $(ARCH_ARM_SRC) $(BASE_SRC) $(S5L8900_SRC) \ + plat-s5l8900/camera.c plat-s5l8900/als-TSL2561.c \ + plat-s5l8900/multitouch-z1.c plat-s5l8900/wm8958.c \ + plat-s5l8900/vibrator-2G.c \ + $(HFS_SRC) $(ACM_SRC) $(USB_SRC) $(NOR_CFI_SRC) $(PMB8876_SRC) $(MENU_SRC) +iPhone2G_FLAGS := $(S5L8900_DEFS) $(S5L8900_INC) \ + $(ACM_INC) $(USB_INC) $(NOR_CFI_INC) $(PMB8876_INC) $(MENU_INC) \ + -DCONFIG_IPHONE_2G -DMACH_ID=3556 \ + -DOPENIBOOT_VERSION_CONFIG='" for iPhone 2G"' +iPhone2G_OUT := iphone_2g_openiboot +iPhone2G_TEMPLATE := mk8900image/template.img3 + +iPhone3G_SRC := \ + $(ARCH_ARM_SRC) $(BASE_SRC) $(S5L8900_SRC) \ + plat-s5l8900/camera.c plat-s5l8900/als-ISL29003.c \ + plat-s5l8900/multitouch-z2.c plat-s5l8900/wm8991.c \ + plat-s5l8900/vibrator-3G.c \ + $(HFS_SRC) $(ACM_SRC) $(USB_SRC) $(NOR_SPI_SRC) $(PMB8878_SRC) $(MENU_SRC) +iPhone3G_FLAGS := $(S5L8900_DEFS) $(S5L8900_INC) \ + $(ACM_INC) $(USB_INC) $(NOR_SPI_INC) $(PMB8878_INC) $(MENU_INC) \ + -DCONFIG_IPHONE_3G -DMACH_ID=3557 \ + -DOPENIBOOT_VERSION_CONFIG='" for iPhone 3G"' +iPhone3G_OUT := iphone_3g_openiboot +iPhone3G_TEMPLATE := mk8900image/template-3g.img3 + +iPodTouch1G_SRC := \ + $(ARCH_ARM_SRC) $(BASE_SRC) $(S5L8900_SRC) \ + plat-s5l8900/piezo.c plat-s5l8900/wm8958.c plat-s5l8900/multitouch-z2.c \ + $(HFS_SRC) $(ACM_SRC) $(USB_SRC) $(NOR_CFI_SRC) $(MENU_SRC) +iPodTouch1G_FLAGS := $(S5L8900_DEFS) $(S5L8900_INC) \ + $(ACM_INC) $(USB_INC) $(NOR_CFI_INC) $(MENU_INC) \ + -DCONFIG_IPOD_TOUCH_1G -DMACH_ID=3558 \ + -DOPENIBOOT_VERSION_CONFIG='" for iPod Touch 1G"' +iPodTouch1G_OUT := ipt_1g_openiboot +iPodTouch1G_TEMPLATE := mk8900image/template-ipt1g.img3 + +iPodTouch2G_SRC := \ + $(ARCH_ARM_SRC) $(S5L8720_BASE_SRC) $(S5L8720_SRC) \ + audiohw-null.c \ + $(HFS_SRC) $(ACM_SRC) $(USB_SRC) $(NOR_SPI_SRC) +iPodTouch2G_FLAGS := $(S5L8720_DEFS) $(S5L8720_INC) \ + $(ACM_INC) $(USB_INC) $(NOR_SPI_INC) \ + -DCONFIG_IPOD_TOUCH_2G \ + -DOPENIBOOT_VERSION_CONFIG='" for iPod Touch 2G"' +iPodTouch2G_OUT := ipt_2g_openiboot +iPodTouch2G_TEMPLATE := mk8900image/template-ipt2g.img3 + +iPhone3GS_SRC := \ + $(ARCH_ARM_SRC) $(BASE_SRC) $(S5L8920_SRC) \ + audiohw-null.c \ + $(HFS_SRC) $(ACM_SRC) $(USB_SRC) $(NOR_SPI_SRC) $(PMB8878_SRC) \ + $(VFL_VFL_SRC) $(VFL_VSVFL_SRC) $(FTL_YAFTL_SRC) +iPhone3GS_FLAGS := $(S5L8920_DEFS) $(S5L8920_INC) \ + $(ACM_INC) $(USB_INC) $(NOR_SPI_INC) $(PMB8878_INC) \ + $(VFL_VFL_INC) $(VFL_VSVFL_INC) $(FTL_YAFTL_INC) \ + -DCONFIG_IPHONE_3GS -DMACH_ID=3562 \ + -DOPENIBOOT_VERSION_CONFIG='" for iPhone 3GS"' +iPhone3GS_OUT := iphone_3gs_openiboot +iPhone3GS_TEMPLATE := + +iPhone4_SRC := \ + $(ARCH_ARM_SRC) $(BASE_SRC) $(A4_SRC) \ + audiohw-null.c plat-a4/accel.c \ + $(HFS_SRC) $(ACM_SRC) $(USB_SRC) $(XGOLD618_SRC) \ + $(VFL_VFL_SRC) $(VFL_VSVFL_SRC) $(FTL_YAFTL_SRC) +iPhone4_FLAGS := $(A4_DEFS) $(A4_INC) \ + $(ACM_INC) $(USB_INC) $(XGOLD618_INC) \ + $(VFL_VFL_INC) $(VFL_VSVFL_INC) $(FTL_YAFTL_INC) \ + -DCONFIG_IPHONE_4 -DMACH_ID=3563 \ + -DOPENIBOOT_VERSION_CONFIG='" for iPhone 4"' +iPhone4_OUT := iphone_4_openiboot +iPhone4_TEMPLATE := + +iPad1G_SRC := \ + $(ARCH_ARM_SRC) $(BASE_SRC) $(A4_SRC) \ + audiohw-null.c plat-a4/accel.c \ + $(HFS_SRC) $(ACM_SRC) $(USB_SRC) $(NOR_SPI_SRC) \ + $(VFL_VFL_SRC) $(VFL_VSVFL_SRC) $(FTL_YAFTL_SRC) +iPad1G_FLAGS := $(A4_DEFS) $(A4_INC) \ + $(ACM_INC) $(USB_INC) $(NOR_SPI_INC) \ + $(VFL_VFL_INC) $(VFL_VSVFL_INC) $(FTL_YAFTL_INC) \ + -DCONFIG_IPAD_1G -DMACH_ID=3593 \ + -DOPENIBOOT_VERSION_CONFIG='" for iPad 1G"' +iPad1G_OUT := ipad_1g_openiboot +iPad1G_TEMPLATE := + +iPodTouch4G_SRC := \ + $(ARCH_ARM_SRC) $(BASE_SRC) $(A4_SRC) \ + audiohw-null.c plat-a4/accel.c \ + $(HFS_SRC) $(ACM_SRC) $(USB_SRC) \ + $(VFL_VFL_SRC) $(VFL_VSVFL_SRC) $(FTL_YAFTL_SRC) +iPodTouch4G_FLAGS := $(A4_DEFS) $(A4_INC) \ + $(ACM_INC) $(USB_INC) \ + $(VFL_VFL_INC) $(VFL_VSVFL_INC) $(FTL_YAFTL_INC) \ + -DCONFIG_IPOD_TOUCH_4G -DMACH_ID=3564 \ + -DOPENIBOOT_VERSION_CONFIG='" for iPod Touch 4G"' +iPodTouch4G_OUT := ipt_4g_openiboot +iPodTouch4G_TEMPLATE := + +aTV2G_SRC := \ + $(ARCH_ARM_SRC) $(BASE_SRC) $(A4_SRC) \ + audiohw-null.c plat-a4/mcu.c \ + $(HFS_SRC) $(ACM_SRC) $(USB_SRC) \ + $(VFL_VFL_SRC) $(VFL_VSVFL_SRC) $(FTL_YAFTL_SRC) +aTV2G_FLAGS := $(A4_DEFS) $(A4_INC) \ + $(ACM_INC) $(USB_INC) \ + $(VFL_VFL_INC) $(VFL_VSVFL_INC) $(FTL_YAFTL_INC) \ + -DCONFIG_ATV_2G -DMACH_ID=3594 \ + -DOPENIBOOT_VERSION_CONFIG='" for aTV 2G"' +aTV2G_OUT := atv_2g_openiboot +aTV2G_TEMPLATE := + +# ── Debug variants (adds -DDEBUG -g, output name gets _debug suffix) ────────── + +iPhone2GD_SRC := $(iPhone2G_SRC) +iPhone2GD_FLAGS := $(iPhone2G_FLAGS) -DDEBUG -g +iPhone2GD_OUT := iphone_2g_openiboot_debug +iPhone2GD_TEMPLATE := $(iPhone2G_TEMPLATE) + +iPhone3GD_SRC := $(iPhone3G_SRC) +iPhone3GD_FLAGS := $(iPhone3G_FLAGS) -DDEBUG -g +iPhone3GD_OUT := iphone_3g_openiboot_debug +iPhone3GD_TEMPLATE := $(iPhone3G_TEMPLATE) + +iPodTouch1GD_SRC := $(iPodTouch1G_SRC) +iPodTouch1GD_FLAGS := $(iPodTouch1G_FLAGS) -DDEBUG -g +iPodTouch1GD_OUT := ipt_1g_openiboot_debug +iPodTouch1GD_TEMPLATE := $(iPodTouch1G_TEMPLATE) + +iPodTouch2GD_SRC := $(iPodTouch2G_SRC) +iPodTouch2GD_FLAGS := $(iPodTouch2G_FLAGS) -DDEBUG -g +iPodTouch2GD_OUT := ipt_2g_openiboot_debug +iPodTouch2GD_TEMPLATE := $(iPodTouch2G_TEMPLATE) + +iPhone3GSD_SRC := $(iPhone3GS_SRC) +iPhone3GSD_FLAGS := $(iPhone3GS_FLAGS) -DDEBUG -g +iPhone3GSD_OUT := iphone_3gs_openiboot_debug +iPhone3GSD_TEMPLATE := $(iPhone3GS_TEMPLATE) + +iPhone4D_SRC := $(iPhone4_SRC) +iPhone4D_FLAGS := $(iPhone4_FLAGS) -DDEBUG -g +iPhone4D_OUT := iphone_4_openiboot_debug +iPhone4D_TEMPLATE := $(iPhone4_TEMPLATE) + +iPad1GD_SRC := $(iPad1G_SRC) +iPad1GD_FLAGS := $(iPad1G_FLAGS) -DDEBUG -g +iPad1GD_OUT := ipad_1g_openiboot_debug +iPad1GD_TEMPLATE := $(iPad1G_TEMPLATE) + +iPodTouch4GD_SRC := $(iPodTouch4G_SRC) +iPodTouch4GD_FLAGS := $(iPodTouch4G_FLAGS) -DDEBUG -g +iPodTouch4GD_OUT := ipt_4g_openiboot_debug +iPodTouch4GD_TEMPLATE := $(iPodTouch4G_TEMPLATE) + +aTV2GD_SRC := $(aTV2G_SRC) +aTV2GD_FLAGS := $(aTV2G_FLAGS) -DDEBUG -g +aTV2GD_OUT := atv_2g_openiboot_debug +aTV2GD_TEMPLATE := $(aTV2G_TEMPLATE) + +# ── Installer variants (s5l8900 only — swaps menu module for installer) ─────── + +iPhone2G-Installer_SRC := \ + $(filter-out $(MENU_SRC),$(iPhone2G_SRC)) $(INSTALLER_SRC) +iPhone2G-Installer_FLAGS := \ + $(filter-out $(MENU_INC),$(iPhone2G_FLAGS)) $(INSTALLER_INC) +iPhone2G-Installer_OUT := iphone_2g_installer +iPhone2G-Installer_TEMPLATE := $(iPhone2G_TEMPLATE) + +iPhone3G-Installer_SRC := \ + $(filter-out $(MENU_SRC),$(iPhone3G_SRC)) $(INSTALLER_SRC) +iPhone3G-Installer_FLAGS := \ + $(filter-out $(MENU_INC),$(iPhone3G_FLAGS)) $(INSTALLER_INC) +iPhone3G-Installer_OUT := iphone_3g_installer +iPhone3G-Installer_TEMPLATE := $(iPhone3G_TEMPLATE) + +iPodTouch1G-Installer_SRC := \ + $(filter-out $(MENU_SRC),$(iPodTouch1G_SRC)) $(INSTALLER_SRC) +iPodTouch1G-Installer_FLAGS := \ + $(filter-out $(MENU_INC),$(iPodTouch1G_FLAGS)) $(INSTALLER_INC) +iPodTouch1G-Installer_OUT := ipt_1g_installer +iPodTouch1G-Installer_TEMPLATE := $(iPodTouch1G_TEMPLATE) + +TARGETS := \ + iPhone2G iPhone3G iPodTouch1G iPodTouch2G \ + iPhone3GS iPhone4 iPad1G iPodTouch4G aTV2G \ + iPhone2GD iPhone3GD iPodTouch1GD iPodTouch2GD \ + iPhone3GSD iPhone4D iPad1GD iPodTouch4GD aTV2GD \ + iPhone2G-Installer iPhone3G-Installer iPodTouch1G-Installer + +# ── Build rule template ─────────────────────────────────────────────────────── + +# src_to_obj T, SRCS — convert source paths to build//path.o +src_to_obj = $(patsubst %.sx,$(BUILD)/$(1)/%.o,$(patsubst %.c,$(BUILD)/$(1)/%.o,$(2))) + +# order_objs T, OBJS — put entry.o first, init.o second, sentinel.o last +order_objs = \ + $(filter $(BUILD)/$(1)/arch-arm/entry.o,$(2)) \ + $(filter $(BUILD)/$(1)/init.o,$(2)) \ + $(filter-out \ + $(BUILD)/$(1)/arch-arm/entry.o \ + $(BUILD)/$(1)/init.o \ + $(BUILD)/$(1)/sentinel.o,$(2)) \ + $(filter $(BUILD)/$(1)/sentinel.o,$(2)) + +define TARGET_RULES + +# All sources including the mandatory bookend files +$(1)_ALLSRC := $$($(1)_SRC) init.c sentinel.c +$(1)_ALLOBJS := $$(call src_to_obj,$(1),$$($(1)_ALLSRC)) +$(1)_OBJS := $$(call order_objs,$(1),$$($(1)_ALLOBJS)) +$(1)_ELF := $(BUILD)/$(1)/$$($(1)_OUT) + +# Compile C sources +$(BUILD)/$(1)/%.o: %.c + @mkdir -p $$(@D) + $(CC) $(CFLAGS) $(INCLUDES) $$($(1)_FLAGS) -MMD -MP -c -o $$@ $$< + +# Compile preprocessed assembly sources +$(BUILD)/$(1)/%.o: %.sx + @mkdir -p $$(@D) + $(CC) $(ASFLAGS) $(INCLUDES) $$($(1)_FLAGS) -c -o $$@ $$< + +# Link ELF +$$($(1)_ELF): $$($(1)_OBJS) + $(CC) $(LDFLAGS) $$($(1)_FLAGS) -o $$@ $$^ -lgcc + +# Package with mk8900image +ifneq ($$($(1)_TEMPLATE),) +# Has an img3 template — produce both .bin and .img3 +$$($(1)_OUT).bin: $$($(1)_ELF) $(MK8900IMG) + $(MK8900IMG) $$< $$@ + +$$($(1)_OUT).img3: $$($(1)_ELF) $$($(1)_TEMPLATE) $(MK8900IMG) + $(MK8900IMG) $$< $$@ $$($(1)_TEMPLATE) + +$(1): $$($(1)_OUT).img3 +else +# No template — produce .bin only +$$($(1)_OUT).bin: $$($(1)_ELF) $(MK8900IMG) + $(MK8900IMG) $$< $$@ + +$(1): $$($(1)_OUT).bin +endif + +.PHONY: $(1) + +# If this target includes installer.c, its object file needs the generated headers +ifneq ($$(filter $(INSTALLER_SRC),$$($(1)_SRC)),) +$(BUILD)/$(1)/installer/installer.o: $(INSTALLER_IMGS) +endif + +-include $$(patsubst %.o,%.d,$$($(1)_ALLOBJS)) + +endef + +# ── Installer image headers ─────────────────────────────────────────────────── + +installer/images/%PNG.h: installer/images/%.png $(BIN2C) + $(BIN2C) data$(*F)PNG < $< > $@ + +# ── Generate rules for all targets ─────────────────────────────────────────── + +$(foreach T,$(TARGETS),$(eval $(call TARGET_RULES,$(T)))) + +# ── Utility targets ─────────────────────────────────────────────────────────── + +.DEFAULT_GOAL := help + +help: + @echo "Usage: make " + @echo "" + @echo "Release builds:" + @echo " s5l8900: iPhone2G iPhone3G iPodTouch1G" + @echo " s5l8720: iPodTouch2G" + @echo " s5l8920: iPhone3GS" + @echo " a4: iPhone4 iPad1G iPodTouch4G aTV2G" + @echo "" + @echo "Debug builds (append D, e.g. iPhone2GD):" + @echo " iPhone2GD iPhone3GD iPodTouch1GD iPodTouch2GD" + @echo " iPhone3GSD iPhone4D iPad1GD iPodTouch4GD aTV2GD" + @echo "" + @echo "Installer builds (s5l8900 only):" + @echo " iPhone2G-Installer iPhone3G-Installer iPodTouch1G-Installer" + @echo "" + @echo "Other:" + @echo " docs Build Doxygen documentation" + @echo "" + @echo "Options: CROSS= (default: arm-none-eabi-)" + +docs: + doxygen Doxyfile + +clean: + rm -rf $(BUILD) + rm -f $(foreach T,$(TARGETS),$($(T)_OUT).bin $($(T)_OUT).img3) + rm -f $(INSTALLER_IMGS) + +.PHONY: help docs clean diff --git a/INSTALLING.md b/INSTALLING.md new file mode 100644 index 0000000..df90cb0 --- /dev/null +++ b/INSTALLING.md @@ -0,0 +1,173 @@ +# Installing openiBoot on a Device + +This document covers how to flash openiBoot onto a supported device. For build instructions, see [README.md](README.md). + +> **WARNING (A4 devices):** DO NOT attempt to permanently flash openiBoot to the NOR on iPhone 4, iPad 1G, iPod Touch 4G, or Apple TV 2G. Doing so may brick your device. These devices are only supported for temporary (RAM) loading at this time. + +--- + +## Supported Devices + +| Device | Chip | Permanent NOR install | Temporary (RAM) load | +|---|---|---|---| +| iPhone 2G | s5l8900 | Yes | Yes | +| iPhone 3G | s5l8900 | Yes | Yes | +| iPod Touch 1G | s5l8900 | Yes | Yes | +| iPod Touch 2G | s5l8720 | Yes | Yes | +| iPhone 3GS | s5l8920 | With caution | Yes | +| iPhone 4 | A4 | **No** | Yes | +| iPad 1G | A4 | **No** | Yes | +| iPod Touch 4G | A4 | **No** | Yes | +| Apple TV 2G | A4 | **No** | Yes | + +--- + +## Prerequisites + +### 1. Jailbreak your device + +openiBoot requires a jailbreak that permits unsigned NOR images. The following jailbreaks are compatible: + +- **redsn0w** +- **PwnageTool** +- **Blackra1n** + +The following jailbreaks are **not** compatible: + +- Spirit +- JailbreakMe (any version) + +### 2. iOS version + +openiBoot is tested against iOS 3.1.2 through 4.1 on s5l8900 devices. iOS 4.2.1 is not yet fully supported. + +### 3. Build or obtain the openiBoot binary + +You will need either: +- The `.img3` file (for loading via recovery/iBoot mode — s5l8900/s5l8720 devices) +- The `.bin` file (for loading via DFU mode — s5l8920/A4 devices) + +See [README.md](README.md) for how to build these from source, or download a pre-built release. + +### 4. Companion tools + +The following tools are required for manual installation and are separate from this repository: + +- **`loadibec`** — sends an img3 to the device in recovery mode +- **`oibc`** — openiBoot console, used to interact with openiBoot over USB once loaded + +These tools are available from the [iDroid Project](https://www.idroidproject.org/) and the [`syringe`](https://github.com/iDroid-Project/syringe) repository. + +--- + +## Method 1: Bootlace (easiest — s5l8900 only) + +Bootlace is a Cydia application that installs openiBoot directly from your device. No computer required. + +**Supports:** iPhone 2G, iPhone 3G, iPod Touch 1G + +1. Open **Cydia** on your jailbroken device. +2. Search for **Bootlace** (hosted by BigBoss) and install it. +3. Open **Bootlace**. It will check your iOS version and jailbreak compatibility. +4. Tap the **OpeniBoot** tab (boot icon, second from right). +5. Tap **Install OpeniBoot**. Bootlace will patch the kernel and flash openiBoot to NOR. +6. The device will reboot into openiBoot on completion. + +> A backup of your original NOR (`norbackup.dump`) is saved to the device. Keep this file — it is the only way to restore your original bootloader if something goes wrong. + +--- + +## Method 2: Manual install via recovery mode (s5l8900/s5l8720) + +**Supports:** iPhone 2G, iPhone 3G, iPod Touch 1G, iPod Touch 2G + +### Step 1 — Enter recovery mode + +Hold **Home + Power** until the device powers off, then continue holding until the iTunes "connect to iTunes" screen appears. + +### Step 2 — Load openiBoot into RAM + +From your computer, run: + +```sh +loadibec openiboot.img3 +``` + +openiBoot will boot from RAM. The device screen will show the openiBoot interface. + +### Step 3 — Connect with oibc + +```sh +oibc +``` + +This opens an interactive console connected to your device over USB. + +### Step 4 — Flash to NOR (permanent install) + +Inside the `oibc` console, type: + +``` +install +``` + +openiBoot will back up your existing NOR to `norbackup.dump` and then write itself to NOR. This takes approximately 30–60 seconds. When complete, the device will display: + +``` +Openiboot installation complete. +``` + +Your device will now boot openiBoot on every power-on. + +--- + +## Method 3: DFU mode load (s5l8920 / A4) + +**Supports:** iPhone 3GS, iPhone 4, iPad 1G, iPod Touch 4G, Apple TV 2G + +> These devices can only load openiBoot temporarily into RAM via DFU mode. Do not attempt a permanent NOR install on A4 devices. + +### Step 1 — Enter DFU mode + +1. Power off the device completely. +2. Hold **Power** for 3 seconds. +3. While still holding Power, also hold **Home** for 10 seconds. +4. Release Power but continue holding **Home** for a further 5 seconds. +5. The screen should remain black. iTunes (or `idevicerestore`) should detect the device in DFU mode. + +### Step 2 — Send the openiBoot binary + +Use a DFU-mode upload tool (e.g. `redsn0w`, `irecovery`, or a platform-specific exploit tool) to send the compiled `.bin` file: + +```sh +irecovery -f openiboot.bin +``` + +openiBoot will load and run from RAM. + +--- + +## Restoring the original bootloader + +If you need to restore your original NOR after a permanent install: + +1. Load openiBoot via recovery mode using `loadibec`. +2. In the `oibc` console, run: + + ``` + norboot + ``` + + This will restore the NOR backup (`norbackup.dump`) that was saved during installation. + +Alternatively, use iTunes to restore the device to factory firmware via DFU mode. + +--- + +## Sources + +- [Running/Installing — iDroid-Project/openiBoot Wiki](https://github.com/iDroid-Project/openiBoot/wiki/Running-Installing) +- [Installing OpeniBoot — iDroid Project](https://www.idroidproject.org/wiki/Installing_OpeniBoot/) +- [Guide: Installing OpeniBoot and Android on your iDevice — GBAtemp](https://gbatemp.net/threads/guide-installing-openiboot-and-android-on-your-idevice.253635/) +- [Guide: iDroid with Bootlace — GBAtemp](https://gbatemp.net/threads/guide-idroid-with-bootlace.263038/) +- [OpeniBoot — Wikipedia](https://en.wikipedia.org/wiki/OpeniBoot) diff --git a/Makefile b/Makefile deleted file mode 100644 index 609ae42..0000000 --- a/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -ifeq ($(PLATFORM),IPHONE2G) - TARGET = iphone_2g_openiboot.img3 -endif - -ifeq ($(PLATFORM),IPHONE3G) - TARGET = iphone_3g_openiboot.img3 -endif - -ifeq ($(PLATFORM),IPT1G) - TARGET = ipt_1g_openiboot.img3 -endif - -ifeq ($(PLATFORM),IPT2G) - TARGET = ipt_2g_openiboot.img3 -endif - -ifeq ($(PLATFORM),IPHONE4) - TARGET = iphone_4_openiboot.bin -endif - -ifeq ($(PLATFORM),IPAD1G) - TARGET = ipad_1g_openiboot.bin -endif - -ifeq ($(PLATFORM),IPT4G) - TARGET = ipt_4g_openiboot.bin -endif - -ifeq ($(PLATFORM),ATV2G) - TARGET = atv_2g_openiboot.bin -endif - -all: - scons $(TARGET) - -clean: - scons -c * - @cd ../utils/syringe; make clean_all - @cd ../utils/oibc; make clean - -install: - make -C ../utils/syringe - sudo ../utils/syringe/utilities/loadibec $(TARGET) diff --git a/README.md b/README.md index 1832d4b..dbac6ef 100644 --- a/README.md +++ b/README.md @@ -1,87 +1,148 @@ -iDroid Project openiBoot ---------------------------------------------------- - Copyright (C) 2008 David Wang (planetbeing). +# openiBoot - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. +An open-source bootloader for Apple's ARM-based devices (iPhone, iPod touch, iPad, Apple TV). Originally developed by the [iDroid Project](https://www.idroidproject.org/) to boot alternative operating systems (Android, Linux) on early Apple hardware. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +## Supported Devices - You should have received a copy of the GNU General Public License - along with this program. If not, see . +| Device | SoC | CPU | Status | +|---|---|---|---| +| iPhone 2G | S5L8900 | ARM1176JZF-S | Stable | +| iPhone 3G | S5L8900 | ARM1176JZF-S | Stable | +| iPod Touch 1G | S5L8900 | ARM1176JZF-S | Stable | +| iPod Touch 2G | S5L8720 | ARM1176JZF-S | Stable | +| iPhone 3GS | S5L8920 | Cortex-A8 | Experimental | +| iPhone 4 | A4 | Cortex-A8 | Experimental | +| iPad 1G | A4 | Cortex-A8 | Experimental | +| iPod Touch 4G | A4 | Cortex-A8 | Experimental | +| Apple TV 2G | A4 | Cortex-A8 | Experimental | -NOTE: Version 0.3 and above will not boot iDroid 2.6.32 series kernels without additional parameters being passed to the kernel. +## Building -Warning ---------------------------------------------------- -IT IS STRONGLY ADVISED THAT YOU DO NOT ATTEMPT TO RUN NAND WRITE FUNCTIONS IN THE A4 VERSION AT THIS POINT IN TIME. +### Prerequisites -DOING SO WILL INEVITABLY CAUSE YOU TO NEED TO RESTORE YOUR DEVICE, MAY LEAVE PERMANENT NAND BLOCK DAMAGE AND MAY ALSO CAUSE GREMLINS TO CRAWL OUT OF YOUR ARSE. +- **ARM cross-compiler:** `arm-none-eabi-gcc` must be on your PATH. + - macOS: Install [Arm GNU Toolchain](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) or `brew install --cask gcc-arm-embedded` + - Linux: `sudo apt install gcc-arm-none-eabi` (Debian/Ubuntu) or download from Arm +- **GNU Make** -(If you read this warning properly, really unless you know wtf you are looking at - leave it alone until we stablise it) +### Build a target -Compiling ---------------------------------------------------- -To run openiboot from recovery mode (a.k.a iboot), you’ll need to create an img3 image. -To run openiboot from DFU mode, you'll need to create a bin. +```sh +make iPhone3G +``` -You will need a system capable of running x86 Linux binaries (Build requires scons, libssl, libpng, libcurl, libusb, libreadline and pthread). +Available targets: -Change into the openiboot subfolder +| SoC | Release | Debug | Installer | +|---|---|---|---| +| S5L8900 | `iPhone2G` `iPhone3G` `iPodTouch1G` | `iPhone2GD` `iPhone3GD` `iPodTouch1GD` | `iPhone2G-Installer` `iPhone3G-Installer` `iPodTouch1G-Installer` | +| S5L8720 | `iPodTouch2G` | `iPodTouch2GD` | | +| S5L8920 | `iPhone3GS` | `iPhone3GSD` | | +| A4 | `iPhone4` `iPad1G` `iPodTouch4G` `aTV2G` | `iPhone4D` `iPad1GD` `iPodTouch4GD` `aTV2GD` | | -**For iPod Touch 1G, run:** -`scons iPodTouch1G` +Debug builds add `-DDEBUG -g`, which enables `DebugPrintf` output and debug symbols. -**For iPhone 2G, run:** -`scons iPhone2G` +### Build output -**For iPhone 3G, run:** -`scons iPhone3G` +- **`.img3`** — For loading via recovery/iBoot mode (S5L8900, S5L8720 devices) +- **`.bin`** — For loading via DFU mode (S5L8920, A4 devices) -**For iPod Touch 2G, run:** -`scons iPodTouch2G` +### Cross-compiler override -**For iPhone 3GS, run:** -`scons iPhone3GS` +```sh +make iPhone3G CROSS=arm-none-eabi- +``` -**For iPhone 4, run:** -`scons iPhone4` +### Other targets -**For iPod Touch 4G, run:** -`scons iPodTouch4G` +```sh +make clean # Remove all build artifacts +make docs # Generate Doxygen documentation +``` -**For iPad 1G, run:** -`scons iPad1G` +## Installing -**For Apple TV 2G, run:** -`scons aTV2G` +See [INSTALLING.md](INSTALLING.md) for detailed instructions on flashing openiBoot to a device, including: -*Alternatively a Makefile has been provided in the openiboot subfolder should you prefer to use it this way - this is not covered by this README but is provided for your convenience should you wish to use it* +- **Bootlace** (Cydia app, easiest for S5L8900 devices) +- **Manual install** via recovery mode with `loadibec` + `oibc` +- **DFU mode** loading for S5L8920/A4 devices +- **Restoring** the original bootloader -Menu Configuration ---------------------------------------------------- -As of version 0.3 OpeniBoot now has a grub-style configurable menu system, OpeniBoot looks for /boot/menu.lst at boot. -Below is an example menu.lst - put it in /boot (This section will be expanded upon at a later date, when newer device ports are further ahead) +## Menu Configuration - title iOS - auto +openiBoot includes a GRUB-style boot menu. On startup it looks for `/boot/menu.lst` on the data partition. If the file is not found, it drops to the interactive console. - title Android - kernel "(hd0,1)/idroid/zImage" "console=tty root=/dev/ram0 init=/init rw" - initrd "(hd0,1)/idroid/android.img.gz" +Example `/boot/menu.lst`: - title iX - kernel "(hd0,1)/iX/zImage" "console=tty root=/dev/ram0 init=/init rw" - initrd "(hd0,1)/iX/initrd.img.gz" +``` +title iOS +auto +title Android +kernel "(hd0,1)/idroid/zImage" "console=tty root=/dev/ram0 init=/init rw" +initrd "(hd0,1)/idroid/android.img.gz" -Reporting issues/requesting features --------------------------------------------------- -Please leave bug reports/pull requests in the Github tracker. +title iX +kernel "(hd0,1)/iX/zImage" "console=tty root=/dev/ram0 init=/init rw" +initrd "(hd0,1)/iX/initrd.img.gz" +``` -For anything else, we can be found lurking in #idroid-dev on irc.freenode.net +**Menu controls (on device):** + +| Button | Action | +|---|---| +| Home | Select / boot highlighted entry | +| Hold switch (or Volume Down) | Next entry | +| Volume Up | Previous entry | + +"Console" is always listed as the last menu entry and opens the interactive USB console. + +## Interactive Console + +openiBoot provides an interactive console accessible over USB using the `oibc` (openiBoot Console) tool. The console supports commands for device inspection, NOR operations, memory access, booting, and more. Type `help` in the console for a list of available commands. + +## Project Structure + +``` +arch-arm/ ARM architecture support (exception vectors, context switch, asm helpers) +plat-s5l8900/ S5L8900 platform drivers (iPhone 2G/3G, iPod Touch 1G) +plat-s5l8720/ S5L8720 platform drivers (iPod Touch 2G) +plat-s5l8920/ S5L8920 platform drivers (iPhone 3GS) +plat-a4/ A4 platform drivers (iPhone 4, iPad 1G, iPod Touch 4G, Apple TV 2G) +includes/ Shared headers +acm/ USB Abstract Control Model (virtual serial port) +usb-synopsys/ Synopsys USB OTG driver +nor-cfi/ CFI NOR flash driver +nor-spi/ SPI NOR flash driver +vfl-vfl/ Virtual Flash Layer +vfl-vsvfl/ VSVFL implementation +ftl-yaftl/ YAFTL Flash Translation Layer +hfs/ HFS+ filesystem support +menu/ Boot menu UI +installer/ On-device installer +radio-pmb8876/ PMB8876 baseband radio driver +radio-pmb8878/ PMB8878 baseband radio driver +radio-xgold618/ XGold 618 baseband radio driver +mk8900image/ Tool to package binaries into img3 format +images/ Boot images and bin2c converter +``` + +## Architecture Notes + +- All C code compiles as **Thumb** (`-mthumb`) with ARM interworking (`-mthumb-interwork`). +- Exception handlers and coprocessor manipulation are in **ARM mode** (`.code 32`). +- The cooperative task scheduler (`tasks.c`) uses manual context switching via `SwapTask` in assembly. +- Critical sections use IRQ/FIQ disable via direct CPSR manipulation. +- The VIC (PL192) interrupt controller dispatches through a handler table in the `.data` section. + +## License + +GNU General Public License v3.0 or later. See [LICENSE.txt](LICENSE.txt). + +Copyright (C) 2008-2011 iDroid Project. Originally created by David Wang (planetbeing). + +## Links + +- [iDroid Project](https://www.idroidproject.org/) +- [Original repository](https://github.com/iDroid-Project/openiBoot) diff --git a/SConstruct b/SConstruct deleted file mode 100644 index 749195d..0000000 --- a/SConstruct +++ /dev/null @@ -1,89 +0,0 @@ -# -# The root build file for OpeniBoot. -# - -import SCons - -# -# Configuration, change this stuff -# -version="0.3" -# /Configuration - -SConscript([ - 'scons/ARMEnvironment.SConscript', - 'scons/Git.SConscript', - ]) -Import('*') - -henv = Environment() -Export('henv') -henv.SConscript(['scons/Doxygen.SConscript']) - -env = ARMEnvironment() -env.Append(CPPDEFINES=[ - 'OPENIBOOT_VERSION='+version, - 'OPENIBOOT_VERSION_BUILD='+GetGitCommit(), - ]) -env.Append(CPPFLAGS = ['-Wall', '-Werror', '-O2', '-Ttext=0x0']) -Export('env') - -def localize(env, ls): - return [File(f) for f in ls] -env.AddMethod(localize, "Localize") - -# Documentation -docs = henv.Doxygen("Doxyfile") -Alias("docs", docs) - -# Base Target Sources -base_src = env.Localize([ - 'device.c', - 'mtd.c', - 'bdev.c', - 'nand.c', - 'vfl.c', - 'ftl.c', - 'audiohw.c', - 'actions.c', - 'commands.c', - 'framebuffer.c', - 'images.c', - 'malloc.c', - 'nvram.c', - 'openiboot.c', - 'printf.c', - 'scripting.c', - 'sha1.c', - 'stb_image.c', - 'syscfg.c', - 'tasks.c', - 'util.c', - 'aes_wrap.c', - ]) -Export('base_src') - -# Build-Environment Modules -henv.SConscript([ - 'images/SConscript', - 'mk8900image/SConscript', - 'scons/Module.SConscript', - ]) - -# Target Modules -env.SConscript([ - 'hfs/SConscript', - 'radio-pmb8876/SConscript', - 'radio-pmb8878/SConscript', - 'radio-xgold618/SConscript', - 'usb-synopsys/SConscript', - 'nor-cfi/SConscript', - 'nor-spi/SConscript', - 'vfl-vfl/SConscript', - 'vfl-vsvfl/SConscript', - 'ftl-yaftl/SConscript', - 'acm/SConscript', - 'menu/SConscript', - 'installer/SConscript', - 'arch-arm/SConscript', - ]) diff --git a/acm/SConscript b/acm/SConscript deleted file mode 100644 index 3f50340..0000000 --- a/acm/SConscript +++ /dev/null @@ -1,8 +0,0 @@ -Import('*') - -acm_src = env.Localize([ - 'acm.c', - ]) - -acm = env.CreateModule('acm', acm_src) -acm.Append(CPPPATH = [Dir('includes')]) diff --git a/arch-arm/SConscript b/arch-arm/SConscript deleted file mode 100644 index 8d806a9..0000000 --- a/arch-arm/SConscript +++ /dev/null @@ -1,19 +0,0 @@ -Import("*") - -env = env.Clone() -env.Append(CPPPATH = [Dir('includes')]) -env.Append(CPPDEFINES = ['CONFIG_ARM']) - -arch_arm_src = env.Localize([ - 'entry.sx', - 'asmhelpers.sx', - 'arm.c', - ]) -Export('arch_arm_src') - -env.SConscript([ - '#plat-s5l8720/SConscript', - '#plat-s5l8900/SConscript', - '#plat-s5l8920/SConscript', - '#plat-a4/SConscript', - ], 'env') diff --git a/arch-arm/asmhelpers.sx b/arch-arm/asmhelpers.sx index cd0cf03..441aaf8 100644 --- a/arch-arm/asmhelpers.sx +++ b/arch-arm/asmhelpers.sx @@ -121,7 +121,7 @@ CallArm: .code 32 - +.type CallThumb, %function CallThumb: BX R0 @@ -129,24 +129,28 @@ CallThumb: @ FIQ/IRQ Control @ +.type EnableCPUIRQ, %function EnableCPUIRQ: MRS R0, CPSR BIC R0, R0, #ARM11_CPSR_IRQDISABLE MSR CPSR_c, R0 BX LR +.type EnableCPUFIQ, %function EnableCPUFIQ: MRS R0, CPSR BIC R0, R0, #ARM11_CPSR_FIQDISABLE MSR CPSR_c, R0 BX LR +.type DisableCPUIRQ, %function DisableCPUIRQ: MRS R0, CPSR ORR R0, R0, #ARM11_CPSR_IRQDISABLE MSR CPSR_c, R0 BX LR +.type DisableCPUFIQ, %function DisableCPUFIQ: MRS R0, CPSR ORR R0, R0, #ARM11_CPSR_FIQDISABLE @@ -157,38 +161,47 @@ DisableCPUFIQ: @ Coprocessor manipulation @ +.type ReadControlRegisterConfigData, %function ReadControlRegisterConfigData: MRC p15, 0, R0, c1, c0, 0 BX LR +.type WriteControlRegisterConfigData, %function WriteControlRegisterConfigData: MCR p15, 0, R0, c1, c0, 0 BX LR +.type ReadAuxiliaryControlRegister, %function ReadAuxiliaryControlRegister: MRC p15, 0, R0, c1, c0, 1 BX LR +.type WriteAuxiliaryControlRegister, %function WriteAuxiliaryControlRegister: MCR p15, 0, R0, c1, c0, 1 BX LR +.type WriteDomainAccessControlRegister, %function WriteDomainAccessControlRegister: MCR p15, 0, R0, c3, c0 BX LR +.type ReadDataFaultStatusRegister, %function ReadDataFaultStatusRegister: MRC p15, 0, R0, c5, c0, 1 BX LR +.type ReadFaultAddressRegister, %function ReadFaultAddressRegister: MRC p15, 0, R0, c6, c0, 1 BX LR +.type WritePeripheralPortMemoryRemapRegister, %function WritePeripheralPortMemoryRemapRegister: MCR p15, 0, R0, c15, c2, 4 BX LR +.type GiveFullAccessCP10CP11, %function GiveFullAccessCP10CP11: MRC p15, 0, R0, c1, c0, 2 MOV R1, #(ARM11_AccessControl_CP10_ALL | ARM11_AccessControl_CP11_ALL) @@ -196,12 +209,14 @@ GiveFullAccessCP10CP11: MCR p15, 0, R0, c1, c0, 2 BX LR +.type EnableVFP, %function EnableVFP: @ FIXME: Not working yet without VFP FMRX R2, FPEXC ORR R2, R2, ARM11_VFP_Enable FMXR FPEXC, R2 BX LR +.type WaitForInterrupt, %function WaitForInterrupt: #ifdef ARM11 MOV R0, #0 @@ -217,14 +232,17 @@ WaitForInterrupt: @ MMU management @ +.type WriteTranslationTableBaseRegister0, %function WriteTranslationTableBaseRegister0: MCR p15, 0, R0, c2, c0 BX LR +.type ReadTranslationTableBaseRegister0, %function ReadTranslationTableBaseRegister0: MRC p15, 0, R0, c2, c0 BX LR +.type InvalidateUnifiedTLBUnlockedEntries, %function InvalidateUnifiedTLBUnlockedEntries: MOV R0, #0 MCR p15, 0, R0, c8, c7 @@ -234,11 +252,13 @@ InvalidateUnifiedTLBUnlockedEntries: @ Cache management @ +.type DataSynchronizationBarrier, %function DataSynchronizationBarrier: MOV R0, #0 MCR p15, 0, R0, c7, c10, 4 @ Data synchronization barrier BX LR +.type ClearCPUInstructionCache, %function ClearCPUInstructionCache: MOV R0, #0 MCR p15, 0, R0, c7, c5 @@ -248,18 +268,22 @@ ClearCPUInstructionCache: NOP BX LR +.type CleanDataCacheLineMVA, %function CleanDataCacheLineMVA: MCR p15, 0, R0, c7, c10, 1 BX LR +.type InvalidateDataCacheLineMVA, %function InvalidateDataCacheLineMVA: MCR p15, 0, R0, c7, c6, 1 BX LR +.type CleanAndInvalidateDataCacheLineMVA, %function CleanAndInvalidateDataCacheLineMVA: MCR p15, 0, R0, c7, c14, 1 BX LR +.type CleanCPUDataCache, %function CleanCPUDataCache: #ifdef ARM11 MOV R0, #0 @@ -283,6 +307,7 @@ CleanCPUDataCache_2: MCR p15, 0, R0, c7, c10, 4 @ Data synchronization barrier BX LR +.type InvalidateCPUDataCache, %function InvalidateCPUDataCache: #ifdef ARM11 MOV R0, #0 @@ -305,6 +330,7 @@ InvalidateCPUDataCache_2: BX LR +.type CleanAndInvalidateCPUDataCache, %function CleanAndInvalidateCPUDataCache: #ifdef ARM11 MOV R0, #0 @@ -329,6 +355,7 @@ CleanAndInvalidateCPUDataCache_2: MCR p15, 0, R0, c7, c10, 4 @ Data synchronization barrier BX LR +.type ClearCPUCaches, %function ClearCPUCaches: STMFD SP!, {LR} BL CleanCPUDataCache @@ -339,15 +366,18 @@ ClearCPUCaches: // These two are used by the 3GS, // clearly for demonic purposes. -- Ricky26 .global GetC9C012 +.type GetC9C012, %function GetC9C012: MRC p15, 1, R0, c9, c0, 2 BX LR .global SetC9C012 +.type SetC9C012, %function SetC9C012: MCR p15, 1, R0, c9, c0, 2 BX LR +.type Reboot, %function Reboot: #if defined(CONFIG_S5L8900) || defined(CONFIG_S5L8720) LDR R0, =WDT_CTRL @@ -392,6 +422,7 @@ Reboot: @ Tasks @ +.type SwapTask, %function SwapTask: @ Store current stuff LDR R1, =CurrentRunning @@ -428,6 +459,7 @@ SwapTask: .global task_run +.type StartTask, %function StartTask: @ R4 = Task PTR @ R5 = Argument @@ -442,6 +474,7 @@ StartTask: B Reboot +.type EndlessLoop, %function EndlessLoop: B EndlessLoop diff --git a/doxygen/readme.txt b/doxygen/readme.txt index 8800fea..58a53b8 100644 --- a/doxygen/readme.txt +++ b/doxygen/readme.txt @@ -2,7 +2,7 @@ This folder will contain doxygen generated documentation. To generate the documentation, make sure you have the appropriate doxygen package installed for your operating system (and that it's -on the system path), then run `scons docs`. +on the system path), then run `make docs`. This will generated html and latex directories alongside this document. diff --git a/framebuffer.c b/framebuffer.c index 90d73ae..0e207e8 100644 --- a/framebuffer.c +++ b/framebuffer.c @@ -56,16 +56,16 @@ static uint32_t ForegroundColor; #define RGBA2BGR(x) ((((x) >> 16) & 0xFF) | ((((x) >> 8) & 0xFF) << 8) | (((x) & 0xFF) << 16)) -inline int getCharPixel(int ch, int x, int y) { +static inline int getCharPixel(int ch, int x, int y) { register int bitIndex = ((fontWidth * fontHeight) * ch) + (fontWidth * y) + x; return (fontData[bitIndex / 8] >> (bitIndex % 8)) & 0x1; } -inline volatile uint32_t* PixelFromCoords(register uint32_t x, register uint32_t y) { +static inline volatile uint32_t* PixelFromCoords(register uint32_t x, register uint32_t y) { return CurFramebuffer + (y * FBWidth) + x; } -inline volatile uint16_t* PixelFromCoords565(register uint32_t x, register uint32_t y) { +static inline volatile uint16_t* PixelFromCoords565(register uint32_t x, register uint32_t y) { return ((uint16_t*)CurFramebuffer) + (y * FBWidth) + x; } diff --git a/ftl-yaftl/SConscript b/ftl-yaftl/SConscript deleted file mode 100644 index 2332f47..0000000 --- a/ftl-yaftl/SConscript +++ /dev/null @@ -1,13 +0,0 @@ -Import('*') - -ftl_yaftl_src = env.Localize([ - 'yaftl_mem.c', - 'yaftl_common.c', - 'yaftl.c', - 'yaftl_gc.c', - 'l2v.c', - ]) - -ftl_yaftl = env.CreateModule('ftl-yaftl', ftl_yaftl_src) -ftl_yaftl.Append(CPPPATH = [Dir('includes')]) -ftl_yaftl.Append(CPPDEFINES = ['CONFIG_FTL_YAFTL']) diff --git a/hfs/SConscript b/hfs/SConscript deleted file mode 100644 index d53717e..0000000 --- a/hfs/SConscript +++ /dev/null @@ -1,16 +0,0 @@ -Import("*") - -hfs_src = env.Localize([ - 'bdev.c', - 'btree.c', - 'catalog.c', - 'extents.c', - 'fastunicodecompare.c', - 'fs.c', - 'rawfile.c', - 'utility.c', - 'volume.c', - 'xattr.c', - 'hfscompress.c', - ]) -Export('hfs_src') diff --git a/images/SConscript b/images/SConscript deleted file mode 100644 index 64a69a7..0000000 --- a/images/SConscript +++ /dev/null @@ -1,24 +0,0 @@ -Import('*') - -# -# Build file for bin2c, and image headers. -# - -bin2c = henv.Program('bin2c', ['bin2c.c']) - -def generate_actions(source, target, env, for_signature=False): - Depends(target, bin2c) - return "%s %s < %s > %s" % (str(bin2c[0]), env['BASE'], source[0], target[0]) - -env.Append(BUILDERS = {'Bin2C': Builder(generator=generate_actions)}) - -def Bin2CList(env, sources, src_pattern, dest_pattern, data_pattern): - ret = [] - for s in sources: - src = src_pattern % s - dest = dest_pattern % s - data = data_pattern % s - target = env.Bin2C(dest, src, BASE=data) - ret.append(target) - return ret -env.AddMethod(Bin2CList, "Bin2CList") diff --git a/includes/openiboot.h b/includes/openiboot.h index 01cac39..64c1159 100644 --- a/includes/openiboot.h +++ b/includes/openiboot.h @@ -112,7 +112,7 @@ typedef void (*EventHandler)(Event* event, void* opaque); typedef struct LinkedList { void* prev; void* next; -} __attribute__ ((packed)) LinkedList; +} LinkedList; typedef struct TaskRegisterState { uint32_t r4; @@ -125,7 +125,7 @@ typedef struct TaskRegisterState { uint32_t r11; uint32_t sp; uint32_t lr; -} __attribute__ ((packed)) TaskRegisterState; +} TaskRegisterState; typedef enum TaskState { TASK_READY = 1, @@ -163,7 +163,7 @@ typedef struct TaskDescriptor { uint32_t identifier2; uint32_t wasWoken; -} __attribute__ ((packed)) TaskDescriptor; +} TaskDescriptor; extern TaskDescriptor* CurrentRunning; diff --git a/includes/util.h b/includes/util.h index b66d2b5..8aeaba7 100644 --- a/includes/util.h +++ b/includes/util.h @@ -294,7 +294,7 @@ uint32_t adler32(uint8_t *buf, int32_t len); const char *strerr(error_t _e); uint32_t next_power_of_two(uint32_t n); -inline void auto_store(void *_ptr, size_t _sz, uint32_t _val); +void auto_store(void *_ptr, size_t _sz, uint32_t _val); #include "printf.h" #include "malloc-2.8.3.h" diff --git a/installer/SConscript b/installer/SConscript deleted file mode 100644 index b312208..0000000 --- a/installer/SConscript +++ /dev/null @@ -1,21 +0,0 @@ -Import('*') - -installer_src = env.Localize([ - 'installer.c', - ]) - -installer = env.CreateModule('installer', installer_src) -installer.Append(CPPPATH = [Dir('includes'), Dir('.')]) - -images = env.Bin2CList([ - 'installerLogo', - 'installerBarEmpty', - 'installerBarFull', - ], "images/%s.png", "images/%sPNG.h", "data%sPNG") -installer.Depends(images) - -def InstallerEnv(env): - e2 = env.Clone() - e2.AddModules(["installer"]) - return e2 -env.AddMethod(InstallerEnv, "InstallerEnv") diff --git a/installer/installer.c b/installer/installer.c index bab8030..e9b0aa1 100644 --- a/installer/installer.c +++ b/installer/installer.c @@ -35,12 +35,12 @@ static void installer_init() } MODULE_INIT_BOOT(installer_init); -void cmd_progress(int argc, char **argv) +error_t cmd_progress(int argc, char **argv) { if(argc != 2) { bufferPrintf("Usage: %s \n", argv[0]); - return; + return SUCCESS; } int x,y,w; @@ -98,5 +98,6 @@ void cmd_progress(int argc, char **argv) cmd_progress_full_width, cmd_progress_full_height, w, cmd_progress_full_height); } + return SUCCESS; } COMMAND("progress", "Set the install progress.", cmd_progress); diff --git a/menu/SConscript b/menu/SConscript deleted file mode 100644 index 1f0e6ba..0000000 --- a/menu/SConscript +++ /dev/null @@ -1,25 +0,0 @@ -Import('*') - -menu_src = env.Localize([ - 'menu.c', - ]) - -menu = env.CreateModule('menu', menu_src) -menu.Append(CPPPATH = [Dir('includes'), Dir('.')]) - -#images = env.Bin2CList([ -# 'Console', -# 'ConsoleSelected', -# 'Header', -# 'iPhoneOS', -# 'iPhoneOSSelected', -# 'AndroidOSSelected', -# 'AndroidOS', -# ], "images/%s.png", "images/%sPNG.h", "data%sPNG") -#menu.Depends(images) - -def MenuEnv(env): - e2 = env.Clone() - e2.AddModules(["menu"]) - return e2 -env.AddMethod(MenuEnv, "MenuEnv") diff --git a/menu/menu.c b/menu/menu.c index d6cbe3f..ff913c2 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -152,6 +152,8 @@ void menu_main() if(script_run_file("(0)/boot/menu.lst")) { + framebuffer_setdisplaytext(TRUE); + framebuffer_clear(); bufferPrintf("menu.lst NOT FOUND - Switching to console...\n"); OpenIBootConsole(); return; diff --git a/mk8900image/SConscript b/mk8900image/SConscript deleted file mode 100644 index 0db5375..0000000 --- a/mk8900image/SConscript +++ /dev/null @@ -1,28 +0,0 @@ -Import("*") - -import platform - -libs = [] -if platform.system() == 'Linux': - if platform.machine() == 'x86_64': - libs += ["x86_64/libxpwn.a", "x86_64/libcommon.a"] - else: - libs += ["x86/libxpwn.a", "x86/libcommon.a"] - -if platform.system() == 'Darwin': - libs += ["mac-x86/libxpwn.a", "mac-x86/libcommon.a"] - -mk8900image = henv.Program('mk8900image', ['mk8900image.c'] + libs, LIBPATH='/usr/X11/lib', LIBS=['m', 'dl', 'png', 'crypto', 'z']) - -def generate_actions(source, target, env, for_sig=False, **kw): - Depends(target, mk8900image) - - if len(source) > 2: - return "%s %s %s %s %s" % (str(mk8900image[0]), source[0], target[0], source[1], source[2]) - - if len(source) > 1: - return "%s %s %s %s" % (str(mk8900image[0]), source[0], target[0], source[1]) - - return "%s %s %s" % (str(mk8900image[0]), source[0], target[0]) - -env.Append(BUILDERS = {'Make8900Image': Builder(generator=generate_actions)}) diff --git a/nor-cfi/SConscript b/nor-cfi/SConscript deleted file mode 100644 index 1f9c4d8..0000000 --- a/nor-cfi/SConscript +++ /dev/null @@ -1,8 +0,0 @@ -Import("*") - -nor_cfi_src = env.Localize([ - 'nor.c' - ]) - -nor_cfi = env.CreateModule('nor-cfi', nor_cfi_src) -nor_cfi.Append(CPPPATH=[Dir('includes')]) diff --git a/nor-spi/SConscript b/nor-spi/SConscript deleted file mode 100644 index 3ac6835..0000000 --- a/nor-spi/SConscript +++ /dev/null @@ -1,8 +0,0 @@ -Import("*") - -nor_spi_src = env.Localize([ - 'nor.c' - ]) - -nor_spi = env.CreateModule('nor-spi', nor_spi_src) -nor_spi.Append(CPPPATH=[Dir('includes')]) diff --git a/openiboot.c b/openiboot.c index 8536b33..1ce81bd 100644 --- a/openiboot.c +++ b/openiboot.c @@ -47,11 +47,14 @@ void OpenIBootStart() platform_init(); init_setup(); + bufferPrintf("boot: init_boot_modules\r\n"); OpenIBootMain = &OpenIBootConsole; init_boot_modules(); + bufferPrintf("boot: calling OpenIBootMain\r\n"); OpenIBootMain(); + bufferPrintf("boot: tasks_run\r\n"); tasks_run(); // Runs forever. } diff --git a/plat-a4/SConscript b/plat-a4/SConscript deleted file mode 100644 index 935691f..0000000 --- a/plat-a4/SConscript +++ /dev/null @@ -1,44 +0,0 @@ -Import("*") - -env = env.Clone() -env.Append(CPPPATH = [Dir('includes')]) -env.Append(CPPDEFINES = ['ARM_A8', 'CONFIG_A4', 'MALLOC_NO_WDT', 'BIG_FONT']) - -env.AddModules([ - "acm", - "usb-synopsys", - "vfl-vfl", - "vfl-vsvfl", - "ftl-yaftl", - ]) - -plat_a4_src = arch_arm_src + base_src + env.Localize([ - 'a4.c', - 'aes.c', - 'buttons.c', - 'chipid.c', - 'clock.c', - 'event.c', - 'gpio.c', - 'i2c.c', - 'interrupt.c', - 'mipi_dsim.c', - 'clcd.c', - 'miu.c', - 'mmu.c', - 'pmu.c', - 'power.c', - 'spi.c', - 'timer.c', - 'uart.c', - 'cdma.c', - 'usbphy.c', - 'h2fmi.c', - 'sdio.c', - ]) + hfs_src -Export('plat_a4_src') - -env.SConscript('iPhone4G.SConscript', 'env') -env.SConscript('iPad1G.SConscript', 'env') -env.SConscript('aTV2G.SConscript', 'env') -env.SConscript('iPodTouch4G.SConscript', 'env') diff --git a/plat-a4/includes/h2fmi.h b/plat-a4/includes/h2fmi.h index ec15330..dfb229b 100644 --- a/plat-a4/includes/h2fmi.h +++ b/plat-a4/includes/h2fmi.h @@ -2,6 +2,7 @@ #define H2FMI_H #include "openiboot.h" +#include "aes.h" #include "cdma.h" #include "nand.h" @@ -159,7 +160,7 @@ error_t h2fmi_read_multi_ftl(uint32_t _ce, uint32_t _page, uint8_t *_ptr); void h2fmi_set_emf(uint32_t enable, uint32_t iv_input); uint32_t h2fmi_get_emf(); -void h2fmi_set_key(uint32_t enable, void* key, uint32_t length, uint32_t sha, uint32_t offset); +void h2fmi_set_key(uint32_t enable, void* key, AESKeyLen keyLen, uint32_t sha, uint32_t offset); typedef struct _emf_key { uint32_t length; diff --git a/plat-s5l8720/SConscript b/plat-s5l8720/SConscript deleted file mode 100644 index 89fd629..0000000 --- a/plat-s5l8720/SConscript +++ /dev/null @@ -1,64 +0,0 @@ -Import("*") - -env = env.Clone() -env.Append(CPPPATH = [Dir('includes')]) -env.Append(CPPDEFINES = ['ARM11', 'CONFIG_S5L8720']) - -env.AddModules([ - "acm", - "nor-spi", - "usb-synopsys", - ]) - -plat_s5l8720_src = arch_arm_src + env.Localize([ - # Include the bits of base_src we use - # until we implement it all - '#device.c', - '#mtd.c', - '#bdev.c', -# '#audiohw.c', - '#actions.c', - '#commands.c', - '#framebuffer.c', - '#images.c', - '#malloc.c', - '#nvram.c', - '#openiboot.c', - '#printf.c', - '#scripting.c', - '#sha1.c', - '#stb_image.c', - '#syscfg.c', - '#tasks.c', - '#util.c', - - 's5l8720.c', - 'accel.c', - 'aes.c', - 'buttons.c', - 'chipid.c', - 'clcd.c', - 'clock.c', - 'dma.c', - 'event.c', -# 'ftl.c', - 'gpio.c', - 'i2c.c', - 'interrupt.c', - 'mipi_dsim.c', - 'miu.c', - 'mmu.c', -# 'nand.c', - 'pmu.c', - 'power.c', -# 'sdio.c', - 'spi.c', - 'timer.c', - 'uart.c', - 'usbphy.c', - 'wdt.c', -# 'wlan.c', - ]) + hfs_src -Export('plat_s5l8720_src') - -env.SConscript('iPodTouch2G.SConscript', 'env') diff --git a/plat-s5l8900/SConscript b/plat-s5l8900/SConscript deleted file mode 100644 index 236fa59..0000000 --- a/plat-s5l8900/SConscript +++ /dev/null @@ -1,43 +0,0 @@ -Import("*") - -env = env.Clone() -env.Append(CPPPATH = [Dir('includes')]) -env.Append(CPPDEFINES = ['ARM11', 'CONFIG_S5L8900']) - -env.AddModules([ - "acm", - "usb-synopsys", - ]) - -plat_s5l8900_src = arch_arm_src + base_src + env.Localize([ - 's5l8900.c', - 'accel.c', - 'aes.c', - 'buttons.c', - 'chipid.c', - 'clock.c', - 'dma.c', - 'event.c', - 'gpio.c', - 'i2c.c', - 'interrupt.c', - 'lcd.c', - 'miu.c', - 'mmu.c', - 'nand.c', - 'ftl.c', - 'pmu.c', - 'power.c', - 'sdio.c', - 'spi.c', - 'timer.c', - 'uart.c', - 'usbphy.c', - 'wdt.c', - 'wlan.c', - ]) + hfs_src -Export('plat_s5l8900_src') - -env.SConscript('iPhone3G.SConscript', 'env') -env.SConscript('iPhone2G.SConscript', 'env') -env.SConscript('iPodTouch1G.SConscript', 'env') diff --git a/plat-s5l8900/dma.c b/plat-s5l8900/dma.c index a8b83bd..694ea76 100644 --- a/plat-s5l8900/dma.c +++ b/plat-s5l8900/dma.c @@ -51,12 +51,6 @@ int dma_setup() { clock_gate_switch(DMAC0_CLOCKGATE, ON); clock_gate_switch(DMAC1_CLOCKGATE, ON); - interrupt_install(DMAC0_INTERRUPT, dmaIRQHandler, 1); - interrupt_install(DMAC1_INTERRUPT, dmaIRQHandler, 2); - - interrupt_enable(DMAC0_INTERRUPT); - interrupt_enable(DMAC1_INTERRUPT); - return 0; } @@ -294,13 +288,28 @@ int dma_perform(uint32_t Source, uint32_t Destination, int size, int continueLis } int dma_finish(int controller, int channel, int timeout) { + uint32_t intTCStatusReg; + uint32_t intTCClearReg; + + if(controller == 1) { + intTCStatusReg = DMAC0 + DMACIntTCStatus; + intTCClearReg = DMAC0 + DMACIntTCClear; + } else { + intTCStatusReg = DMAC1 + DMACIntTCStatus; + intTCClearReg = DMAC1 + DMACIntTCClear; + } + uint64_t startTime = timer_get_system_microtime(); - while(!requests[controller - 1][channel].done) { + while(!(GET_REG(intTCStatusReg) & (1 << channel))) { if(has_elapsed(startTime, timeout * 1000)) { return -1; } } + // Clear the TC status and dispatch + SET_REG(intTCClearReg, 1 << channel); + dispatchRequest(&requests[controller - 1][channel], controller, channel); + EnterCriticalSection(); requests[controller - 1][channel].started = FALSE; requests[controller - 1][channel].done = FALSE; diff --git a/plat-s5l8900/s5l8900.c b/plat-s5l8900/s5l8900.c index c755625..deecaa4 100644 --- a/plat-s5l8900/s5l8900.c +++ b/plat-s5l8900/s5l8900.c @@ -58,8 +58,6 @@ void platform_init() lcd_setup(); framebuffer_setup(); - audiohw_init(); - framebuffer_setdisplaytext(TRUE); } diff --git a/plat-s5l8900/spi.c b/plat-s5l8900/spi.c index 7f69eef..07e3cae 100644 --- a/plat-s5l8900/spi.c +++ b/plat-s5l8900/spi.c @@ -16,8 +16,6 @@ static const SPIRegister SPIRegs[NUM_SPIPORTS] = { static SPIInfo spi_info[NUM_SPIPORTS]; -static void spiIRQHandler(uint32_t port); - int spi_setup() { clock_gate_switch(SPI0_CLOCKGATE, ON); clock_gate_switch(SPI1_CLOCKGATE, ON); @@ -31,12 +29,7 @@ int spi_setup() { SET_REG(SPIRegs[i].control, 0); } - interrupt_install(SPI0_IRQ, spiIRQHandler, 0); - interrupt_install(SPI1_IRQ, spiIRQHandler, 1); - interrupt_install(SPI2_IRQ, spiIRQHandler, 2); - interrupt_enable(SPI0_IRQ); - interrupt_enable(SPI1_IRQ); - interrupt_enable(SPI2_IRQ); + // No interrupt setup — using polled I/O return 0; } @@ -125,28 +118,39 @@ int spi_tx(int port, const uint8_t* buffer, int len, int block, int unknown) { SET_REG(SPIRegs[port].control, GET_REG(SPIRegs[port].control) | (1 << 2)); SET_REG(SPIRegs[port].control, GET_REG(SPIRegs[port].control) | (1 << 3)); - spi_info[port].txBuffer = buffer; - + int txCurrentLen; if(len > MAX_TX_BUFFER) - spi_info[port].txCurrentLen = MAX_TX_BUFFER; + txCurrentLen = MAX_TX_BUFFER; else - spi_info[port].txCurrentLen = len; - - spi_info[port].txTotalLen = len; - spi_info[port].txDone = FALSE; + txCurrentLen = len; if(unknown == 0) { SET_REG(SPIRegs[port].cnt, 0); } - spi_txdata(port, buffer, 0, spi_info[port].txCurrentLen); + spi_txdata(port, buffer, 0, txCurrentLen); SET_REG(SPIRegs[port].control, 1); if(block) { - while(!spi_info[port].txDone || GET_BITS(GET_REG(SPIRegs[port].status), 4, 4) != 0) { - // yield + // Polled TX: feed remaining data as FIFO drains + while(txCurrentLen < len) { + uint32_t status = GET_REG(SPIRegs[port].status); + if(status & (1 << 1)) { + int toTX = len - txCurrentLen; + int canTX = (MAX_TX_BUFFER - GET_BITS(status, 4, 4)) << spi_info[port].wordSize; + if(toTX > canTX) + toTX = canTX; + spi_txdata(port, buffer, txCurrentLen, txCurrentLen + toTX); + txCurrentLen += toTX; + SET_REG(SPIRegs[port].status, status); + } } + // Wait for TX FIFO to fully drain + while(GET_BITS(GET_REG(SPIRegs[port].status), 4, 4) != 0) { + } + // Clear any pending status + SET_REG(SPIRegs[port].status, GET_REG(SPIRegs[port].status)); return len; } else { return 0; @@ -161,12 +165,6 @@ int spi_rx(int port, uint8_t* buffer, int len, int block, int noTransmitJunk) { SET_REG(SPIRegs[port].control, GET_REG(SPIRegs[port].control) | (1 << 2)); SET_REG(SPIRegs[port].control, GET_REG(SPIRegs[port].control) | (1 << 3)); - spi_info[port].rxBuffer = buffer; - spi_info[port].rxDone = FALSE; - spi_info[port].rxCurrentLen = 0; - spi_info[port].rxTotalLen = len; - spi_info[port].counter = 0; - if(noTransmitJunk == 0) { SET_REG(SPIRegs[port].setup, GET_REG(SPIRegs[port].setup) | 1); } @@ -175,23 +173,34 @@ int spi_rx(int port, uint8_t* buffer, int len, int block, int noTransmitJunk) { SET_REG(SPIRegs[port].control, 1); if(block) { + int rxCurrentLen = 0; uint64_t startTime = timer_get_system_microtime(); - while(!spi_info[port].rxDone) { - // yield + + // Polled RX: read data as it arrives in FIFO + while(rxCurrentLen < len) { + uint32_t status = GET_REG(SPIRegs[port].status); + int canRX = GET_BITS(status, 8, 4) << spi_info[port].wordSize; + if(canRX > 0) { + int toRX = len - rxCurrentLen; + if(toRX > canRX) + toRX = canRX; + spi_rxdata(port, buffer, rxCurrentLen, rxCurrentLen + toRX); + rxCurrentLen += toRX; + SET_REG(SPIRegs[port].status, status); + } if(has_elapsed(startTime, 1000)) { - EnterCriticalSection(); - spi_info[port].rxDone = TRUE; - spi_info[port].rxBuffer = NULL; - LeaveCriticalSection(); if(noTransmitJunk == 0) { SET_REG(SPIRegs[port].setup, GET_REG(SPIRegs[port].setup) & ~1); } return -1; } } + if(noTransmitJunk == 0) { SET_REG(SPIRegs[port].setup, GET_REG(SPIRegs[port].setup) & ~1); } + // Clear any pending status + SET_REG(SPIRegs[port].status, GET_REG(SPIRegs[port].status)); return len; } else { return 0; @@ -207,31 +216,59 @@ int spi_txrx(int port, const uint8_t* outBuffer, int outLen, uint8_t* inBuffer, SET_REG(SPIRegs[port].control, GET_REG(SPIRegs[port].control) | (1 << 2)); SET_REG(SPIRegs[port].control, GET_REG(SPIRegs[port].control) | (1 << 3)); - spi_info[port].txBuffer = outBuffer; - + int txCurrentLen; if(outLen > MAX_TX_BUFFER) - spi_info[port].txCurrentLen = MAX_TX_BUFFER; + txCurrentLen = MAX_TX_BUFFER; else - spi_info[port].txCurrentLen = outLen; + txCurrentLen = outLen; - spi_info[port].txTotalLen = outLen; - spi_info[port].txDone = FALSE; - - spi_info[port].rxBuffer = inBuffer; - spi_info[port].rxDone = FALSE; - spi_info[port].rxCurrentLen = 0; - spi_info[port].rxTotalLen = inLen; - spi_info[port].counter = 0; - - spi_txdata(port, outBuffer, 0, spi_info[port].txCurrentLen); + spi_txdata(port, outBuffer, 0, txCurrentLen); SET_REG(SPIRegs[port].cnt, (inLen + ((1<> spi_info[port].wordSize); SET_REG(SPIRegs[port].control, 1); if(block) { - while(!spi_info[port].txDone || !spi_info[port].rxDone || GET_BITS(GET_REG(SPIRegs[port].status), 4, 4) != 0) { - // yield + int txDone = (txCurrentLen >= outLen) ? TRUE : FALSE; + int rxCurrentLen = 0; + + // Polled TX+RX + while(!txDone || rxCurrentLen < inLen) { + uint32_t status = GET_REG(SPIRegs[port].status); + + // Handle TX + if(!txDone && (status & (1 << 1))) { + if(txCurrentLen < outLen) { + int toTX = outLen - txCurrentLen; + int canTX = (MAX_TX_BUFFER - GET_BITS(status, 4, 4)) << spi_info[port].wordSize; + if(toTX > canTX) + toTX = canTX; + spi_txdata(port, outBuffer, txCurrentLen, txCurrentLen + toTX); + txCurrentLen += toTX; + } + if(txCurrentLen >= outLen) + txDone = TRUE; + } + + // Handle RX + if(rxCurrentLen < inLen) { + int canRX = GET_BITS(status, 8, 4) << spi_info[port].wordSize; + if(canRX > 0) { + int toRX = inLen - rxCurrentLen; + if(toRX > canRX) + toRX = canRX; + spi_rxdata(port, inBuffer, rxCurrentLen, rxCurrentLen + toRX); + rxCurrentLen += toRX; + } + } + + SET_REG(SPIRegs[port].status, status); } + + // Wait for TX FIFO to drain + while(GET_BITS(GET_REG(SPIRegs[port].status), 4, 4) != 0) { + } + // Clear any pending status + SET_REG(SPIRegs[port].status, GET_REG(SPIRegs[port].status)); return inLen; } else { return 0; @@ -283,7 +320,7 @@ void spi_set_baud(int port, int baud, SPIWordSize wordSize, int isMaster, int is if(divider > MAX_DIVIDER) { return; } - + SET_REG(SPIRegs[port].clkDivider, divider); spi_info[port].baud = baud; spi_info[port].isMaster = isMaster; @@ -300,66 +337,3 @@ void spi_set_baud(int port, int baud, SPIWordSize wordSize, int isMaster, int is SET_REG(SPIRegs[port].control, 1); } - -static void spiIRQHandler(uint32_t port) { - if(port > (NUM_SPIPORTS - 1)) { - return; - } - - uint32_t status = GET_REG(SPIRegs[port].status); - if(status & (1 << 3)) { - spi_info[port].counter++; - } - - if(status & (1 << 1)) { - while(TRUE) { - // take care of tx - if(spi_info[port].txBuffer != NULL) { - if(spi_info[port].txCurrentLen < spi_info[port].txTotalLen) - { - int toTX = spi_info[port].txTotalLen - spi_info[port].txCurrentLen; - int canTX = (MAX_TX_BUFFER - TX_BUFFER_LEFT(status)) << spi_info[port].wordSize; - - if(toTX > canTX) - toTX = canTX; - - spi_txdata(port, spi_info[port].txBuffer, spi_info[port].txCurrentLen, spi_info[port].txCurrentLen+toTX); - spi_info[port].txCurrentLen += toTX; - - } else { - spi_info[port].txDone = TRUE; - spi_info[port].txBuffer = NULL; - } - } - -dorx: - // take care of rx - if(spi_info[port].rxBuffer == NULL) - break; - - int toRX = spi_info[port].rxTotalLen - spi_info[port].rxCurrentLen; - int canRX = GET_BITS(status, 8, 4) << spi_info[port].wordSize; - - if(toRX > canRX) - toRX = canRX; - - spi_rxdata(port, spi_info[port].rxBuffer, spi_info[port].rxCurrentLen, spi_info[port].rxCurrentLen+toRX); - spi_info[port].rxCurrentLen += toRX; - - if(spi_info[port].rxCurrentLen < spi_info[port].rxTotalLen) - break; - - spi_info[port].rxDone = TRUE; - spi_info[port].rxBuffer = NULL; - } - - - } else if(status & (1 << 0)) { - // jump into middle of the loop to handle rx only, stupidly - goto dorx; - } - - // acknowledge interrupt handling complete - SET_REG(SPIRegs[port].status, status); -} - diff --git a/plat-s5l8920/SConscript b/plat-s5l8920/SConscript deleted file mode 100644 index 3354bc7..0000000 --- a/plat-s5l8920/SConscript +++ /dev/null @@ -1,40 +0,0 @@ -Import("*") - -env = env.Clone() -env.Append(CPPPATH = [Dir('includes')]) -env.Append(CPPDEFINES = ['ARM_A8', 'CONFIG_S5L8920', 'MALLOC_NO_WDT']) - -env.AddModules([ - "acm", - "nor-spi", - "usb-synopsys", - "vfl-vfl", - "vfl-vsvfl", - "ftl-yaftl", - ]) - -plat_s5l8920_src = arch_arm_src + base_src + env.Localize([ - 's5l8920.c', - 'usbphy.c', - 'aes.c', - 'buttons.c', - 'chipid.c', - 'clock.c', - 'event.c', - 'gpio.c', - 'i2c.c', - 'interrupt.c', - 'clcd.c', - 'mipi_dsim.c', - 'miu.c', - 'mmu.c', - 'power.c', - 'spi.c', - 'timer.c', - 'cdma.c', - 'h2fmi.c', - 'uart.c', - ]) + hfs_src -Export('plat_s5l8920_src') - -env.SConscript('iPhone3GS.SConscript', 'env') diff --git a/plat-s5l8920/h2fmi.c b/plat-s5l8920/h2fmi.c index 4ab2173..e17bde2 100644 --- a/plat-s5l8920/h2fmi.c +++ b/plat-s5l8920/h2fmi.c @@ -1626,26 +1626,7 @@ static error_t h2fmi_device_read_single_page(nand_device_t *_dev, uint32_t _chip _buffer, _spareBuffer, NULL, NULL, disable_aes); } -static inline void auto_store(void *_ptr, size_t _sz, uint32_t _val) -{ - switch(_sz) - { - case 0: - return; - - case 1: - *((uint8_t*)_ptr) = _val; - return; - - case 2: - *((uint16_t*)_ptr) = _val; - return; - - case 4: - *((uint32_t*)_ptr) = _val; - return; - } -} +/* auto_store is defined in util.c */ static error_t h2fmi_device_get_info(device_t *_dev, device_info_t _info, void *_result, size_t _size) { diff --git a/plat-s5l8920/includes/h2fmi.h b/plat-s5l8920/includes/h2fmi.h index d913718..219017a 100644 --- a/plat-s5l8920/includes/h2fmi.h +++ b/plat-s5l8920/includes/h2fmi.h @@ -2,6 +2,7 @@ #define H2FMI_H #include "openiboot.h" +#include "aes.h" #include "nand.h" #include "cdma.h" @@ -129,7 +130,7 @@ uint32_t h2fmi_read_single_page(uint32_t _ce, uint32_t _page, uint8_t *_ptr, uin void h2fmi_set_emf(uint32_t enable, uint32_t iv_input); uint32_t h2fmi_get_emf(); -void h2fmi_set_key(uint32_t enable, void* key, uint32_t length, uint32_t sha, uint32_t offset); +void h2fmi_set_key(uint32_t enable, void* key, AESKeyLen keyLen, uint32_t sha, uint32_t offset); typedef struct _emf_key { uint32_t length; diff --git a/radio-pmb8876/SConscript b/radio-pmb8876/SConscript deleted file mode 100644 index bc2dfc4..0000000 --- a/radio-pmb8876/SConscript +++ /dev/null @@ -1,8 +0,0 @@ -Import("*") - -radio_pmb8876_src = env.Localize([ - 'radio.c' - ]) - -radio_pmb8876 = env.CreateModule('radio-pmb8876', radio_pmb8876_src) -radio_pmb8876.Append(CPPPATH=[Dir('includes')]) diff --git a/radio-pmb8878/SConscript b/radio-pmb8878/SConscript deleted file mode 100644 index 27b3913..0000000 --- a/radio-pmb8878/SConscript +++ /dev/null @@ -1,8 +0,0 @@ -Import("*") - -radio_pmb8878_src = env.Localize([ - 'radio.c' - ]) - -radio_pmb8878 = env.CreateModule('radio-pmb8878', radio_pmb8878_src) -radio_pmb8878.Append(CPPPATH=[Dir('includes')]) diff --git a/radio-xgold618/SConscript b/radio-xgold618/SConscript deleted file mode 100644 index 546d1c3..0000000 --- a/radio-xgold618/SConscript +++ /dev/null @@ -1,8 +0,0 @@ -Import("*") - -radio_xgold618_src = env.Localize([ - 'radio.c' - ]) - -radio_xgold618 = env.CreateModule('radio-xgold618', radio_xgold618_src) -radio_xgold618.Append(CPPPATH=[Dir('includes')]) diff --git a/scons/ARMEnvironment.SConscript b/scons/ARMEnvironment.SConscript deleted file mode 100644 index 904b65b..0000000 --- a/scons/ARMEnvironment.SConscript +++ /dev/null @@ -1,29 +0,0 @@ -# -# Setup our cross-compilation environment. -# - -import os - -def ARMEnvironment(*a, **kw): - env = Environment(tools=['gas', 'gcc', 'gnulink', 'ar'], ENV=os.environ, *a, **kw) - plat_flags = ['-mlittle-endian', '-mfpu=vfp', '-mthumb', '-mthumb-interwork', '-fPIC'] - env.Append(CPPPATH = ['#includes']) - env.Append(CPPFLAGS = plat_flags+['-nostdlib']) - env.Append(ASPPFLAGS = ['-xassembler-with-cpp']) - env.Append(LINKFLAGS = plat_flags+['-nostdlib', '--nostdlib', '-Ttext=0x0']) - env.Append(LIBS = ['gcc']) - - env['PROGSUFFIX'] = '' - - if not env.has_key("CROSS"): - if env['ENV'].has_key("CROSS"): - env['CROSS'] = env['ENV']['CROSS'] - else: - env["CROSS"] = 'arm-elf-' - - env["CC"] = env["CROSS"] + 'gcc' - env["OBJCOPY"] = env["CROSS"] + 'objcopy' - env["AR"] = env["CROSS"] + 'ar' - - return env -Export('ARMEnvironment') diff --git a/scons/Doxygen.SConscript b/scons/Doxygen.SConscript deleted file mode 100644 index 597ae83..0000000 --- a/scons/Doxygen.SConscript +++ /dev/null @@ -1,194 +0,0 @@ -# vim: set et sw=3 tw=0 fo=awqorc ft=python: -# -# Astxx, the Asterisk C++ API and Utility Library. -# Copyright (C) 2005, 2006 Matthew A. Nicholson -# Copyright (C) 2006 Tim Blechmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License version 2.1 as published by the Free Software Foundation. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Import('*') - -import os -import os.path -import glob -from fnmatch import fnmatch - -def DoxyfileParse(file_contents): - """ - Parse a Doxygen source file and return a dictionary of all the values. - Values will be strings and lists of strings. - """ - data = {} - - import shlex - lex = shlex.shlex(instream = file_contents, posix = True) - lex.wordchars += "*+./-:" - lex.whitespace = lex.whitespace.replace("\n", "") - lex.escape = "" - - lineno = lex.lineno - token = lex.get_token() - key = token # the first token should be a key - last_token = "" - key_token = False - next_key = False - new_data = True - - def append_data(data, key, new_data, token): - if new_data or len(data[key]) == 0: - data[key].append(token) - else: - data[key][-1] += token - - while token: - if token in ['\n']: - if last_token not in ['\\']: - key_token = True - elif token in ['\\']: - pass - elif key_token: - key = token - key_token = False - else: - if token == "+=": - if key not in data: - data[key] = [] - elif token == "=": - data[key] = [] - else: - append_data( data, key, new_data, token ) - new_data = True - - last_token = token - token = lex.get_token() - - if last_token == '\\' and token != '\n': - new_data = False - append_data( data, key, new_data, '\\' ) - - # compress lists of len 1 into single strings - for k, v in data.items(): - if len(v) == 0: - data.pop(k) - - # items in the following list will be kept as lists and not converted to strings - if k in ["INPUT", "FILE_PATTERNS", "EXCLUDE_PATTERNS"]: - continue - - if len(v) == 1: - data[k] = v[0] - - return data - -def DoxySourceScan(node, env, path): - """ - Doxygen Doxyfile source scanner. This should scan the Doxygen file and add - any files used to generate docs to the list of source files. - """ - default_file_patterns = [ - '*.c', '*.cc', '*.cxx', '*.cpp', '*.c++', '*.java', '*.ii', '*.ixx', - '*.ipp', '*.i++', '*.inl', '*.h', '*.hh ', '*.hxx', '*.hpp', '*.h++', - '*.idl', '*.odl', '*.cs', '*.php', '*.php3', '*.inc', '*.m', '*.mm', - '*.py', - ] - - default_exclude_patterns = [ - '*~', - ] - - sources = [] - - data = DoxyfileParse(node.get_contents()) - - recursive = data.get("RECURSIVE") == "YES" - - file_patterns = data.get("FILE_PATTERNS", default_file_patterns) - exclude_patterns = data.get("EXCLUDE_PATTERNS", default_exclude_patterns) - - for node in data.get("INPUT", []): - if os.path.isfile(node): - sources.append(node) - elif os.path.isdir(node): - if recursive: - for root, dirs, files in os.walk(node): - for f in files: - filename = os.path.join(root, f) - - pattern_check = any(fnmatch(filename, y) for y in file_patterns) - exclude_check = any(fnmatch(filename, y) for y in exclude_patterns) - - if pattern_check and not exclude_check: - sources.append(filename) - else: - for pattern in file_patterns: - sources.extend(glob.glob("/".join([node, pattern]))) - - sources = [env.File(path) for path in sources] - return sources - - -def DoxySourceScanCheck(node, env): - """Check if we should scan this file""" - return os.path.isfile(node.path) - -def DoxyEmitter(source, target, env): - """Doxygen Doxyfile emitter""" - # possible output formats and their default values and output locations - output_formats = { - "HTML": ("YES", "html"), - "LATEX": ("YES", "latex"), - "RTF": ("NO", "rtf"), - "MAN": ("NO", "man"), - "XML": ("NO", "xml"), - } - - data = DoxyfileParse(source[0].get_contents()) - - targets = [] - out_dir = data.get("OUTPUT_DIRECTORY", ".") - - # add our output locations - for k, v in output_formats.items(): - if data.get("GENERATE_" + k, v[0]) == "YES": - targets.append(env.Dir( os.path.join(out_dir, data.get(k + "_OUTPUT", v[1]))) ) - - # don't clobber targets - for node in targets: - env.Precious(node) - - # set up cleaning stuff - for node in targets: - env.Clean(node, node) - - return (targets, source) - -doxyfile_scanner = henv.Scanner( - DoxySourceScan, - "DoxySourceScan", - scan_check = DoxySourceScanCheck, -) - -doxyfile_builder = Builder( - action = "cd ${SOURCE.dir} && ${DOXYGEN} ${SOURCE.file}", - emitter = DoxyEmitter, - target_factory = henv.fs.Entry, - single_source = True, - source_scanner = doxyfile_scanner, -) - -henv.Append(BUILDERS = { - 'Doxygen': doxyfile_builder, -}) - -henv['DOXYGEN'] = 'doxygen' diff --git a/scons/Git.SConscript b/scons/Git.SConscript deleted file mode 100644 index bc493ed..0000000 --- a/scons/Git.SConscript +++ /dev/null @@ -1,7 +0,0 @@ -import subprocess - -def GetGitCommit(): - p = subprocess.Popen('git log | head -n1 | cut -b8-14', shell=True, stdout=subprocess.PIPE) - ret,smth = p.communicate() - return ret[:-1] -Export('GetGitCommit') diff --git a/scons/Module.SConscript b/scons/Module.SConscript deleted file mode 100644 index 5e07194..0000000 --- a/scons/Module.SConscript +++ /dev/null @@ -1,148 +0,0 @@ -import SCons - -Import("*") - -class Module: - def __init__(self, env, name, sources, dependancies=[]): - self.env = env - self.name = name - self.sources = sources - self.dependencies = dependancies - self.appends = [] - - def Append(self, **what): - self.appends.append(what) - - def Depends(self, *what): - for w in what: - if SCons.Util.is_List(w): - self.dependencies += w - else: - self.dependencies.append(w) - - def Add(self, env): - if env['MODULE_SRC'] is None: - env['MODULE_SRC'] = self.sources.clone() - else: - env['MODULE_SRC'] += self.sources - - if env['MODULE_DEPS'] is None: - env['MODULE_DEPS'] = self.dependencies.clone() - else: - env['MODULE_DEPS'] += self.dependencies - - for a in self.appends: - env.Append(**a) - -def FindModule(env, name): - if env['MODULES'] != None and env['MODULES'].has_key(name): - return env['MODULES'][name] - - return None -env.AddMethod(FindModule, "FindModule") - -def CreateModule(env, name, sources, dependancies=[]): - mod = FindModule(env, name) - if mod is not None: - return mod - - mod = Module(env, name, sources, dependancies) - if env['MODULES'] is None: - env['MODULES'] = {name: mod} - else: - env['MODULES'][name] = mod - - return mod -env.AddMethod(CreateModule, "CreateModule") - -def AddModule(env, name): - mod = env.FindModule(name) - if mod is None: - print "No such module %s." % name - return None - - mod.Add(env) - return mod -env.AddMethod(AddModule, "AddModule") - -def AddModules(env, names): - if not SCons.Util.is_List(names): - return [AddModule(env, names)] - - return [AddModule(env, name) for name in names] -env.AddMethod(AddModules, "AddModules") - -def OpenIBootTarget(env, name, fname, flag, sources, img3template=None): - env = env.Clone() - env['OBJPREFIX'] = name + '_' + env['OBJPREFIX'] - env.Append(CPPDEFINES=[flag]) - - if env['MODULE_SRC'] is not None: - sources = sources + env['MODULE_SRC'] - - deps = [] - if env['MODULE_DEPS'] is not None: - deps = env['MODULE_DEPS'] - - denv = env.Clone() - denv['OBJSUFFIX'] = '_debug' + denv['OBJSUFFIX'] - denv.Append(CPPDEFINES=['DEBUG']) - denv.Append(CPPFLAGS=['-g']) - - # Work out filenames - elf_name = '#' + fname - delf_name = elf_name + '_debug' - bin_name = elf_name + '.bin' - dbin_name = delf_name + '.bin' - img3_name = elf_name + '.img3' - dimg3_name = delf_name + '.img3' - - def listify(ls): - ret = [] - for e in ls: - if SCons.Util.is_List(e): - ret += listify(e) - else: - ret.append(e) - return ret - sources = listify(sources) - - # Add init/sentinal, but make sure first file linked is still first - # (this means that _start gets run first... kinda important) -- Ricky26 - sources = sources[:1] + ['#init.c'] + sources[1:] + ['#sentinel.c'] - - # Add Targets - elf = env.Program(elf_name, sources) - Depends(elf, deps) - delf = denv.Program(delf_name, sources) - Depends(delf, deps) - - bin = env.Make8900Image(bin_name, elf) - dbin = denv.Make8900Image(dbin_name, delf) - if img3template is not None: - img3 = env.Make8900Image(img3_name, elf+['#mk8900image/%s.img3' % img3template]) - dimg3 = denv.Make8900Image(dimg3_name, delf+['#mk8900image/%s.img3' % img3template]) - Alias(name, img3) - Alias(name+'D', dimg3) - else: - img3 = None - dimg3 = None - Alias(name, bin) - Alias(name+'D', dbin) - - locals()[elf_name] = elf - locals()[delf_name] = delf - locals()[bin_name] = bin - locals()[dbin_name] = dbin - locals()[img3_name] = img3 - locals()[dimg3_name] = dimg3 - - Export([elf_name, bin_name, img3_name, - delf_name, dbin_name, dimg3_name]) - - return elf, bin, img3 -env.AddMethod(OpenIBootTarget, "OpenIBootTarget") - -env['MODULES'] = {} -env['MODULE_SRC'] = [] -env['MODULE_DEPS'] = [] diff --git a/tasks.c b/tasks.c index 989bf9f..a040041 100644 --- a/tasks.c +++ b/tasks.c @@ -85,6 +85,8 @@ static void task_remove(TaskDescriptor *_t) void tasks_setup() { + CurrentRunning = &bootstrapTask; + task_init(&bootstrapTask, "bootstrap", 0); bootstrapTask.state = TASK_RUNNING; @@ -93,7 +95,6 @@ void tasks_setup() IRQTask = &irqTask; IRQBackupTask = NULL; - CurrentRunning = &bootstrapTask; } void task_init(TaskDescriptor *_td, char *_name, size_t _stackSize) diff --git a/usb-synopsys/SConscript b/usb-synopsys/SConscript deleted file mode 100644 index 6723742..0000000 --- a/usb-synopsys/SConscript +++ /dev/null @@ -1,8 +0,0 @@ -Import('*') - -usb_synopsys_src = env.Localize([ - 'usb.c', - ]) - -usb_synopsys = env.CreateModule('usb-synopsys', usb_synopsys_src) -usb_synopsys.Append(CPPPATH = [Dir('includes')]) diff --git a/vfl-vfl/SConscript b/vfl-vfl/SConscript deleted file mode 100644 index 2441d37..0000000 --- a/vfl-vfl/SConscript +++ /dev/null @@ -1,9 +0,0 @@ -Import('*') - -vfl_vfl_src = env.Localize([ - 'vfl.c', - ]) - -vfl_vfl = env.CreateModule('vfl-vfl', vfl_vfl_src) -vfl_vfl.Append(CPPPATH = [Dir('includes')]) -vfl_vfl.Append(CPPDEFINES = ['CONFIG_VFL_VFL']) diff --git a/vfl-vsvfl/SConscript b/vfl-vsvfl/SConscript deleted file mode 100644 index ebbc53a..0000000 --- a/vfl-vsvfl/SConscript +++ /dev/null @@ -1,9 +0,0 @@ -Import('*') - -vfl_vsvfl_src = env.Localize([ - 'vsvfl.c', - ]) - -vfl_vsvfl = env.CreateModule('vfl-vsvfl', vfl_vsvfl_src) -vfl_vsvfl.Append(CPPPATH = [Dir('includes')]) -vfl_vsvfl.Append(CPPDEFINES = ['CONFIG_VFL_VSVFL'])