ps2rom: Initial commit
This is the first version of the code which works.
This commit is contained in:
commit
d7e07280d0
|
@ -0,0 +1,2 @@
|
|||
bin/
|
||||
**/obj
|
|
@ -0,0 +1,14 @@
|
|||
.PHONY: all clean
|
||||
|
||||
TOP=$(shell pwd)
|
||||
|
||||
# Set a default configuration.
|
||||
ifeq ($(CONFIG),)
|
||||
CONFIG=release
|
||||
endif
|
||||
|
||||
all:
|
||||
make -C rom TOP=$(TOP) CONFIG=$(CONFIG)
|
||||
|
||||
clean:
|
||||
make -C rom TOP=$(TOP) CONFIG=$(CONFIG) clean
|
|
@ -0,0 +1,36 @@
|
|||
# Common GNU Make rules for building the project
|
||||
|
||||
# This makefile is expected to be included after the variables given
|
||||
# have been defined:
|
||||
#
|
||||
# NAME=name
|
||||
#
|
||||
# TARGET=ee|iop
|
||||
#
|
||||
# KIND=bin|lib
|
||||
#
|
||||
# SRCS=[... source-file-list]
|
||||
#
|
||||
|
||||
debug_Valid := y
|
||||
release_Valid := y
|
||||
|
||||
ifneq ($($(CONFIG)_Valid),y)
|
||||
$(error Invalid configuration $(CONFIG) specified)
|
||||
endif
|
||||
|
||||
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)))
|
||||
|
|
@ -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)
|
|
@ -0,0 +1,44 @@
|
|||
NAME=ps2rom
|
||||
TARGET=ee
|
||||
KIND=bin
|
||||
|
||||
SELF=$(shell pwd)
|
||||
INCS = -I$(TOP)/src
|
||||
|
||||
CFLAGS = -ffreestanding -fno-stack-protector -mabi=32
|
||||
CXXFLAGS = -fno-exceptions -fno-rtti
|
||||
LDFLAGS = -nostartfiles -nodefaultlibs -Wl,-Map,$(BINDIR)/$(FINALNAME).map -T$(SELF)/link.ld
|
||||
|
||||
# sources
|
||||
SRCS = start.s \
|
||||
ee_start.c
|
||||
|
||||
|
||||
.PHONY: all clean clean-products
|
||||
include $(TOP)/build/core.mk
|
||||
|
||||
|
||||
all: $(BINDIR)/$(FINALNAME).rom
|
||||
|
||||
|
||||
$(BINDIR)/:
|
||||
mkdir -p $@
|
||||
|
||||
$(OBJDIR)/:
|
||||
mkdir -p $@
|
||||
|
||||
|
||||
clean-products:
|
||||
-rm $(BINDIR)/$(FINALNAME).elf
|
||||
-rm -rf obj
|
||||
|
||||
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 $@
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
#define __noreturn __attribute__((noreturn))
|
||||
|
||||
static void putc(char c) {
|
||||
*((char*)0x1000f180) = c;
|
||||
}
|
||||
|
||||
static void puts(const char* s) {
|
||||
while (*s != 0) {
|
||||
putc(*s++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
__noreturn void _ee_start() {
|
||||
puts("Hello World from Riri~ (EE)\n");
|
||||
while(1);
|
||||
}
|
||||
|
||||
__asm__ (
|
||||
".global ee_start\n"
|
||||
"ee_start:\n"
|
||||
"li $sp, 0x80010000\n"
|
||||
"j _ee_start\n");
|
|
@ -0,0 +1,68 @@
|
|||
_stack_size = 0x80000;
|
||||
_heap_size = 1024*1024*10;
|
||||
|
||||
|
||||
ENTRY(_start);
|
||||
SECTIONS {
|
||||
/* 0xbfc00000 */
|
||||
.text 0xbfc00000 : {
|
||||
_text_origin = .;
|
||||
*start.o /* Always link reset first */
|
||||
|
||||
*(.text)
|
||||
*(.rodata)
|
||||
}
|
||||
_text_size = . - _text_origin;
|
||||
|
||||
.reginfo ALIGN(128) : {
|
||||
*(.reginfo)
|
||||
}
|
||||
|
||||
.data ALIGN(128) : {
|
||||
_data_origin = .;
|
||||
*(.data)
|
||||
}
|
||||
|
||||
.rdata ALIGN(128) : {
|
||||
*(.rdata)
|
||||
}
|
||||
|
||||
_data_size = . - _data_origin;
|
||||
|
||||
_gp = ALIGN(128) + 0x7ff0;
|
||||
.lit4 ALIGN(128) : {
|
||||
*(.lit4)
|
||||
}
|
||||
.lit8 ALIGN(128) : {
|
||||
*(.lit8)
|
||||
}
|
||||
.sdata ALIGN(128) : {
|
||||
*(.sdata)
|
||||
}
|
||||
|
||||
.sbss ALIGN(128) (NOLOAD) : { /* uninitialized data */
|
||||
_fbss = . ;
|
||||
*(.scommon)
|
||||
*(.sbss)
|
||||
}
|
||||
|
||||
.bss ALIGN(128) (NOLOAD) : { /* uninitialized data */
|
||||
*(.bss)
|
||||
}
|
||||
|
||||
.COMMON ALIGN(128) (NOLOAD) : { /* uninitialized data */
|
||||
*(COMMON)
|
||||
}
|
||||
|
||||
_bss_size = . - _fbss;
|
||||
|
||||
_end_bss = . - 4;
|
||||
_stack = .;
|
||||
. += _stack_size ;
|
||||
_end_stack = . - 8*5;
|
||||
_end = . ;
|
||||
__lc_bh = . ;
|
||||
. += _heap_size ;
|
||||
__lc_eh = .;
|
||||
|
||||
}
|
|
@ -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