Skip to content

Shell stub. #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
name: Build
command: |
make -j 2
make -C src/mips/shell -j 2
make -C src/mips/openbios -j 2

workflows:
Expand Down
10 changes: 10 additions & 0 deletions src/mips/shell/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
TARGET = shell

SRCS = \
../common/hardware/cop0.s \
crt0/crt0.s \
main/main.c \

LDSCRIPT = shell.ld

include ../common.mk
43 changes: 43 additions & 0 deletions src/mips/shell/crt0/crt0.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/***************************************************************************
* Copyright (C) 2019 PCSX-Redux authors *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
***************************************************************************/

.section .start, "ax", @progbits
.align 2
.global main
.global _start
.type _start, @function

_start:
la $t0, __bss_start
la $t1, __bss_end

beq $t0, $t1, bss_init_skip

bss_init:
sw $0, 0($t0)
addiu $t0, 4
bne $t0, $t1, bss_init

bss_init_skip:

li $a0, 0
li $a1, 0
jal main

jr $ra
24 changes: 24 additions & 0 deletions src/mips/shell/main/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/***************************************************************************
* Copyright (C) 2019 PCSX-Redux authors *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
***************************************************************************/

#include "common/hardware/cop0.h"

int main() {
return 0;
}
104 changes: 104 additions & 0 deletions src/mips/shell/shell.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/***************************************************************************
* Copyright (C) 2019 PCSX-Redux authors *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
***************************************************************************/

OUTPUT_FORMAT("elf32-tradlittlemips")
OUTPUT_ARCH(mips)

EXTERN(_start)
ENTRY(_start)

MEMORY {
ram (rwx) : ORIGIN = 0x80010000, LENGTH = 2M - 0x10000
dcache : ORIGIN = 0x1f800000, LENGTH = 0x400
}

__ram_top = ORIGIN(ram) + LENGTH(ram);
__sp = __ram_top - 0x100;

__dcache = ORIGIN(dcache);
__dcache_top = ORIGIN(dcache) + LENGTH(dcache);

__bss_len = (__bss_end - __bss_start);

SECTIONS {
__text_start = .;
.text : {
*(.start)
*(.init)
KEEP (*(SORT_NONE(.fini)))
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(.text.exit .text.exit.*)
*(.text.startup .text.startup.*)
*(.text.hot .text.hot.*)
*(.text .stub .text.* .gnu.linkonce.t.*)
. = ALIGN(4);
} > ram

.fini : {
} > ram
. = ALIGN(4);
__text_end = .;

.rodata : {
*(.rodata .rodata.* .rdata .rdata.* .gnu.linkonce.r.*)
} > ram

.rodata1 : {
*(.rodata1)
} > ram

__data_start = .;
.data : {
*(.a0table)
*(.data .data.* .gnu.linkonce.d.*)
*(.data1)
*(.got.plt)
*(.got)
} > ram

. = ALIGN(4);

__bss_start = .;
.sbss : {
*(.dynsbss)
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon)
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
} > ram

. = ALIGN(4);
__bss_end = .;

__end = .;

/DISCARD/ : { *(.MIPS.abiflags) }

/* Everything is statically linked, so discard PLTs. */
/DISCARD/ : { *(.rel.iplt) *(.rela.iplt) *(.rel.plt) *(.rela.plt) *(.plt) *(.iplt) }

/* We don't make use of debugging information, so drop that, too. */
/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) }

/* Discard things that the standard link script drops, too. */
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }

/DISCARD/ : { *(.note.gnu.build-id) }
}