Skip to content

Commit 8f684bf

Browse files
authored
Merge pull request #158 from nicolasnoble/openbios
Starting an OpenBios subproject.
2 parents 96e3e01 + b321952 commit 8f684bf

File tree

21 files changed

+1150
-3
lines changed

21 files changed

+1150
-3
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
name: Build
1919
command: |
2020
make -j 2
21+
make -C src/mips/openbios -j 2
2122
2223
workflows:
2324
version: 2

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ RUN apt install -y wget gnupg
99
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
1010
RUN apt update
1111
RUN apt install -y software-properties-common
12-
RUN apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic main"
12+
RUN apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main"
1313
RUN apt update
1414
RUN apt install -y make g++-8 clang-9 git
1515
RUN apt install -y pkg-config libsdl2-dev libavcodec-dev libavformat-dev libavutil-dev libswresample-dev zlib1g-dev libglfw3-dev libuv1-dev
16+
RUN apt install -y g++-mipsel-linux-gnu
1617

1718
USER coder
1819

dockermake.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#!/bin/sh
22

3+
ROOT=$(dirname $0)
4+
CWD=$(pwd)
5+
cd $ROOT
6+
ROOT=$(pwd)
7+
cd $CWD
8+
39
docker pull grumpycoders/pcsx-redux-build:latest
4-
docker run --rm --env-file env.list -t -i -v "${PWD}:/project" -u `id -u`:`id -g` grumpycoders/pcsx-redux-build:latest make $@
10+
docker run --rm --env-file ${ROOT}/env.list -t -i -w/project${CWD#$ROOT} -v "${ROOT}:/project" -u `id -u`:`id -g` grumpycoders/pcsx-redux-build:latest make $@

src/mips/common.mk

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
PREFIX = mipsel-linux-gnu
2+
3+
CC = $(PREFIX)-gcc
4+
5+
ARCHFLAGS = -march=mips1 -mabi=32 -EL -msoft-float -Wa,-msoft-float -fno-pic -mno-shared -mno-abicalls
6+
CPPFLAGS = -mno-gpopt -fomit-frame-pointer
7+
CPPFLAGS += -fno-builtin
8+
CPPFLAGS += $(ARCHFLAGS)
9+
CPPFLAGS += -I..
10+
11+
LDFLAGS = -Wl,-Map=$(TARGET).map -nostdlib -T$(LDSCRIPT) -static -Wl,--gc-sections
12+
LDFLAGS += $(ARCHFLAGS)
13+
14+
LDFLAGS += -g -O3 -flto
15+
CPPFLAGS += -g -O3 -flto
16+
17+
OBJS += $(addsuffix .o, $(basename $(SRCS)))
18+
19+
all: $(TARGET).bin
20+
21+
clean:
22+
rm -f $(OBJS) $(TARGET).elf $(TARGET).map $(TARGET).bin
23+
24+
$(TARGET).bin: $(TARGET).elf
25+
$(PREFIX)-objcopy -O binary $< $@
26+
27+
$(TARGET).elf: $(OBJS)
28+
$(CC) $(LDFLAGS) -g -o $(TARGET).elf $(OBJS)
29+
30+
%.o: %.s
31+
$(CC) $(ARCHFLAGS) -I.. -g -c -o $@ $<

src/mips/common/compiler/stdint.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/***************************************************************************
2+
* Copyright (C) 2019 PCSX-Redux authors *
3+
* *
4+
* This program is free software; you can redistribute it and/or modify *
5+
* it under the terms of the GNU General Public License as published by *
6+
* the Free Software Foundation; either version 2 of the License, or *
7+
* (at your option) any later version. *
8+
* *
9+
* This program is distributed in the hope that it will be useful, *
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12+
* GNU General Public License for more details. *
13+
* *
14+
* You should have received a copy of the GNU General Public License *
15+
* along with this program; if not, write to the *
16+
* Free Software Foundation, Inc., *
17+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18+
***************************************************************************/
19+
20+
#pragma once
21+
22+
typedef signed char int8_t;
23+
typedef signed short int16_t;
24+
typedef signed int int32_t;
25+
typedef unsigned char uint8_t;
26+
typedef unsigned short uint16_t;
27+
typedef unsigned int uint32_t;

src/mips/common/hardware/cop0.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/***************************************************************************
2+
* Copyright (C) 2019 PCSX-Redux authors *
3+
* *
4+
* This program is free software; you can redistribute it and/or modify *
5+
* it under the terms of the GNU General Public License as published by *
6+
* the Free Software Foundation; either version 2 of the License, or *
7+
* (at your option) any later version. *
8+
* *
9+
* This program is distributed in the hope that it will be useful, *
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12+
* GNU General Public License for more details. *
13+
* *
14+
* You should have received a copy of the GNU General Public License *
15+
* along with this program; if not, write to the *
16+
* Free Software Foundation, Inc., *
17+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18+
***************************************************************************/
19+
20+
#pragma once
21+
22+
#include "common/compiler/stdint.h"
23+
24+
uint32_t readCOP0Status();
25+
void writeCOP0Status(uint32_t);

src/mips/common/hardware/cop0.s

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/***************************************************************************
2+
* Copyright (C) 2019 PCSX-Redux authors *
3+
* *
4+
* This program is free software; you can redistribute it and/or modify *
5+
* it under the terms of the GNU General Public License as published by *
6+
* the Free Software Foundation; either version 2 of the License, or *
7+
* (at your option) any later version. *
8+
* *
9+
* This program is distributed in the hope that it will be useful, *
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12+
* GNU General Public License for more details. *
13+
* *
14+
* You should have received a copy of the GNU General Public License *
15+
* along with this program; if not, write to the *
16+
* Free Software Foundation, Inc., *
17+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18+
***************************************************************************/
19+
20+
.section .text, "ax", @progbits
21+
.set noreorder
22+
23+
.align 2
24+
.global readCOP0Status
25+
.type readCOP0Status, @function
26+
readCOP0Status:
27+
mfc0 $v0, $12
28+
nop
29+
jr $ra
30+
nop
31+
32+
.align 2
33+
.global writeCOP0Status
34+
.type writeCOP0Status, @function
35+
writeCOP0Status:
36+
mtc0 $a0, $12
37+
nop
38+
jr $ra
39+
nop

src/mips/common/hardware/hwregs.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/***************************************************************************
2+
* Copyright (C) 2019 PCSX-Redux authors *
3+
* *
4+
* This program is free software; you can redistribute it and/or modify *
5+
* it under the terms of the GNU General Public License as published by *
6+
* the Free Software Foundation; either version 2 of the License, or *
7+
* (at your option) any later version. *
8+
* *
9+
* This program is distributed in the hope that it will be useful, *
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12+
* GNU General Public License for more details. *
13+
* *
14+
* You should have received a copy of the GNU General Public License *
15+
* along with this program; if not, write to the *
16+
* Free Software Foundation, Inc., *
17+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18+
***************************************************************************/
19+
20+
#pragma once
21+
22+
#include "common/compiler/stdint.h"
23+
24+
#define HW_U8(x) (*(volatile uint8_t *)(x))
25+
#define HW_U16(x) (*(volatile uint16_t *)(x))
26+
#define HW_U32(x) (*(volatile uint32_t *)(x))
27+
#define HW_S8(x) (*(volatile int8_t *)(x))
28+
#define HW_S16(x) (*(volatile int16_t *)(x))
29+
#define HW_S32(x) (*(volatile int32_t *)(x))
30+
31+
#define SPU_MVOL_L HW_U16(0x1f801d80)
32+
#define SPU_MVOL_R HW_U16(0x1f801d82)
33+
#define SPU_REVERB_L HW_U16(0x1f801d84)
34+
#define SPU_REVERB_R HW_U16(0x1f801d86)

src/mips/common/hardware/hwregs.inc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/***************************************************************************
2+
* Copyright (C) 2019 PCSX-Redux authors *
3+
* *
4+
* This program is free software; you can redistribute it and/or modify *
5+
* it under the terms of the GNU General Public License as published by *
6+
* the Free Software Foundation; either version 2 of the License, or *
7+
* (at your option) any later version. *
8+
* *
9+
* This program is distributed in the hope that it will be useful, *
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12+
* GNU General Public License for more details. *
13+
* *
14+
* You should have received a copy of the GNU General Public License *
15+
* along with this program; if not, write to the *
16+
* Free Software Foundation, Inc., *
17+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18+
***************************************************************************/
19+
20+
.set SBUS_DEV0_ADDR, 0x1f801000
21+
.set SBUS_DEV8_ADDR, 0x1f801004
22+
23+
.set SBUS_DEV0_CTRL, 0x1f801008
24+
.set SBUS_DEV1_CTRL, 0x1f80100C
25+
.set SBUS_DEV2_CTRL, 0x1f801010
26+
.set SBUS_DEV4_CTRL, 0x1f801014
27+
.set SBUS_DEV5_CTRL, 0x1f801018
28+
.set SBUS_DEV8_CTRL, 0x1f80101C
29+
30+
.set SBUS_COM_CTRL, 0x1f801020
31+
32+
.set RAM_SIZE, 0x1f801060
33+
34+
.set CACHE_CTRL, 0xfffe0130

src/mips/common/hardware/spu.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/***************************************************************************
2+
* Copyright (C) 2019 PCSX-Redux authors *
3+
* *
4+
* This program is free software; you can redistribute it and/or modify *
5+
* it under the terms of the GNU General Public License as published by *
6+
* the Free Software Foundation; either version 2 of the License, or *
7+
* (at your option) any later version. *
8+
* *
9+
* This program is distributed in the hope that it will be useful, *
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12+
* GNU General Public License for more details. *
13+
* *
14+
* You should have received a copy of the GNU General Public License *
15+
* along with this program; if not, write to the *
16+
* Free Software Foundation, Inc., *
17+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18+
***************************************************************************/
19+
20+
#pragma once
21+
22+
#include "hwregs.h"
23+
24+
static inline void muteSpu() {
25+
SPU_REVERB_R = 0;
26+
SPU_REVERB_L = 0;
27+
SPU_MVOL_R = 0;
28+
SPU_MVOL_L = 0;
29+
}

0 commit comments

Comments
 (0)