├── .gitignore ├── .kateconfig ├── COPYING ├── README.md ├── broadway.mk ├── channel ├── Makefile ├── README ├── banner │ ├── .gitignore │ ├── Makefile │ ├── Makefile.section │ ├── banner │ │ ├── abubble1.png │ │ ├── abubble2.png │ │ ├── abubble3.png │ │ ├── abubble4.png │ │ ├── abubble5.png │ │ ├── abubble6.png │ │ ├── banner_fade.png │ │ ├── banner_shape2.png │ │ ├── banner_title.png │ │ ├── banner_wave1a.png │ │ ├── banner_wave1b.png │ │ ├── banner_wavea.png │ │ ├── banner_waveb.png │ │ ├── bbubble1.png │ │ ├── cbubble1.png │ │ ├── cbubble2.png │ │ ├── mkbanner.py │ │ ├── textures.txt │ │ └── white.png │ ├── icon │ │ ├── icon_fade.png │ │ ├── icon_shape2.png │ │ ├── icon_title.png │ │ ├── icon_wave1a.png │ │ ├── icon_wave1b.png │ │ ├── icon_wavea.png │ │ ├── icon_waveb.png │ │ ├── mkicon.py │ │ ├── textures.txt │ │ └── white.png │ ├── names.txt │ ├── sound │ │ ├── wiibrew-banner-intro-part.wav │ │ └── wiibrew-banner-loop-part.wav │ └── tools │ │ ├── Makefile │ │ ├── addimd5.py │ │ ├── join-imet.py │ │ ├── lz77.c │ │ ├── mkbns.c │ │ └── png2tpl.c ├── channelapp │ ├── .gitignore │ ├── Makefile │ ├── banner │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── banner.ppm │ │ ├── icon.ppm │ │ ├── title │ │ └── twintig.c │ ├── config.h │ ├── data │ │ ├── about.png │ │ ├── apps_grid.png │ │ ├── apps_grid_hover.png │ │ ├── apps_list.png │ │ ├── apps_list_hover.png │ │ ├── apps_next.png │ │ ├── apps_next_hover.png │ │ ├── apps_previous.png │ │ ├── apps_previous_hover.png │ │ ├── background.png │ │ ├── background_wide.png │ │ ├── bubble1.png │ │ ├── bubble2.png │ │ ├── bubble3.png │ │ ├── button.png │ │ ├── button_focus.png │ │ ├── button_small.png │ │ ├── button_small_focus.png │ │ ├── button_tiny.png │ │ ├── button_tiny_focus.png │ │ ├── content_arrow_down.png │ │ ├── content_arrow_up.png │ │ ├── cursor_drag.png │ │ ├── cursor_drag_shade.png │ │ ├── cursor_pic.png │ │ ├── cursor_shade.png │ │ ├── dialog_background.png │ │ ├── dlg_confirm.png │ │ ├── dlg_error.png │ │ ├── dlg_info.png │ │ ├── dlg_warning.png │ │ ├── droid.ttf │ │ ├── droidbold.ttf │ │ ├── icon_network.png │ │ ├── icon_network_active.png │ │ ├── icon_usbgecko.png │ │ ├── icon_usbgecko_active.png │ │ ├── logo.png │ │ ├── progress.png │ │ └── throbber.png │ ├── gdb.txt │ ├── i18n │ │ ├── dutch.po │ │ ├── french.po │ │ ├── german.po │ │ ├── italian.po │ │ ├── japanese.po │ │ ├── spanish.po │ │ └── template.pot │ ├── newrvl.ld │ ├── newrvl.spec │ ├── source │ │ ├── appentry.c │ │ ├── appentry.h │ │ ├── asm.h │ │ ├── blob.c │ │ ├── blob.h │ │ ├── browser.c │ │ ├── browser.h │ │ ├── bubbles.c │ │ ├── bubbles.h │ │ ├── controls.c │ │ ├── controls.h │ │ ├── cursors.c │ │ ├── cursors.h │ │ ├── debug.c │ │ ├── dialogs.c │ │ ├── dialogs.h │ │ ├── dvd.c │ │ ├── dvd.h │ │ ├── ecdsa.c │ │ ├── ecdsa.h │ │ ├── elf_abi.h │ │ ├── font.c │ │ ├── font.h │ │ ├── gfx.c │ │ ├── gfx.h │ │ ├── ggets.c │ │ ├── ggets.h │ │ ├── http.c │ │ ├── http.h │ │ ├── i18n.c │ │ ├── i18n.h │ │ ├── isfs.c │ │ ├── isfs.h │ │ ├── loader.c │ │ ├── loader.h │ │ ├── loader_reloc.c │ │ ├── loader_reloc.h │ │ ├── m_main.c │ │ ├── m_main.h │ │ ├── main.c │ │ ├── manage.c │ │ ├── manage.h │ │ ├── panic.c │ │ ├── panic.h │ │ ├── playtime.c │ │ ├── playtime.h │ │ ├── sha1.c │ │ ├── sha1.h │ │ ├── tcp.c │ │ ├── tcp.h │ │ ├── tex.c │ │ ├── tex.h │ │ ├── theme.c │ │ ├── theme.h │ │ ├── title.c │ │ ├── title.h │ │ ├── unzip.c │ │ ├── unzip.h │ │ ├── unzip_io.c │ │ ├── unzip_io.h │ │ ├── update.c │ │ ├── update.h │ │ ├── view.c │ │ ├── view.h │ │ ├── widgets.c │ │ ├── widgets.h │ │ ├── xml.c │ │ └── xml.h │ └── stub │ │ ├── asm.h │ │ ├── cache.h │ │ ├── cache_asm.S │ │ ├── crt0.S │ │ ├── ios.c │ │ ├── ios.h │ │ ├── processor.h │ │ ├── stub.c │ │ ├── stub_debug.c │ │ ├── stub_debug.h │ │ ├── system.c │ │ ├── system.h │ │ ├── system_asm.S │ │ ├── usb.c │ │ └── usb.h ├── title │ ├── .gitignore │ ├── Makefile │ ├── cetk.template │ ├── dpki │ │ ├── 00000000 │ │ ├── 00000001 │ │ ├── certs │ │ └── footer │ ├── footer │ ├── pywii │ ├── retail │ │ ├── 00000000 │ │ ├── 00000001 │ │ ├── certs │ │ └── footer │ └── tmd.template └── wiiload │ ├── .gitignore │ ├── Makefile │ ├── gecko.c │ ├── gecko.h │ ├── main.c │ └── win32 │ ├── include │ ├── zconf.h │ └── zlib.h │ └── lib │ └── libz.a ├── common.mk ├── pywii ├── Alameda │ └── Alameda.py ├── Common │ ├── Struct.py │ └── pywii │ │ ├── __init__.py │ │ ├── ec.py │ │ └── wii.py ├── README ├── breakfast.py ├── ecmodule │ ├── _ecmodule.c │ └── setup.py └── pywii-tools │ ├── addhash.py │ ├── arclist.py │ ├── arcpack.py │ ├── certinfo.py │ ├── discinfo.py │ ├── dpkisign.py │ ├── ecchecksig.py │ ├── ecgenpriv.py │ ├── ecpriv2pub.py │ ├── ecsign.py │ ├── extract.py │ ├── extractdol.py │ ├── extractfiles.py │ ├── getappldr.py │ ├── inject.py │ ├── injectdol.py │ ├── partsetios.py │ ├── pywii │ ├── rsapatch.py │ ├── saveinfo.py │ ├── tikfix.py │ ├── tikinfo.py │ ├── tmdfix.py │ ├── tmdinfo.py │ ├── tmdupdatecr.py │ ├── tmdvers.py │ ├── wadinfo.py │ ├── wadpack-boot2.py │ ├── wadpack.py │ └── wadunpack.py └── wiipax ├── .gitignore ├── Makefile ├── client ├── .gitignore ├── LzFind.c ├── LzFind.h ├── LzHash.h ├── LzmaDec.c ├── LzmaDec.h ├── LzmaEnc.c ├── LzmaEnc.h ├── Makefile ├── Types.h ├── common.h ├── elf_abi.h ├── lzma.c ├── lzma.h ├── main.c ├── stub_dkp.c ├── stub_dkp_debug.c ├── stub_dkpc.c ├── stub_dkpc_debug.c ├── stub_mini.c └── stub_mini_debug.c └── stub ├── .gitignore ├── LzmaDec.c ├── LzmaDec.h ├── Makefile ├── Types.h ├── channel.ld ├── common.h ├── crt0.s ├── devkitppc.ld ├── elf.c ├── elf.h ├── elf_abi.h ├── exception.c ├── exception_asm.s ├── gecko.c ├── main.c ├── plunge.S ├── realmode.S ├── realmode.ld ├── string.c ├── string.h ├── sync.c ├── time.c ├── vsprintf.c └── vsprintf.h /.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | *.o 3 | *.d 4 | *~ 5 | .*.swp 6 | *.dSYM 7 | *.pyc 8 | .DS_Store 9 | 10 | -------------------------------------------------------------------------------- /.kateconfig: -------------------------------------------------------------------------------- 1 | kate: space-indent off; tab-width 4; indent-width 4; replace-tabs off; eol unix; 2 | -------------------------------------------------------------------------------- /broadway.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(strip $(DEVKITPPC)),) 2 | $(error "Set DEVKITPPC in your environment.") 3 | endif 4 | 5 | PREFIX = $(DEVKITPPC)/bin/powerpc-eabi- 6 | 7 | CFLAGS = -mcpu=750 -m32 -mhard-float -mno-eabi -mno-sdata 8 | CFLAGS += -ffreestanding -ffunction-sections -fdata-sections 9 | CFLAGS += -Wall -Wextra -O2 10 | ASFLAGS = 11 | LDFLAGS = -mcpu=750 -m32 -n -nostartfiles -nodefaultlibs -Wl,-gc-sections 12 | 13 | -------------------------------------------------------------------------------- /channel/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean 2 | 3 | all: 4 | @$(MAKE) -C channelapp channel 5 | @$(MAKE) -C banner 6 | @$(MAKE) -C title 7 | 8 | clean: 9 | @$(MAKE) -C channelapp clean 10 | @$(MAKE) -C banner clean 11 | @$(MAKE) -C title clean 12 | @$(MAKE) -C wiiload clean 13 | @$(MAKE) -C wiiload clean WIN32=1 14 | 15 | -------------------------------------------------------------------------------- /channel/README: -------------------------------------------------------------------------------- 1 | The Homebrew Channel v1.1.2 2 | Copyright (C) 2007-2012 Team Twiizers, all rights reserved. 3 | All rights reserved; do not redistribute 4 | 5 | 6 | Update instructions: 7 | 8 | 9 | If you have previously installed The Homebrew Channel, you can update it. If 10 | this is the first time you are installing it, see README.txt for installation 11 | instructions. The easiest way to update is using the built-in online update 12 | functionality. Simply configure the WiFi network settings for your Wii for 13 | proper Internet connectivity, and boot up the channel. If the connection is 14 | established, you'll see an opaque white (not semitransparent) world icon 15 | in the lower right corner, and an update prompt will automatically appear. 16 | Accept it to begin downloading the update. If you cannot or do not want to 17 | connect your Wii to the Internet, simply run the boot.elf file using any 18 | homebrew booting method. For example, you can upload it using wiiload or 19 | you can make a directory inside /apps (for example, /apps/Update) and copy 20 | boot.elf there. Then, simply run it from the previous version of The Homebrew 21 | Channel. 22 | 23 | 24 | Adding and customizing apps: 25 | 26 | 27 | All user applications should be stored in their own subdirectory inside of 28 | apps/; some examples have been provided. Each subdirectory should have at 29 | least three files; ScummVM will be used as an example. 30 | 31 | * apps/ScummVM/boot.elf main executable to be loaded 32 | * apps/ScummVM/icon.png icon to be displayed in The Homebrew Channel 33 | Menu; should be 128 x 48 pixels 34 | * apps/ScummVM/meta.xml XML description of the channel. This format 35 | might change for future releases of The 36 | Homebrew channel, but we will try to remain 37 | backwards-compatible. See 38 | http://wiibrew.org/wiki/Homebrew_Channel 39 | for information on what data should be included 40 | in this file. 41 | 42 | 43 | Staying current with new releases: 44 | 45 | 46 | Relax, you will not need to do anything to keep up with new releases of the 47 | Homebrew Channel. When a new version is available, a message will appear 48 | giving you the option to download and install the new version, if your Wii 49 | is configured to connect to the Internet. 50 | 51 | 52 | Uninstallation: 53 | 54 | 55 | You may uninstall the channel as you would any other channel, by using the Data 56 | Management screen of the Wii Menu. Erasing every last trace of The Homebrew 57 | Channel is not practical on a complex system such as the Wii. If a need 58 | arises, we will develop a more thorough uninstaller application. 59 | 60 | 61 | Reminder about elf files: 62 | 63 | 64 | Old ELF files were incorrect and will not work. Please use DOL files or 65 | recompile with the latest version of devkitPPC. You can use the following 66 | command to convert a broken ELF file to a DOL file: 67 | 68 | powerpc-gekko-objcopy -O binary boot.elf boot.dol 69 | 70 | -------------------------------------------------------------------------------- /channel/banner/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | channel.imet 3 | tools/png2tpl 4 | tools/mkbns 5 | tools/lz77 6 | *.raw 7 | -------------------------------------------------------------------------------- /channel/banner/Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(WIN32), 1) 2 | export PREFIX = i586-mingw32msvc- 3 | export EXE := .exe 4 | export LFLAGS = -lws2_32 5 | else 6 | export PREFIX = 7 | export EXE = 8 | export LFLAGS = 9 | endif 10 | 11 | export PYWII := $(CURDIR)/../../pywii/pywii-tools 12 | export ALAMEDA := $(CURDIR)/../../pywii/Alameda 13 | 14 | export PNG2TPL := $(CURDIR)/tools/png2tpl$(EXE) 15 | export MKBNS := $(CURDIR)/tools/mkbns$(EXE) 16 | export LZ77 := $(CURDIR)/tools/lz77$(EXE) 17 | export ADDIMD5 := python2 $(CURDIR)/tools/addimd5.py 18 | export ARCPACK := python2 $(PYWII)/arcpack.py 19 | export SOX := sox 20 | 21 | all: channel.imet 22 | 23 | channel.imet: build/data.arc names.txt tools/join-imet.py 24 | python2 tools/join-imet.py $@ build/data.arc build/icon.arc build/banner.arc build/sound.bns names.txt 25 | 26 | build/data.arc : build/data/meta/icon.bin build/data/meta/banner.bin build/data/meta/sound.bin 27 | $(ARCPACK) $@ build/data 28 | 29 | build/data/meta/icon.bin : icon/* $(PNG2TPL) $(LZ77) 30 | $(MAKE) -C icon -f ../Makefile.section 31 | 32 | build/data/meta/banner.bin : banner/* $(PNG2TPL) $(LZ77) 33 | $(MAKE) -C banner -f ../Makefile.section 34 | 35 | build/data/meta/sound.bin : build/sound.bns 36 | @[ ! -d build/data/meta ] && mkdir -p build/data/meta || true 37 | $(ADDIMD5) $< $@ 38 | 39 | build/sound.bns : build/wiibrew-banner-intro-part.raw build/wiibrew-banner-loop-part.raw $(MKBNS) 40 | @[ ! -d build ] && mkdir -p build || true 41 | $(MKBNS) build/wiibrew-banner-intro-part.raw $@ 1 build/wiibrew-banner-loop-part.raw 42 | 43 | build/%.raw : sound/%.wav 44 | @[ ! -d build ] && mkdir -p build || true 45 | $(SOX) $< -r 32000 -c 2 -e signed-integer -b 16 -t raw $@ 46 | 47 | testi : channel.imet 48 | python2 $(ALAMEDA)/Alameda.py channel.imet icon 49 | testb : channel.imet 50 | python2 $(ALAMEDA)/Alameda.py channel.imet banner 51 | 52 | $(PNG2TPL): tools/*.c 53 | $(MAKE) -C tools png2tpl$(EXE) 54 | 55 | $(MKBNS): tools/*.c 56 | $(MAKE) -C tools mkbns$(EXE) 57 | 58 | $(LZ77): tools/*.c 59 | $(MAKE) -C tools lz77$(EXE) 60 | 61 | clean: 62 | rm -f channel.imet 63 | rm -rf build 64 | $(MAKE) -C tools clean 65 | -------------------------------------------------------------------------------- /channel/banner/Makefile.section: -------------------------------------------------------------------------------- 1 | 2 | TYPE = $(notdir $(CURDIR)) 3 | 4 | PNGS = $(wildcard *.png) 5 | TPLS = $(patsubst %.png,../build/$(TYPE)/arc/timg/%.tpl,$(PNGS)) 6 | 7 | ../build/data/meta/$(TYPE).bin : ../build/$(TYPE).lz77 8 | @[ ! -d ../build/data/meta ] && mkdir -p ../build/data/meta || true 9 | $(ADDIMD5) $< $@ 10 | 11 | ../build/$(TYPE).lz77 : ../build/$(TYPE).arc 12 | $(LZ77) $< $@ 13 | 14 | ifeq ($(TYPE),banner) 15 | ANIMS = ../build/$(TYPE)/arc/anim/$(TYPE)_Start.brlan ../build/$(TYPE)/arc/anim/$(TYPE)_Loop.brlan 16 | else 17 | ANIMS = ../build/$(TYPE)/arc/anim/$(TYPE).brlan 18 | endif 19 | ../build/$(TYPE)/arc/blyt/$(TYPE).brlyt $(ANIMS) : mk$(TYPE).py 20 | @[ ! -d ../build/$(TYPE)/arc/anim ] && mkdir -p ../build/$(TYPE)/arc/anim || true 21 | @[ ! -d ../build/$(TYPE)/arc/blyt ] && mkdir -p ../build/$(TYPE)/arc/blyt || true 22 | python2 mk$(TYPE).py ../build/$(TYPE)/arc/blyt/$(TYPE).brlyt $(ANIMS) 23 | 24 | ../build/$(TYPE).arc : $(TPLS) ../build/$(TYPE)/arc/blyt/$(TYPE).brlyt $(ANIMS) 25 | $(ARCPACK) ../build/$(TYPE).arc ../build/$(TYPE) 26 | 27 | ../build/$(TYPE)/arc/timg/%.tpl : %.png 28 | @[ ! -d ../build/$(TYPE)/arc/timg ] && mkdir -p ../build/$(TYPE)/arc/timg || true 29 | $(PNG2TPL) $< $@ `grep $< textures.txt | cut -f 2-` 30 | 31 | -------------------------------------------------------------------------------- /channel/banner/banner/abubble1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/abubble1.png -------------------------------------------------------------------------------- /channel/banner/banner/abubble2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/abubble2.png -------------------------------------------------------------------------------- /channel/banner/banner/abubble3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/abubble3.png -------------------------------------------------------------------------------- /channel/banner/banner/abubble4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/abubble4.png -------------------------------------------------------------------------------- /channel/banner/banner/abubble5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/abubble5.png -------------------------------------------------------------------------------- /channel/banner/banner/abubble6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/abubble6.png -------------------------------------------------------------------------------- /channel/banner/banner/banner_fade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/banner_fade.png -------------------------------------------------------------------------------- /channel/banner/banner/banner_shape2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/banner_shape2.png -------------------------------------------------------------------------------- /channel/banner/banner/banner_title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/banner_title.png -------------------------------------------------------------------------------- /channel/banner/banner/banner_wave1a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/banner_wave1a.png -------------------------------------------------------------------------------- /channel/banner/banner/banner_wave1b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/banner_wave1b.png -------------------------------------------------------------------------------- /channel/banner/banner/banner_wavea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/banner_wavea.png -------------------------------------------------------------------------------- /channel/banner/banner/banner_waveb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/banner_waveb.png -------------------------------------------------------------------------------- /channel/banner/banner/bbubble1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/bbubble1.png -------------------------------------------------------------------------------- /channel/banner/banner/cbubble1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/cbubble1.png -------------------------------------------------------------------------------- /channel/banner/banner/cbubble2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/cbubble2.png -------------------------------------------------------------------------------- /channel/banner/banner/textures.txt: -------------------------------------------------------------------------------- 1 | #----------------------- 2 | # texture x y 3 | #----------------------- 4 | abubble1.png 0 0 5 | abubble2.png 0 0 6 | abubble3.png 0 0 7 | abubble4.png 0 0 8 | abubble5.png 0 0 9 | abubble6.png 0 0 10 | bbubble1.png 0 0 11 | cbubble1.png 0 0 12 | cbubble2.png 0 0 13 | white.png 1 1 14 | banner_fade.png 1 0 15 | banner_title.png 0 0 16 | banner_wave1a.png 0 0 17 | banner_wave1b.png 0 0 18 | banner_wavea.png 1 0 19 | banner_waveb.png 1 0 20 | banner_shape2.png 0 0 21 | -------------------------------------------------------------------------------- /channel/banner/banner/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/banner/white.png -------------------------------------------------------------------------------- /channel/banner/icon/icon_fade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/icon/icon_fade.png -------------------------------------------------------------------------------- /channel/banner/icon/icon_shape2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/icon/icon_shape2.png -------------------------------------------------------------------------------- /channel/banner/icon/icon_title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/icon/icon_title.png -------------------------------------------------------------------------------- /channel/banner/icon/icon_wave1a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/icon/icon_wave1a.png -------------------------------------------------------------------------------- /channel/banner/icon/icon_wave1b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/icon/icon_wave1b.png -------------------------------------------------------------------------------- /channel/banner/icon/icon_wavea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/icon/icon_wavea.png -------------------------------------------------------------------------------- /channel/banner/icon/icon_waveb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/icon/icon_waveb.png -------------------------------------------------------------------------------- /channel/banner/icon/textures.txt: -------------------------------------------------------------------------------- 1 | #----------------------- 2 | # texture x y 3 | #----------------------- 4 | white.png 1 1 5 | icon_fade.png 1 0 6 | icon_title.png 0 0 7 | icon_wave1a.png 0 0 8 | icon_wave1b.png 0 0 9 | icon_wavea.png 1 0 10 | icon_waveb.png 1 0 11 | icon_shape2.png 0 0 12 | -------------------------------------------------------------------------------- /channel/banner/icon/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/icon/white.png -------------------------------------------------------------------------------- /channel/banner/names.txt: -------------------------------------------------------------------------------- 1 | jp=Homebrewチャンネル 2 | en=Homebrew Channel 3 | de=Homebrewkanal 4 | fr=Chaîne Homebrew 5 | sp=Canal Homebrew 6 | it=Canale Homebrew 7 | nl=Homebrewkanaal 8 | cn=Homebrew频道 9 | ko=Homebrew 채널 10 | -------------------------------------------------------------------------------- /channel/banner/sound/wiibrew-banner-intro-part.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/sound/wiibrew-banner-intro-part.wav -------------------------------------------------------------------------------- /channel/banner/sound/wiibrew-banner-loop-part.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/banner/sound/wiibrew-banner-loop-part.wav -------------------------------------------------------------------------------- /channel/banner/tools/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CFLAGS = -O3 -Wall -I/usr/local/include -L/usr/local/lib 3 | 4 | CC = $(PREFIX)gcc 5 | STRIP = $(PREFIX)strip 6 | 7 | all: mkbns$(EXE) png2tpl$(EXE) lz77$(EXE) 8 | 9 | mkbns$(EXE): mkbns.c 10 | $(CC) $(CFLAGS) -o mkbns mkbns.c -lm 11 | 12 | png2tpl$(EXE): png2tpl.c 13 | $(CC) $(CFLAGS) -o png2tpl png2tpl.c -lpng 14 | 15 | lz77$(EXE): lz77.c 16 | $(CC) $(CFLAGS) -o lz77 lz77.c 17 | 18 | clean: 19 | rm -f mkbns$(EXE) png2tpl$(EXE) lz77$(EXE) 20 | -------------------------------------------------------------------------------- /channel/banner/tools/addimd5.py: -------------------------------------------------------------------------------- 1 | import md5, sys, struct 2 | 3 | data= open(sys.argv[1]).read() 4 | 5 | digest = md5.new(data).digest() 6 | 7 | hdr = struct.pack(">4sI8x","IMD5",len(data)) 8 | 9 | f2 = open(sys.argv[2],"w") 10 | f2.write(hdr) 11 | f2.write(digest) 12 | f2.write(data) 13 | f2.close() 14 | -------------------------------------------------------------------------------- /channel/banner/tools/join-imet.py: -------------------------------------------------------------------------------- 1 | import os, sys, struct, md5 2 | 3 | output, datafile, iconarc, bannerarc, soundbns, namesfile = sys.argv[1:] 4 | 5 | data = open(datafile,"r").read() 6 | 7 | names={} 8 | 9 | for i in open(namesfile,"r"): 10 | a,b = i.split("=") 11 | while b[-1] == "\n": 12 | b = b[:-1] 13 | b = b.replace("\\n","\n") 14 | names[a] = b.decode("utf-8") 15 | 16 | def getsize(x): 17 | return os.stat(x).st_size 18 | 19 | def pad(x,l): 20 | if len(x) > l: 21 | raise ValueError("%d > %d",len(x),l) 22 | n = l-len(x) 23 | return x + "\x00"*n 24 | 25 | imet = "\x00"*0x40 26 | imet += struct.pack(">4sIIIIII","IMET",0x600,3,getsize(iconarc),getsize(bannerarc),getsize(soundbns),1) 27 | 28 | for i in ["jp", "en", "de", "fr", "sp", "it", "nl", "cn", None, "ko"]: 29 | try: 30 | imet += pad(names[i].encode("UTF-16BE"),0x54) 31 | except KeyError: 32 | imet += "\x00"*0x54 33 | imet += "\x00"*(0x600 - len(imet)) 34 | 35 | imet = imet[:-16] + md5.new(imet).digest() 36 | 37 | open(output,"w").write(imet) 38 | 39 | f = open(sys.argv[1],"w") 40 | f.write(imet) 41 | f.write(data) 42 | 43 | fsize = f.tell() 44 | 45 | if (fsize % 20) != 0: 46 | f.write("\x00"*(20-(fsize%20))) 47 | 48 | f.close() 49 | -------------------------------------------------------------------------------- /channel/channelapp/.gitignore: -------------------------------------------------------------------------------- 1 | stub.bin 2 | *.dol 3 | *.elf 4 | .*.swp 5 | dist 6 | build 7 | i18n/merge 8 | i18n/*.gen 9 | *.map 10 | 11 | -------------------------------------------------------------------------------- /channel/channelapp/banner/.gitignore: -------------------------------------------------------------------------------- 1 | twintig 2 | banner.bin 3 | 4 | -------------------------------------------------------------------------------- /channel/channelapp/banner/Makefile: -------------------------------------------------------------------------------- 1 | all: banner.bin 2 | 3 | banner.bin: twintig title banner.ppm icon.ppm 4 | @$(CURDIR)/twintig 5 | 6 | twintig: twintig.c 7 | @gcc -g -O2 -Wall $< -o $@ 8 | 9 | clean: 10 | rm -f twintig banner.bin 11 | 12 | -------------------------------------------------------------------------------- /channel/channelapp/banner/banner.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/banner/banner.ppm -------------------------------------------------------------------------------- /channel/channelapp/banner/icon.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/banner/icon.ppm -------------------------------------------------------------------------------- /channel/channelapp/banner/title: -------------------------------------------------------------------------------- 1 | The Homebrew ChannelBrew like a pro! -------------------------------------------------------------------------------- /channel/channelapp/banner/twintig.c: -------------------------------------------------------------------------------- 1 | // Copyright 2007,2008 Segher Boessenkool 2 | // Licensed under the terms of the GNU GPL, version 2 3 | // http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #define ERROR(s) do { fprintf(stderr, s "\n"); exit(1); } while (0) 14 | 15 | // basic data types 16 | typedef unsigned char u8; 17 | typedef unsigned short u16; 18 | typedef unsigned int u32; 19 | 20 | void wbe16(u8 *p, u16 x) { 21 | p[0] = x >> 8; 22 | p[1] = x; 23 | } 24 | 25 | void wbe32(u8 *p, u32 x) { 26 | wbe16(p, x >> 16); 27 | wbe16(p + 2, x); 28 | } 29 | 30 | static int read_image(u8 *data, u32 w, u32 h, const char *name) { 31 | FILE *fp; 32 | u32 x, y; 33 | u32 ww, hh; 34 | 35 | fp = fopen(name, "rb"); 36 | if (!fp) 37 | return -1; 38 | 39 | if (fscanf(fp, "P6 %d %d 255\n", &ww, &hh) != 2) 40 | ERROR("bad ppm"); 41 | if (ww != w || hh != h) 42 | ERROR("wrong size ppm"); 43 | 44 | for (y = 0; y < h; y++) 45 | for (x = 0; x < w; x++) { 46 | u8 pix[3]; 47 | u16 raw; 48 | u32 x0, x1, y0, y1, off; 49 | 50 | x0 = x & 3; 51 | x1 = x >> 2; 52 | y0 = y & 3; 53 | y1 = y >> 2; 54 | off = x0 + 4 * y0 + 16 * x1 + 4 * w * y1; 55 | 56 | if (fread(pix, 3, 1, fp) != 1) 57 | ERROR("read"); 58 | 59 | raw = (pix[0] & 0xf8) << 7; 60 | raw |= (pix[1] & 0xf8) << 2; 61 | raw |= (pix[2] & 0xf8) >> 3; 62 | raw |= 0x8000; 63 | 64 | wbe16(data + 2*off, raw); 65 | } 66 | 67 | fclose(fp); 68 | return 0; 69 | } 70 | 71 | int main(int argc, char **argv) { 72 | FILE *in, *fp; 73 | u8 header[0x72a0]; 74 | 75 | fp = fopen("banner.bin", "wb+"); 76 | if (!fp) 77 | ERROR("open banner.bin"); 78 | 79 | memset(header, 0, sizeof header); 80 | 81 | memcpy(header, "WIBN", 4); 82 | header[9] = 2; // wtf 83 | 84 | in = fopen("title", "rb"); 85 | if (!in) 86 | ERROR("open title"); 87 | if (fread(header + 0x20, 0x80, 1, in) != 1) 88 | ERROR("read title"); 89 | fclose(in); 90 | 91 | if(read_image(header + 0xa0, 192, 64, "banner.ppm")) 92 | ERROR("open banner.ppm"); 93 | 94 | if(read_image(header + 0x60a0, 48, 48, "icon.ppm")) 95 | ERROR("open icon.ppm"); 96 | 97 | if (fwrite(header, 0x72a0, 1, fp) != 1) 98 | ERROR("write header"); 99 | 100 | fclose(fp); 101 | 102 | return 0; 103 | } 104 | -------------------------------------------------------------------------------- /channel/channelapp/config.h: -------------------------------------------------------------------------------- 1 | #ifndef _CONFIG_H_ 2 | #define _CONFIG_H_ 3 | 4 | #define CHANNEL_VERSION_DATE 201611230000llu 5 | #define CHANNEL_VERSION_STR "1.1.3" 6 | 7 | //#define DEBUG_APP 8 | //#define DEBUG_STUB 9 | 10 | #define ENABLE_WIDESCREEN 11 | #define ENABLE_SCREENSHOTS 12 | //#define ENABLE_UPDATES 13 | //#define FORCE_LANG CONF_LANG_JAPANESE 14 | 15 | #ifdef DEBUG_APP 16 | void gprintf_enable(int enable); 17 | int gprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2))); 18 | void hexdump(const void *d, int len); 19 | void memstats(int reset); 20 | #define CHKBUFACC(access, ptr, len) \ 21 | do { \ 22 | if ((access < ptr) || (access >= ptr + len)) \ 23 | gprintf("WARNING: buffer access out of range: %s:%d\n", __FILE__, __LINE__); \ 24 | } while (0) 25 | #else 26 | #define gprintf(...) 27 | #define hexdump(...) 28 | #define memstats(...) 29 | #define gprintf_enable(...) 30 | #define CHKBUFACC(...) 31 | #endif 32 | 33 | #define UPDATE_URL "http://example.com/update.sxml" 34 | #define UPDATE_PUBLIC_KEY \ 35 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ 36 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ 37 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ 38 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 39 | 40 | #define USBGECKO_CHANNEL 1 41 | 42 | #define STUB_MAGIC 0x4c4f41444b544858ull 43 | #define STUB_ADDR_MAGIC ((u64 *) 0x80002f00) 44 | #define STUB_ADDR_TITLE ((u64 *) 0x80002f08) 45 | 46 | #define BOOTMII_IOS 254 47 | #define TITLEID_BOOTMII (0x0000000100000000LL | BOOTMII_IOS) 48 | 49 | #define PREFERRED IOS_GetPreferredVersion() 50 | #define UNCHANGED IOS_GetVersion() 51 | 52 | #define MY_TITLEID 0x000100014f484243ull 53 | #define STUB_LOAD_IOS_VERSION UNCHANGED 54 | #define APPS_IOS_VERSION PREFERRED 55 | 56 | #define VIEW_Z_ORIGIN -420 57 | 58 | #define GFX_ORIGIN_STACK_SIZE 16 59 | 60 | // peak bubbles 61 | #define MAX_BUBBLE_COUNT 20 62 | // minimum bubbles 63 | #define MIN_BUBBLE_COUNT 4 64 | // cycle time in minutes 65 | #define BUBBLE_TIME_CYCLE (60*24) 66 | // time (in minutes, inside cycle) of minimum bubbles 67 | #define BUBBLE_MIN_TIME (60*4) 68 | // time (in minutes) offset from BUBBLE_MIN_TIME of maximum bubbles 69 | #define BUBBLE_MAX_OFFSET (60*12) 70 | // bubble size 71 | #define BUBBLE_SIZE_MIN 0.4 72 | #define BUBBLE_SIZE_MAX 1.0 73 | // bubble pop radius modifier 74 | #define BUBBLE_POP_RADIUS 0.8 75 | // bubble pop generates this many bubbles 76 | #define BUBBLE_POP_MAX 10 77 | #define BUBBLE_POP_MIN 5 78 | // bubble pop sub-bubble size 79 | #define BUBBLE_POP_SIZE_MIN 0.2 80 | #define BUBBLE_POP_SIZE_MAX 0.4 81 | // bubble pop spread out range 82 | #define BUBBLE_POP_SPREAD_X 40 83 | #define BUBBLE_POP_SPREAD_Y 30 84 | 85 | #define IRAND(max) ((int) ((float) (max) * (rand () / (RAND_MAX + 1.0)))) 86 | #define FRAND(max) ((max) * (rand () / (RAND_MAX + 1.0))) 87 | 88 | #define WIDGET_DISABLED_COLOR 0xFFFFFF54 89 | 90 | #define DIALOG_MASK_COLOR 0x101010a0 91 | 92 | #define TEX_LAYER_WIDGETS 2 93 | #define TEX_LAYER_DIALOGS 30 94 | 95 | #define TEX_LAYER_CURSOR 80 96 | 97 | #define APP_ENTRY_ICON_X 8 98 | #define APP_ENTRY_ICON_Y 8 99 | #define GRID_APP_ENTRY_ICON_X 8 100 | #define GRID_APP_ENTRY_ICON_Y 8 101 | #define APP_ENTRY_ICON_WIDTH 128 102 | #define APP_ENTRY_ICON_HEIGHT 48 103 | #define APP_ENTRY_TEXT1_X 156 104 | #define APP_ENTRY_TEXT1_Y 8 105 | #define APP_ENTRY_TEXT2_X 156 106 | #define APP_ENTRY_TEXT2_Y 54 107 | 108 | #define MAX_ENTRIES 1024 109 | 110 | #define TCP_CONNECT_TIMEOUT 5000 111 | #define TCP_BLOCK_SIZE (16 * 1024) 112 | #define TCP_BLOCK_RECV_TIMEOUT 10000 113 | #define TCP_BLOCK_SEND_TIMEOUT 4000 114 | 115 | #define WIILOAD_MIN_VERSION 0x0005 116 | #define ARGS_MAX_LEN 1024 117 | 118 | #define LD_TCP_PORT 4299 119 | #define LD_THREAD_STACKSIZE (1024 * 8) 120 | #define LD_THREAD_PRIO 48 121 | #define LD_TIMEOUT 3000 122 | #define LD_MIN_ADDR 0x80003400 123 | #define LD_MAX_ADDR (BASE_ADDR - 1 - ARGS_MAX_LEN) 124 | #define LD_MAX_SIZE (LD_MAX_ADDR - LD_MIN_ADDR) 125 | #define LD_ARGS_ADDR (LD_MAX_ADDR + 1) 126 | 127 | #define HTTP_THREAD_STACKSIZE (1024 * 8) 128 | #define HTTP_THREAD_PRIO 48 129 | #define HTTP_TIMEOUT 30000 130 | 131 | #define MANAGE_THREAD_STACKSIZE (1024 * 16) 132 | #define MANAGE_THREAD_PRIO 48 133 | 134 | #define APPENTRY_THREAD_STACKSIZE (1024 * 16) 135 | #define APPENTRY_THREAD_PRIO 62 136 | 137 | #define UPDATE_THREAD_STACKSIZE (1024 * 8) 138 | #define UPDATE_THREAD_PRIO 58 139 | 140 | #define FORCE_INLINE __attribute__((always_inline)) 141 | 142 | #endif 143 | 144 | -------------------------------------------------------------------------------- /channel/channelapp/data/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/about.png -------------------------------------------------------------------------------- /channel/channelapp/data/apps_grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/apps_grid.png -------------------------------------------------------------------------------- /channel/channelapp/data/apps_grid_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/apps_grid_hover.png -------------------------------------------------------------------------------- /channel/channelapp/data/apps_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/apps_list.png -------------------------------------------------------------------------------- /channel/channelapp/data/apps_list_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/apps_list_hover.png -------------------------------------------------------------------------------- /channel/channelapp/data/apps_next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/apps_next.png -------------------------------------------------------------------------------- /channel/channelapp/data/apps_next_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/apps_next_hover.png -------------------------------------------------------------------------------- /channel/channelapp/data/apps_previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/apps_previous.png -------------------------------------------------------------------------------- /channel/channelapp/data/apps_previous_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/apps_previous_hover.png -------------------------------------------------------------------------------- /channel/channelapp/data/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/background.png -------------------------------------------------------------------------------- /channel/channelapp/data/background_wide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/background_wide.png -------------------------------------------------------------------------------- /channel/channelapp/data/bubble1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/bubble1.png -------------------------------------------------------------------------------- /channel/channelapp/data/bubble2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/bubble2.png -------------------------------------------------------------------------------- /channel/channelapp/data/bubble3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/bubble3.png -------------------------------------------------------------------------------- /channel/channelapp/data/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/button.png -------------------------------------------------------------------------------- /channel/channelapp/data/button_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/button_focus.png -------------------------------------------------------------------------------- /channel/channelapp/data/button_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/button_small.png -------------------------------------------------------------------------------- /channel/channelapp/data/button_small_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/button_small_focus.png -------------------------------------------------------------------------------- /channel/channelapp/data/button_tiny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/button_tiny.png -------------------------------------------------------------------------------- /channel/channelapp/data/button_tiny_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/button_tiny_focus.png -------------------------------------------------------------------------------- /channel/channelapp/data/content_arrow_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/content_arrow_down.png -------------------------------------------------------------------------------- /channel/channelapp/data/content_arrow_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/content_arrow_up.png -------------------------------------------------------------------------------- /channel/channelapp/data/cursor_drag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/cursor_drag.png -------------------------------------------------------------------------------- /channel/channelapp/data/cursor_drag_shade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/cursor_drag_shade.png -------------------------------------------------------------------------------- /channel/channelapp/data/cursor_pic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/cursor_pic.png -------------------------------------------------------------------------------- /channel/channelapp/data/cursor_shade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/cursor_shade.png -------------------------------------------------------------------------------- /channel/channelapp/data/dialog_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/dialog_background.png -------------------------------------------------------------------------------- /channel/channelapp/data/dlg_confirm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/dlg_confirm.png -------------------------------------------------------------------------------- /channel/channelapp/data/dlg_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/dlg_error.png -------------------------------------------------------------------------------- /channel/channelapp/data/dlg_info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/dlg_info.png -------------------------------------------------------------------------------- /channel/channelapp/data/dlg_warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/dlg_warning.png -------------------------------------------------------------------------------- /channel/channelapp/data/droid.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/droid.ttf -------------------------------------------------------------------------------- /channel/channelapp/data/droidbold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/droidbold.ttf -------------------------------------------------------------------------------- /channel/channelapp/data/icon_network.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/icon_network.png -------------------------------------------------------------------------------- /channel/channelapp/data/icon_network_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/icon_network_active.png -------------------------------------------------------------------------------- /channel/channelapp/data/icon_usbgecko.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/icon_usbgecko.png -------------------------------------------------------------------------------- /channel/channelapp/data/icon_usbgecko_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/icon_usbgecko_active.png -------------------------------------------------------------------------------- /channel/channelapp/data/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/logo.png -------------------------------------------------------------------------------- /channel/channelapp/data/progress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/progress.png -------------------------------------------------------------------------------- /channel/channelapp/data/throbber.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/channelapp/data/throbber.png -------------------------------------------------------------------------------- /channel/channelapp/gdb.txt: -------------------------------------------------------------------------------- 1 | target remote /dev/ttyUSB0 2 | info threads 3 | bt 4 | 5 | -------------------------------------------------------------------------------- /channel/channelapp/i18n/template.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: PACKAGE VERSION\n" 9 | "Report-Msgid-Bugs-To: \n" 10 | "POT-Creation-Date: 2016-11-22 21:29+0900\n" 11 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 12 | "Last-Translator: NICKNAME \n" 13 | "Language-Team: LANGUAGE\n" 14 | "Language: \n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | 19 | #: source/dialogs.c:53 20 | msgid "no description available" 21 | msgstr "" 22 | 23 | # This and the following strings are dialog box "title bars" 24 | #: source/dialogs.c:55 25 | msgid "Information" 26 | msgstr "" 27 | 28 | #: source/dialogs.c:56 29 | msgid "Confirmation" 30 | msgstr "" 31 | 32 | #: source/dialogs.c:57 33 | msgid "Warning" 34 | msgstr "" 35 | 36 | #: source/dialogs.c:58 37 | msgid "Error" 38 | msgstr "" 39 | 40 | # button text 41 | #: source/dialogs.c:59 42 | msgid "Ok" 43 | msgstr "" 44 | 45 | # button text 46 | #: source/dialogs.c:60 47 | msgid "Cancel" 48 | msgstr "" 49 | 50 | # button text 51 | #: source/dialogs.c:61 52 | msgid "Yes" 53 | msgstr "" 54 | 55 | # button text 56 | #: source/dialogs.c:62 57 | msgid "No" 58 | msgstr "" 59 | 60 | #: source/dialogs.c:63 61 | msgid "Delete" 62 | msgstr "" 63 | 64 | # button text 65 | #: source/dialogs.c:64 66 | msgid "Load" 67 | msgstr "" 68 | 69 | # button text 70 | #: source/dialogs.c:65 source/m_main.c:95 71 | msgid "Back" 72 | msgstr "" 73 | 74 | #: source/dialogs.c:66 75 | msgid "Options" 76 | msgstr "" 77 | 78 | #: source/dialogs.c:67 79 | msgid "Device:" 80 | msgstr "" 81 | 82 | #: source/dialogs.c:68 83 | msgid "Internal SD Slot" 84 | msgstr "" 85 | 86 | #: source/dialogs.c:69 87 | msgid "USB device" 88 | msgstr "" 89 | 90 | #: source/dialogs.c:70 91 | msgid "SDGecko Slot A" 92 | msgstr "" 93 | 94 | #: source/dialogs.c:71 95 | msgid "SDGecko Slot B" 96 | msgstr "" 97 | 98 | #: source/dialogs.c:72 99 | msgid "Sort applications by:" 100 | msgstr "" 101 | 102 | #: source/dialogs.c:73 103 | msgid "Name" 104 | msgstr "" 105 | 106 | #: source/dialogs.c:74 107 | msgid "Date" 108 | msgstr "" 109 | 110 | #: source/dialogs.c:110 111 | msgid " translation by " 112 | msgstr "" 113 | 114 | #: source/dialogs.c:115 115 | msgid "Theme:" 116 | msgstr "" 117 | 118 | #: source/dialogs.c:125 119 | #, c-format 120 | msgid "Version: %s" 121 | msgstr "" 122 | 123 | #: source/dialogs.c:126 124 | #, c-format 125 | msgid "Author: %s" 126 | msgstr "" 127 | 128 | #: source/loader.c:716 129 | msgid "Error while reading the application from the SD card" 130 | msgstr "" 131 | 132 | #: source/loader.c:717 133 | msgid "Error while receiving the application" 134 | msgstr "" 135 | 136 | #: source/loader.c:718 137 | msgid "Error uncompressing the received data" 138 | msgstr "" 139 | 140 | #: source/loader.c:719 141 | msgid "This is not a valid Wii application" 142 | msgstr "" 143 | 144 | #: source/loader.c:720 145 | msgid "This is not a usable ZIP file" 146 | msgstr "" 147 | 148 | #: source/loader.c:721 149 | msgid "Not enough memory" 150 | msgstr "" 151 | 152 | #: source/loader.c:763 153 | #, c-format 154 | msgid "Loading %s" 155 | msgstr "" 156 | 157 | #: source/loader.c:772 158 | #, c-format 159 | msgid "Receiving over USBGecko" 160 | msgstr "" 161 | 162 | #: source/loader.c:782 163 | #, c-format 164 | msgid "Receiving from %s" 165 | msgstr "" 166 | 167 | #: source/loader.c:968 168 | #, c-format 169 | msgid "" 170 | "Extract the received ZIP file?\n" 171 | "%s of free space are required." 172 | msgstr "" 173 | 174 | #: source/loader.c:969 175 | #, c-format 176 | msgid "WARNING: Files in '%s' will be overwritten" 177 | msgstr "" 178 | 179 | #: source/loader.c:970 180 | msgid "Error while extracting the ZIP file" 181 | msgstr "" 182 | 183 | #: source/main.c:250 184 | msgid "Do you really want to delete this application?" 185 | msgstr "" 186 | 187 | #: source/main.c:251 188 | #, c-format 189 | msgid "Error deleting '%s'" 190 | msgstr "" 191 | 192 | #: source/manage.c:518 193 | msgid "Extracting" 194 | msgstr "" 195 | 196 | #: source/m_main.c:80 197 | msgid "Network not initialized" 198 | msgstr "" 199 | 200 | #: source/m_main.c:81 201 | #, c-format 202 | msgid "Your Wii's IP is %u.%u.%u.%u" 203 | msgstr "" 204 | 205 | # button text 206 | #: source/m_main.c:97 207 | msgid "About" 208 | msgstr "" 209 | 210 | #: source/m_main.c:102 211 | msgid "Launch BootMii" 212 | msgstr "" 213 | 214 | #: source/m_main.c:106 215 | msgid "Exit to System Menu" 216 | msgstr "" 217 | 218 | #: source/m_main.c:109 219 | msgid "Shutdown" 220 | msgstr "" 221 | 222 | #: source/update.c:232 223 | #, c-format 224 | msgid "" 225 | "An update to the Homebrew Channel (version %s, replacing the installed " 226 | "version %s) is available for installation, do you want to update now?\n" 227 | "\n" 228 | "Release notes:\n" 229 | "\n" 230 | "%s" 231 | msgstr "" 232 | 233 | #: source/update.c:262 234 | #, c-format 235 | msgid "Downloading Update (%u kB)" 236 | msgstr "" 237 | 238 | #: source/update.c:304 239 | msgid "Download failed" 240 | msgstr "" 241 | 242 | #: source/widgets.c:16 243 | msgid "" 244 | msgstr "" 245 | -------------------------------------------------------------------------------- /channel/channelapp/newrvl.spec: -------------------------------------------------------------------------------- 1 | *link_start_rvl: 2 | -T newrvl.ld%s 3 | -------------------------------------------------------------------------------- /channel/channelapp/source/appentry.h: -------------------------------------------------------------------------------- 1 | #ifndef _APPENTRY_H_ 2 | #define _APPENTRY_H_ 3 | 4 | #include 5 | 6 | #include "gfx.h" 7 | #include "xml.h" 8 | 9 | #define DEVICE_COUNT 4 10 | #define MAX_THEME_ZIP_SIZE (20 * 1024 * 1024) 11 | 12 | typedef enum { 13 | AET_BOOT_ELF = 0, 14 | AET_BOOT_DOL, 15 | AET_THEME 16 | } app_entry_type; 17 | 18 | typedef struct { 19 | app_entry_type type; 20 | u32 size; 21 | char *dirname; 22 | gfx_entity *icon; 23 | meta_info *meta; 24 | } app_entry; 25 | 26 | typedef enum { 27 | AE_ACT_NONE = 0, 28 | AE_ACT_REMOVE, 29 | AE_ACT_ADD 30 | } ae_action; 31 | 32 | typedef enum { 33 | APP_FILTER_ALL = 0, 34 | APP_FILTER_ICONSONLY, 35 | APP_FILTER_DATEONLY 36 | } app_filter; 37 | 38 | typedef enum { 39 | APP_SORT_NAME = 0, 40 | APP_SORT_DATE 41 | } app_sort; 42 | 43 | extern const char *app_path; 44 | extern const char *app_fn_boot_elf; 45 | extern const char *app_fn_boot_dol; 46 | extern const char *app_fn_theme; 47 | extern const char *app_fn_meta; 48 | extern const char *app_fn_icon; 49 | 50 | extern app_entry *entries[MAX_ENTRIES]; 51 | extern u32 entry_count; 52 | 53 | void app_entry_init (void); 54 | void app_entry_deinit (void); 55 | 56 | void app_entries_free(void); 57 | 58 | void app_entry_scan(void); 59 | ae_action app_entry_action(void); 60 | 61 | void app_entry_poll_status(bool reset); 62 | int app_entry_get_status(bool *status); 63 | 64 | void app_entry_set_prefered(int device); 65 | void app_entry_set_device(int device); 66 | 67 | bool app_entry_get_path(char *buf); 68 | bool app_entry_get_filename(char *buf, app_entry *app); 69 | app_entry *app_entry_find(char *dirname); 70 | 71 | app_sort app_entry_get_sort(void); 72 | void app_entry_set_sort(app_sort sort); 73 | 74 | app_entry *app_entry_add(const char *dirname); 75 | bool app_entry_remove(app_entry *app); 76 | 77 | bool app_entry_is_loading(void); 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /channel/channelapp/source/blob.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../config.h" 5 | #include "debug.h" 6 | #include "panic.h" 7 | #include "blob.h" 8 | 9 | #define MAX_BLOBS 8 10 | #define BLOB_MINSLACK (512*1024) 11 | 12 | typedef struct { 13 | void *the_blob; 14 | size_t blob_size; 15 | void *old_arena2hi; 16 | } blob_t; 17 | 18 | blob_t blobs[MAX_BLOBS]; 19 | int num_blobs = 0; 20 | 21 | // supports only stack-type allocs (free last alloced) 22 | void *blob_alloc(size_t size) 23 | { 24 | u32 level; 25 | u32 addr; 26 | void *old_arena2hi; 27 | 28 | _CPU_ISR_Disable(level); 29 | if (num_blobs >= MAX_BLOBS) { 30 | _CPU_ISR_Restore(level); 31 | gprintf("too many blobs\n"); 32 | panic(); 33 | } 34 | 35 | old_arena2hi = SYS_GetArena2Hi(); 36 | addr = (((u32)old_arena2hi) - size) & (~0x1f); 37 | 38 | if (addr < (BLOB_MINSLACK + (u32)SYS_GetArena2Lo())) { 39 | _CPU_ISR_Restore(level); 40 | return NULL; 41 | } 42 | 43 | blobs[num_blobs].old_arena2hi = old_arena2hi; 44 | blobs[num_blobs].the_blob = (void*)addr; 45 | blobs[num_blobs].blob_size = size; 46 | num_blobs++; 47 | 48 | SYS_SetArena2Hi((void*)addr); 49 | _CPU_ISR_Restore(level); 50 | gprintf("allocated blob size %d at 0x%08x\n", size, addr); 51 | return (void*)addr; 52 | } 53 | 54 | void blob_free(void *p) 55 | { 56 | u32 level; 57 | if (!p) 58 | return; 59 | 60 | _CPU_ISR_Disable(level); 61 | 62 | if (num_blobs == 0) { 63 | _CPU_ISR_Restore(level); 64 | gprintf("blob_free with no blobs\n"); 65 | panic(); 66 | } 67 | 68 | num_blobs--; 69 | if (p != blobs[num_blobs].the_blob) { 70 | _CPU_ISR_Restore(level); 71 | gprintf("mismatched blob_free (%p != %p)\n", p, blobs[num_blobs].the_blob); 72 | panic(); 73 | } 74 | if (SYS_GetArena2Hi() != p) { 75 | _CPU_ISR_Restore(level); 76 | gprintf("someone else used MEM2 (%p != %p)\n", p, SYS_GetArena2Hi()); 77 | panic(); 78 | } 79 | 80 | SYS_SetArena2Hi(blobs[num_blobs].old_arena2hi); 81 | _CPU_ISR_Restore(level); 82 | gprintf("freed blob size %d at %p\n", blobs[num_blobs].blob_size, p); 83 | } 84 | 85 | -------------------------------------------------------------------------------- /channel/channelapp/source/blob.h: -------------------------------------------------------------------------------- 1 | #ifndef _BLOB_H_ 2 | #define _BLOB_H_ 3 | 4 | #include 5 | 6 | void *blob_alloc(size_t size); 7 | void blob_free(void *p); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /channel/channelapp/source/browser.h: -------------------------------------------------------------------------------- 1 | #ifndef _BROWSER_H_ 2 | #define _BROWSER_H_ 3 | 4 | #include 5 | 6 | #include "view.h" 7 | 8 | typedef enum { 9 | BA_ADD = 0, 10 | BA_REMOVE, 11 | BA_REFRESH, 12 | BA_NEXT, 13 | BA_PREV 14 | } browser_action; 15 | 16 | view * browser_init(void); 17 | void browser_deinit(void); 18 | void browser_theme_reinit(void); 19 | 20 | void browser_gen_view(browser_action action, const app_entry *app); 21 | void browser_set_focus(u32 bd); 22 | app_entry *browser_sel(void); 23 | void browser_switch_mode(void); 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /channel/channelapp/source/bubbles.h: -------------------------------------------------------------------------------- 1 | #ifndef _BUBBLES_H_ 2 | #define _BUBBLES_H_ 3 | 4 | #include 5 | 6 | void bubbles_init(void); 7 | void bubbles_deinit(void); 8 | void bubbles_theme_reinit(void); 9 | 10 | void bubble_update(bool wm, s32 x, s32 y); 11 | 12 | void bubble_popall(void); 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /channel/channelapp/source/controls.h: -------------------------------------------------------------------------------- 1 | #ifndef _CONTROLS_H_ 2 | #define _CONTROLS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // fake wiimote buttons for mapping extension buttons 8 | #define PADW_BUTTON_NET_INIT 0x2000 9 | #define PADW_BUTTON_SCREENSHOT 0x4000 10 | 11 | #define PADS_A (PAD_BUTTON_A | (WPAD_BUTTON_A << 16)) 12 | #define PADS_B (PAD_BUTTON_B | (WPAD_BUTTON_B << 16)) 13 | #define PADS_MINUS (PAD_TRIGGER_L | (WPAD_BUTTON_MINUS << 16)) 14 | #define PADS_PLUS (PAD_TRIGGER_R | (WPAD_BUTTON_PLUS << 16)) 15 | #define PADS_1 (PAD_BUTTON_X | (WPAD_BUTTON_1 << 16)) 16 | #define PADS_2 (PAD_BUTTON_Y | (WPAD_BUTTON_2 << 16)) 17 | #define PADS_HOME (PAD_BUTTON_START | (WPAD_BUTTON_HOME << 16)) 18 | #define PADS_UP (PAD_BUTTON_UP | (WPAD_BUTTON_UP << 16)) 19 | #define PADS_DOWN (PAD_BUTTON_DOWN | (WPAD_BUTTON_DOWN << 16)) 20 | #define PADS_LEFT (PAD_BUTTON_LEFT | (WPAD_BUTTON_LEFT << 16)) 21 | #define PADS_RIGHT (PAD_BUTTON_RIGHT | (WPAD_BUTTON_RIGHT << 16)) 22 | #define PADS_DPAD (PADS_UP | PADS_DOWN | PADS_LEFT | PADS_RIGHT) 23 | #define PADS_NET_INIT (PAD_TRIGGER_Z | (PADW_BUTTON_NET_INIT << 16)) 24 | #define PADS_SCREENSHOT (PADW_BUTTON_SCREENSHOT << 16) 25 | 26 | void controls_init (void); 27 | void controls_deinit (void); 28 | 29 | void controls_scan (u32 *down, u32 *held, u32 *up); 30 | bool controls_ir (s32 *x, s32 *y, f32 *roll); 31 | void controls_rumble(int rumble); 32 | s32 controls_sticky(void); 33 | void controls_set_ir_threshold(int on); 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /channel/channelapp/source/cursors.c: -------------------------------------------------------------------------------- 1 | #include "../config.h" 2 | 3 | #include 4 | 5 | #include "cursor_drag_png.h" 6 | #include "cursor_drag_shade_png.h" 7 | #include "cursor_pic_png.h" 8 | #include "cursor_shade_png.h" 9 | 10 | #include "cursors.h" 11 | 12 | static cursor cursors[CUR_MAX]; 13 | 14 | void cursors_init (void) { 15 | cursors[CUR_STD].tex[0] = tex_from_png (cursor_shade_png, 16 | cursor_shade_png_size, 96,96); 17 | cursors[CUR_STD].tex[1] = tex_from_png (cursor_pic_png, cursor_pic_png_size, 18 | 96, 96); 19 | 20 | cursors[CUR_STD].hotspot_x = cursors[CUR_STD].tex[1]->w / 2; 21 | cursors[CUR_STD].hotspot_y = cursors[CUR_STD].tex[1]->h / 2; 22 | 23 | cursors[CUR_DRAG].tex[0] = tex_from_png (cursor_drag_shade_png, 24 | cursor_drag_shade_png_size, 25 | 96, 96); 26 | cursors[CUR_DRAG].tex[1] = tex_from_png (cursor_drag_png, 27 | cursor_drag_png_size, 96, 96); 28 | cursors[CUR_DRAG].hotspot_x = cursors[CUR_DRAG].tex[1]->w / 2; 29 | cursors[CUR_DRAG].hotspot_y = cursors[CUR_DRAG].tex[1]->h / 2; 30 | } 31 | 32 | void cursors_deinit (void) { 33 | u8 i; 34 | 35 | for (i = 0; i < CUR_MAX; ++i) { 36 | tex_free (cursors[i].tex[0]); 37 | tex_free (cursors[i].tex[1]); 38 | } 39 | } 40 | 41 | void cursors_queue (gfx_queue_entry *queue, cursor_type type, s16 x, s16 y, 42 | f32 roll) { 43 | gfx_qe_entity (&queue[0], cursors[type].tex[0], 44 | x - cursors[type].hotspot_x + 2, 45 | y - cursors[type].hotspot_y + 4, TEX_LAYER_CURSOR, 46 | COL_DEFAULT); 47 | gfx_qe_entity (&queue[1], cursors[type].tex[1], 48 | x - cursors[type].hotspot_x, 49 | y - cursors[type].hotspot_y, TEX_LAYER_CURSOR + 1, 50 | COL_DEFAULT); 51 | 52 | queue[0].entity.rad = roll; 53 | queue[1].entity.rad = roll; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /channel/channelapp/source/cursors.h: -------------------------------------------------------------------------------- 1 | #ifndef _CURSORS_H_ 2 | #define _CURSORS_H_ 3 | 4 | #include 5 | 6 | #include "gfx.h" 7 | #include "tex.h" 8 | 9 | typedef enum { 10 | CUR_STD = 0, 11 | CUR_DRAG, 12 | 13 | CUR_MAX 14 | } cursor_type; 15 | 16 | typedef struct { 17 | gfx_entity *tex[2]; 18 | 19 | s16 hotspot_x, hotspot_y; 20 | } cursor; 21 | 22 | void cursors_init (void); 23 | void cursors_deinit (void); 24 | void cursors_queue (gfx_queue_entry *queue, cursor_type type, s16 x, s16 y, 25 | f32 roll); 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /channel/channelapp/source/debug.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include "../config.h" 8 | 9 | #ifdef DEBUG_APP 10 | 11 | //#define DEBUG_MEMSTATS 12 | 13 | static int gprintf_enabled = 1; 14 | 15 | void gprintf_enable(int enable) { 16 | gprintf_enabled = enable; 17 | } 18 | 19 | int gprintf(const char *format, ...) 20 | { 21 | va_list ap; 22 | u32 level; 23 | int ret; 24 | 25 | if (!gprintf_enabled) 26 | return 0; 27 | 28 | level = IRQ_Disable(); 29 | va_start(ap, format); 30 | ret = vprintf(format, ap); 31 | va_end(ap); 32 | IRQ_Restore(level); 33 | 34 | return ret; 35 | } 36 | 37 | /********* you know you love it **********/ 38 | static char ascii(char s) { 39 | if(s < 0x20) return '.'; 40 | if(s > 0x7E) return '.'; 41 | return s; 42 | } 43 | 44 | void hexdump(const void *d, int len) { 45 | u8 *data; 46 | int i, off; 47 | data = (u8*)d; 48 | for (off=0; off=len) gprintf(" "); 52 | else gprintf("%02x ",data[off+i]); 53 | 54 | gprintf(" "); 55 | for(i=0; i<16; i++) 56 | if((i+off)>=len) gprintf(" "); 57 | else gprintf("%c",ascii(data[off+i])); 58 | gprintf("\n"); 59 | } 60 | } 61 | /********* you know you love it **********/ 62 | 63 | #ifndef UINT_MAX 64 | #define UINT_MAX ((u32)((s32)-1)) 65 | #endif 66 | void memstats(int reset) { 67 | #ifdef DEBUG_MEMSTATS 68 | static u32 min_free = UINT_MAX; 69 | static u32 temp_free; 70 | static u32 level; 71 | 72 | if (reset) 73 | min_free = UINT_MAX; 74 | 75 | _CPU_ISR_Disable(level); 76 | 77 | temp_free = (u32) SYS_GetArena2Hi() - (u32) SYS_GetArena2Lo(); 78 | 79 | _CPU_ISR_Restore(level); 80 | 81 | if (temp_free < min_free) { 82 | min_free = temp_free; 83 | gprintf("MEM2 free: %8u\n", min_free); 84 | } 85 | #endif 86 | } 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /channel/channelapp/source/dialogs.h: -------------------------------------------------------------------------------- 1 | #ifndef _DIALOGS_H_ 2 | #define _DIALOGS_H_ 3 | 4 | #include 5 | 6 | #include "gfx.h" 7 | #include "view.h" 8 | 9 | typedef enum { 10 | DLGMT_INFO = 0, 11 | DLGMT_CONFIRM, 12 | DLGMT_WARNING, 13 | DLGMT_ERROR 14 | } dialog_message_type; 15 | 16 | typedef enum { 17 | DLGB_OK, 18 | DLGB_OKCANCEL, 19 | DLGB_YESNO 20 | } dialog_message_buttons; 21 | 22 | typedef struct { 23 | bool confirmed; 24 | int device; 25 | app_sort sort; 26 | } dialog_options_result; 27 | 28 | extern u16 width_dialog, height_dialog; 29 | 30 | void dialogs_init (void); 31 | void dialogs_theme_reinit (void); 32 | void dialogs_deinit (void); 33 | 34 | void dialog_fade (view *v, bool fade_in); 35 | 36 | view * dialog_app (const app_entry *entry, const view *sub_view); 37 | view * dialog_progress (const view *sub_view, const char *caption, u32 max); 38 | void dialog_set_progress (const view *v, u32 progress); 39 | view * dialog_about (const view *sub_view); 40 | 41 | s8 show_message (const view *sub_view, dialog_message_type type, 42 | dialog_message_buttons buttons, const char *text, u8 focus); 43 | dialog_options_result show_options_dialog(const view *sub_view); 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /channel/channelapp/source/dvd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "../config.h" 7 | 8 | static u32 inbuf[8] __attribute__((aligned(0x20))); 9 | static u32 outbuf[8] __attribute__((aligned(0x20))); 10 | 11 | static s32 _dvd_fd = -1; 12 | 13 | static const char _dvd_path[] __attribute__((aligned(0x20))) = "/dev/di"; 14 | 15 | typedef enum { 16 | WDVD_OPEN = 0, 17 | WDVD_STOP, 18 | WDVD_CLOSE, 19 | WDVD_DONE 20 | } wiidvd_state; 21 | 22 | static wiidvd_state _state; 23 | 24 | static s32 __WiiDVD_Callback(s32 result, void *userdata) 25 | { 26 | s32 res = -1; 27 | 28 | switch (_state) { 29 | case WDVD_OPEN: 30 | _dvd_fd = result; 31 | if (_dvd_fd < 0) 32 | return 0; 33 | 34 | memset(inbuf, 0, 0x20); 35 | inbuf[0x00] = 0xe3000000; 36 | inbuf[0x01] = 0; 37 | inbuf[0x02] = 0; 38 | 39 | _state = WDVD_STOP; 40 | res = IOS_IoctlAsync( _dvd_fd, 0xe3, inbuf, 0x20, outbuf, 0x20, 41 | __WiiDVD_Callback, NULL); 42 | break; 43 | 44 | case WDVD_STOP: 45 | _state = WDVD_CLOSE; 46 | res = IOS_CloseAsync(_dvd_fd, __WiiDVD_Callback, NULL); 47 | break; 48 | 49 | case WDVD_CLOSE: 50 | _dvd_fd = -1; 51 | _state = WDVD_DONE; 52 | res = 0; 53 | break; 54 | 55 | default: 56 | break; 57 | } 58 | 59 | return res; 60 | } 61 | 62 | s32 WiiDVD_StopMotorAsync(void) { 63 | _state = WDVD_OPEN; 64 | 65 | gprintf("starting DVD motor stop callback chain\n"); 66 | return IOS_OpenAsync(_dvd_path, 0, __WiiDVD_Callback, NULL); 67 | } 68 | 69 | void WiiDVD_ShutDown(void) { 70 | s32 fd = _dvd_fd; 71 | 72 | if (fd > 0) { 73 | _dvd_fd = -1; 74 | _state = WDVD_DONE; 75 | IOS_Close(fd); 76 | gprintf("killed DVD motor stop callback chain\n"); 77 | } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /channel/channelapp/source/dvd.h: -------------------------------------------------------------------------------- 1 | #ifndef _DVD_H_ 2 | #define _DVD_H_ 3 | 4 | #include 5 | 6 | s32 WiiDVD_StopMotorAsync(void); 7 | void WiiDVD_ShutDown(void); 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /channel/channelapp/source/ecdsa.h: -------------------------------------------------------------------------------- 1 | #ifndef _ECDSA_H_ 2 | #define _ECDSA_H_ 3 | 4 | #include 5 | 6 | int check_ecdsa(const u8 *Q, u8 *R, u8 *S, u8 *hash); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /channel/channelapp/source/font.h: -------------------------------------------------------------------------------- 1 | #ifndef _FONT_H_ 2 | #define _FONT_H_ 3 | 4 | #include 5 | 6 | #include "gfx.h" 7 | 8 | typedef enum { 9 | FONT_LABEL = 0, 10 | FONT_DLGTITLE, 11 | FONT_MEMO, 12 | FONT_APPNAME, 13 | FONT_APPDESC, 14 | FONT_BUTTON, 15 | FONT_BUTTON_DESEL, 16 | 17 | FONT_MAX 18 | } font_id; 19 | 20 | typedef enum { 21 | FA_LEFT = 0, 22 | FA_CENTERED, 23 | FA_RIGHT 24 | } font_xalign; 25 | 26 | typedef enum { 27 | FA_ASCENDER = 0, 28 | FA_EM_TOP, 29 | FA_EM_CENTERED, 30 | FA_BASELINE, 31 | FA_DESCENDER, 32 | } font_yalign; 33 | 34 | 35 | void font_init (void); 36 | void font_clear (void); 37 | void font_deinit (void); 38 | 39 | int font_get_height (font_id id); 40 | int font_get_em_height (font_id id); 41 | int font_get_ascender (font_id id); 42 | int font_get_y_spacing (font_id id); 43 | int font_get_min_y(font_id id); 44 | 45 | int font_get_char_count (font_id id, const char *s, u16 max_width); 46 | int font_wrap_string (char ***lines, font_id id, const char *s, u16 max_width); 47 | void font_free_lines (char **lines, u32 count); 48 | 49 | void font_plot_string (gfx_queue_entry *entries, int count, font_id id, 50 | const char *s, u16 x, u16 y, u16 layer, u16 width, 51 | font_xalign xalign, font_yalign yalign); 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /channel/channelapp/source/gfx.h: -------------------------------------------------------------------------------- 1 | #ifndef _GFX_H_ 2 | #define _GFX_H_ 3 | 4 | #include 5 | 6 | #define COL_DEFAULT 0xFFFFFFFF 7 | 8 | #define WIDESCREEN_RATIO (852.0/640.0) 9 | 10 | typedef struct { 11 | f32 x, y, z; 12 | } gfx_coordinates; 13 | 14 | typedef enum { 15 | GFXT_RGBA8, 16 | GFXT_A8 17 | } gfx_tex_type; 18 | 19 | typedef enum { 20 | GFXE_GRADIENT, 21 | GFXE_TEXTURE 22 | } gfx_entity_type; 23 | 24 | typedef struct { 25 | gfx_entity_type type; 26 | u16 w, h; 27 | 28 | union { 29 | struct { 30 | u32 c1, c2, c3, c4; 31 | } gradient; 32 | 33 | struct { 34 | u8 *pixels; 35 | gfx_tex_type type; 36 | GXTexObj obj; 37 | } texture; 38 | }; 39 | } gfx_entity; 40 | 41 | typedef enum { 42 | GFXQ_NULL = -1, 43 | GFXQ_ORIGIN, 44 | GFXQ_SCISSOR, 45 | GFXQ_ENTITY 46 | } gfx_queue_type; 47 | 48 | typedef struct { 49 | gfx_queue_type type; 50 | 51 | union { 52 | struct { 53 | gfx_coordinates *coords; 54 | } origin; 55 | 56 | struct { 57 | u16 x, y, z, w, h; 58 | } scissor; 59 | 60 | struct { 61 | gfx_coordinates coords; 62 | f32 scale; 63 | f32 rad; 64 | gfx_entity *entity; 65 | u32 color; 66 | } entity; 67 | }; 68 | } gfx_queue_entry; 69 | 70 | extern bool widescreen; 71 | extern u16 view_height, view_width; 72 | 73 | void gfx_init_video (void); 74 | void gfx_init (void); 75 | void gfx_deinit (void); 76 | 77 | void gfx_get_efb_size(u16 *x, u16 *y); 78 | void gfx_set_efb_buffer(u32 *buffer); 79 | 80 | void gfx_gen_gradient (gfx_entity *entity, u16 w, u16 h, 81 | u32 c1, u32 c2, u32 c3, u32 c4); 82 | void gfx_gen_tex (gfx_entity *entity, u16 w, u16 h, u8 *pixels, gfx_tex_type type); 83 | 84 | void gfx_qe_origin_push (gfx_queue_entry *entry, gfx_coordinates *coords); 85 | void gfx_qe_origin_pop (gfx_queue_entry *entry); 86 | void gfx_qe_scissor_reset (gfx_queue_entry *entry); 87 | void gfx_qe_scissor (gfx_queue_entry *entry, u16 x, u16 y, u16 z, u16 w, u16 h); 88 | void gfx_qe_entity (gfx_queue_entry *entry, gfx_entity *entity, f32 x, f32 y, 89 | s16 layer, u32 color); 90 | 91 | void gfx_frame_start (void); 92 | void gfx_frame_push (const gfx_queue_entry *entries, int count); 93 | void gfx_frame_end (void); 94 | 95 | #endif 96 | 97 | -------------------------------------------------------------------------------- /channel/channelapp/source/ggets.c: -------------------------------------------------------------------------------- 1 | /* File ggets.c - goodgets is a safe alternative to gets */ 2 | /* By C.B. Falconer. Public domain 2002-06-22 */ 3 | /* attribution appreciated. */ 4 | 5 | /* Revised 2002-06-26 New prototype. 6 | 2002-06-27 Incomplete final lines 7 | 2006-06-14 Simplified, using getc, not fgets 8 | 2006-06-15 Fixed memory leak at EOF 9 | */ 10 | 11 | /* fggets and ggets [which is fggets(ln, stdin)] set *ln to 12 | a buffer filled with the next complete line from the text 13 | stream f. The storage has been allocated within fggets, 14 | and is normally reduced to be an exact fit. The trailing 15 | \n has been removed, so the resultant line is ready for 16 | dumping with puts. The buffer will be as large as is 17 | required to hold the complete line. 18 | 19 | Note: this means a final file line without a \n terminator 20 | has an effective \n appended, as EOF occurs within the read. 21 | 22 | If no error occurs fggets returns 0. If an EOF occurs on 23 | the input file, EOF is returned. For memory allocation 24 | errors some positive value is returned. In this case *ln 25 | may point to a partial line. For other errors memory is 26 | freed and *ln is set to NULL. 27 | 28 | Freeing of assigned storage is the callers responsibility 29 | */ 30 | 31 | #include 32 | #include 33 | #include "panic.h" 34 | #include "ggets.h" 35 | 36 | #define INITSIZE 112 /* power of 2 minus 16, helps malloc */ 37 | #define DELTASIZE (INITSIZE + 16) 38 | 39 | enum {OK = 0, NOMEM}; 40 | 41 | int fggets(char* *ln, FILE *f) 42 | { 43 | int cursize, ch, ix; 44 | char *buffer; 45 | 46 | *ln = NULL; /* default */ 47 | buffer = pmalloc(INITSIZE); 48 | cursize = INITSIZE; 49 | 50 | ix = 0; 51 | while ((EOF != (ch = getc(f))) && ('\n' != ch)) { 52 | if (ix >= (cursize - 1)) { /* extend buffer */ 53 | cursize += DELTASIZE; 54 | buffer = prealloc(buffer, (size_t)cursize); 55 | } 56 | buffer[ix++] = ch; 57 | } 58 | if ((EOF == ch) && (0 == ix)) { 59 | free(buffer); 60 | return EOF; 61 | } 62 | 63 | buffer[ix] = '\0'; 64 | *ln = prealloc(buffer, (size_t)ix + 1); 65 | return OK; 66 | } /* fggets */ 67 | /* End of ggets.c */ 68 | -------------------------------------------------------------------------------- /channel/channelapp/source/ggets.h: -------------------------------------------------------------------------------- 1 | /* File ggets.h - goodgets is a safe alternative to gets */ 2 | /* By C.B. Falconer. Public domain 2002-06-22 */ 3 | /* attribution appreciated. */ 4 | 5 | 6 | /* Revised 2002-06-26 New prototype. 7 | 2002-06-27 Incomplete final lines 8 | */ 9 | 10 | /* fggets and ggets [which is fggets(ln, stdin)] set *ln to 11 | a buffer filled with the next complete line from the text 12 | stream f. The storage has been allocated within fggets, 13 | and is normally reduced to be an exact fit. The trailing 14 | \n has been removed, so the resultant line is ready for 15 | dumping with puts. The buffer will be as large as is 16 | required to hold the complete line. 17 | 18 | Note: this means a final file line without a \n terminator 19 | has an effective \n appended, as EOF occurs within the read. 20 | 21 | If no error occurs fggets returns 0. If an EOF occurs on 22 | the input file, EOF is returned. For memory allocation 23 | errors some positive value is returned. In this case *ln 24 | may point to a partial line. For other errors memory is 25 | freed and *ln is set to NULL. 26 | 27 | Freeing of assigned storage is the callers responsibility 28 | */ 29 | 30 | #ifndef ggets_h_ 31 | # define ggets_h_ 32 | 33 | # ifdef __cplusplus 34 | extern "C" { 35 | # endif 36 | 37 | int fggets(char* *ln, FILE *f); 38 | 39 | #define ggets(ln) fggets(ln, stdin) 40 | 41 | # ifdef __cplusplus 42 | } 43 | # endif 44 | #endif 45 | /* END ggets.h */ 46 | -------------------------------------------------------------------------------- /channel/channelapp/source/http.h: -------------------------------------------------------------------------------- 1 | #ifndef _HTTP_H_ 2 | #define _HTTP_H_ 3 | 4 | #include 5 | 6 | typedef enum { 7 | HTTPS_IDLE = 0, 8 | HTTPS_CONNECTING, 9 | HTTPS_REQUESTING, 10 | HTTPS_RECEIVING 11 | } http_state; 12 | 13 | typedef enum { 14 | HTTPR_OK, 15 | HTTPR_ERR_CONNECT, 16 | HTTPR_ERR_REQUEST, 17 | HTTPR_ERR_STATUS, 18 | HTTPR_ERR_TOOBIG, 19 | HTTPR_ERR_RECEIVE 20 | } http_res; 21 | 22 | void http_init (void); 23 | void http_deinit (void); 24 | 25 | bool http_ready (void); 26 | 27 | bool http_request (const char *url, u32 max_size); 28 | bool http_get_state (http_state *state, u32 *content_length, u32 *progress); 29 | bool http_get_result (http_res *res, u32 *http_status, u8 **content, 30 | u32 *length); 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /channel/channelapp/source/i18n.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "../config.h" 7 | 8 | struct mo_entry { 9 | u32 length; 10 | u32 offset; 11 | } __attribute__((packed)); 12 | 13 | struct mo_hdr { 14 | u32 magic; 15 | u32 revision; 16 | u32 count; 17 | struct mo_entry *source; 18 | struct mo_entry *target; 19 | u32 hash_size; 20 | void *hashes; 21 | } __attribute__((packed)); 22 | 23 | static struct mo_hdr mo; 24 | static int mo_inited = false; 25 | static const char *mo_data = NULL; 26 | 27 | #define MAGIC_SWAB 0xde120495 28 | #define MAGIC 0x950412de 29 | 30 | #define SWAB16(x) ((((x)>>8)&0xFF) | (((x)&0xFF)<<8)) 31 | #define SWAB32(x) ((SWAB16((x)&0xFFFF)<<16)|(SWAB16(((x)>>16)&0xFFFF))) 32 | 33 | #define ENDIAN(x) ((mo.magic == MAGIC_SWAB) ? SWAB32(x) : (x)) 34 | 35 | void i18n_set_mo(const void *mo_file) { 36 | mo_inited = true; 37 | if(!mo_file) { 38 | mo_data = NULL; 39 | gprintf("i18n: unset mo file\n"); 40 | return; 41 | } 42 | 43 | memcpy(&mo, mo_file, sizeof(struct mo_hdr)); 44 | if(mo.magic == MAGIC_SWAB) { 45 | mo.revision = SWAB32(mo.revision); 46 | mo.count = SWAB32(mo.count); 47 | mo.source = (struct mo_entry*)SWAB32((u32)mo.source); 48 | mo.target = (struct mo_entry*)SWAB32((u32)mo.target); 49 | mo.hash_size = SWAB32(mo.hash_size); 50 | mo.hashes = (void*)SWAB32((u32)mo.magic); 51 | } else if(mo.magic != MAGIC) { 52 | gprintf("i18n: bad mo file magic 0x%08x\n",mo.magic); 53 | return; 54 | } 55 | 56 | if(mo.revision != 0) 57 | gprintf("i18n: bad mo file revision 0x%08x\n",mo.revision); 58 | 59 | mo_data = (char*)mo_file; 60 | mo.source = (struct mo_entry*)(mo_data + (u32)mo.source); 61 | gprintf("i18n: configured mo file at %p\n",mo_data); 62 | mo.target = (struct mo_entry*)(mo_data + (u32)mo.target); 63 | } 64 | 65 | const char *i18n(char *english_string) { 66 | int i; 67 | 68 | if(!mo_inited) 69 | gprintf("i18n: warning: attempted to translate '%s' before init\n", english_string); 70 | 71 | if(!mo_data) 72 | return english_string; 73 | 74 | for(i = 0; i < mo.count; i++) { 75 | if(!strcmp(english_string, &mo_data[ENDIAN(mo.source[i].offset)])) 76 | return &mo_data[ENDIAN(mo.target[i].offset)]; 77 | } 78 | 79 | gprintf("i18n: could not find string for %s\n", english_string); 80 | 81 | return english_string; 82 | } 83 | 84 | u32 i18n_have_mo(void) { 85 | return mo_data ? 1 : 0; 86 | } 87 | -------------------------------------------------------------------------------- /channel/channelapp/source/i18n.h: -------------------------------------------------------------------------------- 1 | #ifndef _I18N_H_ 2 | #define _I18N_H_ 3 | 4 | #include 5 | 6 | #define _(x) i18n(x) 7 | 8 | void i18n_set_mo(const void *mo_file); 9 | const char *i18n(char *english_string); 10 | u32 i18n_have_mo(void); 11 | 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /channel/channelapp/source/isfs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include "../config.h" 8 | #include "blob.h" 9 | #include "panic.h" 10 | #include "isfs.h" 11 | 12 | #define ROUNDUP32B(x) ((x + 32 - 1) & ~(32 - 1)) 13 | 14 | static fstats __st ATTRIBUTE_ALIGN(32); 15 | 16 | s32 isfs_get(const char *path, u8 **buf, u32 expected, u32 maxsize, bool use_blob) { 17 | s32 ret; 18 | s32 fd; 19 | u8 *__buf; 20 | 21 | gprintf("reading %s (expecting %u bytes)\n", path, expected); 22 | ret = ISFS_Open(path, ISFS_OPEN_READ); 23 | if (ret < 0) { 24 | gprintf("ISFS_Open failed (%d)\n", ret); 25 | return ret; 26 | } 27 | 28 | fd = ret; 29 | 30 | ret = ISFS_GetFileStats(fd, &__st); 31 | if (ret < 0) { 32 | gprintf("ISFS_GetFileStats failed (%d)\n", ret); 33 | return ret; 34 | } 35 | DCInvalidateRange(&__st, sizeof(__st)); 36 | 37 | if ((__st.file_length == 0) || 38 | (maxsize && (__st.file_length > maxsize)) || 39 | (expected && (__st.file_length != expected))) { 40 | gprintf("invalid size: %u\n", __st.file_length); 41 | ISFS_Close(fd); 42 | return -1; 43 | } 44 | 45 | if (use_blob) { 46 | __buf = blob_alloc(ROUNDUP32B(__st.file_length + 1)); 47 | if (!__buf) 48 | panic(); 49 | } else { 50 | __buf = pmemalign(32, ROUNDUP32B(__st.file_length + 1)); 51 | } 52 | 53 | gprintf("reading %u bytes\n", __st.file_length); 54 | ret = ISFS_Read(fd, __buf, __st.file_length); 55 | if (ret < 0) { 56 | gprintf("ISFS_Read failed (%d)\n", ret); 57 | free(__buf); 58 | ISFS_Close(fd); 59 | return ret; 60 | } 61 | DCInvalidateRange(__buf, __st.file_length + 1); 62 | __buf[__st.file_length] = 0; 63 | 64 | if (ret != __st.file_length) { 65 | gprintf("ISFS_Read short read (%d)\n", ret); 66 | free(__buf); 67 | ISFS_Close(fd); 68 | return -1; 69 | } 70 | 71 | ret = ISFS_Close(fd); 72 | if (ret < 0) { 73 | gprintf("ISFS_Close failed (%d)\n", ret); 74 | free(__buf); 75 | return ret; 76 | } 77 | 78 | *buf = __buf; 79 | return __st.file_length; 80 | } 81 | 82 | s32 isfs_put(const char *path, const void *buf, u32 len) { 83 | s32 fd, ret; 84 | 85 | ISFS_Delete(path); 86 | 87 | gprintf("writing %s (%u bytes)\n", path, len); 88 | ret = ISFS_CreateFile(path, 0, 3, 3, 0); 89 | if (ret < 0) { 90 | gprintf("ISFS_CreateFile failed (%d)\n", ret); 91 | return ret; 92 | } 93 | 94 | ret = ISFS_Open(path, 3); 95 | if (ret < 0) { 96 | gprintf("ISFS_Open failed (%d)\n", ret); 97 | ISFS_Delete(path); 98 | return ret; 99 | } 100 | 101 | fd = ret; 102 | 103 | DCFlushRange((void *) buf, len); 104 | 105 | ret = ISFS_Write(fd, buf, len); 106 | if (ret < 0) { 107 | gprintf("ISFS_Write failed (%d)\n", ret); 108 | ISFS_Close(fd); 109 | ISFS_Delete(path); 110 | return ret; 111 | } 112 | 113 | if (ret != len) { 114 | gprintf("ISFS_Write short write (%d)\n", ret); 115 | ISFS_Close(fd); 116 | ISFS_Delete(path); 117 | return -1; 118 | } 119 | 120 | ret = ISFS_Close(fd); 121 | if (ret < 0) { 122 | gprintf("ISFS_Close failed (%d)\n", ret); 123 | ISFS_Delete(path); 124 | return ret; 125 | } 126 | 127 | return 0; 128 | } 129 | 130 | -------------------------------------------------------------------------------- /channel/channelapp/source/isfs.h: -------------------------------------------------------------------------------- 1 | #ifndef ___ISFS_H__ 2 | #define ___ISFS_H__ 3 | 4 | #include 5 | 6 | s32 isfs_get(const char *path, u8 **buf, u32 expected, u32 maxsize, bool use_blob); 7 | s32 isfs_put(const char *path, const void *buf, u32 len); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /channel/channelapp/source/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef _LOADER_H_ 2 | #define _LOADER_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "loader_reloc.h" 10 | #include "appentry.h" 11 | #include "view.h" 12 | 13 | typedef enum { 14 | LT_UNKNOWN = 0, 15 | LT_EXECUTABLE, 16 | LT_ZIP_APP, 17 | LT_ZIP_THEME 18 | } loader_type; 19 | 20 | typedef struct { 21 | loader_type type; 22 | 23 | u8 *data; 24 | u32 data_len; 25 | 26 | char args[ARGS_MAX_LEN]; 27 | u32 args_len; 28 | 29 | char dirname[PATH_MAX]; 30 | u32 bytes; 31 | } loader_result; 32 | 33 | void loader_init (void); 34 | void loader_deinit (void); 35 | 36 | void loader_tcp_init (void); 37 | void loader_signal_threads (void); 38 | bool loader_gecko_initialized (void); 39 | bool loader_tcp_initializing (void); 40 | bool loader_tcp_initialized (void); 41 | bool loader_handshaked (void); 42 | 43 | void loader_load(loader_result *result, view *sub_view, app_entry *entry); 44 | bool loader_load_executable(entry_point *ep, loader_result *result, 45 | view *sub_view); 46 | bool loader_handle_zip_app(loader_result *result, view *sub_view); 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /channel/channelapp/source/loader_reloc.h: -------------------------------------------------------------------------------- 1 | #ifndef _LOADER_RELOC_H_ 2 | #define _LOADER_RELOC_H_ 3 | 4 | #include 5 | 6 | typedef void (*entry_point) (void); 7 | 8 | bool loader_reloc (entry_point *ep, const u8 *addr, u32 size, const char *args, 9 | u16 arg_len, bool check_overlap); 10 | void loader_exec (entry_point ep); 11 | 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /channel/channelapp/source/m_main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include "../config.h" 8 | #include "theme.h" 9 | #include "view.h" 10 | #include "loader.h" 11 | #include "i18n.h" 12 | #include "panic.h" 13 | 14 | #include "m_main.h" 15 | 16 | static view *v_m_main; 17 | 18 | static const char *text_no_ip; 19 | static const char *text_has_ip; 20 | 21 | static bool bootmii_ios = false; 22 | 23 | static bool bootmii_is_installed(u64 title_id) { 24 | u32 tmd_view_size; 25 | u8 *tmdbuf; 26 | bool ret; 27 | 28 | if (ES_GetTMDViewSize(title_id, &tmd_view_size) < 0) 29 | return false; 30 | 31 | if (tmd_view_size < 90) 32 | return false; 33 | 34 | if (tmd_view_size > 1024) 35 | return false; 36 | 37 | tmdbuf = pmemalign(32, 1024); 38 | 39 | if (ES_GetTMDView(title_id, tmdbuf, tmd_view_size) < 0) { 40 | free(tmdbuf); 41 | return false; 42 | } 43 | 44 | if (tmdbuf[50] == 'B' && tmdbuf[51] == 'M') 45 | ret = true; 46 | else 47 | ret = false; 48 | 49 | free(tmdbuf); 50 | 51 | return ret; 52 | } 53 | 54 | static bool inited_widgets = false; 55 | 56 | view * m_main_init (void) { 57 | bootmii_ios = bootmii_is_installed(TITLEID_BOOTMII); 58 | 59 | v_m_main = view_new (8, NULL, 0, 0, 0, 0); 60 | 61 | m_main_theme_reinit(); 62 | m_main_update(); 63 | 64 | view_set_focus(v_m_main, 0); 65 | 66 | return v_m_main; 67 | } 68 | 69 | void m_main_deinit(void) { 70 | view_free (v_m_main); 71 | inited_widgets = false; 72 | v_m_main = NULL; 73 | } 74 | 75 | void m_main_theme_reinit(void) { 76 | u16 x, y, yadd; 77 | int i; 78 | char buffer[20]; 79 | 80 | text_no_ip = _("Network not initialized"); 81 | text_has_ip = _("Your Wii's IP is %u.%u.%u.%u"); 82 | 83 | if (inited_widgets) 84 | for (i = 0; i < v_m_main->widget_count; ++i) 85 | widget_free(&v_m_main->widgets[i]); 86 | 87 | if (bootmii_ios) 88 | yadd = 16; 89 | else 90 | yadd = 32; 91 | 92 | x = (view_width - theme_gfx[THEME_BUTTON]->w) / 2; 93 | y = 80; 94 | 95 | widget_button (&v_m_main->widgets[0], x, y, 0, BTN_NORMAL, _("Back")); 96 | y += theme_gfx[THEME_BUTTON]->h + yadd; 97 | widget_button (&v_m_main->widgets[1], x, y, 0, BTN_NORMAL, _("About")); 98 | y += theme_gfx[THEME_BUTTON]->h + yadd; 99 | 100 | if (bootmii_ios) { 101 | widget_button (&v_m_main->widgets[2], x, y, 0, BTN_NORMAL, 102 | _("Launch BootMii")); 103 | y += theme_gfx[THEME_BUTTON]->h + yadd; 104 | } 105 | 106 | widget_button (&v_m_main->widgets[3], x, y, 0, BTN_NORMAL, _("Exit to System Menu")); 107 | y += theme_gfx[THEME_BUTTON]->h + yadd; 108 | 109 | widget_button (&v_m_main->widgets[4], x, y, 0, BTN_NORMAL, _("Shutdown")); 110 | 111 | widget_label (&v_m_main->widgets[5], view_width / 3 * 2 - 16, 32, 0, 112 | CHANNEL_VERSION_STR, view_width / 3 - 32, FA_RIGHT, 113 | FA_ASCENDER, FONT_LABEL); 114 | 115 | sprintf(buffer, "IOS%d v%d.%d", IOS_GetVersion(), IOS_GetRevisionMajor(), 116 | IOS_GetRevisionMinor()); 117 | 118 | widget_label (&v_m_main->widgets[6], view_width / 3 * 2 - 16, 119 | 32 + font_get_y_spacing(FONT_LABEL), 0, buffer, 120 | view_width / 3 - 32, FA_RIGHT, FA_ASCENDER, FONT_LABEL); 121 | 122 | inited_widgets = true; 123 | } 124 | 125 | void m_main_update (void) { 126 | u32 ip; 127 | char buffer[64]; 128 | 129 | if (loader_tcp_initialized ()) { 130 | ip = net_gethostip (); 131 | sprintf (buffer, text_has_ip, (ip >> 24) & 0xff, (ip >> 16) & 0xff, 132 | (ip >> 8) & 0xff, ip & 0xff); 133 | widget_label (&v_m_main->widgets[7], 48, 32, 0, buffer, 134 | view_width / 3 * 2 - 32, FA_LEFT, FA_ASCENDER, FONT_LABEL); 135 | } else { 136 | widget_label (&v_m_main->widgets[7], 48, 32, 0, text_no_ip, 137 | view_width / 3 * 2 - 32, FA_LEFT, FA_ASCENDER, FONT_LABEL); 138 | } 139 | 140 | } 141 | 142 | -------------------------------------------------------------------------------- /channel/channelapp/source/m_main.h: -------------------------------------------------------------------------------- 1 | #ifndef _M_MAIN_H_ 2 | #define _M_MAIN_H_ 3 | 4 | #include 5 | 6 | #include "view.h" 7 | 8 | view * m_main_init (void); 9 | void m_main_deinit (void); 10 | void m_main_theme_reinit (void); 11 | 12 | void m_main_update (void); 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /channel/channelapp/source/manage.h: -------------------------------------------------------------------------------- 1 | #ifndef _MANAGE_H_ 2 | #define _MANAGE_H_ 3 | 4 | #include 5 | 6 | #include "view.h" 7 | 8 | s32 dir_exists(char *dirname); 9 | 10 | bool manage_is_zip(const u8 *data); 11 | bool manage_check_zip_app(u8 *data, u32 data_len, char *dirname, u32 *bytes); 12 | bool manage_check_zip_theme(u8 *data, u32 data_len); 13 | 14 | bool manage_run(view *sub_view, const char *dirname, 15 | u8 *data, u32 data_len, u32 bytes); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /channel/channelapp/source/panic.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "panic.h" 5 | 6 | // steal from libogc 7 | extern unsigned char console_font_8x16[]; 8 | 9 | #define BLACK 0x00800080 10 | #define RED 0x4C544CFF 11 | 12 | static vu32 *fb; 13 | 14 | static void pchar(u32 cx, u32 cy, char c) 15 | { 16 | int x,y; 17 | unsigned char *p = &console_font_8x16[16*c]; 18 | 19 | for (y=0; y<16; y++) { 20 | char v = *p++; 21 | for (x=0; x<4; x++) { 22 | u32 c = RED; 23 | switch (v&0xc0) { 24 | case 0x00: 25 | c = BLACK; 26 | break; 27 | case 0x40: 28 | c = (RED & 0x0000FF00) | (BLACK & 0xFFFF00FF); 29 | break; 30 | case 0x80: 31 | c = (RED & 0xFFFF00FF) | (BLACK & 0x0000FF00); 32 | break; 33 | case 0xc0: 34 | c = RED; 35 | break; 36 | } 37 | fb[320*(cy+y)+cx+x] = c; 38 | v<<=2; 39 | } 40 | } 41 | } 42 | 43 | static void putsc(u32 y, char *s) { 44 | u32 x = (320-strlen(s)*4)/2; 45 | while(*s) { 46 | pchar(x, y, *s++); 47 | x += 4; 48 | } 49 | } 50 | 51 | static void hex(u32 v, char *p) { 52 | int i; 53 | for (i=0; i<8; i++) { 54 | if ((v>>28) >= 10) 55 | *p++ = 'A' + (v>>28) - 10; 56 | else 57 | *p++ = '0' + (v>>28); 58 | v <<= 4; 59 | } 60 | } 61 | 62 | #define HW_REG_BASE 0xd800000 63 | #define HW_RESETS (HW_REG_BASE + 0x194) 64 | 65 | // written to be as generic and reliable as possible 66 | void _panic(u32 file, u32 line) 67 | { 68 | u32 level; 69 | u32 fbr; 70 | int count = 30; 71 | int x,y; 72 | u32 bcolor = BLACK; 73 | u16 vtr; 74 | int lines; 75 | char guru[] = "Guru Meditation #00000000.00000000"; 76 | _CPU_ISR_Disable(level); 77 | 78 | fbr = read32(0xc00201c) & 0x1fffffff; 79 | if (fbr&0x10000000) 80 | fbr <<= 5; 81 | 82 | fb = (vu32*)(fbr | 0xC0000000); 83 | 84 | vtr = read16(0xc002000); 85 | if ((vtr & 0xf) > 10) 86 | lines = vtr >> 4; 87 | else 88 | lines = 2 * (vtr >> 4); 89 | 90 | for(y=(lines-1); y>=116; y--) 91 | for(x=0; x<320; x++) 92 | fb[y*320+x] = fb[(y-116)*320+x]; 93 | for(y=0; y<116; y++) 94 | for(x=0; x<320; x++) 95 | fb[y*320+x] = BLACK; 96 | 97 | hex(file, &guru[17]); 98 | hex(line, &guru[26]); 99 | 100 | putsc(42, "Software Failure. Press reset button to continue."); 101 | putsc(62, guru); 102 | 103 | // wait for reset button 104 | while(read32(0xcc003000)&0x10000) { 105 | // blink 106 | if (count >= 25) { 107 | if (bcolor == RED) 108 | bcolor = BLACK; 109 | else 110 | bcolor = RED; 111 | 112 | for(y=28; y<34; y++) 113 | for(x=14; x<306; x++) 114 | fb[y*320+x] = bcolor; 115 | for(y=34; y<84; y++) { 116 | for(x=14; x<17; x++) 117 | fb[y*320+x] = bcolor; 118 | for(x=303; x<306; x++) 119 | fb[y*320+x] = bcolor; 120 | } 121 | for(y=84; y<90; y++) 122 | for(x=14; x<306; x++) 123 | fb[y*320+x] = bcolor; 124 | 125 | count = 0; 126 | } 127 | 128 | // hacky waitvsync 129 | while(read16(0xc00202c) >= 200); 130 | while(read16(0xc00202c) < 200); 131 | count++; 132 | } 133 | 134 | // needs AHBPROT, is evil. so sue me. 135 | write32(HW_RESETS, read32(HW_RESETS)&(~1)); 136 | while(1); 137 | } 138 | -------------------------------------------------------------------------------- /channel/channelapp/source/panic.h: -------------------------------------------------------------------------------- 1 | #ifndef _PANIC_H_ 2 | #define _PANIC_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | // to skip 'source/' 9 | #define FOFF 7 10 | 11 | #define S2I(s) (((s)[FOFF+0]<<24)|((s)[FOFF+1]<<16)|((s)[FOFF+2]<<8)|((s)[FOFF+3])) 12 | 13 | #define panic() _panic(S2I(__FILE__)^0xDEADBEEF, __LINE__) 14 | void _panic(u32 file, u32 line) __attribute__((noreturn)); 15 | 16 | #define pmalloc(s) _pmalloc(s, S2I(__FILE__)^0xDEADBEEF, __LINE__) 17 | static inline void *_pmalloc(size_t s, u32 file, u32 line) 18 | { 19 | void *p = malloc(s); 20 | if (!p) 21 | _panic(file, line); 22 | return p; 23 | } 24 | 25 | #define pmemalign(a,s) _pmemalign(a, s, S2I(__FILE__)^0xDEADBEEF, __LINE__) 26 | static inline void *_pmemalign(size_t a, size_t s, u32 file, u32 line) 27 | { 28 | void *p = memalign(a, s); 29 | if (!p) 30 | _panic(file, line); 31 | return p; 32 | } 33 | 34 | #define prealloc(p,s) _prealloc(p, s, S2I(__FILE__)^0xDEADBEEF, __LINE__) 35 | static inline void *_prealloc(void *p, size_t s, u32 file, u32 line) 36 | { 37 | p = realloc(p, s); 38 | if (!p) 39 | _panic(file, line); 40 | return p; 41 | } 42 | 43 | #define pstrdup(s) _pstrdup(s, S2I(__FILE__)^0xDEADBEEF, __LINE__) 44 | static inline void *_pstrdup(const char *s, u32 file, u32 line) 45 | { 46 | char *p; 47 | p = strdup(s); 48 | if (!p) 49 | _panic(file, line); 50 | return p; 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /channel/channelapp/source/playtime.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "../config.h" 10 | #include "playtime.h" 11 | 12 | static char _playtime_path[] __attribute__((aligned(32))) = 13 | "/title/00000001/00000002/data/play_rec.dat"; 14 | 15 | void playtime_destroy(void) { 16 | s32 res; 17 | s32 pt_fd = -1; 18 | static u8 pt_buf[4] __attribute__((aligned(32))); 19 | 20 | gprintf("destroying playtime\n"); 21 | 22 | pt_fd = IOS_Open(_playtime_path, IPC_OPEN_RW); 23 | if(pt_fd < 0) { 24 | gprintf("playtime open failed: %d\n", pt_fd); 25 | return; 26 | } 27 | 28 | memset(pt_buf, 0, sizeof(pt_buf)); 29 | 30 | res = IOS_Write(pt_fd, &pt_buf, sizeof(pt_buf)); 31 | if (res != sizeof(pt_buf)) { 32 | IOS_Close(pt_fd); 33 | gprintf("error destroying playtime (%d)\n", res); 34 | return; 35 | } 36 | 37 | IOS_Close(pt_fd); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /channel/channelapp/source/playtime.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLAYTIME_H_ 2 | #define _PLAYTIME_H_ 3 | 4 | #include 5 | 6 | typedef union { 7 | struct { 8 | u32 checksum; 9 | u16 name[0x28]; 10 | u32 _pad1; 11 | u64 ticks_boot; 12 | u64 ticks_last; 13 | u32 title_id; 14 | u32 _pad2[5]; 15 | }; 16 | struct { 17 | u32 _checksum; 18 | u32 data[0x1f]; 19 | }; 20 | } __attribute__((packed)) playtime_t; 21 | 22 | void playtime_destroy(void); 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /channel/channelapp/source/sha1.h: -------------------------------------------------------------------------------- 1 | #ifndef __SHA1_H__ 2 | #define __SHA1_H__ 3 | 4 | typedef struct { 5 | unsigned long state[5]; 6 | unsigned long count[2]; 7 | unsigned char buffer[64]; 8 | } SHA1_CTX; 9 | 10 | void SHA1Transform(unsigned long state[5], const unsigned char buffer[64]); 11 | void SHA1Init(SHA1_CTX* context); 12 | void SHA1Update(SHA1_CTX* context, const unsigned char* data, unsigned int len); 13 | void SHA1Final(unsigned char digest[20], SHA1_CTX* context); 14 | 15 | void SHA1(unsigned char *ptr, unsigned int size, unsigned char *outbuf); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /channel/channelapp/source/tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef _TCP_H_ 2 | #define _TCP_H_ 3 | 4 | #include 5 | #include 6 | 7 | s32 tcp_socket (void); 8 | s32 tcp_connect (char *host, u16 port); 9 | s32 tcp_listen (u16 port, s32 backlog); 10 | 11 | char * tcp_readln (s32 s, u16 max_length, s64 start_time, u16 timeout); 12 | bool tcp_read (s32 s, u8 *buffer, u32 length, const mutex_t *mutex, u32 *progress); 13 | bool tcp_write (s32 s, const u8 *buffer, u32 length, const mutex_t *mutex, 14 | u32 *progress); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /channel/channelapp/source/tex.h: -------------------------------------------------------------------------------- 1 | #ifndef _TEX_H_ 2 | #define _TEX_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include "gfx.h" 8 | 9 | void tex_free (gfx_entity *entity); 10 | 11 | gfx_entity * tex_from_png(const u8 *data, u32 size, u16 width, u16 height); 12 | gfx_entity * tex_from_png_file(const char *fn, const struct stat *st, 13 | u16 width, u16 height); 14 | gfx_entity * tex_from_tex_vsplit (gfx_entity *ge, u16 hstart, u16 hend); 15 | 16 | void save_rgba_png(u32 *buffer, u16 x, u16 y); 17 | 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /channel/channelapp/source/theme.h: -------------------------------------------------------------------------------- 1 | #ifndef _THEME_H_ 2 | #define _THEME_H_ 3 | 4 | #include 5 | 6 | #include "gfx.h" 7 | #include "xml.h" 8 | 9 | typedef enum { 10 | // view.c 11 | THEME_BACKGROUND = 0, 12 | THEME_LOGO, 13 | 14 | // bubbles.c 15 | THEME_BUBBLE1, 16 | THEME_BUBBLE2, 17 | THEME_BUBBLE3, 18 | 19 | // browser.c 20 | THEME_ARROW_LEFT, 21 | THEME_ARROW_LEFT_FOCUS, 22 | THEME_ARROW_RIGHT, 23 | THEME_ARROW_RIGHT_FOCUS, 24 | THEME_GECKO, 25 | THEME_GECKO_ACTIVE, 26 | THEME_LAN, 27 | THEME_LAN_ACTIVE, 28 | THEME_THROBBER, 29 | 30 | // dialogc.c 31 | THEME_ABOUT, 32 | THEME_DIALOG, 33 | THEME_DLG_INFO, 34 | THEME_DLG_CONFIRM, 35 | THEME_DLG_WARNING, 36 | THEME_DLG_ERROR, 37 | 38 | // widgets.c 39 | THEME_BUTTON, 40 | THEME_BUTTON_FOCUS, 41 | THEME_BUTTON_SMALL, 42 | THEME_BUTTON_SMALL_FOCUS, 43 | THEME_BUTTON_TINY, 44 | THEME_BUTTON_TINY_FOCUS, 45 | THEME_APP_ENTRY, 46 | THEME_APP_ENTRY_FOCUS, 47 | THEME_GRID_APP_ENTRY, 48 | THEME_GRID_APP_ENTRY_FOCUS, 49 | THEME_PROGRESS, 50 | THEME_CONTENT_ARROW_UP, 51 | THEME_CONTENT_ARROW_DOWN, 52 | 53 | THEME_LAST 54 | } theme_entry; 55 | 56 | typedef struct { 57 | const char *file; 58 | void *data; 59 | u32 data_len; 60 | int size; 61 | u32 color; 62 | } theme_font; 63 | 64 | extern gfx_entity *theme_gfx[THEME_LAST]; 65 | 66 | extern theme_font theme_fonts[FONT_MAX]; 67 | 68 | extern const char *theme_fn_xml; 69 | 70 | void theme_init(u8 *data, u32 data_len); 71 | void theme_deinit(void); 72 | 73 | bool theme_is_valid_fn(const char *filename); 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /channel/channelapp/source/title.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "title.h" 8 | 9 | u32 ng_id = 0; 10 | u32 ms_id = 0; 11 | 12 | static u64 title_id = 0; 13 | static char title_path[ISFS_MAXPATH] __attribute__((aligned(0x20))); 14 | 15 | static u8 buf[0x1000] __attribute__((aligned(0x20))); 16 | 17 | static void title_get_ngid(void) { 18 | s32 res; 19 | 20 | res = ES_GetDeviceID(&ng_id); 21 | if (res < 0) { 22 | gprintf("ES_GetDeviceID failed: %d\n", res); 23 | } 24 | } 25 | 26 | static void title_get_msid(void) { 27 | s32 ret; 28 | 29 | // check for dpki 30 | ret = ES_GetDeviceCert(buf); 31 | if (ret < 0) { 32 | gprintf("ES_GetDeviceCert failed: %d\n", ret); 33 | return; 34 | } 35 | 36 | ms_id = buf[0x99] - '0'; 37 | 38 | if (ms_id == 3) { 39 | gprintf("We're on dpki\n"); 40 | } else if (ms_id == 2) { 41 | gprintf("We're on retail\n"); 42 | } else { 43 | gprintf("Unknown ms-id %d?\n", ms_id); 44 | } 45 | } 46 | 47 | static void title_get_title_path(void) { 48 | s32 res; 49 | 50 | res = ES_GetTitleID(&title_id); 51 | if (res < 0) { 52 | gprintf("ES_GetTitleID failed: %d\n", res); 53 | return; 54 | } 55 | 56 | res = ES_GetDataDir(title_id, title_path); 57 | if (res < 0) { 58 | gprintf("ES_GetDataDir failed: %d\n", res); 59 | return; 60 | } 61 | 62 | gprintf("data path is '%s'\n", title_path); 63 | } 64 | 65 | const char *title_get_path(void) { 66 | return title_path; 67 | } 68 | 69 | static bool title_is_installed(u64 title_id) { 70 | s32 ret; 71 | u32 x; 72 | 73 | ret = ES_GetTitleContentsCount(title_id, &x); 74 | 75 | if (ret < 0) 76 | return false; // title was never installed 77 | 78 | if (x <= 0) 79 | return false; // title was installed but deleted via Channel Management 80 | 81 | return true; 82 | } 83 | 84 | #define TITLEID_200 0x0000000100000200ll 85 | 86 | bool is_vwii(void) { 87 | return title_is_installed(TITLEID_200); 88 | } 89 | 90 | void title_init(void) { 91 | memset(title_path, 0, sizeof(title_path)); 92 | title_get_msid(); 93 | title_get_ngid(); 94 | title_get_title_path(); 95 | } 96 | -------------------------------------------------------------------------------- /channel/channelapp/source/title.h: -------------------------------------------------------------------------------- 1 | #ifndef _TITLE_H_ 2 | #define _TITLE_H_ 3 | 4 | #include 5 | #include "../config.h" 6 | 7 | const char *title_get_path(void); 8 | void title_init(void); 9 | bool is_vwii(void); 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /channel/channelapp/source/unzip_io.c: -------------------------------------------------------------------------------- 1 | /* ioapi_mem2.c -- IO base function header for compress/uncompress .zip 2 | files using zlib + zip or unzip API 3 | 4 | This version of ioapi is designed to access memory rather than files. 5 | We do use a region of memory to put data in to and take it out of. We do 6 | not have auto-extending buffers and do not inform anyone else that the 7 | data has been written. It is really intended for accessing a zip archive 8 | embedded in an application such that I can write an installer with no 9 | external files. Creation of archives has not been attempted, although 10 | parts of the framework are present. 11 | 12 | Based on Unzip ioapi.c version 0.22, May 19th, 2003 13 | 14 | Copyright (C) 1998-2003 Gilles Vollant 15 | (C) 2003 Justin Fletcher 16 | 17 | Dynamically allocated memory version. Troels K 2004 18 | mem_close deletes the data: file is single-session. No filenames. 19 | 20 | This file is under the same license as the Unzip tool it is distributed 21 | with. 22 | */ 23 | 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | #include "panic.h" 32 | #include "unzip_io.h" 33 | 34 | static voidpf ZCALLBACK mem_open OF(( 35 | voidpf opaque, 36 | void* buffer, 37 | size_t buf_len, 38 | int mode)); 39 | 40 | static uLong ZCALLBACK mem_read OF(( 41 | voidpf opaque, 42 | voidpf stream, 43 | void* buf, 44 | uLong size)); 45 | 46 | static long ZCALLBACK mem_tell OF(( 47 | voidpf opaque, 48 | voidpf stream)); 49 | 50 | static long ZCALLBACK mem_seek OF(( 51 | voidpf opaque, 52 | voidpf stream, 53 | uLong offset, 54 | int origin)); 55 | 56 | static int ZCALLBACK mem_close OF(( 57 | voidpf opaque, 58 | voidpf stream)); 59 | 60 | static int ZCALLBACK mem_error OF(( 61 | voidpf opaque, 62 | voidpf stream)); 63 | 64 | typedef struct _MEMFILE 65 | { 66 | void* buffer; /* Base of the region of memory we're using */ 67 | long length; /* Size of the region of memory we're using */ 68 | long position; /* Current offset in the area */ 69 | } MEMFILE; 70 | 71 | static voidpf ZCALLBACK mem_open (opaque, buffer, buf_len, mode) 72 | voidpf opaque; 73 | void* buffer; 74 | size_t buf_len; 75 | int mode; 76 | { 77 | MEMFILE* handle = pmalloc(sizeof(*handle)); 78 | 79 | handle->position = 0; 80 | handle->buffer = buffer; 81 | handle->length = buf_len; 82 | return handle; 83 | } 84 | 85 | static uLong ZCALLBACK mem_read (opaque, stream, buf, size) 86 | voidpf opaque; 87 | voidpf stream; 88 | void* buf; 89 | uLong size; 90 | { 91 | MEMFILE* handle = (MEMFILE*) stream; 92 | 93 | if ( (handle->position + size) > handle->length) 94 | { 95 | size = handle->length - handle->position; 96 | } 97 | memcpy(buf, ((char*)handle->buffer) + handle->position, size); 98 | handle->position+=size; 99 | return size; 100 | } 101 | 102 | static long ZCALLBACK mem_tell (opaque, stream) 103 | voidpf opaque; 104 | voidpf stream; 105 | { 106 | MEMFILE *handle = (MEMFILE *)stream; 107 | return handle->position; 108 | } 109 | 110 | static long ZCALLBACK mem_seek (opaque, stream, offset, origin) 111 | voidpf opaque; 112 | voidpf stream; 113 | uLong offset; 114 | int origin; 115 | { 116 | MEMFILE* handle = (MEMFILE*)stream; 117 | 118 | int bOK = 1; 119 | switch (origin) 120 | { 121 | case SEEK_SET : 122 | //bOK = (offset >= 0) && (offset <= size); 123 | if (bOK) handle->position = offset; 124 | break; 125 | case SEEK_CUR : 126 | bOK = ((offset + handle->position) >= 0) && (((offset + handle->position) <= handle->length)); 127 | if (bOK) handle->position = offset + handle->position; 128 | break; 129 | case SEEK_END: 130 | bOK = ((handle->length - offset) >= 0) && (((handle->length - offset) <= handle->length)); 131 | if (bOK) handle->position = offset + handle->length - 0; 132 | break; 133 | default: 134 | bOK = 0; 135 | break; 136 | } 137 | return bOK ? 0 : -1; 138 | } 139 | 140 | int ZCALLBACK mem_close (opaque, stream) 141 | voidpf opaque; 142 | voidpf stream; 143 | { 144 | MEMFILE *handle = (MEMFILE *)stream; 145 | 146 | free (handle); 147 | return 0; 148 | } 149 | 150 | int ZCALLBACK mem_error (opaque, stream) 151 | voidpf opaque; 152 | voidpf stream; 153 | { 154 | //MEMFILE *handle = (MEMFILE *)stream; 155 | /* We never return errors */ 156 | return 0; 157 | } 158 | 159 | void mem_simple_create_file(zlib_filefunc_def* api) 160 | { 161 | api->zopen_file = mem_open; 162 | api->zread_file = mem_read; 163 | api->zwrite_file = NULL; 164 | api->ztell_file = mem_tell; 165 | api->zseek_file = mem_seek; 166 | api->zclose_file = mem_close; 167 | api->zerror_file = mem_error; 168 | api->opaque = NULL; 169 | } 170 | 171 | -------------------------------------------------------------------------------- /channel/channelapp/source/unzip_io.h: -------------------------------------------------------------------------------- 1 | #ifndef _UNZIP_IO_H_ 2 | #define _UNZIP_IO_H_ 3 | 4 | #define ZLIB_FILEFUNC_SEEK_CUR (1) 5 | #define ZLIB_FILEFUNC_SEEK_END (2) 6 | #define ZLIB_FILEFUNC_SEEK_SET (0) 7 | 8 | #define ZLIB_FILEFUNC_MODE_READ (1) 9 | #define ZLIB_FILEFUNC_MODE_WRITE (2) 10 | #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) 11 | 12 | #define ZLIB_FILEFUNC_MODE_EXISTING (4) 13 | #define ZLIB_FILEFUNC_MODE_CREATE (8) 14 | 15 | 16 | #ifndef ZCALLBACK 17 | 18 | #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) 19 | #define ZCALLBACK CALLBACK 20 | #else 21 | #define ZCALLBACK 22 | #endif 23 | 24 | #endif 25 | 26 | typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, void* buffer, size_t buf_len, int mode)); 27 | typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); 28 | typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); 29 | typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); 30 | typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); 31 | typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); 32 | typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); 33 | 34 | typedef struct zlib_filefunc_def_s 35 | { 36 | open_file_func zopen_file; 37 | read_file_func zread_file; 38 | write_file_func zwrite_file; 39 | tell_file_func ztell_file; 40 | seek_file_func zseek_file; 41 | close_file_func zclose_file; 42 | testerror_file_func zerror_file; 43 | voidpf opaque; 44 | } zlib_filefunc_def; 45 | 46 | 47 | extern void mem_simple_create_file(zlib_filefunc_def* api); 48 | 49 | #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) 50 | #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) 51 | #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) 52 | #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) 53 | #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) 54 | #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) 55 | 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /channel/channelapp/source/update.h: -------------------------------------------------------------------------------- 1 | #ifndef _UPDATE_H_ 2 | #define _UPDATE_H_ 3 | 4 | #include 5 | 6 | #include "loader_reloc.h" 7 | 8 | bool update_signal(void); 9 | bool update_busy(bool *update_available); 10 | bool update_execute(view *sub_view, entry_point *ep); 11 | 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /channel/channelapp/source/view.h: -------------------------------------------------------------------------------- 1 | #ifndef _VIEW_H_ 2 | #define _VIEW_H_ 3 | 4 | #include 5 | 6 | #include "widgets.h" 7 | 8 | typedef struct _view { 9 | gfx_coordinates coords; 10 | gfx_queue_entry qe_coords_push, qe_coords_pop; 11 | 12 | u8 widget_count; 13 | widget *widgets; 14 | 15 | const struct _view *sub_view; 16 | 17 | s8 focus; 18 | s8 cursor; 19 | 20 | bool drag; 21 | s8 drag_widget; 22 | u32 drag_btn; 23 | s32 drag_start_x, drag_start_y, drag_x, drag_y; 24 | } view; 25 | 26 | extern bool view_bubbles; 27 | extern bool allow_screenshot; 28 | 29 | void view_init (); 30 | void view_deinit (); 31 | void view_theme_reinit(void); 32 | 33 | view * view_new (u8 widget_count, const view *sub_view, s16 x, s16 y, s16 z, 34 | u32 drag_btn); 35 | void view_free (view *v); 36 | 37 | void view_plot (view *v, u32 alpha, u32 *down, u32 *held, u32 *up); 38 | void view_fade (view *v, s16 z, u32 c1, u32 c2, u32 c3, u32 c4, u8 steps, 39 | s8 modifier); 40 | 41 | void view_set_focus (view *v, s8 new_focus); 42 | u8 view_set_focus_prev (view *v); 43 | u8 view_set_focus_next (view *v); 44 | u8 view_move_focus(view *v, s8 mod); 45 | 46 | void view_enable_cursor (bool enable); 47 | s8 view_widget_at_xy (const view *v, s32 x, s32 y); 48 | s8 view_widget_at_ir (const view *v); 49 | 50 | void view_show_throbber(bool show); 51 | void view_throbber_tickle(void); 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /channel/channelapp/source/widgets.h: -------------------------------------------------------------------------------- 1 | #ifndef _WIDGETS_H_ 2 | #define _WIDGETS_H_ 3 | 4 | #include 5 | 6 | #include "gfx.h" 7 | #include "cursors.h" 8 | #include "appentry.h" 9 | #include "font.h" 10 | 11 | #define WF_VISIBLE 1 12 | #define WF_ENABLED 2 13 | #define WF_FOCUSABLE 4 14 | #define WF_RUMBLE 8 15 | 16 | #define WF_CURSOR 32 17 | #define WF_FOCUSED 64 18 | 19 | #define WF_FLAGS_MASK 0xff 20 | #define WF_FLAGS_OR 0 21 | #define WF_FLAGS_AND 256 22 | 23 | typedef enum { 24 | WT_LABEL, 25 | WT_IMAGE, 26 | WT_BUTTON, 27 | WT_APP_ENTRY, 28 | WT_PROGRESS, 29 | WT_GRADIENT, 30 | WT_MEMO 31 | } widget_type; 32 | 33 | typedef struct { 34 | u32 flags; 35 | u32 flags_invert; 36 | u16 gfx_entry_count; 37 | gfx_queue_entry *gfx_entries; 38 | } widget_layer; 39 | 40 | typedef struct { 41 | widget_type type; 42 | u32 flags; 43 | u16 width, height; 44 | 45 | cursor_type cur; 46 | 47 | gfx_coordinates coords; 48 | gfx_queue_entry qe_coords_push, qe_coords_pop; 49 | 50 | int layer_count; 51 | widget_layer *layers; 52 | 53 | union { 54 | struct { 55 | gfx_entity *mask; 56 | } image; 57 | 58 | struct { 59 | u32 max; 60 | gfx_entity *gradient; 61 | } progress; 62 | 63 | struct { 64 | gfx_entity *gradient; 65 | } gradient; 66 | 67 | struct { 68 | s16 y_min, y_max; 69 | } memo; 70 | }; 71 | } widget; 72 | 73 | typedef enum { 74 | BTN_NORMAL = 0, 75 | BTN_SMALL, 76 | BTN_TINY 77 | } button_size; 78 | 79 | void widgets_init (void); 80 | void widgets_theme_reinit (void); 81 | void widgets_deinit (void); 82 | 83 | void widget_free (widget *w); 84 | 85 | void widget_set_flag (widget *w, u32 flag, bool set); 86 | void widget_toggle_flag (widget *w, u32 flag); 87 | void widget_set_progress (widget *w, u32 progress); 88 | void widget_fade_gradient (widget *w, s8 modifier); 89 | bool widget_scroll_memo (widget *w, s16 modifier); 90 | bool widget_scroll_memo_deco (widget *w, s16 modifier); 91 | 92 | void widget_label (widget *w, s16 x, s16 y, s16 z, const char *caption, 93 | u16 width, font_xalign xalign, font_yalign yalign, 94 | font_id font); 95 | 96 | void widget_image(widget *w, s16 x, s16 y, s16 z, 97 | gfx_entity *image, gfx_entity *image_disabled, 98 | bool rumble, gfx_entity *image_cursor); 99 | 100 | void widget_button (widget *w, s16 x, s16 y, s16 z, 101 | button_size size, const char *caption); 102 | void widget_button_set_caption(widget *w, font_id font, const char *caption); 103 | 104 | void widget_app_entry (widget *w, s16 x, s16 y, s16 z, 105 | const app_entry *entry); 106 | void widget_grid_app_entry (widget *w, s16 x, s16 y, s16 z, 107 | const app_entry *entry); 108 | 109 | void widget_progress (widget *w, s16 x, s16 y, s16 z, 110 | const char *caption, u32 max); 111 | void widget_gradient (widget *w, s16 x, s16 y, s16 z, 112 | u16 width, u16 height, 113 | u32 c1, u32 c2, u32 c3, u32 c4); 114 | void widget_memo (widget *w, s16 x, s16 y, s16 z, 115 | u16 width, u16 height, 116 | const char *text, font_xalign align); 117 | void widget_memo_deco (widget *w, s16 x, s16 y, s16 z, 118 | u16 width, u16 height, 119 | const char *text, font_xalign align); 120 | 121 | #endif 122 | 123 | -------------------------------------------------------------------------------- /channel/channelapp/source/xml.h: -------------------------------------------------------------------------------- 1 | #ifndef _XML_H_ 2 | #define _XML_H_ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include "font.h" 9 | 10 | #define NO_COLOR 0x0DEADF00 11 | 12 | typedef struct { 13 | char *name; 14 | char *coder; 15 | char *version; 16 | time_t release_date; 17 | char *short_description; 18 | char *long_description; 19 | char *args; 20 | u16 argslen; 21 | bool ahb_access; 22 | } meta_info; 23 | 24 | typedef struct { 25 | char *version; 26 | u64 date; 27 | char *notes; 28 | char *uri; 29 | char *hash; 30 | } update_info; 31 | 32 | typedef struct { 33 | int device; 34 | int sort_order; 35 | int browse_mode; 36 | char app_sel[64]; 37 | } settings_t; 38 | 39 | typedef struct { 40 | u32 ul, ur, lr, ll; 41 | } theme_gradient_t; 42 | 43 | typedef struct { 44 | char *file; 45 | int size; 46 | u32 color; 47 | } theme_font_t; 48 | 49 | typedef enum { 50 | TLANG_JA = 0x01, 51 | TLANG_KO = 0x02, 52 | TLANG_ZH = 0x04, 53 | } theme_lang_t; 54 | 55 | typedef struct { 56 | theme_gradient_t progress; 57 | char *description; 58 | theme_font_t default_font; 59 | theme_font_t fonts[FONT_MAX]; 60 | theme_lang_t langs; 61 | } theme_t; 62 | 63 | extern settings_t settings; 64 | extern theme_t theme; 65 | 66 | meta_info *meta_parse(char *fn); 67 | void meta_free(meta_info *info); 68 | 69 | update_info *update_parse(char *buf); 70 | void update_free(update_info *info); 71 | 72 | bool settings_load(void); 73 | bool settings_save(void); 74 | 75 | void theme_xml_init(void); 76 | bool load_theme_xml(char *buf); 77 | 78 | #endif 79 | 80 | -------------------------------------------------------------------------------- /channel/channelapp/stub/ios.h: -------------------------------------------------------------------------------- 1 | 2 | struct ioctlv { 3 | void *data; 4 | u32 len; 5 | }; 6 | 7 | int ios_open(const char *filename, u32 mode); 8 | int ios_close(int fd); 9 | int ios_ioctlv(int fd, u32 n, u32 in_count, u32 out_count, struct ioctlv *vec); 10 | int ios_ioctlvreboot(int fd, u32 n, u32 in_count, u32 out_count, struct ioctlv *vec); 11 | void reset_ios(void); 12 | -------------------------------------------------------------------------------- /channel/channelapp/stub/processor.h: -------------------------------------------------------------------------------- 1 | // this file was taken from libogc, see http://www.devkitpro.org/ 2 | 3 | #ifndef __PROCESSOR_H__ 4 | #define __PROCESSOR_H__ 5 | 6 | #include 7 | 8 | #define __stringify(rn) #rn 9 | #define ATTRIBUTE_ALIGN(v) __attribute__((aligned(v))) 10 | 11 | #define _sync() asm volatile("sync") 12 | #define _nop() asm volatile("nop") 13 | #define ppcsync() asm volatile("sc") 14 | #define ppchalt() ({ \ 15 | asm volatile("sync"); \ 16 | while(1) { \ 17 | asm volatile("nop"); \ 18 | asm volatile("li 3,0"); \ 19 | asm volatile("nop"); \ 20 | } \ 21 | }) 22 | 23 | #define mfdcr(_rn) ({register u32 _rval; \ 24 | asm volatile("mfdcr %0," __stringify(_rn) \ 25 | : "=r" (_rval)); _rval;}) 26 | #define mtdcr(rn, val) asm volatile("mtdcr " __stringify(rn) ",%0" : : "r" (val)) 27 | 28 | #define mfmsr() ({register u32 _rval; \ 29 | asm volatile("mfmsr %0" : "=r" (_rval)); _rval;}) 30 | #define mtmsr(val) asm volatile("mtmsr %0" : : "r" (val)) 31 | 32 | #define mfdec() ({register u32 _rval; \ 33 | asm volatile("mfdec %0" : "=r" (_rval)); _rval;}) 34 | #define mtdec(_val) asm volatile("mtdec %0" : : "r" (_val)) 35 | 36 | #define mfspr(_rn) \ 37 | ({ register u32 _rval = 0; \ 38 | asm volatile("mfspr %0," __stringify(_rn) \ 39 | : "=r" (_rval));\ 40 | _rval; \ 41 | }) 42 | 43 | #define mtspr(_rn, _val) asm volatile("mtspr " __stringify(_rn) ",%0" : : "r" (_val)) 44 | 45 | #define mfwpar() mfspr(WPAR) 46 | #define mtwpar(_val) mtspr(WPAR,_val) 47 | 48 | #define mfmmcr0() mfspr(MMCR0) 49 | #define mtmmcr0(_val) mtspr(MMCR0,_val) 50 | #define mfmmcr1() mfspr(MMCR1) 51 | #define mtmmcr1(_val) mtspr(MMCR1,_val) 52 | 53 | #define mfpmc1() mfspr(PMC1) 54 | #define mtpmc1(_val) mtspr(PMC1,_val) 55 | #define mfpmc2() mfspr(PMC2) 56 | #define mtpmc2(_val) mtspr(PMC2,_val) 57 | #define mfpmc3() mfspr(PMC3) 58 | #define mtpmc3(_val) mtspr(PMC3,_val) 59 | #define mfpmc4() mfspr(PMC4) 60 | #define mtpmc4(_val) mtspr(PMC4,_val) 61 | 62 | #define mfhid0() mfspr(HID0) 63 | #define mthid0(_val) mtspr(HID0,_val) 64 | #define mfhid1() mfspr(HID1) 65 | #define mthid1(_val) mtspr(HID1,_val) 66 | #define mfhid2() mfspr(HID2) 67 | #define mthid2(_val) mtspr(HID2,_val) 68 | #define mfhid4() mfspr(HID4) 69 | #define mthid4(_val) mtspr(HID4,_val) 70 | 71 | #define cntlzw(_val) ({register u32 _rval; \ 72 | asm volatile("cntlzw %0, %1" : "=r"((_rval)) : "r"((_val))); _rval;}) 73 | 74 | #define _CPU_MSR_GET( _msr_value ) \ 75 | do { \ 76 | _msr_value = 0; \ 77 | asm volatile ("mfmsr %0" : "=&r" ((_msr_value)) : "0" ((_msr_value))); \ 78 | } while (0) 79 | 80 | #define _CPU_MSR_SET( _msr_value ) \ 81 | { asm volatile ("mtmsr %0" : "=&r" ((_msr_value)) : "0" ((_msr_value))); } 82 | 83 | #define _CPU_ISR_Enable() \ 84 | { register u32 _val = 0; \ 85 | asm volatile ("mfmsr %0; ori %0,%0,0x8000; mtmsr %0" : \ 86 | "=&r" (_val) : "0" (_val));\ 87 | } 88 | 89 | #define _CPU_ISR_Disable( _isr_cookie ) \ 90 | { register u32 _disable_mask = MSR_EE; \ 91 | _isr_cookie = 0; \ 92 | asm volatile ( \ 93 | "mfmsr %0; andc %1,%0,%1; mtmsr %1" : \ 94 | "=&r" ((_isr_cookie)), "=&r" ((_disable_mask)) : \ 95 | "0" ((_isr_cookie)), "1" ((_disable_mask)) \ 96 | ); \ 97 | } 98 | 99 | #define _CPU_ISR_Restore( _isr_cookie ) \ 100 | { \ 101 | asm volatile ( "mtmsr %0" : \ 102 | "=r" ((_isr_cookie)) : \ 103 | "0" ((_isr_cookie))); \ 104 | } 105 | 106 | #define _CPU_ISR_Flash( _isr_cookie ) \ 107 | { register u32 _disable_mask = MSR_EE; \ 108 | asm volatile ( \ 109 | "mtmsr %0; andc %1,%0,%1; mtmsr %1" : \ 110 | "=r" ((_isr_cookie)), "=r" ((_disable_mask)) : \ 111 | "0" ((_isr_cookie)), "1" ((_disable_mask)) \ 112 | ); \ 113 | } 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /channel/channelapp/stub/stub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 dhewg, #wiidev efnet 3 | * Copyright (C) 2008 marcan, #wiidev efnet 4 | * 5 | * this file is part of the Homebrew Channel 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include "system.h" 23 | #include "stub_debug.h" 24 | #include "usb.h" 25 | #include "ios.h" 26 | #include "cache.h" 27 | #include "../config.h" 28 | 29 | #define IOCTL_ES_LAUNCH 0x08 30 | #define IOCTL_ES_GETVIEWCNT 0x12 31 | #define IOCTL_ES_GETVIEWS 0x13 32 | 33 | struct ioctlv vecs[3] __attribute__((aligned(32))); 34 | 35 | u64 *conf_magic = STUB_ADDR_MAGIC; 36 | u64 *conf_titleID = STUB_ADDR_TITLE; 37 | 38 | int es_fd; 39 | 40 | int LaunchTitle(u64 titleID) { 41 | static u64 xtitleID __attribute__((aligned(32))); 42 | static u32 cntviews __attribute__((aligned(32))); 43 | static u8 tikviews[0xd8*4] __attribute__((aligned(32))); 44 | int ret; 45 | 46 | debug_string("LaunchTitle: "); 47 | debug_uint(titleID>>32); 48 | debug_string("-"); 49 | debug_uint(titleID&0xFFFFFFFF); 50 | 51 | xtitleID = titleID; 52 | 53 | debug_string("\n\rGetTicketViewCount: "); 54 | 55 | vecs[0].data = &xtitleID; 56 | vecs[0].len = 8; 57 | vecs[1].data = &cntviews; 58 | vecs[1].len = 4; 59 | ret = ios_ioctlv(es_fd, IOCTL_ES_GETVIEWCNT, 1, 1, vecs); 60 | debug_uint(ret); 61 | debug_string(", views: "); 62 | debug_uint(cntviews); 63 | debug_string("\n\r"); 64 | if(ret<0) return ret; 65 | if(cntviews>4) return -1; 66 | 67 | debug_string("GetTicketViews: "); 68 | vecs[0].data = &xtitleID; 69 | vecs[0].len = 8; 70 | vecs[1].data = &cntviews; 71 | vecs[1].len = 4; 72 | vecs[2].data = tikviews; 73 | vecs[2].len = 0xd8*cntviews; 74 | ret = ios_ioctlv(es_fd, IOCTL_ES_GETVIEWS, 2, 1, vecs); 75 | debug_uint(ret); 76 | debug_string("\n\r"); 77 | if(ret<0) return ret; 78 | debug_string("Attempting to launch...\n\r"); 79 | vecs[0].data = &xtitleID; 80 | vecs[0].len = 8; 81 | vecs[1].data = tikviews; 82 | vecs[1].len = 0xd8; 83 | ret = ios_ioctlvreboot(es_fd, IOCTL_ES_LAUNCH, 2, 0, vecs); 84 | if(ret < 0) { 85 | debug_string("Launch failed: "); 86 | debug_uint(ret); 87 | debug_string("\r\n"); 88 | } 89 | return ret; 90 | } 91 | 92 | s32 IOS_GetVersion() 93 | { 94 | u32 vercode; 95 | u16 version; 96 | DCInvalidateRange((void*)0x80003140,8); 97 | vercode = *((u32*)0x80003140); 98 | version = vercode >> 16; 99 | if(version == 0) return -1; 100 | if(version > 0xff) return -1; 101 | return version; 102 | } 103 | 104 | void printversion(void) { 105 | debug_string("IOS version: "); 106 | debug_uint(IOS_GetVersion()); 107 | debug_string("\n\r"); 108 | } 109 | 110 | int es_init(void) { 111 | debug_string("Opening /dev/es: "); 112 | es_fd = ios_open("/dev/es", 0); 113 | debug_uint(es_fd); 114 | debug_string("\n\r"); 115 | return es_fd; 116 | } 117 | 118 | 119 | void _main (void) { 120 | int iosver; 121 | u64 titleID = MY_TITLEID; 122 | 123 | debug_string("\n\rHomebrew Channel stub code\n\r"); 124 | 125 | if(*conf_magic == STUB_MAGIC) titleID = *conf_titleID; 126 | 127 | reset_ios(); 128 | 129 | if(es_init() < 0) goto fail; 130 | 131 | iosver = STUB_LOAD_IOS_VERSION; 132 | if(iosver < 0) 133 | iosver = 21; //bah 134 | printversion(); 135 | debug_string("\n\rReloading IOS...\n\r"); 136 | LaunchTitle(0x0000000100000000LL | iosver); 137 | printversion(); 138 | 139 | if(es_init() < 0) goto fail; 140 | debug_string("\n\rLoading requested channel...\n\r"); 141 | LaunchTitle(titleID); 142 | // if fail, try system menu 143 | debug_string("\n\rChannel load failed, trying with system menu...\n\r"); 144 | LaunchTitle(0x0000000100000002LL); 145 | printversion(); 146 | 147 | fail: 148 | debug_string("FAILURE\n\r"); 149 | while(1); 150 | } 151 | 152 | -------------------------------------------------------------------------------- /channel/channelapp/stub/stub_debug.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 dhewg, #wiidev efnet 3 | * 4 | * this file is part of the Homebrew Channel 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #include "stub_debug.h" 22 | #include "usb.h" 23 | 24 | #ifdef DEBUG_STUB 25 | 26 | static char int2hex[] = "0123456789abcdef"; 27 | 28 | void debug_uint (u32 i) { 29 | int j; 30 | 31 | usb_sendbuffersafe ("0x", 2); 32 | for (j = 0; j < 8; ++j) { 33 | usb_sendbuffersafe (&int2hex[(i >> 28) & 0xf], 1); 34 | i <<= 4; 35 | } 36 | } 37 | 38 | void debug_string (const char *s) { 39 | u32 i = 0; 40 | 41 | while (s[i]) 42 | i++; 43 | 44 | usb_sendbuffersafe (s, i); 45 | } 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /channel/channelapp/stub/stub_debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 dhewg, #wiidev efnet 3 | * 4 | * this file is part of the Homebrew Channel 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef _STUB_DEBUG_H_ 22 | #define _STUB_DEBUG_H_ 23 | 24 | #include 25 | 26 | #include "../config.h" 27 | 28 | #ifdef DEBUG_STUB 29 | 30 | void debug_uint (u32 i); 31 | void debug_string (const char *s); 32 | 33 | #else 34 | 35 | #define debug_uint(x) 36 | #define debug_string(x) 37 | 38 | #endif 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /channel/channelapp/stub/system.c: -------------------------------------------------------------------------------- 1 | #include "asm.h" 2 | #include "cache.h" 3 | #include "system.h" 4 | #include "processor.h" 5 | 6 | extern char systemcallhandler_start[], systemcallhandler_end[]; 7 | 8 | void __SyscallInit(void) 9 | { 10 | memcpy((void*)0x80000c00, systemcallhandler_start, 11 | systemcallhandler_end - systemcallhandler_start); 12 | DCFlushRangeNoSync((void*)0x80000c00, 0x100); 13 | ICInvalidateRange((void*)0x80000c00, 0x100); 14 | _sync(); 15 | } 16 | 17 | void *memcpy(void *ptr, const void *src, int size) { 18 | char* ptr2 = ptr; 19 | const char* src2 = src; 20 | while(size--) *ptr2++ = *src2++; 21 | return ptr; 22 | } 23 | 24 | int strlen(const char *ptr) { 25 | int i=0; 26 | while(*ptr++) i++; 27 | return i; 28 | } 29 | -------------------------------------------------------------------------------- /channel/channelapp/stub/system.h: -------------------------------------------------------------------------------- 1 | // this code was taken from libogc, see http://www.devkitpro.org/ 2 | 3 | #ifndef __SYSTEM_H__ 4 | #define __SYSTEM_H__ 5 | 6 | #include 7 | 8 | void ICInvalidateRange(void *startaddress,u32 len); 9 | void DCInvalidateRange(void *startaddress,u32 len); 10 | void DCFlushRange(void *startaddress,u32 len); 11 | void DCFlushRangeNoSync(void *startaddress,u32 len); 12 | 13 | void dol_relocstart(void *dolstart); 14 | 15 | void* memmove(void *dst0,const void *src0,register int length); 16 | extern void _memset(void *,int,int); 17 | //void *memset(void *ptr, int c, int size); 18 | #define memset _memset 19 | void *memcpy(void *ptr, const void *src, int size); 20 | int strlen(const char *ptr); 21 | 22 | extern void __exception_closeall(); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /channel/channelapp/stub/system_asm.S: -------------------------------------------------------------------------------- 1 | // this code was taken from libogc, see http://www.devkitpro.org/ 2 | 3 | #include "asm.h" 4 | 5 | .extern ICFlashInvalidate 6 | .extern ICEnable 7 | .extern DCEnable 8 | .extern L2Init 9 | .extern L2Enable 10 | .globl __CacheInit 11 | __CacheInit: 12 | mflr r0 13 | stw r0, 4(sp) 14 | stwu sp, -16(sp) 15 | stw r31, 12(sp) 16 | 17 | mfspr r3,HID0 # (HID0) 18 | rlwinm r0,r3, 0, 16, 16 19 | cmplwi r0, 0x0000 # Check if the Instruction Cache has been enabled or not. 20 | bne ICEnabled 21 | 22 | bl ICEnable 23 | ICEnabled: 24 | mfspr r3, HID0 # bl PPCMfhid0 25 | rlwinm r0, r3, 0, 17, 17 26 | cmplwi r0, 0x0000 # Check if the Data Cache has been enabled or not. 27 | bne DCEnabled 28 | 29 | bl DCEnable 30 | DCEnabled: 31 | 32 | mfspr r3, L2CR # (L2CR) 33 | clrrwi r0, r3, 31 # Clear all of the bits except 31 34 | cmplwi r0, 0x0000 35 | bne L2Enabled 36 | 37 | bl L2Init 38 | bl L2Enable 39 | 40 | L2Enabled: 41 | # Restore the non-volatile registers to their previous values and return. 42 | lwz r0, 20(sp) 43 | lwz r31, 12(sp) 44 | addi sp, sp, 16 45 | mtlr r0 46 | blr 47 | 48 | .globl __SystemInit 49 | __SystemInit: 50 | mflr r0 51 | stw r0, 4(sp) 52 | stwu sp, -24(sp) 53 | stw r31, 20(sp) 54 | stw r30, 16(sp) 55 | stw r29, 12(sp) 56 | 57 | # Clear various SPR's 58 | li r3,0 59 | mtspr 952, r3 60 | mtspr 956, r3 61 | mtspr 953, r3 62 | mtspr 954, r3 63 | mtspr 957, r3 64 | mtspr 958, r3 65 | 66 | #if 0 67 | lis r3,0x8390 //bits set: H4A(HID4 access), SBE(2nd BAT enabled), SR0(store 0), LPE(PS LE exception), L2CFI(L2 castout prior to L2 inv. flash) 68 | mtspr HID4,r3 69 | #endif 70 | 71 | # Disable Speculative Bus Accesses to non-guarded space from both caches. 72 | mfspr r3, HID0 73 | ori r3, r3, 0x0200 74 | mtspr HID0, r3 75 | 76 | mfspr r3,HID2 # (HID2) 77 | rlwinm r3, r3, 0, 2, 0 78 | mtspr HID2,r3 # (HID2) 79 | 80 | # Restore the non-volatile registers to their previous values and return. 81 | lwz r0, 28(sp) 82 | lwz r31,20(sp) 83 | lwz r30,16(sp) 84 | lwz r29,12(sp) 85 | addi sp, sp, 24 86 | mtlr r0 87 | blr 88 | 89 | 90 | .global systemcallhandler_start,systemcallhandler_end 91 | systemcallhandler_start: 92 | mfspr r3,HID0 93 | ori r4,r3,0x0008 94 | mtspr HID0,r4 95 | isync 96 | sync 97 | mtspr HID0,r3 98 | rfi 99 | systemcallhandler_end: 100 | nop 101 | -------------------------------------------------------------------------------- /channel/channelapp/stub/usb.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * USB Gecko Development Kit - http://www.usbgecko.com 3 | * -------------------------------------------------------------------------------------------- 4 | * 5 | * 6 | * usb.h - functions for the USB Gecko adapter (www.usbgecko.com). 7 | * 8 | * Copyright (c) 2008 - Nuke - 9 | * 10 | *---------------------------------------------------------------------------------------------*/ 11 | 12 | #ifndef __USB_H__ 13 | #define __USB_H__ 14 | 15 | #include "../config.h" 16 | 17 | #ifdef DEBUG_STUB 18 | 19 | #define WIIMODE 20 | // Wii Mode 21 | #ifdef WIIMODE 22 | #define exi_chan0sr *(volatile unsigned int*) 0xCD006800 // Channel 0 Status Register 23 | #define exi_chan1sr *(volatile unsigned int*) 0xCD006814 // Channel 1 Status Register 24 | #define exi_chan2sr *(volatile unsigned int*) 0xCD006828 // Channel 2 Status Register 25 | #define exi_chan0cr *(volatile unsigned int*) 0xCD00680c // Channel 0 Control Register 26 | #define exi_chan1cr *(volatile unsigned int*) 0xCD006820 // Channel 1 Control Register 27 | #define exi_chan2cr *(volatile unsigned int*) 0xCD006834 // Channel 2 Control Register 28 | #define exi_chan0data *(volatile unsigned int*) 0xCD006810 // Channel 0 Immediate Data 29 | #define exi_chan1data *(volatile unsigned int*) 0xCD006824 // Channel 1 Immediate Data 30 | #define exi_chan2data *(volatile unsigned int*) 0xCD006838 // Channel 2 Immediate Data 31 | #define exi_chan0dmasta *(volatile unsigned int*) 0xCD006804 // Channel 0 DMA Start address 32 | #define exi_chan1dmasta *(volatile unsigned int*) 0xCD006818 // Channel 1 DMA Start address 33 | #define exi_chan2dmasta *(volatile unsigned int*) 0xCD00682c // Channel 2 DMA Start address 34 | #define exi_chan0dmalen *(volatile unsigned int*) 0xCD006808 // Channel 0 DMA Length 35 | #define exi_chan1dmalen *(volatile unsigned int*) 0xCD00681c // Channel 1 DMA Length 36 | #define exi_chan2dmalen *(volatile unsigned int*) 0xCD006830 // Channel 2 DMA Length 37 | #else 38 | // GC Mode 39 | #define exi_chan0sr *(volatile unsigned int*) 0xCC006800 // Channel 0 Status Register 40 | #define exi_chan1sr *(volatile unsigned int*) 0xCC006814 // Channel 1 Status Register 41 | #define exi_chan2sr *(volatile unsigned int*) 0xCC006828 // Channel 2 Status Register 42 | #define exi_chan0cr *(volatile unsigned int*) 0xCC00680c // Channel 0 Control Register 43 | #define exi_chan1cr *(volatile unsigned int*) 0xCC006820 // Channel 1 Control Register 44 | #define exi_chan2cr *(volatile unsigned int*) 0xCC006834 // Channel 2 Control Register 45 | #define exi_chan0data *(volatile unsigned int*) 0xCC006810 // Channel 0 Immediate Data 46 | #define exi_chan1data *(volatile unsigned int*) 0xCC006824 // Channel 1 Immediate Data 47 | #define exi_chan2data *(volatile unsigned int*) 0xCC006838 // Channel 2 Immediate Data 48 | #define exi_chan0dmasta *(volatile unsigned int*) 0xCC006804 // Channel 0 DMA Start address 49 | #define exi_chan1dmasta *(volatile unsigned int*) 0xCC006818 // Channel 1 DMA Start address 50 | #define exi_chan2dmasta *(volatile unsigned int*) 0xCC00682c // Channel 2 DMA Start address 51 | #define exi_chan0dmalen *(volatile unsigned int*) 0xCC006808 // Channel 0 DMA Length 52 | #define exi_chan1dmalen *(volatile unsigned int*) 0xCC00681c // Channel 1 DMA Length 53 | #define exi_chan2dmalen *(volatile unsigned int*) 0xCC006830 // Channel 2 DMA Length 54 | #endif 55 | 56 | // Function prototypes 57 | void usb_flush(); 58 | int usb_checkgecko(); 59 | void usb_sendbuffer (const void *buffer, int size); 60 | void usb_receivebuffer (void *buffer, int size); 61 | void usb_sendbuffersafe (const void *buffer, int size); 62 | void usb_receivebuffersafe (void *buffer, int size); 63 | #endif 64 | 65 | #endif // __USB_H__ 66 | -------------------------------------------------------------------------------- /channel/title/.gitignore: -------------------------------------------------------------------------------- 1 | /00000000 2 | /00000001 3 | retail/cetk 4 | retail/tmd 5 | dpki/cetk 6 | dpki/tmd 7 | *.wad 8 | -------------------------------------------------------------------------------- /channel/title/Makefile: -------------------------------------------------------------------------------- 1 | INSTALLER_VER_MAJOR = 1 2 | INSTALLER_VER_MINOR = 2 3 | 4 | TOOLS = $(CURDIR)/../../pywii/pywii-tools 5 | CERTS = $(CURDIR)/dpki/certs 6 | DPKI_ISSUER_TIK = Root-CA00000002-XS00000006 7 | DPKI_ISSUER_TMD = Root-CA00000002-CP00000007 8 | 9 | all: channel_retail.wad 10 | 11 | dpki: channel_dpki.wad 12 | 13 | channel_retail.wad: retail/cetk retail/tmd 00000000 00000001 14 | @$(TOOLS)/wadpack.py $@ retail/ 15 | 16 | channel_dpki.wad: dpki/cetk dpki/tmd 00000000 00000001 17 | @$(TOOLS)/wadpack.py -dpki $@ dpki/ 18 | 19 | 00000000: ../banner/channel.imet 20 | @cat footer $< > $@ 21 | 22 | 00000001: ../channelapp/channelapp-channel.dol 23 | @cp $< $@ 24 | 25 | retail/cetk: cetk.template 26 | @cp $< $@ 27 | @$(TOOLS)/tikfix.py $@ 28 | 29 | dpki/cetk: retail/cetk 30 | @$(TOOLS)/dpkisign.py -cetk $< $@ $(CERTS) $(DPKI_ISSUER_TIK) 31 | 32 | retail/tmd: tmd.template 00000000 00000001 33 | @cp $< $@ 34 | @$(TOOLS)/tmdupdatecr.py $@ $(CURDIR) 35 | @$(TOOLS)/tmdvers.py $@ $(INSTALLER_VER_MAJOR) $(INSTALLER_VER_MINOR) 36 | 37 | dpki/tmd: retail/tmd 38 | @$(TOOLS)/dpkisign.py -tmd $< $@ $(CERTS) $(DPKI_ISSUER_TMD) 39 | 40 | check: all dpki 41 | @echo ===== RETAIL ===== 42 | @$(TOOLS)/tikinfo.py retail/cetk retail/certs 43 | @$(TOOLS)/tmdinfo.py retail/tmd retail/certs 44 | @echo ===== DPKI ===== 45 | @$(TOOLS)/tikinfo.py -dpki dpki/cetk dpki/certs 46 | @$(TOOLS)/tmdinfo.py -dpki dpki/tmd dpki/certs 47 | 48 | clean: 49 | rm -f retail/cetk dpki/cetk retail/tmd retail/tmd 00000000 00000001 channel_retail.wad channel_dpki.wad 50 | 51 | -------------------------------------------------------------------------------- /channel/title/cetk.template: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/title/cetk.template -------------------------------------------------------------------------------- /channel/title/dpki/00000000: -------------------------------------------------------------------------------- 1 | ../00000000 -------------------------------------------------------------------------------- /channel/title/dpki/00000001: -------------------------------------------------------------------------------- 1 | ../00000001 -------------------------------------------------------------------------------- /channel/title/dpki/certs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/title/dpki/certs -------------------------------------------------------------------------------- /channel/title/dpki/footer: -------------------------------------------------------------------------------- 1 | ../footer -------------------------------------------------------------------------------- /channel/title/footer: -------------------------------------------------------------------------------- 1 | TheHomebrewChanneltwiizers@wiidev -------------------------------------------------------------------------------- /channel/title/pywii: -------------------------------------------------------------------------------- 1 | ../../pywii/Common/pywii -------------------------------------------------------------------------------- /channel/title/retail/00000000: -------------------------------------------------------------------------------- 1 | ../00000000 -------------------------------------------------------------------------------- /channel/title/retail/00000001: -------------------------------------------------------------------------------- 1 | ../00000001 -------------------------------------------------------------------------------- /channel/title/retail/certs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/title/retail/certs -------------------------------------------------------------------------------- /channel/title/retail/footer: -------------------------------------------------------------------------------- 1 | ../footer -------------------------------------------------------------------------------- /channel/title/tmd.template: -------------------------------------------------------------------------------- 1 | Root-CA00000001-CP00000004:OHBCHB!!SSSSSSSSHHHHHHHHHHHHHHHHHHHHSSSSSSSSHHHHHHHHHHHHHHHHHHHH -------------------------------------------------------------------------------- /channel/wiiload/.gitignore: -------------------------------------------------------------------------------- 1 | wiiload 2 | wiiload.exe 3 | 4 | -------------------------------------------------------------------------------- /channel/wiiload/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS += -Wall -Wextra -Os -g -pipe 2 | 3 | ifeq ($(WIN32), 1) 4 | PREFIX ?= i586-mingw32msvc- 5 | BIN_EXT = .exe 6 | CFLAGS += -Iwin32/include 7 | LDFLAGS += -Lwin32/lib -lws2_32 -lz 8 | else 9 | PREFIX ?= 10 | BIN_EXT = 11 | LDFLAGS += -lz 12 | endif 13 | 14 | ifeq ($(FTDI), 1) 15 | CFLAGS += -DUSE_LIBFTDI 16 | LDFLAGS += -lftdi -lusb 17 | endif 18 | 19 | CC = $(PREFIX)gcc 20 | STRIP = $(PREFIX)strip 21 | 22 | BIN = wiiload$(BIN_EXT) 23 | 24 | OBJS = gecko.o main.o 25 | 26 | all: $(BIN) 27 | 28 | clean: 29 | @rm -f *.o core core.* $(BIN) 30 | 31 | strip: all 32 | $(STRIP) $(BIN) 33 | 34 | install: strip 35 | install -m 755 $(BIN) $(DEVKITPPC)/bin 36 | 37 | $(BIN): $(OBJS) 38 | $(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@ 39 | 40 | %o: %.c 41 | $(CC) $(CFLAGS) -c $< -o $@ 42 | 43 | osx: 44 | $(MAKE) clean 45 | PREFIX=/opt/toolchains/powerpc-apple-darwin8-10.2/bin/ppc-apple-darwin8- CFLAGS=-fabi-version=1 $(MAKE) strip 46 | cp $(BIN) $(BIN)_ppc 47 | $(MAKE) clean 48 | PREFIX=/opt/toolchains/i686-apple-darwin9-10.4/bin/i686-apple-darwin9- $(MAKE) strip 49 | cp $(BIN) $(BIN)_intel 50 | $(MAKE) clean 51 | /opt/toolchains/i686-apple-darwin9-10.4/bin/i686-apple-darwin9-lipo -create $(BIN)_ppc $(BIN)_intel -output $(BIN) 52 | rm $(BIN)_ppc $(BIN)_intel 53 | 54 | -------------------------------------------------------------------------------- /channel/wiiload/gecko.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 dhewg, #wiidev efnet 3 | * 4 | * this file is part of wiifuse 5 | * http://wiibrew.org/index.php?title=Wiifuse 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef _GECKO_H_ 23 | #define _GECKO_H_ 24 | 25 | int gecko_open (const char *dev); 26 | void gecko_close (); 27 | void gecko_flush (); 28 | int gecko_read (void *buf, size_t count); 29 | int gecko_write (const void *buf, size_t count); 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /channel/wiiload/win32/lib/libz.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fail0verflow/hbc/13305cfbe5db47eebc5e62aeed14f7adfbb83a5a/channel/wiiload/win32/lib/libz.a -------------------------------------------------------------------------------- /common.mk: -------------------------------------------------------------------------------- 1 | AR = $(PREFIX)ar 2 | AS = $(PREFIX)as 3 | CC = $(PREFIX)gcc 4 | CXX = $(PREFIX)g++ 5 | LD = $(PREFIX)ld 6 | OBJCOPY = $(PREFIX)objcopy 7 | RANLIB = $(PREFIX)ranlib 8 | STRIP = $(PREFIX)strip 9 | 10 | BIN2S = $(DEVKITPRO)/tools/bin/bin2s 11 | 12 | ifeq ($(NOMAPFILE),) 13 | LDFLAGS += -Wl,-Map,$(TARGET).map 14 | endif 15 | 16 | ifneq ($(LDSCRIPT),) 17 | LDFLAGS += -Wl,-T$(LDSCRIPT) 18 | endif 19 | 20 | DEPDIR = .deps 21 | 22 | all: $(TARGET) 23 | 24 | $(TARGET): $(OBJS) 25 | @echo " LINK $@" 26 | @$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ 27 | 28 | ifneq ($(LDSCRIPT),) 29 | $(TARGET): $(LDSCRIPT) 30 | endif 31 | 32 | %.o: %.c 33 | @echo " COMPILE $<" 34 | @mkdir -p $(DEPDIR) 35 | @$(CC) $(CFLAGS) $(DEFINES) -Wp,-MMD,$(DEPDIR)/$(*F).d,-MQ,"$@",-MP -c $< -o $@ 36 | 37 | %.o: %.s 38 | @echo " ASSEMBLE $<" 39 | @$(CC) $(CFLAGS) $(DEFINES) $(ASFLAGS) -c $< -o $@ 40 | 41 | %.o: %.S 42 | @echo " ASSEMBLE $<" 43 | @$(CC) $(CFLAGS) $(DEFINES) $(ASFLAGS) -c $< -o $@ 44 | 45 | clean: 46 | rm -rf $(DEPDIR) 47 | rm -f $(TARGET) $(TARGET).map $(OBJS) 48 | 49 | define bin2o 50 | @echo " BIN2S $(notdir $<)" 51 | @$(BIN2S) -a 32 $< | $(AS) -o $(@) 52 | @echo "extern const u8" `(echo $( `(echo $(> `(echo $(> `(echo $( (self.time+self.contents.cooking_time) 33 | def getTimeLeft(self): 34 | return max(0,(self.time+self.contents.cooking_time) - time.time()) 35 | def getContents(self): 36 | if self.contentsAreCooked(): 37 | batter = self.contents.batter 38 | cookedbatter = zlib.decompress(base64.b64decode(batter)) 39 | self.contents = Waffle(cookedbatter) 40 | else: 41 | raise RuntimeError("Waffle is not yet cooked!") 42 | return self.contents 43 | 44 | class BreakfastType: 45 | def __init__(self): 46 | raise NotImplementedError("BreakfastType is abstract") 47 | 48 | class Waffles(BreakfastType): 49 | def __init__(self): 50 | pass 51 | def make(self): 52 | batter = WaffleBatter() 53 | iron = WaffleIron() 54 | iron.switchPower(True) 55 | cooktime = iron.fill(batter) 56 | cm, cs = divmod(cooktime,60) 57 | if cm > 0: 58 | print "Cooking time will be approximately %d minute%s and %d second%s"%(cm, 's'*(cm!=1), cs, 's'*(cs!=1)) 59 | else: 60 | print "Cooking time will be approximately %d second%s"%(cs, 's'*(cs!=1)) 61 | while not iron.contentsAreCooked(): 62 | left = iron.getTimeLeft() 63 | m,s = divmod(left+0.99,60) 64 | sys.stdout.write("%02d:%02d"%(m,s)) 65 | sys.stdout.flush() 66 | time.sleep(0.5) 67 | sys.stdout.write("\x08"*5) 68 | sys.stdout.flush() 69 | print 70 | waffle = iron.getContents() 71 | iron.switchPower(False) 72 | return waffle 73 | 74 | class BreakfastMaker: 75 | preferredBreakfasts = {'bushing':Waffles} 76 | def __init__(self): 77 | pass 78 | def makeBreakfastFor(self, user): 79 | if not user in self.preferredBreakfasts: 80 | raise ValueError("I don't know how to make breakfast for %s!"%user) 81 | maker = self.preferredBreakfasts[user] 82 | breakfast = maker().make() 83 | return breakfast 84 | 85 | print "Breakfast Maker v0.2" 86 | user = raw_input("Please enter your username: ") 87 | maker = BreakfastMaker() 88 | print "Making breakfast for %s..."%user 89 | breakfast = maker.makeBreakfastFor(user) 90 | print 91 | print "Your breakfast is ready!" 92 | print 93 | breakfast.display() 94 | print "\a" 95 | -------------------------------------------------------------------------------- /pywii/ecmodule/_ecmodule.c: -------------------------------------------------------------------------------- 1 | // Copyright 2007,2008 Segher Boessenkool 2 | // Copyright 2008 Hector Martin 3 | // Licensed under the terms of the GNU GPL, version 2 4 | // http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt 5 | #include "Python.h" 6 | #include 7 | 8 | typedef uint8_t u8; 9 | typedef uint32_t u32; 10 | 11 | /* ----------------------------------------------------- */ 12 | 13 | static void elt_copy(u8 *d, const u8 *a) 14 | { 15 | memcpy(d, a, 30); 16 | } 17 | 18 | static void elt_zero(u8 *d) 19 | { 20 | memset(d, 0, 30); 21 | } 22 | 23 | static int elt_is_zero(const u8 *d) 24 | { 25 | u32 i; 26 | 27 | for (i = 0; i < 30; i++) 28 | if (d[i] != 0) 29 | return 0; 30 | 31 | return 1; 32 | } 33 | 34 | static void elt_add(u8 *d, const u8 *a, const u8 *b) 35 | { 36 | u32 i; 37 | 38 | for (i = 0; i < 30; i++) 39 | d[i] = a[i] ^ b[i]; 40 | } 41 | 42 | static void elt_mul_x(u8 *d, const u8 *a) 43 | { 44 | u8 carry, x, y; 45 | u32 i; 46 | 47 | carry = a[0] & 1; 48 | 49 | x = 0; 50 | for (i = 0; i < 29; i++) { 51 | y = a[i + 1]; 52 | d[i] = x ^ (y >> 7); 53 | x = y << 1; 54 | } 55 | d[29] = x ^ carry; 56 | 57 | d[20] ^= carry << 2; 58 | } 59 | 60 | static void elt_mul(u8 *d, const u8 *a, const u8 *b) 61 | { 62 | u32 i, n; 63 | u8 mask; 64 | 65 | elt_zero(d); 66 | 67 | i = 0; 68 | mask = 1; 69 | for (n = 0; n < 233; n++) { 70 | elt_mul_x(d, d); 71 | 72 | if ((a[i] & mask) != 0) 73 | elt_add(d, d, b); 74 | 75 | mask >>= 1; 76 | if (mask == 0) { 77 | mask = 0x80; 78 | i++; 79 | } 80 | } 81 | } 82 | 83 | static const u8 square[16] = 84 | "\x00\x01\x04\x05\x10\x11\x14\x15\x40\x41\x44\x45\x50\x51\x54\x55"; 85 | 86 | static void elt_square_to_wide(u8 *d, const u8 *a) 87 | { 88 | u32 i; 89 | 90 | for (i = 0; i < 30; i++) { 91 | d[2*i] = square[a[i] >> 4]; 92 | d[2*i + 1] = square[a[i] & 15]; 93 | } 94 | } 95 | 96 | static void wide_reduce(u8 *d) 97 | { 98 | u32 i; 99 | u8 x; 100 | 101 | for (i = 0; i < 30; i++) { 102 | x = d[i]; 103 | 104 | d[i + 19] ^= x >> 7; 105 | d[i + 20] ^= x << 1; 106 | 107 | d[i + 29] ^= x >> 1; 108 | d[i + 30] ^= x << 7; 109 | } 110 | 111 | x = d[30] & ~1; 112 | 113 | d[49] ^= x >> 7; 114 | d[50] ^= x << 1; 115 | 116 | d[59] ^= x >> 1; 117 | 118 | d[30] &= 1; 119 | } 120 | 121 | static void elt_square(u8 *d, const u8 *a) 122 | { 123 | u8 wide[60]; 124 | 125 | elt_square_to_wide(wide, a); 126 | wide_reduce(wide); 127 | 128 | elt_copy(d, wide + 30); 129 | } 130 | 131 | static void itoh_tsujii(u8 *d, const u8 *a, const u8 *b, u32 j) 132 | { 133 | u8 t[30]; 134 | 135 | elt_copy(t, a); 136 | while (j--) { 137 | elt_square(d, t); 138 | elt_copy(t, d); 139 | } 140 | 141 | elt_mul(d, t, b); 142 | } 143 | 144 | static void elt_inv(u8 *d, const u8 *a) 145 | { 146 | u8 t[30]; 147 | u8 s[30]; 148 | 149 | itoh_tsujii(t, a, a, 1); 150 | itoh_tsujii(s, t, a, 1); 151 | itoh_tsujii(t, s, s, 3); 152 | itoh_tsujii(s, t, a, 1); 153 | itoh_tsujii(t, s, s, 7); 154 | itoh_tsujii(s, t, t, 14); 155 | itoh_tsujii(t, s, a, 1); 156 | itoh_tsujii(s, t, t, 29); 157 | itoh_tsujii(t, s, s, 58); 158 | itoh_tsujii(s, t, t, 116); 159 | elt_square(d, s); 160 | } 161 | 162 | /* ----------------------------------------------------- */ 163 | 164 | static PyObject * 165 | _ec_elt_mul(PyObject *self /* Not used */, PyObject *args) 166 | { 167 | const char *a, *b; 168 | char d[30]; 169 | int la, lb; 170 | if (!PyArg_ParseTuple(args, "s#s#", &a, &la, &b, &lb)) 171 | return NULL; 172 | 173 | if(la != 30 || lb != 30) { 174 | PyErr_SetString(PyExc_ValueError, "ELT lengths must be 30"); 175 | return NULL; 176 | } 177 | elt_mul(d,a,b); 178 | return Py_BuildValue("s#", d, 30); 179 | } 180 | 181 | static PyObject * 182 | _ec_elt_inv(PyObject *self /* Not used */, PyObject *args) 183 | { 184 | const char *a; 185 | char d[30]; 186 | int la; 187 | 188 | if (!PyArg_ParseTuple(args, "s#", &a, &la)) 189 | return NULL; 190 | 191 | if(la != 30) { 192 | PyErr_SetString(PyExc_ValueError, "ELT length must be 30"); 193 | return NULL; 194 | } 195 | elt_inv(d,a); 196 | return Py_BuildValue("s#", d, 30); 197 | } 198 | 199 | static PyObject * 200 | _ec_elt_square(PyObject *self /* Not used */, PyObject *args) 201 | { 202 | const char *a; 203 | char d[30]; 204 | int la; 205 | 206 | if (!PyArg_ParseTuple(args, "s#", &a, &la)) 207 | return NULL; 208 | 209 | if(la != 30) { 210 | PyErr_SetString(PyExc_ValueError, "ELT length must be 30"); 211 | return NULL; 212 | } 213 | elt_square(d,a); 214 | return Py_BuildValue("s#", d, 30); 215 | } 216 | 217 | /* List of methods defined in the module */ 218 | 219 | static struct PyMethodDef _ec_methods[] = { 220 | {"elt_mul", (PyCFunction)_ec_elt_mul, METH_VARARGS, "Multiply two ELTs"}, 221 | {"elt_inv", (PyCFunction)_ec_elt_inv, METH_VARARGS, "Take the inverse of an ELT"}, 222 | {"elt_square", (PyCFunction)_ec_elt_square, METH_VARARGS, "Efficiently square an ELT"}, 223 | 224 | {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */ 225 | }; 226 | 227 | 228 | /* Initialization function for the module (*must* be called init_ec) */ 229 | 230 | static char _ec_module_documentation[] = 231 | "Faster C versions of some ELT functions" 232 | ; 233 | 234 | void 235 | init_ec() 236 | { 237 | PyObject *m, *d; 238 | 239 | /* Create the module and add the functions */ 240 | m = Py_InitModule4("_ec", _ec_methods, 241 | _ec_module_documentation, 242 | (PyObject*)NULL,PYTHON_API_VERSION); 243 | 244 | /* Check for errors */ 245 | if (PyErr_Occurred()) 246 | Py_FatalError("can't initialize module _ec"); 247 | } 248 | 249 | -------------------------------------------------------------------------------- /pywii/ecmodule/setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup, Extension 2 | 3 | module1 = Extension('_ec', 4 | sources = ['_ecmodule.c']) 5 | 6 | setup (name = 'ELT_C', 7 | version = '0.1', 8 | description = 'C ELT functions', 9 | ext_modules = [module1]) -------------------------------------------------------------------------------- /pywii/pywii-tools/addhash.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | import sys 3 | import re 4 | import pywii as wii 5 | 6 | hash = wii.SHA.new(open(sys.argv[2]).read()).digest().encode("hex") 7 | f = open(sys.argv[1], "r") 8 | data = f.read() 9 | f.close() 10 | data = re.sub('@SHA1SUM@', hash, data) 11 | open(sys.argv[3], "w").write(data) 12 | -------------------------------------------------------------------------------- /pywii/pywii-tools/arclist.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path, struct 4 | import pywii as wii 5 | 6 | arc = open(sys.argv[1], "rb") 7 | 8 | tag, fstoff, fstsize, dataoff = struct.unpack(">IIII16x",arc.read(0x20)) 9 | 10 | arc.seek(fstoff) 11 | fst = arc.read(fstsize) 12 | 13 | fst = wii.WiiFST(fst) 14 | 15 | fst.show() 16 | -------------------------------------------------------------------------------- /pywii/pywii-tools/arcpack.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path, struct 4 | import pywii as wii 5 | 6 | fstb = wii.WiiFSTBuilder(0x20) 7 | 8 | fstb.addfrom(sys.argv[2]) 9 | 10 | arc = open(sys.argv[1],"wb") 11 | # dummy generate to get length 12 | fstlen = len(fstb.fst.generate()) 13 | dataoff = wii.align(0x20+fstlen,0x20) 14 | fst = fstb.fst.generate(dataoff) 15 | 16 | hdr = struct.pack(">IIII16x",0x55AA382d,0x20,fstlen,dataoff) 17 | arc.write(hdr) 18 | 19 | arc.write(fst) 20 | wii.falign(arc,0x20) 21 | for f in fstb.files: 22 | data = open(f, "rb").read() 23 | arc.write(data) 24 | wii.falign(arc,0x20) 25 | 26 | arc.close() 27 | -------------------------------------------------------------------------------- /pywii/pywii-tools/certinfo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | args = sys.argv[1:] 7 | 8 | if args[0] == "-dpki": 9 | wii.loadkeys_dpki() 10 | args.pop(0) 11 | else: 12 | wii.loadkeys() 13 | 14 | certfile = args.pop(0) 15 | 16 | certs, certlist = wii.parse_certs(open(args.pop(0), "rb").read()) 17 | 18 | print "Certification file %s: " % certfile 19 | cert = wii.WiiCert(open(certfile, "rb").read()) 20 | cert.showinfo(" ") 21 | cert.showsig(certs," ") 22 | 23 | print "Certificates:" 24 | for cert in certlist: 25 | cert.showinfo(" - ") 26 | cert.showsig(certs," ") 27 | -------------------------------------------------------------------------------- /pywii/pywii-tools/discinfo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | wii.loadkeys() 7 | 8 | isofile = sys.argv[1] 9 | disc = wii.WiiDisc(isofile,readonly=True) 10 | disc.showinfo() 11 | 12 | partitions = disc.read_partitions() 13 | 14 | parts = range(len(partitions)) 15 | 16 | try: 17 | pnum = int(sys.argv[2]) 18 | partitions[pnum] 19 | parts = [pnum] 20 | except: 21 | pass 22 | 23 | for partno in parts: 24 | part = wii.WiiCachedPartition(disc,partno) 25 | part.showinfo() 26 | pdat = wii.WiiPartitionData(part) 27 | pdat.showinfo() 28 | 29 | -------------------------------------------------------------------------------- /pywii/pywii-tools/dpkisign.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii 5 | 6 | pywii.loadkeys_dpki() 7 | 8 | args = sys.argv[1:] 9 | mode = args.pop(0) 10 | infile = args.pop(0) 11 | outfile = args.pop(0) 12 | certfile = args.pop(0) 13 | issuer = args.pop(0) 14 | 15 | if sys.argv[1] == "-cetk": 16 | signed = pywii.WiiTik(open(infile, "rb").read()) 17 | elif sys.argv[1] == "-tmd": 18 | signed = pywii.WiiTmd(open(infile, "rb").read()) 19 | else: 20 | print "EYOUFAILIT" 21 | sys.exit(1) 22 | 23 | certs, certlist = pywii.parse_certs(open(certfile).read()) 24 | 25 | signed.update_issuer(issuer) 26 | 27 | if not signed.sign(certs): 28 | print "dpki signing failed" 29 | sys.exit(1) 30 | 31 | open(outfile, "wb").write(signed.data) 32 | 33 | print "successfully signed %s" % outfile 34 | sys.exit(0) 35 | 36 | -------------------------------------------------------------------------------- /pywii/pywii-tools/ecchecksig.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys 4 | import pywii as wii 5 | 6 | if len(sys.argv) != 3: 7 | print "Usage: %s keyfile.[priv|pub] infile"%sys.argv[0] 8 | sys.exit(1) 9 | 10 | if sys.argv[1] == "-": 11 | k = sys.stdin.read() 12 | else: 13 | k = open(sys.argv[1],"rb").read() 14 | if len(k) not in (30,60): 15 | print "Failed to read key" 16 | sys.exit(2) 17 | 18 | if len(k) == 30: 19 | print "Key is a private key, generating public key..." 20 | q = wii.ec.priv_to_pub(k) 21 | else: 22 | q = k 23 | 24 | print "Public key:" 25 | pq = q.encode('hex') 26 | print "X =",pq[:30] 27 | print " ",pq[30:60] 28 | print "Y =",pq[60:90] 29 | print " ",pq[90:] 30 | print 31 | 32 | indata = open(sys.argv[2],"rb").read() 33 | 34 | if len(indata) < 64 or indata[:4] != "SIG0": 35 | print "Invalid header" 36 | sys.exit(3) 37 | 38 | r = indata[4:34] 39 | s = indata[34:64] 40 | 41 | sha = wii.SHA.new(indata[64:]).digest() 42 | print "SHA1: %s"%sha.encode('hex') 43 | 44 | print 45 | print "Signature:" 46 | print "R =",r[:15].encode('hex') 47 | print " ",r[15:].encode('hex') 48 | print "S =",s[:15].encode('hex') 49 | print " ",s[15:].encode('hex') 50 | print 51 | 52 | if wii.ec.check_ecdsa(q,r,s,sha): 53 | print "Signature is VALID" 54 | else: 55 | print "Signature is INVALID" 56 | sys.exit(4) 57 | 58 | -------------------------------------------------------------------------------- /pywii/pywii-tools/ecgenpriv.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os 4 | import pywii as wii 5 | 6 | if len(sys.argv) != 2: 7 | print "Usage: %s keyfile.priv"%sys.argv[0] 8 | sys.exit(1) 9 | 10 | print "Generating private key..." 11 | 12 | k = wii.ec.gen_priv_key() 13 | 14 | print "Private key:" 15 | pk = k.encode('hex') 16 | print "K =",pk[:30] 17 | print " ",pk[30:] 18 | 19 | print 20 | print "Corresponding public key:" 21 | q = wii.ec.priv_to_pub(k) 22 | pq = q.encode('hex') 23 | print "X =",pq[:30] 24 | print " ",pq[30:60] 25 | print "Y =",pq[60:90] 26 | print " ",pq[90:] 27 | 28 | fd = open(sys.argv[1],"wb") 29 | os.fchmod(fd.fileno(), 0o600) 30 | fd.write(k) 31 | fd.close() 32 | 33 | print "Saved private key to %s"%sys.argv[1] 34 | -------------------------------------------------------------------------------- /pywii/pywii-tools/ecpriv2pub.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys 4 | import pywii as wii 5 | 6 | if len(sys.argv) not in (2,3): 7 | print "Usage: %s keyfile.priv [keyfile.pub]"%sys.argv[0] 8 | sys.exit(1) 9 | 10 | if sys.argv[1] == "-": 11 | k = sys.stdin.read() 12 | else: 13 | k = open(sys.argv[1],"rb").read() 14 | if len(k) != 30: 15 | print "Failed to read private key" 16 | sys.exit(2) 17 | 18 | print "Public key:" 19 | q = wii.ec.priv_to_pub(k) 20 | pq = q.encode('hex') 21 | print "X =",pq[:30] 22 | print " ",pq[30:60] 23 | print "Y =",pq[60:90] 24 | print " ",pq[90:] 25 | 26 | if len(sys.argv) == 3: 27 | fd = open(sys.argv[2],"wb") 28 | fd.write(q) 29 | fd.close() 30 | print "Saved public key to %s"%sys.argv[2] 31 | -------------------------------------------------------------------------------- /pywii/pywii-tools/ecsign.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys 4 | import pywii as wii 5 | 6 | if len(sys.argv) != 4: 7 | print "Usage: %s keyfile.priv infile outfile"%sys.argv[0] 8 | sys.exit(1) 9 | 10 | if sys.argv[1] == "-": 11 | k = sys.stdin.read() 12 | else: 13 | k = open(sys.argv[1],"rb").read() 14 | 15 | if len(k) != 30: 16 | print "Failed to read private key" 17 | sys.exit(2) 18 | 19 | indata = open(sys.argv[2],"rb").read() 20 | sha = wii.SHA.new(indata).digest() 21 | 22 | print "SHA1: %s"%sha.encode('hex') 23 | print 24 | print "Signature:" 25 | r,s = wii.ec.generate_ecdsa(k,sha) 26 | print "R =",r[:15].encode('hex') 27 | print " ",r[15:].encode('hex') 28 | print "S =",s[:15].encode('hex') 29 | print " ",s[15:].encode('hex') 30 | 31 | outdata = "SIG0" + r + s + indata 32 | 33 | fd = open(sys.argv[3],"wb") 34 | fd.write(outdata) 35 | fd.close() 36 | -------------------------------------------------------------------------------- /pywii/pywii-tools/extract.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | wii.loadkeys() 7 | 8 | def parseint(d): 9 | if len(d) > 2 and d[0:2].lower()=='0x': 10 | return int(d,16) 11 | return int(d) 12 | 13 | if len(sys.argv) < 4 or len(sys.argv) > 7: 14 | print "Usage:" 15 | print " python %s [Partition offset] [length]"%sys.argv[0] 16 | sys.exit(1) 17 | 18 | iso_name, partno, data_name = sys.argv[1:4] 19 | partno = int(partno) 20 | part_offset = 0 21 | data_offset = 0 22 | copy_length = None 23 | 24 | if len(sys.argv) >= 5: 25 | part_offset = parseint(sys.argv[4]) 26 | if len(sys.argv) == 6: 27 | copy_length = parseint(sys.argv[5]) 28 | 29 | if copy_length is not None and copy_length < 0: 30 | print "Error: negative copy length" 31 | sys.exit(1) 32 | 33 | disc = wii.WiiDisc(iso_name) 34 | disc.showinfo() 35 | part = wii.WiiCachedPartition(disc, partno, cachesize=32, debug=False, checkhash=False) 36 | if part_offset >= part.data_bytes: 37 | print "Error: Offset past end of partition" 38 | sys.exit(1) 39 | if copy_length is None: 40 | copy_length = part.data_bytes - part_offset 41 | if copy_length > (part.data_bytes - part_offset): 42 | print "Error: Length too large" 43 | sys.exit(1) 44 | 45 | dataf = open(data_name, "wb") 46 | left = copy_length 47 | offset = part_offset 48 | while left > 0: 49 | blocklen = min(left, 4*1024*1024) 50 | d = part.read(offset, blocklen) 51 | if len(d) != blocklen: 52 | print "Part EOF reached!" 53 | sys.exit(1) 54 | dataf.write(d) 55 | offset += blocklen 56 | left -= blocklen 57 | 58 | dataf.close() 59 | 60 | -------------------------------------------------------------------------------- /pywii/pywii-tools/extractdol.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python2 2 | 3 | import sys, os, os.path 4 | sys.path.append(os.path.realpath(os.path.dirname(sys.argv[0]))+"/../Common") 5 | import pywii as wii 6 | 7 | wii.loadkeys(os.environ["HOME"]+os.sep+".wii") 8 | 9 | if len(sys.argv) != 4: 10 | print "Usage:" 11 | print " python %s "%sys.argv[0] 12 | sys.exit(1) 13 | 14 | iso_name, partno, dol_name = sys.argv[1:4] 15 | partno = int(partno) 16 | 17 | disc = wii.WiiDisc(iso_name) 18 | disc.showinfo() 19 | part = wii.WiiCachedPartition(disc, partno, cachesize=32, debug=False) 20 | partdata = wii.WiiPartitionData(part) 21 | 22 | dolf = open(dol_name, "wb") 23 | dolf.write(partdata.dol) 24 | dolf.close() 25 | 26 | 27 | -------------------------------------------------------------------------------- /pywii/pywii-tools/extractfiles.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | wii.loadkeys() 7 | 8 | def parseint(d): 9 | if len(d) > 2 and d[0:2].lower()=='0x': 10 | return int(d,16) 11 | return int(d) 12 | 13 | if len(sys.argv) < 4 or len(sys.argv) > 7: 14 | print "Usage:" 15 | print " python %s "%sys.argv[0] 16 | sys.exit(1) 17 | 18 | iso_name, partno, data_name = sys.argv[1:4] 19 | partno = int(partno) 20 | part_offset = 0 21 | data_offset = 0 22 | copy_length = None 23 | 24 | if len(sys.argv) >= 5: 25 | part_offset = parseint(sys.argv[4]) 26 | if len(sys.argv) == 6: 27 | copy_length = parseint(sys.argv[5]) 28 | 29 | if copy_length is not None and copy_length < 0: 30 | print "Error: negative copy length" 31 | sys.exit(1) 32 | 33 | disc = wii.WiiDisc(iso_name) 34 | disc.showinfo() 35 | part = wii.WiiCachedPartition(disc, partno, cachesize=32, debug=False, checkhash=False) 36 | if part_offset >= part.data_bytes: 37 | print "Error: Offset past end of partition" 38 | sys.exit(1) 39 | if copy_length is None: 40 | copy_length = part.data_bytes - part_offset 41 | if copy_length > (part.data_bytes - part_offset): 42 | print "Error: Length too large" 43 | sys.exit(1) 44 | 45 | dataf = open(data_name, "wb") 46 | left = copy_length 47 | offset = part_offset 48 | while left > 0: 49 | blocklen = min(left, 4*1024*1024) 50 | d = part.read(offset, blocklen) 51 | if len(d) != blocklen: 52 | print "Part EOF reached!" 53 | sys.exit(1) 54 | dataf.write(d) 55 | offset += blocklen 56 | left -= blocklen 57 | 58 | dataf.close() 59 | 60 | -------------------------------------------------------------------------------- /pywii/pywii-tools/getappldr.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | wii.loadkeys() 7 | 8 | if len(sys.argv) != 5: 9 | print "Usage:" 10 | print " python %s "%sys.argv[0] 11 | sys.exit(1) 12 | 13 | iso_name, partno, app_name, trail_name = sys.argv[1:5] 14 | partno = int(partno) 15 | 16 | disc = wii.WiiDisc(iso_name) 17 | disc.showinfo() 18 | part = wii.WiiCachedPartition(disc, partno, cachesize=32, debug=False) 19 | partdata = wii.WiiPartitionData(part) 20 | 21 | apploader = partdata.apploader 22 | apploader.showinfo() 23 | open(app_name,"wb").write(apploader.text) 24 | open(trail_name,"wb").write(apploader.trailer) 25 | -------------------------------------------------------------------------------- /pywii/pywii-tools/inject.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | wii.loadkeys() 7 | 8 | def parseint(d): 9 | if len(d) > 2 and d[0:2].lower()=='0x': 10 | return int(d,16) 11 | return int(d) 12 | 13 | if len(sys.argv) < 4 or len(sys.argv) > 7: 14 | print "Usage:" 15 | print " python %s [Partition offset] [data offset] [length]"%sys.argv[0] 16 | sys.exit(1) 17 | 18 | iso_name, partno, data_name = sys.argv[1:4] 19 | partno = int(partno) 20 | part_offset = 0 21 | data_offset = 0 22 | copy_length = None 23 | 24 | if len(sys.argv) >= 5: 25 | part_offset = parseint(sys.argv[4]) 26 | if len(sys.argv) >= 6: 27 | data_offset = parseint(sys.argv[5]) 28 | if len(sys.argv) == 7: 29 | copy_length = parseint(sys.argv[6]) 30 | 31 | data_len = os.stat(data_name).st_size 32 | 33 | if copy_length == None: 34 | copy_length = data_len - data_offset 35 | copy_end = data_offset + copy_length 36 | if copy_length < 0: 37 | print "Error: negative copy length" 38 | sys.exit(1) 39 | if copy_end > data_len: 40 | print "Error: data file is too small" 41 | sys.exit(1) 42 | 43 | disc = wii.WiiDisc(iso_name) 44 | disc.showinfo() 45 | part = wii.WiiCachedPartition(disc, partno, cachesize=32, debug=False, checkhash=False) 46 | 47 | dataf = open(data_name, "rb") 48 | dataf.seek(data_offset) 49 | left = copy_length 50 | offset = part_offset 51 | while left > 0: 52 | blocklen = min(left, 4*1024*1024) 53 | d = dataf.read(blocklen) 54 | if len(d) != blocklen: 55 | print "File EOF reached!" 56 | sys.exit(1) 57 | part.write(offset, d) 58 | offset += blocklen 59 | left -= blocklen 60 | 61 | part.flush() 62 | part.update() 63 | part.tmd.null_signature() 64 | part.tmd.brute_sha() 65 | part.updatetmd() 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /pywii/pywii-tools/injectdol.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | wii.loadkeys() 7 | 8 | if len(sys.argv) != 4: 9 | print "Usage:" 10 | print " python %s "%sys.argv[0] 11 | sys.exit(1) 12 | 13 | iso_name, partno, dol_name = sys.argv[1:4] 14 | partno = int(partno) 15 | 16 | doldata = open(dol_name, "rb").read() 17 | 18 | disc = wii.WiiDisc(iso_name) 19 | disc.showinfo() 20 | part = wii.WiiCachedPartition(disc, partno, cachesize=32, debug=False) 21 | partdata = wii.WiiPartitionData(part) 22 | partdata.replacedol(doldata) 23 | 24 | part.flush() 25 | part.update() 26 | part.tmd.null_signature() 27 | part.tmd.brute_sha() 28 | part.updatetmd() 29 | part.showinfo() 30 | 31 | 32 | -------------------------------------------------------------------------------- /pywii/pywii-tools/partsetios.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | wii.loadkeys() 7 | 8 | if len(sys.argv) != 4: 9 | print "Usage:" 10 | print " python %s "%sys.argv[0] 11 | print " IOS version should be just the minor number (16, 33, etc) in decimal" 12 | sys.exit(1) 13 | 14 | iso_name, partno, ios = sys.argv[1:4] 15 | partno = int(partno) 16 | iosno = int(ios) 17 | 18 | disc = wii.WiiDisc(iso_name) 19 | disc.showinfo() 20 | part = wii.WiiCachedPartition(disc, partno, cachesize=32, debug=False) 21 | part.tmd.sys_version = 0x100000000 + iosno 22 | part.tmd.update() 23 | part.tmd.null_signature() 24 | part.tmd.brute_sha() 25 | part.updatetmd() 26 | part.showinfo() 27 | 28 | 29 | -------------------------------------------------------------------------------- /pywii/pywii-tools/pywii: -------------------------------------------------------------------------------- 1 | ../Common/pywii -------------------------------------------------------------------------------- /pywii/pywii-tools/rsapatch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | def hexdump(s): 7 | return ' '.join(map(lambda x: "%02x"%x,map(ord,s))) 8 | 9 | isofile = sys.argv[1] 10 | disc = WiiDisc(isofile) 11 | disc.showinfo() 12 | part = WiiPartition(disc,int(sys.argv[2])) 13 | part.showinfo() 14 | 15 | part.tmd.update_signature(file("signthree.bin").read()) 16 | part.tmd.brute_sha() 17 | part.updatetmd() 18 | 19 | part.showinfo() 20 | 21 | -------------------------------------------------------------------------------- /pywii/pywii-tools/saveinfo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | wii.loadkeys() 7 | 8 | savefile = sys.argv[1] 9 | save = wii.WiiSave(savefile) 10 | save.showcerts() 11 | -------------------------------------------------------------------------------- /pywii/pywii-tools/tikfix.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | wii.loadkeys() 7 | 8 | tikfile = sys.argv[1] 9 | print "fixing Tik file %s " % tikfile 10 | tik = wii.WiiTik(open(tikfile, "rb").read()) 11 | tik.null_signature() 12 | tik.brute_sha() 13 | tik.update() 14 | f = open(tikfile,"wb") 15 | f.write(tik.data) 16 | f.close() 17 | 18 | -------------------------------------------------------------------------------- /pywii/pywii-tools/tikinfo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | args = sys.argv[1:] 7 | 8 | if args[0] == "-dpki": 9 | wii.loadkeys_dpki() 10 | args.pop(0) 11 | else: 12 | wii.loadkeys() 13 | 14 | tikfile = args.pop(0) 15 | 16 | certs = None 17 | if len(args) > 0: 18 | certs, certlist = wii.parse_certs(open(args.pop(0), "rb").read()) 19 | 20 | print "ETicket file %s:"%tikfile 21 | tik = wii.WiiTik(open(tikfile, "rb").read()) 22 | tik.showinfo(" ") 23 | if certs is not None: 24 | tik.showsig(certs," ") 25 | print "Certificates:" 26 | for cert in certlist: 27 | cert.showinfo(" - ") 28 | cert.showsig(certs," ") 29 | -------------------------------------------------------------------------------- /pywii/pywii-tools/tmdfix.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | wii.loadkeys() 7 | 8 | tmdfile = sys.argv[1] 9 | print "TMD file %s:"%tmdfile 10 | tmd = wii.WiiTmd(open(tmdfile, "rb").read()) 11 | tmd.null_signature() 12 | tmd.brute_sha() 13 | tmd.update() 14 | tmd.parse() 15 | tmd.showinfo(" ") 16 | f = open(tmdfile,"wb") 17 | f.write(tmd.data) 18 | f.close() 19 | -------------------------------------------------------------------------------- /pywii/pywii-tools/tmdinfo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | args = sys.argv[1:] 7 | 8 | if args[0] == "-dpki": 9 | wii.loadkeys_dpki() 10 | args.pop(0) 11 | else: 12 | wii.loadkeys() 13 | 14 | tmdfile = args.pop(0) 15 | 16 | certs = None 17 | if len(args) > 0: 18 | certs, certlist = wii.parse_certs(open(args.pop(0), "rb").read()) 19 | 20 | print "TMD file %s:"%tmdfile 21 | tmd = wii.WiiTmd(open(tmdfile, "rb").read()) 22 | tmd.showinfo(" ") 23 | if certs is not None: 24 | tmd.showsig(certs," ") 25 | print "Certificates:" 26 | for cert in certlist: 27 | cert.showinfo(" - ") 28 | cert.showsig(certs," ") 29 | -------------------------------------------------------------------------------- /pywii/pywii-tools/tmdupdatecr.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | try: 6 | from Cryptodome.Hash import SHA 7 | except ImportError: 8 | from Crypto.Hash import SHA 9 | 10 | wii.loadkeys() 11 | 12 | args = sys.argv[1:] 13 | 14 | tmdfile = args.pop(0) 15 | indir = args.pop(0) 16 | 17 | print "updating content records of TMD file %s" % tmdfile 18 | tmd = wii.WiiTmd(open(tmdfile, "rb").read()) 19 | 20 | for i, cr in enumerate(tmd.get_content_records()): 21 | data = open(os.path.join(indir, "%08X" % cr.cid), "rb").read() 22 | cr.sha = SHA.new(data).digest() 23 | cr.size = len(data) 24 | tmd.update_content_record(i, cr) 25 | 26 | tmd.null_signature() 27 | tmd.brute_sha() 28 | tmd.update() 29 | f = open(tmdfile, "wb") 30 | f.write(tmd.data) 31 | f.close() 32 | 33 | -------------------------------------------------------------------------------- /pywii/pywii-tools/tmdvers.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | wii.loadkeys() 7 | 8 | args = sys.argv[1:] 9 | 10 | tmdfile = args.pop(0) 11 | 12 | if len(args) == 2: 13 | newvers = int(args.pop(0)) << 8 | int(args.pop(0)) 14 | else: 15 | newvers = int(args.pop(0), 16) 16 | 17 | print "setting version of TMD file %s to 0x%04x" % (tmdfile, newvers) 18 | tmd = wii.WiiTmd(open(tmdfile, "rb").read()) 19 | tmd.title_version = newvers 20 | tmd.update() 21 | f = open(tmdfile,"wb") 22 | f.write(tmd.data) 23 | f.close() 24 | -------------------------------------------------------------------------------- /pywii/pywii-tools/wadinfo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | args = sys.argv[1:] 7 | 8 | if args[0] == "-dpki": 9 | wii.loadkeys_dpki() 10 | args.pop(0) 11 | else: 12 | wii.loadkeys() 13 | 14 | wadfile = args.pop(0) 15 | wad = wii.WiiWad(wadfile) 16 | wad.showinfo() 17 | -------------------------------------------------------------------------------- /pywii/pywii-tools/wadpack-boot2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | wii.loadkeys() 7 | 8 | wadfile = sys.argv[1] 9 | indir = sys.argv[2] 10 | 11 | tmd = wii.WiiTmd(open(indir+os.sep+"tmd", "rb").read()) 12 | tik = wii.WiiTik(open(indir+os.sep+"cetk", "rb").read()) 13 | 14 | certs, certlist = wii.parse_certs(open(os.path.join(indir, "certs"), "rb").read()) 15 | 16 | footer = open(indir+os.sep+"footer", "rb").read() 17 | 18 | wad = wii.WiiWadMaker(wadfile, tmd, tik, certlist, footer, nandwad=True) 19 | 20 | for i,ct in enumerate(tmd.get_content_records()): 21 | data = open(indir+os.sep+"%08X"%ct.cid, "rb").read() 22 | wad.adddata(data,ct.cid) 23 | 24 | wad.finish() 25 | 26 | if not wad.tik.signcheck(wad.certs): 27 | wad.tik.null_signature() 28 | wad.tik.brute_sha() 29 | wad.updatetik() 30 | 31 | if not wad.tmd.signcheck(wad.certs): 32 | wad.tmd.null_signature() 33 | wad.tmd.brute_sha() 34 | wad.updatetmd() 35 | -------------------------------------------------------------------------------- /pywii/pywii-tools/wadpack.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | args = sys.argv[1:] 7 | 8 | if args[0] == "-dpki": 9 | wii.loadkeys_dpki() 10 | args.pop(0) 11 | else: 12 | wii.loadkeys() 13 | 14 | wadfile = args.pop(0) 15 | indir = args.pop(0) 16 | 17 | tmd = wii.WiiTmd(open(os.path.join(indir, "tmd"), "rb").read()) 18 | tik = wii.WiiTik(open(os.path.join(indir, "cetk"), "rb").read()) 19 | 20 | certs, certlist = wii.parse_certs(open(os.path.join(indir, "certs"), "rb").read()) 21 | 22 | footer = open(os.path.join(indir, "footer"), "rb").read() 23 | 24 | wad = wii.WiiWadMaker(wadfile, tmd, tik, certlist, footer) 25 | 26 | for i,ct in enumerate(tmd.get_content_records()): 27 | data = open(os.path.join(indir, "%08X" % ct.cid), "rb").read() 28 | wad.adddata(data,ct.cid) 29 | 30 | wad.finish() 31 | 32 | if not wad.tik.signcheck(wad.certs): 33 | wad.tik.null_signature() 34 | wad.tik.brute_sha() 35 | wad.updatetik() 36 | 37 | if not wad.tmd.signcheck(wad.certs): 38 | wad.tmd.null_signature() 39 | wad.tmd.brute_sha() 40 | wad.updatetmd() 41 | -------------------------------------------------------------------------------- /pywii/pywii-tools/wadunpack.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import sys, os, os.path 4 | import pywii as wii 5 | 6 | args = sys.argv[1:] 7 | 8 | if args[0] == "-dpki": 9 | wii.loadkeys_dpki() 10 | args.pop(0) 11 | else: 12 | wii.loadkeys() 13 | 14 | wadfile = args.pop(0) 15 | outdir = args.pop(0) 16 | wad = wii.WiiWad(wadfile) 17 | wad.showinfo() 18 | 19 | if not os.path.isdir(outdir): 20 | os.mkdir(outdir) 21 | 22 | for ct in wad.tmd.get_content_records(): 23 | data = wad.getcontent(ct.index) 24 | f = open(os.path.join(outdir, "%08X" % ct.cid),"wb") 25 | f.write(data) 26 | f.close() 27 | 28 | f = open(os.path.join(outdir, "cetk"),"wb") 29 | f.write(wad.tik.data) 30 | f.close() 31 | 32 | f = open(os.path.join(outdir, "tmd"),"wb") 33 | f.write(wad.tmd.data) 34 | f.close() 35 | 36 | f = open(os.path.join(outdir, "certs"),"wb") 37 | for cert in wad.certlist: 38 | f.write(cert.data) 39 | wii.falign(f,0x40) 40 | f.close() 41 | 42 | f = open(os.path.join(outdir, "footer"),"wb") 43 | f.write(wad.footer) 44 | f.close() 45 | -------------------------------------------------------------------------------- /wiipax/.gitignore: -------------------------------------------------------------------------------- 1 | *.map 2 | 3 | -------------------------------------------------------------------------------- /wiipax/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | $(MAKE) -C stub release 3 | $(MAKE) -C client 4 | 5 | clean distclean: 6 | $(MAKE) -C stub distclean 7 | $(MAKE) -C client clean 8 | 9 | install: 10 | $(MAKE) -C client install 11 | 12 | -------------------------------------------------------------------------------- /wiipax/client/.gitignore: -------------------------------------------------------------------------------- 1 | wiipax 2 | out.elf 3 | x.lzma 4 | 5 | -------------------------------------------------------------------------------- /wiipax/client/LzFind.h: -------------------------------------------------------------------------------- 1 | /* LzFind.h -- Match finder for LZ algorithms 2 | 2008-10-04 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZFIND_H 5 | #define __LZFIND_H 6 | 7 | #include "Types.h" 8 | 9 | typedef UInt32 CLzRef; 10 | 11 | typedef struct _CMatchFinder 12 | { 13 | Byte *buffer; 14 | UInt32 pos; 15 | UInt32 posLimit; 16 | UInt32 streamPos; 17 | UInt32 lenLimit; 18 | 19 | UInt32 cyclicBufferPos; 20 | UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */ 21 | 22 | UInt32 matchMaxLen; 23 | CLzRef *hash; 24 | CLzRef *son; 25 | UInt32 hashMask; 26 | UInt32 cutValue; 27 | 28 | Byte *bufferBase; 29 | ISeqInStream *stream; 30 | int streamEndWasReached; 31 | 32 | UInt32 blockSize; 33 | UInt32 keepSizeBefore; 34 | UInt32 keepSizeAfter; 35 | 36 | UInt32 numHashBytes; 37 | int directInput; 38 | int btMode; 39 | /* int skipModeBits; */ 40 | int bigHash; 41 | UInt32 historySize; 42 | UInt32 fixedHashSize; 43 | UInt32 hashSizeSum; 44 | UInt32 numSons; 45 | SRes result; 46 | UInt32 crc[256]; 47 | } CMatchFinder; 48 | 49 | #define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer) 50 | #define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)]) 51 | 52 | #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos) 53 | 54 | int MatchFinder_NeedMove(CMatchFinder *p); 55 | Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p); 56 | void MatchFinder_MoveBlock(CMatchFinder *p); 57 | void MatchFinder_ReadIfRequired(CMatchFinder *p); 58 | 59 | void MatchFinder_Construct(CMatchFinder *p); 60 | 61 | /* Conditions: 62 | historySize <= 3 GB 63 | keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB 64 | */ 65 | int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, 66 | UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, 67 | ISzAlloc *alloc); 68 | void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc); 69 | void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems); 70 | void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue); 71 | 72 | UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son, 73 | UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue, 74 | UInt32 *distances, UInt32 maxLen); 75 | 76 | /* 77 | Conditions: 78 | Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func. 79 | Mf_GetPointerToCurrentPos_Func's result must be used only before any other function 80 | */ 81 | 82 | typedef void (*Mf_Init_Func)(void *object); 83 | typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index); 84 | typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object); 85 | typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object); 86 | typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances); 87 | typedef void (*Mf_Skip_Func)(void *object, UInt32); 88 | 89 | typedef struct _IMatchFinder 90 | { 91 | Mf_Init_Func Init; 92 | Mf_GetIndexByte_Func GetIndexByte; 93 | Mf_GetNumAvailableBytes_Func GetNumAvailableBytes; 94 | Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos; 95 | Mf_GetMatches_Func GetMatches; 96 | Mf_Skip_Func Skip; 97 | } IMatchFinder; 98 | 99 | void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable); 100 | 101 | void MatchFinder_Init(CMatchFinder *p); 102 | UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); 103 | UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); 104 | void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); 105 | void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /wiipax/client/LzHash.h: -------------------------------------------------------------------------------- 1 | /* LzHash.h -- HASH functions for LZ algorithms 2 | 2008-10-04 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZHASH_H 5 | #define __LZHASH_H 6 | 7 | #define kHash2Size (1 << 10) 8 | #define kHash3Size (1 << 16) 9 | #define kHash4Size (1 << 20) 10 | 11 | #define kFix3HashSize (kHash2Size) 12 | #define kFix4HashSize (kHash2Size + kHash3Size) 13 | #define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) 14 | 15 | #define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8); 16 | 17 | #define HASH3_CALC { \ 18 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 19 | hash2Value = temp & (kHash2Size - 1); \ 20 | hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; } 21 | 22 | #define HASH4_CALC { \ 23 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 24 | hash2Value = temp & (kHash2Size - 1); \ 25 | hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ 26 | hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; } 27 | 28 | #define HASH5_CALC { \ 29 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 30 | hash2Value = temp & (kHash2Size - 1); \ 31 | hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ 32 | hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \ 33 | hashValue = (hash4Value ^ (p->crc[cur[4]] << 3)) & p->hashMask; \ 34 | hash4Value &= (kHash4Size - 1); } 35 | 36 | /* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */ 37 | #define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF; 38 | 39 | 40 | #define MT_HASH2_CALC \ 41 | hash2Value = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1); 42 | 43 | #define MT_HASH3_CALC { \ 44 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 45 | hash2Value = temp & (kHash2Size - 1); \ 46 | hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } 47 | 48 | #define MT_HASH4_CALC { \ 49 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 50 | hash2Value = temp & (kHash2Size - 1); \ 51 | hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ 52 | hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /wiipax/client/LzmaEnc.h: -------------------------------------------------------------------------------- 1 | /* LzmaEnc.h -- LZMA Encoder 2 | 2008-10-04 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZMAENC_H 5 | #define __LZMAENC_H 6 | 7 | #include "Types.h" 8 | 9 | #define LZMA_PROPS_SIZE 5 10 | 11 | typedef struct _CLzmaEncProps 12 | { 13 | int level; /* 0 <= level <= 9 */ 14 | UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version 15 | (1 << 12) <= dictSize <= (1 << 30) for 64-bit version 16 | default = (1 << 24) */ 17 | int lc; /* 0 <= lc <= 8, default = 3 */ 18 | int lp; /* 0 <= lp <= 4, default = 0 */ 19 | int pb; /* 0 <= pb <= 4, default = 2 */ 20 | int algo; /* 0 - fast, 1 - normal, default = 1 */ 21 | int fb; /* 5 <= fb <= 273, default = 32 */ 22 | int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */ 23 | int numHashBytes; /* 2, 3 or 4, default = 4 */ 24 | UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */ 25 | unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */ 26 | int numThreads; /* 1 or 2, default = 2 */ 27 | } CLzmaEncProps; 28 | 29 | void LzmaEncProps_Init(CLzmaEncProps *p); 30 | void LzmaEncProps_Normalize(CLzmaEncProps *p); 31 | UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2); 32 | 33 | 34 | /* ---------- CLzmaEncHandle Interface ---------- */ 35 | 36 | /* LzmaEnc_* functions can return the following exit codes: 37 | Returns: 38 | SZ_OK - OK 39 | SZ_ERROR_MEM - Memory allocation error 40 | SZ_ERROR_PARAM - Incorrect paramater in props 41 | SZ_ERROR_WRITE - Write callback error. 42 | SZ_ERROR_PROGRESS - some break from progress callback 43 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) 44 | */ 45 | 46 | typedef void * CLzmaEncHandle; 47 | 48 | CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc); 49 | void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig); 50 | SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props); 51 | SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size); 52 | SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream, 53 | ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); 54 | SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, 55 | int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); 56 | 57 | /* ---------- One Call Interface ---------- */ 58 | 59 | /* LzmaEncode 60 | Return code: 61 | SZ_OK - OK 62 | SZ_ERROR_MEM - Memory allocation error 63 | SZ_ERROR_PARAM - Incorrect paramater 64 | SZ_ERROR_OUTPUT_EOF - output buffer overflow 65 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) 66 | */ 67 | 68 | SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, 69 | const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, 70 | ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /wiipax/client/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS = -Wall -W -Os -g 2 | TARGET = wiipax 3 | OBJS = LzFind.o LzmaEnc.o LzmaDec.o lzma.o main.o 4 | OBJS += stub_mini.o stub_mini_debug.o 5 | OBJS += stub_dkp.o stub_dkp_debug.o 6 | OBJS += stub_dkpc.o stub_dkpc_debug.o 7 | 8 | NOMAPFILE = 1 9 | 10 | include ../../common.mk 11 | 12 | install: all 13 | install -m 755 $(TARGET) $(WIIDEV)/bin 14 | 15 | -------------------------------------------------------------------------------- /wiipax/client/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | typedef unsigned char u8; 5 | typedef signed char s8; 6 | typedef unsigned short u16; 7 | typedef signed short s16; 8 | typedef unsigned int u32; 9 | typedef signed int s32; 10 | typedef unsigned long long u64; 11 | typedef signed long long s64; 12 | 13 | #define round_up(x,n) (-(-(x) & -(n))) 14 | 15 | #define die(...) { \ 16 | fprintf(stderr, __VA_ARGS__); \ 17 | fprintf(stderr, "\n"); exit(1); \ 18 | } 19 | 20 | #define perrordie(x) { perror(x); exit(1); } 21 | 22 | #if BYTE_ORDER == BIG_ENDIAN 23 | 24 | #define be32(x) (x) 25 | #define be16(x) (x) 26 | 27 | #else 28 | 29 | static inline u32 be32(const u32 v) { 30 | return (v >> 24) | 31 | ((v >> 8) & 0x0000FF00) | 32 | ((v << 8) & 0x00FF0000) | 33 | (v << 24); 34 | } 35 | 36 | static inline u16 be16(const u16 v) { 37 | return (v >> 8) | (v << 8); 38 | } 39 | 40 | #endif /* BIG_ENDIAN */ 41 | 42 | #endif /* _COMMON_H_ */ 43 | 44 | -------------------------------------------------------------------------------- /wiipax/client/lzma.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "common.h" 9 | #include "lzma.h" 10 | 11 | #include "LzmaDec.h" 12 | 13 | static void *lz_malloc(void *p, size_t size) { 14 | (void) p; 15 | return malloc(size); 16 | } 17 | 18 | static void lz_free(void *p, void *address) { 19 | (void) p; 20 | free(address); 21 | } 22 | 23 | static ISzAlloc lz_alloc = { lz_malloc, lz_free }; 24 | 25 | static lzma_t *lzma_alloc(const u32 len) { 26 | lzma_t *lzma; 27 | 28 | lzma = (lzma_t *) calloc(1, sizeof(lzma_t)); 29 | 30 | if (!lzma) 31 | die("Failed to alloc 0x%x bytes", (u32) sizeof(lzma_t)); 32 | 33 | lzma->data = calloc(1, len); 34 | if (!lzma->data) 35 | die("Failed to alloc 0x%x bytes", len); 36 | 37 | return lzma; 38 | } 39 | 40 | void lzma_free(lzma_t *lzma) { 41 | free(lzma->data); 42 | free(lzma); 43 | } 44 | 45 | lzma_t *lzma_compress(const u8 *src, const u32 len) { 46 | lzma_t *lzma; 47 | CLzmaEncProps props; 48 | size_t len_out; 49 | size_t len_props = LZMA_PROPS_SIZE; 50 | SRes res; 51 | 52 | printf("Compressing..."); 53 | fflush(stdout); 54 | 55 | lzma = lzma_alloc(2*len); 56 | 57 | LzmaEncProps_Init(&props); 58 | props.level = 7; 59 | LzmaEncProps_Normalize(&props); 60 | 61 | len_out = 2*len; 62 | res = LzmaEncode(lzma->data, &len_out, src, len, &props, lzma->props, 63 | &len_props, 1, NULL, &lz_alloc, &lz_alloc); 64 | 65 | if (res != SZ_OK) 66 | die(" failed (%d)", res); 67 | 68 | if (len_props != LZMA_PROPS_SIZE) 69 | die(" failed: encoder propsize %u != %u", (u32) len_props, 70 | LZMA_PROPS_SIZE); 71 | 72 | printf(" %u -> %u = %3.2f%%\n", len, (u32) len_out, 73 | 100.0 * (float) len_out / (float) len); 74 | 75 | lzma->len_in = len; 76 | lzma->len_out = len_out; 77 | 78 | return lzma; 79 | } 80 | 81 | void lzma_decode(const lzma_t *lzma, u8 *dst) { 82 | SizeT len_in; 83 | SizeT len_out; 84 | ELzmaStatus status; 85 | SRes res; 86 | 87 | len_in = lzma->len_out; 88 | len_out = lzma->len_in; 89 | 90 | res = LzmaDecode(dst, &len_out, lzma->data, &len_in, lzma->props, 91 | LZMA_PROPS_SIZE, LZMA_FINISH_END, &status, &lz_alloc); 92 | 93 | if (res != SZ_OK) 94 | die("Error decoding %d (%u)\n", res, status); 95 | 96 | *dst = len_out; 97 | } 98 | 99 | void lzma_write(const char *filename, const lzma_t *lzma) { 100 | int fd; 101 | int i; 102 | 103 | fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0755); 104 | if (fd < 0) 105 | perrordie("Could not open file"); 106 | 107 | if (write(fd, lzma->props, LZMA_PROPS_SIZE) != LZMA_PROPS_SIZE) 108 | perrordie("Could not write to file"); 109 | 110 | u64 size = lzma->len_in; 111 | for (i = 0; i < 8; ++i) { 112 | u8 j = size & 0xff; 113 | size >>= 8; 114 | if (write(fd, &j, 1) != 1) 115 | perrordie("Could not write to file"); 116 | } 117 | 118 | if (write(fd, lzma->data, lzma->len_out) != lzma->len_out) 119 | perrordie("Could not write to file"); 120 | 121 | close(fd); 122 | } 123 | 124 | -------------------------------------------------------------------------------- /wiipax/client/lzma.h: -------------------------------------------------------------------------------- 1 | #ifndef _LZMA_H_ 2 | #define _LZMA_H_ 3 | 4 | #include "common.h" 5 | #include "LzmaEnc.h" 6 | 7 | typedef struct { 8 | u32 len_in; 9 | u32 len_out; 10 | u8 props[LZMA_PROPS_SIZE]; 11 | u8 *data; 12 | } lzma_t; 13 | 14 | lzma_t *lzma_compress(const u8 *src, const u32 len); 15 | void lzma_decode(const lzma_t *lzma, u8 *dst); 16 | void lzma_write(const char *filename, const lzma_t *lzma); 17 | void lzma_free(lzma_t *lzma); 18 | 19 | #endif /* _LZMA_H_ */ 20 | 21 | -------------------------------------------------------------------------------- /wiipax/client/stub_dkp.c: -------------------------------------------------------------------------------- 1 | ../stub/stub_dkp.c -------------------------------------------------------------------------------- /wiipax/client/stub_dkp_debug.c: -------------------------------------------------------------------------------- 1 | ../stub/stub_dkp_debug.c -------------------------------------------------------------------------------- /wiipax/client/stub_dkpc.c: -------------------------------------------------------------------------------- 1 | ../stub/stub_dkpc.c -------------------------------------------------------------------------------- /wiipax/client/stub_dkpc_debug.c: -------------------------------------------------------------------------------- 1 | ../stub/stub_dkpc_debug.c -------------------------------------------------------------------------------- /wiipax/client/stub_mini.c: -------------------------------------------------------------------------------- 1 | ../stub/stub_mini.c -------------------------------------------------------------------------------- /wiipax/client/stub_mini_debug.c: -------------------------------------------------------------------------------- 1 | ../stub/stub_mini_debug.c -------------------------------------------------------------------------------- /wiipax/stub/.gitignore: -------------------------------------------------------------------------------- 1 | stub_*.elf 2 | stub_*.c 3 | 4 | -------------------------------------------------------------------------------- /wiipax/stub/Makefile: -------------------------------------------------------------------------------- 1 | include ../../broadway.mk 2 | 3 | CFLAGS += -mno-eabi -mno-sdata -O2 -ffreestanding 4 | CFLAGS += -Wall -Wextra 5 | DEFINES = 6 | LDFLAGS += -nostartfiles -nodefaultlibs 7 | 8 | OBJS_COMMON = crt0.o main.o string.o sync.o elf.o time.o LzmaDec.o 9 | TARGET_ID = 10 | 11 | ifeq ($(DKPPC),1) 12 | DEFINES += -DDKPPC 13 | OBJS = $(OBJS_COMMON) 14 | LDSCRIPT = devkitppc.ld 15 | TARGET_ID = _dkp 16 | else 17 | ifeq ($(DKPPCCHANNEL),1) 18 | DEFINES += -DDKPPC 19 | OBJS = realmode.o $(OBJS_COMMON) 20 | LDSCRIPT = channel.ld 21 | TARGET_ID = _dkpc 22 | else 23 | OBJS = realmode.o plunge.o $(OBJS_COMMON) 24 | LDSCRIPT = realmode.ld 25 | TARGET_ID = _mini 26 | endif 27 | endif 28 | 29 | ifeq ($(NDEBUG),1) 30 | DEFINES += -DNDEBUG 31 | TARGET_DEBUG = 32 | else 33 | OBJS += exception.o exception_asm.o vsprintf.o gecko.o 34 | TARGET_DEBUG = _debug 35 | endif 36 | 37 | TARGET = stub$(TARGET_ID)$(TARGET_DEBUG).elf 38 | 39 | include ../../common.mk 40 | 41 | all: xxd 42 | 43 | xxd: $(TARGET) 44 | @echo " XXD $^" 45 | @xxd -i $(TARGET) > $(subst .elf,.c,$(TARGET)) 46 | 47 | distclean: clean 48 | rm -f stub_*.elf stub_*.c 49 | 50 | release: 51 | $(Q)$(MAKE) clean 52 | $(Q)$(MAKE) 53 | $(Q)$(MAKE) clean 54 | $(Q)$(MAKE) NDEBUG=1 55 | $(Q)$(MAKE) NDEBUG=1 clean 56 | $(Q)$(MAKE) DKPPC=1 57 | $(Q)$(MAKE) DKPPC=1 clean 58 | $(Q)$(MAKE) DKPPC=1 NDEBUG=1 59 | $(Q)$(MAKE) DKPPC=1 NDEBUG=1 clean 60 | $(Q)$(MAKE) DKPPCCHANNEL=1 61 | $(Q)$(MAKE) DKPPCCHANNEL=1 clean 62 | $(Q)$(MAKE) DKPPCCHANNEL=1 NDEBUG=1 63 | $(Q)$(MAKE) DKPPCCHANNEL=1 NDEBUG=1 clean 64 | 65 | .PHONY: release 66 | 67 | -------------------------------------------------------------------------------- /wiipax/stub/channel.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-powerpc") 2 | OUTPUT_ARCH(powerpc:common) 3 | 4 | __mem1_start = 0x80004000; 5 | __mem2_start = 0x90010000; 6 | 7 | __mem1_entry = _start - __mem2_start + __mem1_start; 8 | ENTRY(__mem1_entry) 9 | 10 | PHDRS { 11 | realmode PT_LOAD FLAGS(5); 12 | paxx PT_LOAD FLAGS(7); 13 | } 14 | 15 | SECTIONS { 16 | . = 0x80003400; 17 | 18 | .realmode : { KEEP(*(.realmode)) } :realmode = 0 19 | 20 | . = __mem2_start; 21 | 22 | .start : AT(__mem1_start) { KEEP(*(.start)) } :paxx = 0 23 | .text : { *(.text) *(.text.*) } 24 | 25 | . = ALIGN(4); 26 | 27 | .payload : { 28 | __payload = .; 29 | LONG(0); 30 | LONG(0); 31 | LONG(0); 32 | LONG(0); 33 | LONG(0); 34 | LONG(0); 35 | } 36 | 37 | .rodata : { *(.rodata) *(.rodata.*) } 38 | 39 | . = (( . +19)&0xFFFFFFF0) - 4; 40 | .padding : { 41 | LONG(0xdeadbeef); 42 | } 43 | 44 | .sdata : { *(.sdata) *(.sdata.*) } 45 | .data : { *(.data) *(.data.*) } 46 | 47 | . = ALIGN(32); 48 | __self_end = .; 49 | 50 | __bss_start = .; 51 | .bss : { *(.bss) } :NONE = 0 52 | .sbss : { *(.sbss) } 53 | __bss_end = .; 54 | 55 | . = ALIGN(32); 56 | 57 | .stack : { 58 | _stack_top = .; 59 | . += 32768; 60 | _stack_bot = .; 61 | } 62 | 63 | } 64 | 65 | -------------------------------------------------------------------------------- /wiipax/stub/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _LOADER_H_ 2 | #define _LOADER_H_ 3 | 4 | #include 5 | 6 | // Basic types. 7 | 8 | typedef unsigned char u8; 9 | typedef signed char s8; 10 | typedef unsigned short int u16; 11 | typedef signed short int s16; 12 | typedef unsigned int u32; 13 | typedef signed int s32; 14 | 15 | // Basic I/O. 16 | 17 | static inline u32 read32(u32 addr) { 18 | u32 x; 19 | 20 | asm volatile("lwz %0,0(%1) ; sync" : "=r"(x) : "b"(0xc0000000 | addr)); 21 | 22 | return x; 23 | } 24 | 25 | static inline void write32(u32 addr, u32 x) { 26 | asm("stw %0,0(%1) ; eieio" : : "r"(x), "b"(0xc0000000 | addr)); 27 | } 28 | 29 | static inline u16 read16(u32 addr) { 30 | u16 x; 31 | 32 | asm volatile("lhz %0,0(%1) ; sync" : "=r"(x) : "b"(0xc0000000 | addr)); 33 | 34 | return x; 35 | } 36 | 37 | static inline u8 read8(u32 addr) { 38 | u8 x; 39 | 40 | asm volatile("lbz %0,0(%1) ; sync" : "=r"(x) : "b"(0xc0000000 | addr)); 41 | 42 | return x; 43 | } 44 | 45 | static inline void write16(u32 addr, u16 x) { 46 | asm("sth %0,0(%1) ; eieio" : : "r"(x), "b"(0xc0000000 | addr)); 47 | } 48 | 49 | static inline void write8(u32 addr, u8 x) { 50 | asm("stb %0,0(%1) ; eieio" : : "r"(x), "b"(0xc0000000 | addr)); 51 | } 52 | 53 | static inline void mask32(u32 addr, u32 clear, u32 set) 54 | { 55 | write32(addr, (read32(addr)&(~clear)) | set); 56 | } 57 | 58 | // Address mapping. 59 | 60 | static inline u32 virt_to_phys(const void *p) { 61 | return (u32)p & 0x7fffffff; 62 | } 63 | 64 | static inline void *phys_to_virt(u32 x) { 65 | return (void *)(x | 0x80000000); 66 | } 67 | 68 | 69 | // Cache synchronisation. 70 | 71 | void sync_before_read(void *p, u32 len); 72 | void sync_after_write(const void *p, u32 len); 73 | void sync_before_exec(const void *p, u32 len); 74 | 75 | 76 | // Time. 77 | 78 | void udelay(u32 us); 79 | 80 | 81 | // Special purpose registers. 82 | 83 | #define mtspr(n, x) do { asm("mtspr %1,%0" : : "r"(x), "i"(n)); } while (0) 84 | #define mfspr(n) ({ \ 85 | u32 x; asm volatile("mfspr %0,%1" : "=r"(x) : "i"(n)); x; \ 86 | }) 87 | 88 | 89 | // Exceptions. 90 | 91 | #ifdef NDEBUG 92 | #define printf(...) { } 93 | #else 94 | void exception_init(void); 95 | void gecko_init(void); 96 | int printf(const char *fmt, ...); 97 | #endif 98 | 99 | 100 | // Debug: blink the tray led. 101 | 102 | static inline void blink(void) { 103 | write32(0x0d8000c0, read32(0x0d8000c0) ^ 0x20); 104 | } 105 | 106 | #endif 107 | 108 | -------------------------------------------------------------------------------- /wiipax/stub/devkitppc.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-powerpc") 2 | OUTPUT_ARCH(powerpc:common) 3 | 4 | __mem1_start = 0x80004000; 5 | __mem2_start = 0x90010000; 6 | 7 | __mem1_entry = _start - __mem2_start + __mem1_start; 8 | ENTRY(__mem1_entry) 9 | 10 | PHDRS { 11 | paxx PT_LOAD FLAGS(7); 12 | } 13 | 14 | SECTIONS { 15 | . = __mem2_start; 16 | 17 | .start : AT(__mem1_start) { KEEP(*(.start)) } :paxx = 0 18 | .text : { *(.text) *(.text.*) } 19 | 20 | . = ALIGN(4); 21 | 22 | .payload : { 23 | __payload = .; 24 | LONG(0); 25 | LONG(0); 26 | LONG(0); 27 | LONG(0); 28 | LONG(0); 29 | LONG(0); 30 | } 31 | 32 | .rodata : { *(.rodata) *(.rodata.*) } 33 | 34 | . = (( . +19)&0xFFFFFFF0) - 4; 35 | .padding : { 36 | LONG(0xdeadbeef); 37 | } 38 | 39 | .sdata : { *(.sdata) *(.sdata.*) } 40 | .data : { *(.data) *(.data.*) } 41 | 42 | . = ALIGN(32); 43 | __self_end = .; 44 | 45 | __bss_start = .; 46 | .bss : { *(.bss) } :NONE = 0 47 | .sbss : { *(.sbss) } 48 | __bss_end = .; 49 | 50 | . = ALIGN(32); 51 | 52 | .stack : { 53 | _stack_top = .; 54 | . += 32768; 55 | _stack_bot = .; 56 | } 57 | 58 | } 59 | 60 | -------------------------------------------------------------------------------- /wiipax/stub/elf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001 William L. Pitts 3 | * Modifications (c) 2004 Felix Domke 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms are freely 7 | * permitted provided that the above copyright notice and this 8 | * paragraph and the following disclaimer are duplicated in all 9 | * such forms. 10 | * 11 | * This software is provided "AS IS" and without any express or 12 | * implied warranties, including, without limitation, the implied 13 | * warranties of merchantability and fitness for a particular 14 | * purpose. 15 | */ 16 | 17 | #include "common.h" 18 | #include "elf_abi.h" 19 | #include "string.h" 20 | 21 | int valid_elf_image (void *addr) { 22 | Elf32_Ehdr *ehdr; /* Elf header structure pointer */ 23 | 24 | ehdr = (Elf32_Ehdr *) addr; 25 | 26 | if (!IS_ELF (*ehdr)) 27 | return 0; 28 | 29 | if (ehdr->e_ident[EI_CLASS] != ELFCLASS32) 30 | return -1; 31 | 32 | if (ehdr->e_ident[EI_DATA] != ELFDATA2MSB) 33 | return -1; 34 | 35 | if (ehdr->e_ident[EI_VERSION] != EV_CURRENT) 36 | return -1; 37 | 38 | if (ehdr->e_type != ET_EXEC) 39 | return -1; 40 | 41 | if (ehdr->e_machine != EM_PPC) 42 | return -1; 43 | 44 | return 1; 45 | } 46 | 47 | u32 load_elf_image(void *addr) { 48 | Elf32_Ehdr *ehdr; 49 | Elf32_Phdr *phdrs; 50 | u8 *image; 51 | int i; 52 | 53 | ehdr = (Elf32_Ehdr *)addr; 54 | 55 | if(ehdr->e_phoff == 0 || ehdr->e_phnum == 0) { 56 | printf("ELF has no phdrs\n"); 57 | return 0; 58 | } 59 | 60 | if(ehdr->e_phentsize != sizeof(Elf32_Phdr)) { 61 | printf("Invalid ELF phdr size\n"); 62 | return 0; 63 | } 64 | 65 | phdrs = (Elf32_Phdr*)(addr + ehdr->e_phoff); 66 | 67 | for(i = 0; i < ehdr->e_phnum; i++) { 68 | if(phdrs[i].p_type != PT_LOAD) { 69 | printf("skip PHDR %d of type %d\n", i, phdrs[i].p_type); 70 | continue; 71 | } 72 | 73 | // translate paddr to this BAT setup 74 | phdrs[i].p_paddr &= 0x3FFFFFFF; 75 | phdrs[i].p_paddr |= 0x80000000; 76 | 77 | printf("PHDR %d 0x%08x [0x%x] -> 0x%08x [0x%x] <", i, 78 | phdrs[i].p_offset, phdrs[i].p_filesz, 79 | phdrs[i].p_paddr, phdrs[i].p_memsz); 80 | 81 | if(phdrs[i].p_flags & PF_R) 82 | printf("R"); 83 | if(phdrs[i].p_flags & PF_W) 84 | printf("W"); 85 | if(phdrs[i].p_flags & PF_X) 86 | printf("X"); 87 | printf(">\n"); 88 | 89 | if(phdrs[i].p_filesz > phdrs[i].p_memsz) { 90 | printf("-> file size > mem size\n"); 91 | return 0; 92 | } 93 | 94 | if(phdrs[i].p_filesz) { 95 | printf("-> load 0x%x\n", phdrs[i].p_filesz); 96 | image = (u8 *)(addr + phdrs[i].p_offset); 97 | memcpy((void *)phdrs[i].p_paddr, (const void *)image, 98 | phdrs[i].p_filesz); 99 | memset((void *)image, 0, phdrs[i].p_filesz); 100 | 101 | sync_after_write((void *)phdrs[i].p_paddr, phdrs[i].p_memsz); 102 | 103 | if(phdrs[i].p_flags & PF_X) 104 | sync_before_exec((void *)phdrs[i].p_paddr, phdrs[i].p_memsz); 105 | } else { 106 | printf ("-> skip\n"); 107 | } 108 | } 109 | 110 | // entry point of the ELF _has_ to be correct - no translation done 111 | return ehdr->e_entry; 112 | } 113 | 114 | -------------------------------------------------------------------------------- /wiipax/stub/elf.h: -------------------------------------------------------------------------------- 1 | #ifndef _ELF_H 2 | #define _ELF_H 3 | 4 | int valid_elf_image (void *addr); 5 | u32 load_elf_image (void *addr); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /wiipax/stub/exception.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "string.h" 3 | 4 | extern char exception_asm_start, exception_asm_end; 5 | 6 | void exception_handler(int exception) 7 | { 8 | u32 *x; 9 | u32 i; 10 | 11 | printf("\nException %04x occurred!\n", exception); 12 | 13 | x = (u32 *)0x80003500; 14 | 15 | printf("\n R0..R7 R8..R15 R16..R23 R24..R31\n"); 16 | for (i = 0; i < 8; i++) { 17 | printf("%08x %08x %08x %08x\n", x[0], x[8], x[16], x[24]); 18 | x++; 19 | } 20 | x += 24; 21 | 22 | printf("\n CR/XER LR/CTR SRR0/SRR1 DAR/DSISR\n"); 23 | for (i = 0; i < 2; i++) { 24 | printf("%08x %08x %08x %08x\n", x[0], x[2], x[4], x[6]); 25 | x++; 26 | } 27 | 28 | // Hang. 29 | for (;;) 30 | ; 31 | } 32 | 33 | void exception_init(void) 34 | { 35 | u32 vector; 36 | u32 len_asm; 37 | 38 | for (vector = 0x100; vector < 0x1800; vector += 0x10) { 39 | u32 *insn = (u32 *)(0x80000000 + vector); 40 | 41 | insn[0] = 0xbc003500; // stmw 0,0x3500(0) 42 | insn[1] = 0x38600000 | vector; // li 3,vector 43 | insn[2] = 0x48003602; // ba 0x3600 44 | insn[3] = 0; 45 | } 46 | sync_before_exec((void *)0x80000100, 0x1f00); 47 | 48 | len_asm = &exception_asm_end - &exception_asm_start; 49 | memcpy((void *)0x80003600, &exception_asm_start, len_asm); 50 | sync_before_exec((void *)0x80003600, len_asm); 51 | } 52 | 53 | -------------------------------------------------------------------------------- /wiipax/stub/exception_asm.s: -------------------------------------------------------------------------------- 1 | .globl exception_asm_start, exception_asm_end 2 | 3 | exception_asm_start: 4 | # store all interesting regs 5 | mfcr 0 ; stw 0,0x3580(0) 6 | mfxer 0 ; stw 0,0x3584(0) 7 | mflr 0 ; stw 0,0x3588(0) 8 | mfctr 0 ; stw 0,0x358c(0) 9 | mfsrr0 0 ; stw 0,0x3590(0) 10 | mfsrr1 0 ; stw 0,0x3594(0) 11 | mfdar 0 ; stw 0,0x3598(0) 12 | mfdsisr 0 ; stw 0,0x359c(0) 13 | 14 | # switch on FP, DR, IR 15 | mfmsr 0 ; ori 0,0,0x2030 ; mtsrr1 0 16 | 17 | # go to C handler 18 | lis 0,exception_handler@h ; ori 0,0,exception_handler@l ; mtsrr0 0 19 | rfi 20 | exception_asm_end: 21 | 22 | -------------------------------------------------------------------------------- /wiipax/stub/gecko.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "vsprintf.h" 3 | 4 | #define EXI_REG_BASE 0xd806800 5 | #define EXI0_REG_BASE (EXI_REG_BASE+0x000) 6 | #define EXI1_REG_BASE (EXI_REG_BASE+0x014) 7 | #define EXI2_REG_BASE (EXI_REG_BASE+0x028) 8 | 9 | #define EXI0_CSR (EXI0_REG_BASE+0x000) 10 | #define EXI0_MAR (EXI0_REG_BASE+0x004) 11 | #define EXI0_LENGTH (EXI0_REG_BASE+0x008) 12 | #define EXI0_CR (EXI0_REG_BASE+0x00c) 13 | #define EXI0_DATA (EXI0_REG_BASE+0x010) 14 | 15 | #define EXI1_CSR (EXI1_REG_BASE+0x000) 16 | #define EXI1_MAR (EXI1_REG_BASE+0x004) 17 | #define EXI1_LENGTH (EXI1_REG_BASE+0x008) 18 | #define EXI1_CR (EXI1_REG_BASE+0x00c) 19 | #define EXI1_DATA (EXI1_REG_BASE+0x010) 20 | 21 | #define EXI2_CSR (EXI2_REG_BASE+0x000) 22 | #define EXI2_MAR (EXI2_REG_BASE+0x004) 23 | #define EXI2_LENGTH (EXI2_REG_BASE+0x008) 24 | #define EXI2_CR (EXI2_REG_BASE+0x00c) 25 | #define EXI2_DATA (EXI2_REG_BASE+0x010) 26 | 27 | static int gecko_console_enabled = 0; 28 | 29 | static u32 _gecko_command(u32 command) { 30 | u32 i; 31 | // Memory Card Port B (Channel 1, Device 0, Frequency 3 (32Mhz Clock)) 32 | write32(EXI1_CSR, 0xd0); 33 | write32(EXI1_DATA, command); 34 | write32(EXI1_CR, 0x19); 35 | i = 1000; 36 | while ((read32(EXI1_CR) & 1) && (i--)); 37 | i = read32(EXI1_DATA); 38 | write32(EXI1_CSR, 0); 39 | return i; 40 | } 41 | 42 | static u32 _gecko_sendbyte(char sendbyte) { 43 | u32 i = 0; 44 | i = _gecko_command(0xB0000000 | (sendbyte<<20)); 45 | if (i&0x04000000) 46 | return 1; // Return 1 if byte was sent 47 | return 0; 48 | } 49 | 50 | #if 0 51 | static u32 _gecko_recvbyte(char *recvbyte) { 52 | u32 i = 0; 53 | *recvbyte = 0; 54 | i = _gecko_command(0xA0000000); 55 | if (i&0x08000000) { 56 | // Return 1 if byte was received 57 | *recvbyte = (i>>16)&0xff; 58 | return 1; 59 | } 60 | return 0; 61 | } 62 | 63 | static u32 _gecko_checksend(void) { 64 | u32 i = 0; 65 | i = _gecko_command(0xC0000000); 66 | if (i&0x04000000) 67 | return 1; // Return 1 if safe to send 68 | return 0; 69 | } 70 | 71 | static u32 _gecko_checkrecv(void) { 72 | u32 i = 0; 73 | i = _gecko_command(0xD0000000); 74 | if (i&0x04000000) 75 | return 1; // Return 1 if safe to recv 76 | return 0; 77 | } 78 | 79 | static void gecko_flush(void) { 80 | char tmp; 81 | while(_gecko_recvbyte(&tmp)); 82 | } 83 | #endif 84 | 85 | static int gecko_isalive(void) { 86 | u32 i = 0; 87 | i = _gecko_command(0x90000000); 88 | if (i&0x04700000) 89 | return 1; 90 | return 0; 91 | } 92 | 93 | #if 0 94 | static int gecko_recvbuffer(void *buffer, u32 size) { 95 | u32 left = size; 96 | char *ptr = (char*)buffer; 97 | 98 | while(left>0) { 99 | if(!_gecko_recvbyte(ptr)) 100 | break; 101 | ptr++; 102 | left--; 103 | } 104 | return (size - left); 105 | } 106 | #endif 107 | 108 | static int gecko_sendbuffer(const void *buffer, u32 size) { 109 | u32 left = size; 110 | char *ptr = (char*)buffer; 111 | 112 | while(left>0) { 113 | if(!_gecko_sendbyte(*ptr)) 114 | break; 115 | ptr++; 116 | left--; 117 | } 118 | return (size - left); 119 | } 120 | 121 | #if 0 122 | static int gecko_recvbuffer_safe(void *buffer, u32 size) { 123 | u32 left = size; 124 | char *ptr = (char*)buffer; 125 | 126 | while(left>0) { 127 | if(_gecko_checkrecv()) { 128 | if(!_gecko_recvbyte(ptr)) 129 | break; 130 | ptr++; 131 | left--; 132 | } 133 | } 134 | return (size - left); 135 | } 136 | 137 | static int gecko_sendbuffer_safe(const void *buffer, u32 size) { 138 | u32 left = size; 139 | char *ptr = (char*)buffer; 140 | 141 | while(left>0) { 142 | if(_gecko_checksend()) { 143 | if(!_gecko_sendbyte(*ptr)) 144 | break; 145 | ptr++; 146 | left--; 147 | } 148 | } 149 | return (size - left); 150 | } 151 | #endif 152 | 153 | void gecko_init(void) 154 | { 155 | // unlock EXI 156 | write32(0x0d00643c, 0); 157 | 158 | write32(EXI0_CSR, 0); 159 | write32(EXI1_CSR, 0); 160 | write32(EXI2_CSR, 0); 161 | write32(EXI0_CSR, 0x2000); 162 | write32(EXI0_CSR, 3<<10); 163 | write32(EXI1_CSR, 3<<10); 164 | 165 | if (!gecko_isalive()) 166 | return; 167 | 168 | gecko_console_enabled = 1; 169 | } 170 | 171 | int printf(const char *fmt, ...) { 172 | if (!gecko_console_enabled) 173 | return 0; 174 | 175 | va_list args; 176 | char buffer[1024]; 177 | int i; 178 | 179 | va_start(args, fmt); 180 | i = vsprintf(buffer, fmt, args); 181 | va_end(args); 182 | 183 | return gecko_sendbuffer(buffer, i); 184 | } 185 | 186 | -------------------------------------------------------------------------------- /wiipax/stub/main.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "string.h" 4 | #include "elf.h" 5 | 6 | #include "LzmaDec.h" 7 | 8 | extern const u8 __self_start[], __self_end[]; 9 | extern const u8 __payload[]; 10 | 11 | extern void _plunge(u32 entry); 12 | 13 | typedef struct { 14 | u8 * const data; 15 | const u32 len_in; 16 | const u32 len_out; 17 | const u8 props[LZMA_PROPS_SIZE]; 18 | } __attribute__((packed)) _payload; 19 | 20 | const _payload * const payload = (void *) __payload; 21 | 22 | u8 * const code_buffer = (u8 *) 0x90100000; 23 | 24 | static void *lz_malloc(void *p, size_t size) { 25 | (void) p; 26 | (void) size; 27 | printf("lz_malloc %u\n", size); 28 | return (void *) 0x90081000; 29 | } 30 | 31 | static void lz_free(void *p, void *address) { 32 | (void) p; 33 | (void) address; 34 | printf("lz_free %p\n", address); 35 | } 36 | 37 | static const ISzAlloc lz_alloc = { lz_malloc, lz_free }; 38 | 39 | static inline __attribute__((always_inline)) int decode(void) { 40 | SizeT len_in; 41 | SizeT len_out; 42 | ELzmaStatus status; 43 | SRes res; 44 | 45 | len_in = payload->len_in; 46 | len_out = payload->len_out; 47 | 48 | printf("in: %d out: %d\n", len_in, len_out); 49 | 50 | res = LzmaDecode(code_buffer, &len_out, payload->data, &len_in, 51 | payload->props, LZMA_PROPS_SIZE, LZMA_FINISH_END, 52 | &status, (ISzAlloc*)&lz_alloc); 53 | 54 | if (res != SZ_OK) { 55 | printf("decoding error %d (%u)\n", res, status); 56 | return res; 57 | } 58 | 59 | return 0; 60 | } 61 | 62 | void stubmain(void) { 63 | #ifndef NDEBUG 64 | exception_init(); 65 | #endif 66 | 67 | // clear interrupt mask 68 | write32(0x0c003004, 0); 69 | 70 | #ifndef NDEBUG 71 | #ifndef DKPPC 72 | udelay(500 * 1000); // wait for mini - avoid EXI battle 73 | #endif 74 | gecko_init(); 75 | #endif 76 | printf("hello world\n"); 77 | printf("payload @%p blob @%p\n", payload, payload->data); 78 | 79 | if (decode() == 0 && valid_elf_image(code_buffer)) { 80 | printf("Valid ELF image detected.\n"); 81 | u32 entry = load_elf_image(code_buffer); 82 | 83 | if (entry) { 84 | // Disable all IRQs; ack all pending IRQs. 85 | write32(0x0c003004, 0); 86 | write32(0x0c003000, 0xffffffff); 87 | 88 | printf("Branching to 0x%08x\n", entry); 89 | #ifndef DKPPC 90 | // detect failkit apps packed with the mini stub 91 | if (entry & 0xc0000000) { 92 | void (*ep)() = (void (*)()) entry; 93 | ep(); 94 | } else { 95 | _plunge(entry); 96 | } 97 | #else 98 | void (*ep)() = (void (*)()) entry; 99 | ep(); 100 | #endif 101 | } 102 | } 103 | 104 | error: 105 | blink(); 106 | udelay(500000); 107 | goto error; 108 | } 109 | 110 | -------------------------------------------------------------------------------- /wiipax/stub/plunge.S: -------------------------------------------------------------------------------- 1 | .text 2 | .section .text 3 | .globl _plunge 4 | 5 | _plunge: 6 | isync 7 | mtsrr0 3 8 | 9 | mfmsr 3 10 | li 4,0x30 11 | andc 3,3,4 12 | mtsrr1 3 13 | rfi 14 | -------------------------------------------------------------------------------- /wiipax/stub/realmode.S: -------------------------------------------------------------------------------- 1 | #define IBAT0U 528 2 | #define IBAT0L 529 3 | #define IBAT1U 530 4 | #define IBAT1L 531 5 | #define IBAT2U 532 6 | #define IBAT2L 533 7 | #define IBAT3U 534 8 | #define IBAT3L 535 9 | #define IBAT4U 560 10 | #define IBAT4L 561 11 | #define IBAT5U 562 12 | #define IBAT5L 563 13 | #define IBAT6U 564 14 | #define IBAT6L 565 15 | #define IBAT7U 566 16 | #define IBAT7L 567 17 | 18 | #define DBAT0U 536 19 | #define DBAT0L 537 20 | #define DBAT1U 538 21 | #define DBAT1L 539 22 | #define DBAT2U 540 23 | #define DBAT2L 541 24 | #define DBAT3U 542 25 | #define DBAT3L 543 26 | #define DBAT4U 568 27 | #define DBAT4L 569 28 | #define DBAT5U 570 29 | #define DBAT5L 571 30 | #define DBAT6U 572 31 | #define DBAT6L 573 32 | #define DBAT7U 574 33 | #define DBAT7L 575 34 | 35 | 36 | .text 37 | .section .realmode,"ax",@progbits 38 | .extern _start 39 | .align 2 40 | .globl _realmode_vector 41 | 42 | _realmode_vector: 43 | // HID0 = 00110c64: 44 | // bus checkstops off, sleep modes off, 45 | // caches off, caches invalidate, 46 | // store gathering off, enable data cache 47 | // flush assist, enable branch target cache, 48 | // enable branch history table 49 | lis 3,0x0011 ; ori 3,3,0x0c64 ; mtspr 1008,3 ; isync 50 | 51 | // MSR = 00002000 (FP on) 52 | li 4,0x2000 ; mtmsr 4 53 | 54 | // HID0 |= 0000c000 (caches on) 55 | ori 3,3,0xc000 ; mtspr 1008,3 ; isync 56 | 57 | // clear all BATs 58 | li 0,0 59 | mtspr 528,0 ; mtspr 530,0 ; mtspr 532,0 ; mtspr 534,0 // IBATU 0..3 60 | mtspr 536,0 ; mtspr 538,0 ; mtspr 540,0 ; mtspr 542,0 // DBATU 0..3 61 | mtspr 560,0 ; mtspr 562,0 ; mtspr 564,0 ; mtspr 566,0 // IBATU 4..7 62 | mtspr 568,0 ; mtspr 570,0 ; mtspr 572,0 ; mtspr 574,0 // DBATU 4..7 63 | isync 64 | 65 | // clear all SRs 66 | lis 0,0x8000 67 | mtsr 0,0 ; mtsr 1,0 ; mtsr 2,0 ; mtsr 3,0 68 | mtsr 4,0 ; mtsr 5,0 ; mtsr 6,0 ; mtsr 7,0 69 | mtsr 8,0 ; mtsr 9,0 ; mtsr 10,0 ; mtsr 11,0 70 | mtsr 12,0 ; mtsr 13,0 ; mtsr 14,0 ; mtsr 15,0 71 | isync 72 | 73 | // set [DI]BAT0 for 256MB@80000000, 74 | // real 00000000, WIMG=0000, R/W 75 | li 3,2 ; lis 4,0x8000 ; ori 4,4,0x1fff 76 | mtspr IBAT0L,3 ; mtspr IBAT0U,4 ; mtspr DBAT0L,3 ; mtspr DBAT0U,4 ; isync 77 | 78 | // set [DI]BAT4 for 256MB@90000000, 79 | // real 10000000, WIMG=0000, R/W 80 | addis 3,3,0x1000 ; addis 4,4,0x1000 81 | mtspr IBAT4L,3 ; mtspr IBAT4U,4 ; mtspr DBAT4L,3 ; mtspr DBAT4U,4 ; isync 82 | 83 | // set DBAT1 for 256MB@c0000000, 84 | // real 00000000, WIMG=0101, R/W 85 | li 3,0x2a ; lis 4,0xc000 ; ori 4,4,0x1fff 86 | mtspr DBAT1L,3 ; mtspr DBAT1U,4 ; isync 87 | 88 | // set DBAT5 for 256MB@d0000000, 89 | // real 10000000, WIMG=0101, R/W 90 | addis 3,3,0x1000 ; addis 4,4,0x1000 91 | mtspr DBAT5L,3 ; mtspr DBAT5U,4 ; isync 92 | 93 | // enable [DI]BAT4-7 in HID4 94 | lis 3, 0x8200 95 | mtspr 1011,3 96 | 97 | // set MSR[DR:IR] = 11, jump to _start 98 | lis 3,__mem1_entry@h ; ori 3,3,__mem1_entry@l ; mtsrr0 3 99 | 100 | mfmsr 3 ; ori 3,3,0x30 ; mtsrr1 3 101 | rfi 102 | -------------------------------------------------------------------------------- /wiipax/stub/realmode.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-powerpc") 2 | OUTPUT_ARCH(powerpc:common) 3 | 4 | __mem1_start = 0x80004000; 5 | __mem2_start = 0x90010000; 6 | 7 | __mem1_entry = _start - __mem2_start + __mem1_start; 8 | ENTRY(_realmode_vector) 9 | 10 | PHDRS { 11 | realmode PT_LOAD FLAGS(5); 12 | paxx PT_LOAD FLAGS(7); 13 | } 14 | 15 | SECTIONS { 16 | . = 0x00003400; 17 | 18 | .realmode : { *(.realmode) } :realmode = 0 19 | 20 | . = __mem2_start; 21 | 22 | .start : AT(__mem1_start & 0x3FFFFFFF) { KEEP(*(.start)) } :paxx = 0 23 | .text : { *(.text) *(.text.*) } 24 | 25 | . = ALIGN(4); 26 | 27 | .payload : { 28 | __payload = .; 29 | LONG(0); 30 | LONG(0); 31 | LONG(0); 32 | LONG(0); 33 | LONG(0); 34 | LONG(0); 35 | } 36 | 37 | .rodata : { *(.rodata) *(.rodata.*) } 38 | 39 | . = (( . +19)&0xFFFFFFF0) - 4; 40 | .padding : { 41 | LONG(0xdeadbeef); 42 | } 43 | 44 | .sdata : { *(.sdata) *(.sdata.*) } 45 | .data : { *(.data) *(.data.*) } 46 | 47 | . = ALIGN(32); 48 | __self_end = .; 49 | 50 | __bss_start = .; 51 | .bss : { *(.bss) } :NONE = 0 52 | .sbss : { *(.sbss) } 53 | __bss_end = .; 54 | 55 | . = ALIGN(32); 56 | 57 | .stack : { 58 | _stack_top = .; 59 | . += 32768; 60 | _stack_bot = .; 61 | } 62 | 63 | } 64 | 65 | -------------------------------------------------------------------------------- /wiipax/stub/string.c: -------------------------------------------------------------------------------- 1 | /* 2 | * linux/lib/string.c 3 | * 4 | * Copyright (C) 1991, 1992 Linus Torvalds 5 | */ 6 | 7 | #include "string.h" 8 | 9 | size_t strnlen(const char *s, size_t count) 10 | { 11 | const char *sc; 12 | 13 | for (sc = s; count-- && *sc != '\0'; ++sc) 14 | /* nothing */; 15 | return sc - s; 16 | } 17 | 18 | size_t strlen(const char *s) 19 | { 20 | const char *sc; 21 | 22 | for (sc = s; *sc != '\0'; ++sc) 23 | /* nothing */; 24 | return sc - s; 25 | } 26 | 27 | char *strncpy(char *dst, const char *src, size_t n) 28 | { 29 | char *ret = dst; 30 | 31 | while (n && (*dst++ = *src++)) 32 | n--; 33 | 34 | while (n--) 35 | *dst++ = 0; 36 | 37 | return ret; 38 | } 39 | 40 | char *strcpy(char *dst, const char *src) 41 | { 42 | char *ret = dst; 43 | 44 | while ((*dst++ = *src++)) 45 | ; 46 | 47 | return ret; 48 | } 49 | 50 | int strcmp(const char *p, const char *q) 51 | { 52 | for (;;) { 53 | unsigned char a, b; 54 | a = *p++; 55 | b = *q++; 56 | if (a == 0 || a != b) 57 | return a - b; 58 | } 59 | } 60 | 61 | void *memset(void *dst, int x, size_t n) 62 | { 63 | unsigned char *p; 64 | 65 | for (p = dst; n; n--) 66 | *p++ = x; 67 | 68 | return dst; 69 | } 70 | 71 | void *memcpy(void *dst, const void *src, size_t n) 72 | { 73 | unsigned char *p; 74 | const unsigned char *q; 75 | 76 | for (p = dst, q = src; n; n--) 77 | *p++ = *q++; 78 | 79 | return dst; 80 | } 81 | 82 | int memcmp(const void *s1, const void *s2, size_t n) 83 | { 84 | unsigned char *us1 = (unsigned char *) s1; 85 | unsigned char *us2 = (unsigned char *) s2; 86 | while (n-- != 0) { 87 | if (*us1 != *us2) 88 | return (*us1 < *us2) ? -1 : +1; 89 | us1++; 90 | us2++; 91 | } 92 | return 0; 93 | } 94 | 95 | -------------------------------------------------------------------------------- /wiipax/stub/string.h: -------------------------------------------------------------------------------- 1 | #ifndef _STRING_H_ 2 | #define _STRING_H_ 3 | 4 | #include 5 | 6 | char *strcpy(char *, const char *); 7 | char *strncpy(char *, const char *, size_t); 8 | int strcmp(const char *, const char *); 9 | size_t strlen(const char *); 10 | size_t strnlen(const char *, size_t); 11 | void *memset(void *, int, size_t); 12 | void *memcpy(void *, const void *, size_t); 13 | int memcmp(const void *s1, const void *s2, size_t n); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /wiipax/stub/sync.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | void sync_before_read(void *p, u32 len) 4 | { 5 | u32 a, b; 6 | 7 | a = (u32)p & ~0x1f; 8 | b = ((u32)p + len + 0x1f) & ~0x1f; 9 | 10 | for ( ; a < b; a += 32) 11 | asm("dcbi 0,%0" : : "b"(a)); 12 | 13 | asm("sync ; isync"); 14 | } 15 | 16 | void sync_after_write(const void *p, u32 len) 17 | { 18 | u32 a, b; 19 | 20 | a = (u32)p & ~0x1f; 21 | b = ((u32)p + len + 0x1f) & ~0x1f; 22 | 23 | for ( ; a < b; a += 32) 24 | asm("dcbst 0,%0" : : "b"(a)); 25 | 26 | asm("sync ; isync"); 27 | } 28 | 29 | void sync_before_exec(const void *p, u32 len) 30 | { 31 | u32 a, b; 32 | 33 | a = (u32)p & ~0x1f; 34 | b = ((u32)p + len + 0x1f) & ~0x1f; 35 | 36 | for ( ; a < b; a += 32) 37 | asm("dcbst 0,%0 ; sync ; icbi 0,%0" : : "b"(a)); 38 | 39 | asm("sync ; isync"); 40 | } 41 | -------------------------------------------------------------------------------- /wiipax/stub/time.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | // Timebase frequency is bus frequency / 4. Ignore roundoff, this 4 | // doesn't have to be very accurate. 5 | #define TICKS_PER_USEC (243/4) 6 | 7 | static u32 mftb(void) 8 | { 9 | u32 x; 10 | 11 | asm volatile("mftb %0" : "=r"(x)); 12 | 13 | return x; 14 | } 15 | 16 | static void __delay(u32 ticks) 17 | { 18 | u32 start = mftb(); 19 | 20 | while (mftb() - start < ticks) 21 | ; 22 | } 23 | 24 | void udelay(u32 us) 25 | { 26 | __delay(TICKS_PER_USEC * us); 27 | } 28 | -------------------------------------------------------------------------------- /wiipax/stub/vsprintf.h: -------------------------------------------------------------------------------- 1 | #ifndef _VSPRINTF_H_ 2 | #define _VSPRINTF_H_ 3 | 4 | #include 5 | 6 | int vsprintf(char *buf, const char *fmt, va_list args); 7 | 8 | #endif 9 | 10 | --------------------------------------------------------------------------------