Compare commits
No commits in common. "d6810cf729c0b7ed1bcbafe7a005c19390a867e1" and "d7e07280d0406883e01d1c8a7836b44a0895def6" have entirely different histories.
d6810cf729
...
d7e07280d0
11
Makefile
11
Makefile
|
@ -1,4 +1,4 @@
|
||||||
.PHONY: all copy clean
|
.PHONY: all clean
|
||||||
|
|
||||||
TOP=$(shell pwd)
|
TOP=$(shell pwd)
|
||||||
|
|
||||||
|
@ -8,16 +8,7 @@ CONFIG=release
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all:
|
all:
|
||||||
make -C rom/ee TOP=$(TOP) CONFIG=$(CONFIG)
|
|
||||||
make -C rom TOP=$(TOP) CONFIG=$(CONFIG)
|
make -C rom TOP=$(TOP) CONFIG=$(CONFIG)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
make -C rom/ee TOP=$(TOP) CONFIG=$(CONFIG) clean
|
|
||||||
make -C rom TOP=$(TOP) CONFIG=$(CONFIG) clean
|
make -C rom TOP=$(TOP) CONFIG=$(CONFIG) clean
|
||||||
|
|
||||||
# copy to PCSX2 BIOS root
|
|
||||||
# NOTE: You will have to manually edit the PCSX2 ini file,
|
|
||||||
# since our ROM file does not have anything resembling a
|
|
||||||
# ROMDIR (and the BIOS selection menu only shows ROMs with a ROMDIR)
|
|
||||||
copy:
|
|
||||||
cp bin/ps2rom_$(CONFIG).rom ~/.config/PCSX2/bios
|
|
||||||
|
|
13
README.md
13
README.md
|
@ -1,13 +0,0 @@
|
||||||
# ps2rom
|
|
||||||
|
|
||||||
A bare-metal "template"? for the PS2. This essentially builds a replacement BIOS for both the EE and IOP.
|
|
||||||
|
|
||||||
No EE kernel, or IOP RTOS is loaded in this state. It's up to you to write the code to initalize either side of the system.
|
|
||||||
|
|
||||||
# Building
|
|
||||||
|
|
||||||
PS2SDK should be enough. (in theory, only ps2toolchain is actually needed, but I don't think there's a really good way to get that on its own)
|
|
||||||
|
|
||||||
`make CONFIG=[release|debug]` builds each flavor of the ROM.
|
|
||||||
|
|
||||||
There are some linker warnings currently, but they are fine to ignore.
|
|
|
@ -23,14 +23,14 @@ BINDIR = $(TOP)/bin
|
||||||
OBJDIR = obj/$(CONFIG)
|
OBJDIR = obj/$(CONFIG)
|
||||||
|
|
||||||
|
|
||||||
|
# include target-specific recipies specifying how to
|
||||||
|
# build for the target.
|
||||||
|
include $(TOP)/build/$(TARGET)-common.mk
|
||||||
|
#include $(TOP)/build/$(TARGET)-$(KIND).mk
|
||||||
|
|
||||||
FINALNAME=$(NAME)_$(CONFIG)
|
FINALNAME=$(NAME)_$(CONFIG)
|
||||||
|
|
||||||
OBJECTS := $(patsubst %.c,obj/$(CONFIG)/%.o,$(filter %.c,$(SRCS)))
|
OBJECTS := $(patsubst %.c,obj/$(CONFIG)/%.o,$(filter %.c,$(SRCS)))
|
||||||
OBJECTS += $(patsubst %.cpp,obj/$(CONFIG)/%.o,$(filter %.cpp,$(SRCS)))
|
OBJECTS += $(patsubst %.cpp,obj/$(CONFIG)/%.o,$(filter %.cpp,$(SRCS)))
|
||||||
OBJECTS += $(patsubst %.s,obj/$(CONFIG)/%.o,$(filter %.s,$(SRCS)))
|
OBJECTS += $(patsubst %.s,obj/$(CONFIG)/%.o,$(filter %.s,$(SRCS)))
|
||||||
|
|
||||||
# include target-specific recipies specifying how to
|
|
||||||
# build for the target.
|
|
||||||
include $(TOP)/build/targets/$(TARGET).mk
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
FINALNAME=$(NAME)_$(CONFIG)
|
||||||
|
|
||||||
|
OBJECTS := $(patsubst %.c,obj/$(CONFIG)/%.o,$(filter %.c,$(SRCS)))
|
||||||
|
OBJECTS += $(patsubst %.cpp,obj/$(CONFIG)/%.o,$(filter %.cpp,$(SRCS)))
|
||||||
|
OBJECTS += $(patsubst %.s,obj/$(CONFIG)/%.o,$(filter %.s,$(SRCS)))
|
||||||
|
|
||||||
|
$(BINDIR)/$(FINALNAME).elf: $(OBJDIR)/ $(BINDIR)/ $(OBJECTS)
|
||||||
|
$(LD) $(LDFLAGS) $(LIBS) $(OBJECTS) -o $@
|
||||||
|
|
||||||
|
clean-products:
|
||||||
|
-rm $(BINDIR)/$(FINALNAME).elf
|
||||||
|
-rm -rf obj
|
|
@ -0,0 +1,36 @@
|
||||||
|
# common EE toolchain stuff
|
||||||
|
|
||||||
|
# EE toolchain root.
|
||||||
|
EE_TRIPLET=mips64r5900el-ps2-elf
|
||||||
|
|
||||||
|
CC=$(EE_TRIPLET)-gcc
|
||||||
|
AS=$(CC) -mabi=32 -march=r3000 #HACK
|
||||||
|
CXX=$(EE_TRIPLET)-g++
|
||||||
|
#LD=$(CC)
|
||||||
|
LD=mipsel-ps2-irx-gcc # HACK
|
||||||
|
AR=$(EE_TRIPLET)-ar
|
||||||
|
OBJCOPY=$(EE_TRIPLET)-objcopy
|
||||||
|
|
||||||
|
ifeq ($(CONFIG),release)
|
||||||
|
CFLAGS := $(CFLAGS) -G0 -O3 -Wall -Wextra -Werror -fno-common -fno-strict-aliasing
|
||||||
|
ASFLAGS := -xassembler-with-cpp
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG),debug)
|
||||||
|
CFLAGS := $(CFLAGS) -G0 -O0 -g3 -Wall -Wextra -fno-common -fno-strict-aliasing
|
||||||
|
ASFLAGS := -xassembler-with-cpp -g3
|
||||||
|
endif
|
||||||
|
|
||||||
|
CXXFLAGS := $(CXXFLAGS) $(CFLAGS)
|
||||||
|
|
||||||
|
# compile rules
|
||||||
|
$(OBJDIR)/%.o: %.c
|
||||||
|
$(CC) -c $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o: %.cpp
|
||||||
|
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o: %.s
|
||||||
|
$(AS) -c $(ASFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
FINALNAME=$(NAME)_$(CONFIG)
|
||||||
|
|
||||||
|
OBJECTS := $(patsubst %.c,obj/$(CONFIG)/%.o,$(filter %.c,$(SRCS)))
|
||||||
|
OBJECTS += $(patsubst %.cpp,obj/$(CONFIG)/%.o,$(filter %.cpp,$(SRCS)))
|
||||||
|
OBJECTS += $(patsubst %.s,obj/$(CONFIG)/%.o,$(filter %.s,$(SRCS)))
|
||||||
|
|
||||||
|
clean-products:
|
||||||
|
-rm $(BINDIR)/lib$(FINALNAME).a
|
||||||
|
-rm -rf obj
|
||||||
|
|
||||||
|
$(BINDIR)/lib$(FINALNAME).a: $(OBJDIR)/ $(BINDIR)/ $(OBJECTS)
|
||||||
|
$(AR) rv $@ $(OBJECTS)
|
|
@ -1,7 +0,0 @@
|
||||||
$(BINDIR)/$(FINALNAME).elf: $(OBJDIR)/ $(BINDIR)/ $(OBJECTS)
|
|
||||||
$(LD) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@
|
|
||||||
|
|
||||||
clean-products:
|
|
||||||
-rm $(BINDIR)/$(FINALNAME).elf
|
|
||||||
-rm $(BINDIR)/$(FINALNAME).map
|
|
||||||
-rm -rf obj
|
|
|
@ -1,8 +0,0 @@
|
||||||
|
|
||||||
$(BINDIR)/lib$(FINALNAME).a: $(OBJDIR)/ $(BINDIR)/ $(OBJECTS)
|
|
||||||
$(AR) rv $@ $(OBJECTS)
|
|
||||||
|
|
||||||
|
|
||||||
clean-products:
|
|
||||||
-rm $(BINDIR)/lib$(FINALNAME).a
|
|
||||||
-rm -rf obj
|
|
|
@ -1,41 +0,0 @@
|
||||||
# common EE toolchain stuff
|
|
||||||
|
|
||||||
# EE toolchain root.
|
|
||||||
EE_TRIPLET=mips64r5900el-ps2-elf
|
|
||||||
|
|
||||||
CC=$(EE_TRIPLET)-gcc
|
|
||||||
AS=$(CC)
|
|
||||||
CXX=$(EE_TRIPLET)-g++
|
|
||||||
|
|
||||||
# we need to use this to link, because
|
|
||||||
# we target the 32bit ABI, which the
|
|
||||||
# EE linker really doesn't like.
|
|
||||||
# It seems like a hack, probably because it is.
|
|
||||||
LD=mipsel-ps2-irx-gcc
|
|
||||||
AR=$(EE_TRIPLET)-ar
|
|
||||||
OBJCOPY=$(EE_TRIPLET)-objcopy
|
|
||||||
|
|
||||||
ifeq ($(CONFIG),release)
|
|
||||||
CFLAGS := $(CFLAGS) -mabi=32 -G0 -O3 -Wall -Wextra -Werror -fno-common -fno-strict-aliasing
|
|
||||||
ASFLAGS := -mabi=32 -xassembler-with-cpp $(ASFLAGS)
|
|
||||||
LDFLAGS := -s $(LDFLAGS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG),debug)
|
|
||||||
CFLAGS := $(CFLAGS) -mabi=32 -G0 -O0 -g3 -Wall -Wextra -fno-common -fno-strict-aliasing
|
|
||||||
ASFLAGS := -mabi=32 -xassembler-with-cpp -g3 $(ASFLAGS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
CXXFLAGS := $(CXXFLAGS) $(CFLAGS)
|
|
||||||
|
|
||||||
# compile rules
|
|
||||||
$(OBJDIR)/%.o: %.c
|
|
||||||
$(CC) -c $(CFLAGS) $< -o $@
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
|
||||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o: %.s
|
|
||||||
$(AS) -c $(ASFLAGS) $< -o $@
|
|
||||||
|
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
# common IOP toolchain stuff
|
|
||||||
|
|
||||||
# EE toolchain root.
|
|
||||||
IOP_TRIPLET=mipsel-ps2-irx
|
|
||||||
|
|
||||||
CC=$(IOP_TRIPLET)-gcc
|
|
||||||
AS=$(CC)
|
|
||||||
CXX=$(IOP_TRIPLET)-g++
|
|
||||||
LD=$(CC)
|
|
||||||
AR=$(IOP_TRIPLET)-ar
|
|
||||||
OBJCOPY=$(IOP_TRIPLET)-objcopy
|
|
||||||
|
|
||||||
ifeq ($(CONFIG),release)
|
|
||||||
CFLAGS := $(CFLAGS) -msoft-float -G0 -O3 -Wall -Wextra -Werror -fno-common -fno-strict-aliasing
|
|
||||||
ASFLAGS := -EL -xassembler-with-cpp
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG),debug)
|
|
||||||
CFLAGS := $(CFLAGS) -msoft-float -G0 -O0 -g3 -Wall -Wextra -fno-common -fno-strict-aliasing
|
|
||||||
ASFLAGS := -EL -xassembler-with-cpp -g3
|
|
||||||
endif
|
|
||||||
|
|
||||||
CXXFLAGS := $(CXXFLAGS) $(CFLAGS)
|
|
||||||
|
|
||||||
# compile rules
|
|
||||||
$(OBJDIR)/%.o: %.c
|
|
||||||
$(CC) -c $(CFLAGS) $< -o $@
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
|
||||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o: %.s
|
|
||||||
$(AS) -c $(ASFLAGS) $< -o $@
|
|
||||||
|
|
||||||
|
|
33
rom/Makefile
33
rom/Makefile
|
@ -1,39 +1,44 @@
|
||||||
NAME=ps2rom
|
NAME=ps2rom
|
||||||
TARGET=iop
|
TARGET=ee
|
||||||
KIND=bin
|
KIND=bin
|
||||||
|
|
||||||
SELF=$(shell pwd)
|
SELF=$(shell pwd)
|
||||||
INCS = -I$(TOP)/rom
|
INCS = -I$(TOP)/src
|
||||||
|
|
||||||
CFLAGS = -ffreestanding -fno-stack-protector
|
CFLAGS = -ffreestanding -fno-stack-protector -mabi=32
|
||||||
CXXFLAGS = -fno-exceptions -fno-rtti
|
CXXFLAGS = -fno-exceptions -fno-rtti
|
||||||
LDFLAGS = -nostartfiles -nodefaultlibs -Wl,-Map,$(BINDIR)/$(FINALNAME).map -T$(SELF)/link.ld -L$(BINDIR)
|
LDFLAGS = -nostartfiles -nodefaultlibs -Wl,-Map,$(BINDIR)/$(FINALNAME).map -T$(SELF)/link.ld
|
||||||
|
|
||||||
# Link to each portion of the ROM codebase. For now,
|
|
||||||
# this will only link to the EE ROM codebase.
|
|
||||||
LIBS=-lps2rom_ee_$(CONFIG)
|
|
||||||
|
|
||||||
# sources
|
# sources
|
||||||
SRCS = rom_start.s
|
SRCS = start.s \
|
||||||
|
ee_start.c
|
||||||
include $(TOP)/build/core.mk
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: all clean clean-products
|
.PHONY: all clean clean-products
|
||||||
|
include $(TOP)/build/core.mk
|
||||||
|
|
||||||
|
|
||||||
all: $(BINDIR)/$(FINALNAME).rom
|
all: $(BINDIR)/$(FINALNAME).rom
|
||||||
|
|
||||||
|
|
||||||
$(BINDIR)/:
|
$(BINDIR)/:
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
$(OBJDIR)/:
|
$(OBJDIR)/:
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
$(BINDIR)/$(FINALNAME).rom: $(BINDIR)/$(FINALNAME).elf
|
|
||||||
$(OBJCOPY) -O binary $< $@
|
clean-products:
|
||||||
|
-rm $(BINDIR)/$(FINALNAME).elf
|
||||||
|
-rm -rf obj
|
||||||
|
|
||||||
clean: clean-products
|
clean: clean-products
|
||||||
-rm $(BINDIR)/$(FINALNAME).rom
|
-rm $(BINDIR)/$(FINALNAME).rom
|
||||||
|
|
||||||
include $(TOP)/build/products/$(KIND).mk
|
|
||||||
|
$(BINDIR)/$(FINALNAME).rom: $(BINDIR)/$(FINALNAME).elf
|
||||||
|
$(OBJCOPY) -O binary $< $@
|
||||||
|
|
||||||
|
$(BINDIR)/$(FINALNAME).elf: $(OBJDIR)/ $(BINDIR)/ $(OBJECTS)
|
||||||
|
$(LD) $(LDFLAGS) $(LIBS) $(OBJECTS) -o $@
|
||||||
|
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
NAME=ps2rom_ee
|
|
||||||
TARGET=ee
|
|
||||||
KIND=lib
|
|
||||||
|
|
||||||
INCS = -I$(TOP)/rom
|
|
||||||
|
|
||||||
CFLAGS = -ffreestanding -fno-stack-protector
|
|
||||||
CXXFLAGS = -fno-exceptions -fno-rtti
|
|
||||||
|
|
||||||
# sources
|
|
||||||
SRCS = _ee_start.s \
|
|
||||||
ee_start.c
|
|
||||||
|
|
||||||
.PHONY: all clean clean-products
|
|
||||||
|
|
||||||
include $(TOP)/build/core.mk
|
|
||||||
|
|
||||||
all: $(BINDIR)/lib$(FINALNAME).a
|
|
||||||
|
|
||||||
$(BINDIR)/:
|
|
||||||
mkdir -p $@
|
|
||||||
|
|
||||||
$(OBJDIR)/:
|
|
||||||
mkdir -p $@
|
|
||||||
|
|
||||||
clean: clean-products
|
|
||||||
|
|
||||||
include $(TOP)/build/products/$(KIND).mk
|
|
|
@ -1,9 +0,0 @@
|
||||||
.set noat
|
|
||||||
.globl _ee_start
|
|
||||||
.extern ee_start
|
|
||||||
|
|
||||||
// __noreturn __naked void _ee_start()
|
|
||||||
// This is the primary entrypoint for the EE code
|
|
||||||
_ee_start:
|
|
||||||
li $sp, 0x80010000 // temporary stack
|
|
||||||
j ee_start
|
|
|
@ -6,11 +6,19 @@ static void putc(char c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void puts(const char* s) {
|
static void puts(const char* s) {
|
||||||
while (*s)
|
while (*s != 0) {
|
||||||
putc(*s++);
|
putc(*s++);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
__noreturn void _ee_start() {
|
__noreturn void _ee_start() {
|
||||||
puts("EE: Hello World from Lily~\n");
|
puts("Hello World from Riri~ (EE)\n");
|
||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__asm__ (
|
||||||
|
".global ee_start\n"
|
||||||
|
"ee_start:\n"
|
||||||
|
"li $sp, 0x80010000\n"
|
||||||
|
"j _ee_start\n");
|
|
@ -1,25 +0,0 @@
|
||||||
// This is the entry point of the ROM.
|
|
||||||
// It is limited to 32-bit MIPS-I code,
|
|
||||||
// because it runs on both the EE and the IOP.
|
|
||||||
//
|
|
||||||
// The task of this relatively short bit of code
|
|
||||||
// is to start the approiate part of the ROM
|
|
||||||
// on the correct processor.
|
|
||||||
//
|
|
||||||
// It's a bit creative, but also a bit annoying.
|
|
||||||
.org 0
|
|
||||||
.set noat
|
|
||||||
|
|
||||||
// externs
|
|
||||||
.extern _ee_start
|
|
||||||
|
|
||||||
.globl _start
|
|
||||||
_start:
|
|
||||||
mfc0 $at, $15 // load the PRID
|
|
||||||
sltiu $at, 0x59 // Check for EE PRID
|
|
||||||
bne $15, 0, __iop // Branch if not EE
|
|
||||||
nop
|
|
||||||
j _ee_start // Call EE start routine
|
|
||||||
nop
|
|
||||||
__iop: // for now the iop stalls.
|
|
||||||
j __iop
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
.org 0
|
||||||
|
.set noat
|
||||||
|
|
||||||
|
// externs
|
||||||
|
.extern ee_start
|
||||||
|
|
||||||
|
.globl _start
|
||||||
|
_start:
|
||||||
|
mfc0 $at, $15 // load PRID
|
||||||
|
sltiu $at, 0x59
|
||||||
|
bne $15, 0, __iop
|
||||||
|
nop
|
||||||
|
j ee_start
|
||||||
|
nop
|
||||||
|
__iop: // for now iop stalls.
|
||||||
|
j __iop
|
Loading…
Reference in New Issue