Skip to content

Commit

Permalink
Version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurelio92 committed May 18, 2021
1 parent bc19b26 commit b7f2c6c
Show file tree
Hide file tree
Showing 323 changed files with 78,305 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# RVLoader
Game loader specifically designed for Wii portables.
140 changes: 140 additions & 0 deletions bootloader/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif

include $(DEVKITPPC)/wii_rules

#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------

CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE)
CXXFLAGS = $(CFLAGS)

LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lwiiuse -lbte -logc -lm -lfat

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS :=

#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

export OUTPUT := $(CURDIR)/$(TARGET)

export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))

export DEPSDIR := $(CURDIR)/$(BUILD)

#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif

export OFILES_BIN := $(addsuffix .o,$(BINFILES))
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)

export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES)))

#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC)

#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := -L$(LIBOGC_LIB) $(foreach dir,$(LIBDIRS),-L$(dir)/lib)

export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean

#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
@cp $(TARGET).dol boot.dol
@cp $(TARGET).dol ../installer/data/$(TARGET).dol

#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol

#---------------------------------------------------------------------------------
run:
wiiload $(TARGET).dol


#---------------------------------------------------------------------------------
else

DEPENDS := $(OFILES:.o=.d)

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)

$(OFILES_SOURCES) : $(HFILES)

#---------------------------------------------------------------------------------
# This rule links in binary data with the .bin extension
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)

-include $(DEPENDS)

#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
Binary file added bootloader/data/dolbooter.bin
Binary file not shown.
48 changes: 48 additions & 0 deletions bootloader/include/gpio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#pragma once

//#define HW_GPIO_BASE 0x0d8000C0
#define HW_GPIO_BASE 0xCD0000C0
#define HW_GPIO_BASE_ADDR 0x0D8000C0

#define HW_GPIOB_OUT (*((vu32*)(HW_GPIO_BASE + 0x00)))
#define HW_GPIOB_DIR (*((vu32*)(HW_GPIO_BASE + 0x04)))
#define HW_GPIOB_IN (*((vu32*)(HW_GPIO_BASE + 0x08)))
#define HW_GPIOB_INTLVL (*((vu32*)(HW_GPIO_BASE + 0x0C)))
#define HW_GPIOB_INTFLAG (*((vu32*)(HW_GPIO_BASE + 0x10)))
#define HW_GPIOB_INTMASK (*((vu32*)(HW_GPIO_BASE + 0x14)))
#define HW_GPIOB_INMIR (*((vu32*)(HW_GPIO_BASE + 0x18)))
#define HW_GPIO_ENABLE (*((vu32*)(HW_GPIO_BASE + 0x1C)))
#define HW_GPIO_OUT (*((vu32*)(HW_GPIO_BASE + 0x20)))
#define HW_GPIO_DIR (*((vu32*)(HW_GPIO_BASE + 0x24)))
#define HW_GPIO_IN (*((vu32*)(HW_GPIO_BASE + 0x28)))
#define HW_GPIO_INTLVL (*((vu32*)(HW_GPIO_BASE + 0x2C)))
#define HW_GPIO_INTFLAG (*((vu32*)(HW_GPIO_BASE + 0x30)))
#define HW_GPIO_INTMASK (*((vu32*)(HW_GPIO_BASE + 0x34)))
#define HW_GPIO_INMIR (*((vu32*)(HW_GPIO_BASE + 0x38)))
//#define HW_GPIO_OWNER (HW_GPIO_BASE + 0x3C)

#define HW_GPIOB_OUT_ADDR (HW_GPIO_BASE_ADDR + 0x00)
#define HW_GPIOB_DIR_ADDR (HW_GPIO_BASE_ADDR + 0x04)
#define HW_GPIOB_IN_ADDR (HW_GPIO_BASE_ADDR + 0x08)
#define HW_GPIOB_INTLVL_ADDR (HW_GPIO_BASE_ADDR + 0x0C)
#define HW_GPIOB_INTFLAG_ADDR (HW_GPIO_BASE_ADDR + 0x10)
#define HW_GPIOB_INTMASK_ADDR (HW_GPIO_BASE_ADDR + 0x14)
#define HW_GPIOB_INMIR_ADDR (HW_GPIO_BASE_ADDR + 0x18)
#define HW_GPIO_ENABLE_ADDR (HW_GPIO_BASE_ADDR + 0x1C)
#define HW_GPIO_OUT_ADDR (HW_GPIO_BASE_ADDR + 0x20)
#define HW_GPIO_DIR_ADDR (HW_GPIO_BASE_ADDR + 0x24)
#define HW_GPIO_IN_ADDR (HW_GPIO_BASE_ADDR + 0x28)
#define HW_GPIO_INTLVL_ADDR (HW_GPIO_BASE_ADDR + 0x2C)
#define HW_GPIO_INTFLAG_ADDR (HW_GPIO_BASE_ADDR + 0x30)
#define HW_GPIO_INTMASK_ADDR (HW_GPIO_BASE_ADDR + 0x34)
#define HW_GPIO_INMIR_ADDR (HW_GPIO_BASE_ADDR + 0x38)
#define HW_GPIO_OWNER_ADDR (HW_GPIO_BASE_ADDR + 0x3C)

#define GPIO_DEBUG0 (1<<16)
#define GPIO_DEBUG1 (1<<17)
#define GPIO_DEBUG2 (1<<18)
#define GPIO_DEBUG3 (1<<19)
#define GPIO_DEBUG4 (1<<20)
#define GPIO_DEBUG5 (1<<21)
#define GPIO_DEBUG6 (1<<22)
#define GPIO_DEBUG7 (1<<23)
43 changes: 43 additions & 0 deletions bootloader/include/i2c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef _I2C_H_
#define _I2C_H_

#include <gccore.h>

#define GPIO_SCL (1<<14)
#define GPIO_SDA (1<<15)
#define GPIO_I2C (GPIO_SCL | GPIO_SDA)

#define AVE_ADDR (0x70 << 1)
#define LM49450_ADDR (0x7D << 1)

#ifdef __cplusplus
extern "C" {
#endif

void i2c_setSCLDir(u8 dir);
void i2c_setSDADir(u8 dir);
void i2c_setSCL(u8 s);
void i2c_setSDA(u8 s);
u8 i2c_getSDA(void);
void i2c_init(void);
void i2c_deinit(void);
void i2c_start(void);
void i2c_stop(void);
void i2c_restart(void);
void i2c_ack(void);
void i2c_nack(void);
u8 i2c_sendByte(u8 byte);
u8 i2c_getByte(void);

u8 i2c_read8(u8 addr, u8 reg, u8* error);
u16 i2c_read16(u8 addr, u8 reg, u8* error);
void i2c_readBuffer(u8 addr, u8 reg, u8* error, u8* buffer, u16 len);
void i2c_write8(u8 addr, u8 reg, u8 value, u8* error);
void i2c_write16(u8 addr, u8 reg, u16 value, u8* error);
void i2c_writeBuffer(u8 addr, u8 reg, u8* data, u16 len, u8* error);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions bootloader/include/system.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

int reloadIOS(int ios, int* ahbprot);
bool initFAT();
void bootDOL(const char* path, const char* args);
void bootPriiloader();
void bootSysMenu();
void systemError(const char* errorType, const char* error, ...);
Loading

0 comments on commit b7f2c6c

Please sign in to comment.