Compare commits
2 Commits
d7e07280d0
...
d6810cf729
Author | SHA1 | Date |
---|---|---|
Lily Tsuru | d6810cf729 | |
Lily Tsuru | feb0648b9a |
11
Makefile
11
Makefile
|
@ -1,4 +1,4 @@
|
|||
.PHONY: all clean
|
||||
.PHONY: all copy clean
|
||||
|
||||
TOP=$(shell pwd)
|
||||
|
||||
|
@ -8,7 +8,16 @@ CONFIG=release
|
|||
endif
|
||||
|
||||
all:
|
||||
make -C rom/ee TOP=$(TOP) CONFIG=$(CONFIG)
|
||||
make -C rom TOP=$(TOP) CONFIG=$(CONFIG)
|
||||
|
||||
clean:
|
||||
make -C rom/ee 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
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# 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)
|
||||
|
||||
|
||||
# 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)
|
||||
|
||||
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)))
|
||||
|
||||
# include target-specific recipies specifying how to
|
||||
# build for the target.
|
||||
include $(TOP)/build/targets/$(TARGET).mk
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
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
|
|
@ -1,36 +0,0 @@
|
|||
# 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 $@
|
||||
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
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)
|
|
@ -0,0 +1,7 @@
|
|||
$(BINDIR)/$(FINALNAME).elf: $(OBJDIR)/ $(BINDIR)/ $(OBJECTS)
|
||||
$(LD) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@
|
||||
|
||||
clean-products:
|
||||
-rm $(BINDIR)/$(FINALNAME).elf
|
||||
-rm $(BINDIR)/$(FINALNAME).map
|
||||
-rm -rf obj
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
$(BINDIR)/lib$(FINALNAME).a: $(OBJDIR)/ $(BINDIR)/ $(OBJECTS)
|
||||
$(AR) rv $@ $(OBJECTS)
|
||||
|
||||
|
||||
clean-products:
|
||||
-rm $(BINDIR)/lib$(FINALNAME).a
|
||||
-rm -rf obj
|
|
@ -0,0 +1,41 @@
|
|||
# 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 $@
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
# 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 $@
|
||||
|
||||
|
35
rom/Makefile
35
rom/Makefile
|
@ -1,44 +1,39 @@
|
|||
NAME=ps2rom
|
||||
TARGET=ee
|
||||
TARGET=iop
|
||||
KIND=bin
|
||||
|
||||
SELF=$(shell pwd)
|
||||
INCS = -I$(TOP)/src
|
||||
INCS = -I$(TOP)/rom
|
||||
|
||||
CFLAGS = -ffreestanding -fno-stack-protector -mabi=32
|
||||
CFLAGS = -ffreestanding -fno-stack-protector
|
||||
CXXFLAGS = -fno-exceptions -fno-rtti
|
||||
LDFLAGS = -nostartfiles -nodefaultlibs -Wl,-Map,$(BINDIR)/$(FINALNAME).map -T$(SELF)/link.ld
|
||||
LDFLAGS = -nostartfiles -nodefaultlibs -Wl,-Map,$(BINDIR)/$(FINALNAME).map -T$(SELF)/link.ld -L$(BINDIR)
|
||||
|
||||
# Link to each portion of the ROM codebase. For now,
|
||||
# this will only link to the EE ROM codebase.
|
||||
LIBS=-lps2rom_ee_$(CONFIG)
|
||||
|
||||
# sources
|
||||
SRCS = start.s \
|
||||
ee_start.c
|
||||
SRCS = rom_start.s
|
||||
|
||||
|
||||
.PHONY: all clean clean-products
|
||||
include $(TOP)/build/core.mk
|
||||
|
||||
|
||||
all: $(BINDIR)/$(FINALNAME).rom
|
||||
.PHONY: all clean clean-products
|
||||
|
||||
|
||||
all: $(BINDIR)/$(FINALNAME).rom
|
||||
|
||||
$(BINDIR)/:
|
||||
mkdir -p $@
|
||||
|
||||
$(OBJDIR)/:
|
||||
mkdir -p $@
|
||||
|
||||
|
||||
clean-products:
|
||||
-rm $(BINDIR)/$(FINALNAME).elf
|
||||
-rm -rf obj
|
||||
$(BINDIR)/$(FINALNAME).rom: $(BINDIR)/$(FINALNAME).elf
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
||||
clean: clean-products
|
||||
-rm $(BINDIR)/$(FINALNAME).rom
|
||||
|
||||
|
||||
$(BINDIR)/$(FINALNAME).rom: $(BINDIR)/$(FINALNAME).elf
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
||||
$(BINDIR)/$(FINALNAME).elf: $(OBJDIR)/ $(BINDIR)/ $(OBJECTS)
|
||||
$(LD) $(LDFLAGS) $(LIBS) $(OBJECTS) -o $@
|
||||
|
||||
include $(TOP)/build/products/$(KIND).mk
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
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
|
|
@ -0,0 +1,9 @@
|
|||
.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,19 +6,11 @@ static void putc(char c) {
|
|||
}
|
||||
|
||||
static void puts(const char* s) {
|
||||
while (*s != 0) {
|
||||
while (*s)
|
||||
putc(*s++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
__noreturn void _ee_start() {
|
||||
puts("Hello World from Riri~ (EE)\n");
|
||||
puts("EE: Hello World from Lily~\n");
|
||||
while(1);
|
||||
}
|
||||
|
||||
__asm__ (
|
||||
".global ee_start\n"
|
||||
"ee_start:\n"
|
||||
"li $sp, 0x80010000\n"
|
||||
"j _ee_start\n");
|
|
@ -0,0 +1,25 @@
|
|||
// 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
|
16
rom/start.s
16
rom/start.s
|
@ -1,16 +0,0 @@
|
|||
.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