From 2e8f55af565eeee472ba414cb015a1e6c8225e43 Mon Sep 17 00:00:00 2001 From: graf_chokolo Date: Sat, 9 Apr 2011 16:50:22 +0200 Subject: [PATCH] initial import --- Makefile | 79 ++++++++++++++++++++++++++++++++++ source/main.c | 82 ++++++++++++++++++++++++++++++++++++ source/otheros_bootloader_loader.hex | 34 +++++++++++++++ 3 files changed, 195 insertions(+) create mode 100644 Makefile create mode 100644 source/main.c create mode 100644 source/otheros_bootloader_loader.hex diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..74422f8 --- /dev/null +++ b/Makefile @@ -0,0 +1,79 @@ +.SUFFIXES: +ifeq ($(strip $(PSL1GHT)),) +$(error "PSL1GHT must be set in the environment.") +endif + +include $(PSL1GHT)/host/ppu.mk + +TARGET := $(notdir $(CURDIR)) +BUILD := build +SOURCE := ../common/source source +INCLUDE := ../common/include include +DATA := data +LIBS := -lnet -lsysmodule + +TITLE := Install OtherOS Bootloader Loader +APPID := IOBL00003 +CONTENTID := UP0001-$(APPID)_00-0000000000000000 +PKGFILES := release + +CFLAGS += -O2 -Wall -std=gnu99 +CXXFLAGS += -O2 -Wall + +ifneq ($(BUILD),$(notdir $(CURDIR))) + +export OUTPUT := $(CURDIR)/$(TARGET) +export VPATH := $(foreach dir,$(SOURCE),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) +export BUILDDIR := $(CURDIR)/$(BUILD) +export DEPSDIR := $(BUILDDIR) + +CFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.c))) +CXXFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.S))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) +VCGFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.vcg))) + +ifeq ($(strip $(CXXFILES)),) +export LD := $(CC) +else +export LD := $(CXX) +endif + +export OFILES := $(CFILES:.c=.o) \ + $(CXXFILES:.cpp=.o) \ + $(SFILES:.S=.o) \ + $(VCGFILES:.vcg=.vcg.o) \ + $(BINFILES:.bin=.bin.o) + +export BINFILES := $(BINFILES:.bin=.bin.h) + +export INCLUDES := $(foreach dir,$(INCLUDE),-I$(CURDIR)/$(dir)) \ + -I$(CURDIR)/$(BUILD) + +.PHONY: $(BUILD) clean pkg run + +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +clean: + @echo "[RM] $(notdir $(OUTPUT))" + @rm -rf $(BUILD) $(OUTPUT).elf $(OUTPUT).self $(OUTPUT).a $(OUTPUT)*.pkg + +run: $(BUILD) + @$(PS3LOADAPP) $(OUTPUT).self + +pkg: $(BUILD) $(OUTPUT).pkg + +else + +DEPENDS := $(OFILES:.o=.d) + +$(OUTPUT).self: $(OUTPUT).elf +$(OUTPUT).elf: $(OFILES) +$(OFILES): $(BINFILES) + +-include $(DEPENDS) + +endif diff --git a/source/main.c b/source/main.c new file mode 100644 index 0000000..f5e766e --- /dev/null +++ b/source/main.c @@ -0,0 +1,82 @@ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include + +#include +#include + +/* + * log2 of boot memory size for GameOS (3.41) + */ +#define LOG2_PAGE_SIZE_OFFSET (0x000a5dd0ull + 0x1b0ull) +#define LOG2_PAGE_SIZE 0x0000001bull + +/* + * sll_load_lv2 (3.41) + */ +#define SLL_LOAD_LV2_OFFSET 0x00165e44ull + +static uint8_t otheros_bootloader_loader[] = { +#include "otheros_bootloader_loader.hex" +}; + +/* + * main + */ +int main(int argc, char **argv) +{ + int result; + + netInitialize(); + + udp_printf_init(); + + PRINTF("%s:%d: start\n", __func__, __LINE__); + + PRINTF("%s:%d: OtherOS bootloader loader size (0x%08x)\n", + __func__, __LINE__, sizeof(otheros_bootloader_loader)); + + result = lv1_map(); + if (result) { + PRINTF("%s:%d: lv1_map failed (0x%08x)\n", __func__, __LINE__, result); + goto done; + } + + PRINTF("%s:%d: patching log2 page size\n", __func__, __LINE__); + + lv1_poke(LOG2_PAGE_SIZE_OFFSET, LOG2_PAGE_SIZE); + + PRINTF("%s:%d: patching sll load lv2\n", __func__, __LINE__); + + lv1_memcpy_to(SLL_LOAD_LV2_OFFSET, otheros_bootloader_loader, sizeof(otheros_bootloader_loader)); + + PRINTF("%s:%d: end\n", __func__, __LINE__); + +done: + + result = lv1_unmap(); + if (result) + PRINTF("%s:%d: lv1_unmap failed (0x%08x)\n", __func__, __LINE__, result); + + udp_printf_deinit(); + + netDeinitialize(); + + return 0; +} diff --git a/source/otheros_bootloader_loader.hex b/source/otheros_bootloader_loader.hex new file mode 100644 index 0000000..171450b --- /dev/null +++ b/source/otheros_bootloader_loader.hex @@ -0,0 +1,34 @@ + 0xf8, 0x21, 0xff, 0x01, 0x7c, 0x08, 0x02, 0xa6, 0xf8, 0x01, 0x01, 0x10, 0xfb, 0x21, 0x00, 0xf8, + 0xfb, 0x41, 0x00, 0xf0, 0xfb, 0x61, 0x00, 0xe8, 0xfb, 0x81, 0x00, 0xe0, 0xfb, 0xa1, 0x00, 0xd8, + 0xfb, 0xc1, 0x00, 0xd0, 0xfb, 0xe1, 0x00, 0xc8, 0x48, 0x00, 0x00, 0x05, 0x7f, 0xe8, 0x02, 0xa6, + 0x3b, 0xff, 0xff, 0xd4, 0x7c, 0xa3, 0x2b, 0x78, 0x38, 0x80, 0x00, 0x00, 0xeb, 0x5f, 0x01, 0xe8, + 0xeb, 0x9f, 0x02, 0x00, 0x7c, 0xba, 0xe2, 0x14, 0x38, 0xc1, 0x00, 0xc0, 0x3b, 0xc0, 0x00, 0x00, + 0x67, 0xde, 0x80, 0x00, 0x63, 0xde, 0x26, 0xb4, 0x7f, 0xc9, 0x03, 0xa6, 0x4e, 0x80, 0x04, 0x21, + 0x2f, 0x83, 0x00, 0x00, 0x7c, 0x7b, 0x1b, 0x78, 0x40, 0x9e, 0x01, 0x50, 0xe8, 0x61, 0x00, 0xc0, + 0x38, 0x80, 0x00, 0x00, 0x7f, 0x85, 0xe3, 0x78, 0x3b, 0xc0, 0x00, 0x00, 0x67, 0xde, 0x80, 0x00, + 0x63, 0xde, 0x02, 0x78, 0x7f, 0xc9, 0x03, 0xa6, 0x4e, 0x80, 0x04, 0x21, 0x38, 0x7f, 0x02, 0x08, + 0x38, 0x80, 0x00, 0x00, 0x3b, 0x60, 0x00, 0x10, 0x3b, 0xc0, 0x00, 0x00, 0x67, 0xde, 0x80, 0x01, + 0x63, 0xde, 0x3d, 0x40, 0x7f, 0xc9, 0x03, 0xa6, 0x4e, 0x80, 0x04, 0x21, 0x2f, 0x83, 0x00, 0x00, + 0x7c, 0x7d, 0x1b, 0x78, 0x41, 0x9c, 0x00, 0xe8, 0x7f, 0xa3, 0x07, 0xb4, 0xe8, 0x81, 0x00, 0xc0, + 0xeb, 0x3f, 0x01, 0xf0, 0x7f, 0x25, 0xcb, 0x78, 0x3b, 0x60, 0x00, 0x10, 0x3b, 0xc0, 0x00, 0x00, + 0x67, 0xde, 0x80, 0x01, 0x63, 0xde, 0x3d, 0xb8, 0x7f, 0xc9, 0x03, 0xa6, 0x4e, 0x80, 0x04, 0x21, + 0x7f, 0xa3, 0xc8, 0x00, 0x40, 0x9e, 0x00, 0xa0, 0x3b, 0x60, 0x00, 0x14, 0xe8, 0x7f, 0x01, 0xf8, + 0xe8, 0xa1, 0x00, 0xc0, 0xe8, 0x85, 0x00, 0x00, 0x7f, 0xa3, 0x20, 0x00, 0x40, 0x9e, 0x00, 0x88, + 0xeb, 0x25, 0x00, 0x08, 0x7f, 0xb9, 0xe0, 0x00, 0x41, 0x9d, 0x00, 0x7c, 0x7f, 0xa3, 0x07, 0xb4, + 0xe8, 0x81, 0x00, 0xc0, 0x7f, 0x25, 0xcb, 0x78, 0x3b, 0x60, 0x00, 0x10, 0x3b, 0xc0, 0x00, 0x00, + 0x67, 0xde, 0x80, 0x01, 0x63, 0xde, 0x3d, 0xb8, 0x7f, 0xc9, 0x03, 0xa6, 0x4e, 0x80, 0x04, 0x21, + 0x7f, 0xa3, 0xc8, 0x00, 0x40, 0x9e, 0x00, 0x50, 0x39, 0x20, 0x00, 0x00, 0x48, 0x00, 0x00, 0x14, + 0xe8, 0x01, 0x00, 0xc0, 0x7c, 0x09, 0x02, 0x14, 0x7c, 0x00, 0x00, 0x6c, 0x39, 0x29, 0x00, 0x80, + 0x7f, 0xa9, 0xe0, 0x00, 0x41, 0x9c, 0xff, 0xec, 0x7c, 0x00, 0x04, 0xac, 0x39, 0x20, 0x00, 0x00, + 0x48, 0x00, 0x00, 0x14, 0xe8, 0x01, 0x00, 0xc0, 0x7c, 0x09, 0x02, 0x14, 0x7c, 0x00, 0x07, 0xac, + 0x39, 0x29, 0x00, 0x80, 0x7f, 0xa9, 0xe0, 0x00, 0x41, 0x9c, 0xff, 0xec, 0x4c, 0x00, 0x01, 0x2c, + 0x3b, 0x60, 0x00, 0x00, 0x7f, 0xa3, 0x07, 0xb4, 0x3b, 0xc0, 0x00, 0x00, 0x67, 0xde, 0x80, 0x01, + 0x63, 0xde, 0x3d, 0x7c, 0x7f, 0xc9, 0x03, 0xa6, 0x4e, 0x80, 0x04, 0x21, 0xe8, 0x61, 0x00, 0xc0, + 0x7c, 0x9a, 0xe2, 0x14, 0x3b, 0xc0, 0x00, 0x00, 0x67, 0xde, 0x80, 0x01, 0x63, 0xde, 0x3e, 0xb8, + 0x7f, 0xc9, 0x03, 0xa6, 0x4e, 0x80, 0x04, 0x21, 0x7b, 0x63, 0x00, 0x20, 0xe8, 0x01, 0x01, 0x10, + 0xeb, 0x21, 0x00, 0xf8, 0xeb, 0x41, 0x00, 0xf0, 0xeb, 0x61, 0x00, 0xe8, 0xeb, 0x81, 0x00, 0xe0, + 0xeb, 0xa1, 0x00, 0xd8, 0xeb, 0xc1, 0x00, 0xd0, 0xeb, 0xe1, 0x00, 0xc8, 0x38, 0x21, 0x01, 0x00, + 0x7c, 0x08, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0f, 0xac, 0xe0, 0xff, 0xde, 0xad, 0xba, 0xbe, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x2f, 0x64, 0x65, 0x76, 0x2f, 0x72, 0x66, 0x6c, + 0x61, 0x73, 0x68, 0x5f, 0x6c, 0x78, 0x00, -- 2.11.4.GIT