Skip to content

Commit ad25507

Browse files
authored
Merge pull request #163 from nicolasnoble/shell
Shell stub.
2 parents 8f684bf + b02e175 commit ad25507

File tree

5 files changed

+182
-0
lines changed

5 files changed

+182
-0
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/shell -j 2
2122
make -C src/mips/openbios -j 2
2223
2324
workflows:

src/mips/shell/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
TARGET = shell
2+
3+
SRCS = \
4+
../common/hardware/cop0.s \
5+
crt0/crt0.s \
6+
main/main.c \
7+
8+
LDSCRIPT = shell.ld
9+
10+
include ../common.mk

src/mips/shell/crt0/crt0.s

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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 .start, "ax", @progbits
21+
.align 2
22+
.global main
23+
.global _start
24+
.type _start, @function
25+
26+
_start:
27+
la $t0, __bss_start
28+
la $t1, __bss_end
29+
30+
beq $t0, $t1, bss_init_skip
31+
32+
bss_init:
33+
sw $0, 0($t0)
34+
addiu $t0, 4
35+
bne $t0, $t1, bss_init
36+
37+
bss_init_skip:
38+
39+
li $a0, 0
40+
li $a1, 0
41+
jal main
42+
43+
jr $ra

src/mips/shell/main/main.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
#include "common/hardware/cop0.h"
21+
22+
int main() {
23+
return 0;
24+
}

src/mips/shell/shell.ld

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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+
OUTPUT_FORMAT("elf32-tradlittlemips")
21+
OUTPUT_ARCH(mips)
22+
23+
EXTERN(_start)
24+
ENTRY(_start)
25+
26+
MEMORY {
27+
ram (rwx) : ORIGIN = 0x80010000, LENGTH = 2M - 0x10000
28+
dcache : ORIGIN = 0x1f800000, LENGTH = 0x400
29+
}
30+
31+
__ram_top = ORIGIN(ram) + LENGTH(ram);
32+
__sp = __ram_top - 0x100;
33+
34+
__dcache = ORIGIN(dcache);
35+
__dcache_top = ORIGIN(dcache) + LENGTH(dcache);
36+
37+
__bss_len = (__bss_end - __bss_start);
38+
39+
SECTIONS {
40+
__text_start = .;
41+
.text : {
42+
*(.start)
43+
*(.init)
44+
KEEP (*(SORT_NONE(.fini)))
45+
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
46+
*(.text.exit .text.exit.*)
47+
*(.text.startup .text.startup.*)
48+
*(.text.hot .text.hot.*)
49+
*(.text .stub .text.* .gnu.linkonce.t.*)
50+
. = ALIGN(4);
51+
} > ram
52+
53+
.fini : {
54+
} > ram
55+
. = ALIGN(4);
56+
__text_end = .;
57+
58+
.rodata : {
59+
*(.rodata .rodata.* .rdata .rdata.* .gnu.linkonce.r.*)
60+
} > ram
61+
62+
.rodata1 : {
63+
*(.rodata1)
64+
} > ram
65+
66+
__data_start = .;
67+
.data : {
68+
*(.a0table)
69+
*(.data .data.* .gnu.linkonce.d.*)
70+
*(.data1)
71+
*(.got.plt)
72+
*(.got)
73+
} > ram
74+
75+
. = ALIGN(4);
76+
77+
__bss_start = .;
78+
.sbss : {
79+
*(.dynsbss)
80+
*(.sbss .sbss.* .gnu.linkonce.sb.*)
81+
*(.scommon)
82+
*(.dynbss)
83+
*(.bss .bss.* .gnu.linkonce.b.*)
84+
*(COMMON)
85+
} > ram
86+
87+
. = ALIGN(4);
88+
__bss_end = .;
89+
90+
__end = .;
91+
92+
/DISCARD/ : { *(.MIPS.abiflags) }
93+
94+
/* Everything is statically linked, so discard PLTs. */
95+
/DISCARD/ : { *(.rel.iplt) *(.rela.iplt) *(.rel.plt) *(.rela.plt) *(.plt) *(.iplt) }
96+
97+
/* We don't make use of debugging information, so drop that, too. */
98+
/DISCARD/ : { *(.debug) *(.debug_srcinfo) *(.debug_sfnames) *(.debug_aranges) *(.debug_pubnames) *(.debug_info .gnu.linkonce.wi.*) *(.debug_abbrev) *(.debug_line .debug_line.* .debug_line_end ) *(.debug_frame) *(.debug_str) *(.debug_loc) *(.debug_macinfo) *(.debug_weaknames) *(.debug_funcnames) *(.debug_typenames) *(.debug_varnames) *(.debug_pubtypes) *(.debug_ranges) *(.debug_macro) *(.mdebug.abi32) *(.mdebug.abiN32) *(.mdebug.abi64) *(.mdebug.abiO64) *(.mdebug.eabi32) *(.mdebug.eabi64) }
99+
100+
/* Discard things that the standard link script drops, too. */
101+
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
102+
103+
/DISCARD/ : { *(.note.gnu.build-id) }
104+
}

0 commit comments

Comments
 (0)