Skip to content

Commit 18be7ad

Browse files
committed
Tinyload!
1 parent 713ca8e commit 18be7ad

File tree

8 files changed

+267
-281
lines changed

8 files changed

+267
-281
lines changed

src/mips/tinyload/Makefile

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
TARGET = tinyload.psx
1+
TARGET = tinyload.bin
22
TLOAD_ADDR = 0x80030000
33
SRCS = \
44
crt0/crt0.S \
55
src/main.c \
6-
src/syscalls.S
7-
6+
src/exec.S \
7+
src/flushcache.s
8+
89
LIBS =
910

10-
LDSCRIPT = ../psx-exe.ld
11-
CPPFLAGS := -I../ps1sdk/include -Isrc -Iinclude
11+
LDSCRIPT = ../shell/shell.ld
12+
CPPFLAGS := -Isrc -Iinclude
1213
LDFLAGS :=
1314

1415
include ../common.mk

src/mips/tinyload/Makefile.binary

-14
This file was deleted.

src/mips/tinyload/crt0-dummy/crt0.S

-62
This file was deleted.

src/mips/tinyload/crt0/crt0.S

+1-28
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,10 @@
2828
.global main
2929
.global _start
3030
.type _start, @function
31+
.ent _start
3132
_start:
32-
la t0, __bss_start
33-
la t1, __bss_end
34-
addiu t1, t1, 3
35-
srl t1, t1, 2
36-
sll t1, t1, 2
37-
beq t0, t1, _zero_bss_done
38-
nop
39-
40-
_zero_bss:
41-
sw zero, 0(t0)
42-
addiu t0, t0, 4
43-
bne t0, t1, _zero_bss
44-
nop
45-
46-
_zero_bss_done:
47-
/* la gp, _gp*/
4833
li a0, 0
4934
j main
5035
li a1, 0
51-
52-
/*
5336
.end _start
54-
.data
55-
56-
.bss
57-
*/
58-
.extern __bss_start
59-
.extern __bss_end
60-
.extern _gp
61-
/* int _main(int argc, const char **argv, const char **envp) */
62-
.extern main
63-
6437
.set pop

src/mips/tinyload/shell.ld

-114
This file was deleted.

src/mips/tinyload/src/exec.S

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
.set push
2+
.set noreorder
3+
.set noat
4+
5+
#include <mipsregs.h>
6+
7+
.text
8+
9+
// sizeof() == 0x3C(60)
10+
#define ExecInfo_entry 0x00 // Address of program entry-point.
11+
#define ExecInfo_init_gp 0x04 // SCE only. Initial value the "gp" register is set to. 0 for PS-X EXE.
12+
#define ExecInfo_text_addr 0x08 // Memory address to which the .text section is loaded.
13+
#define ExecInfo_text_size 0x0C // Size of the .text section in the file and memory.
14+
#define ExecInfo_data_addr 0x10 // SCE only. Memory address to which the .data section is loaded. 0 for PS-X EXE.
15+
#define ExecInfo_data_size 0x14 // SCE only. Size of the .data section in the file and memory. 0 for PS-X EXE.
16+
#define ExecInfo_bss_addr 0x18 // Memory address of the .bss section. .bss is initialized by Exec().
17+
#define ExecInfo_bss_size 0x1C // Size of the .bss section in memory.
18+
#define ExecInfo_stack_addr 0x20 // Memory address pointing to the bottom(lowest address) of the stack. BIOS replaces
19+
// with "STACK" parameter of "SYSTEM.CNF" file.
20+
#define ExecInfo_stack_size 0x24 // Size of the stack. Can be 0.
21+
#define ExecInfo_saved_sp 0x28 // Used by BIOS Exec() function to preserve the "sp" register.
22+
#define ExecInfo_saved_fp 0x2C // Used by BIOS Exec() function to preserve the "fp" register.
23+
#define ExecInfo_saved_gp 0x30 // Used by BIOS Exec() function to preserve the "gp" register.
24+
#define ExecInfo_saved_ra 0x34 // Used by BIOS Exec() function to preserve the "ra" register.
25+
#define ExecInfo_saved_s0 0x38 // Used by BIOS Exec() function to preserve the "s0" register.
26+
27+
.global Exec2
28+
.type Exec2, @function
29+
.ent Exec2
30+
Exec2:
31+
sw s0, ExecInfo_saved_s0(a0)
32+
or s0, zero, a0
33+
sw ra, ExecInfo_saved_ra(s0)
34+
sw sp, ExecInfo_saved_sp(s0)
35+
sw fp, ExecInfo_saved_fp(s0)
36+
lw t0, ExecInfo_bss_size(s0)
37+
sw gp, ExecInfo_saved_gp(s0)
38+
39+
beqz t0, _no_bss
40+
41+
lw t1, ExecInfo_bss_addr(s0)
42+
nop
43+
_bss_clear_loop:
44+
addiu t0, t0, -4
45+
sw zero, 0(t1)
46+
bgtz t0, _bss_clear_loop
47+
addiu t1, t1, 4
48+
49+
_no_bss:
50+
lw t0, ExecInfo_stack_addr(s0)
51+
nop
52+
beqz t0, _no_stack
53+
nop
54+
55+
lw t1, ExecInfo_stack_size(s0)
56+
nop
57+
add t0, t1
58+
move sp, t0
59+
move fp, sp
60+
61+
62+
_no_stack:
63+
lw t3, ExecInfo_entry(s0)
64+
lw gp, ExecInfo_init_gp(s0)
65+
move a0, a1
66+
jalr t3
67+
move a1, a2
68+
69+
lw ra, ExecInfo_saved_ra(s0)
70+
lw sp, ExecInfo_saved_sp(s0)
71+
lw fp, ExecInfo_saved_fp(s0)
72+
lw gp, ExecInfo_saved_gp(s0)
73+
lw s0, ExecInfo_saved_s0(s0)
74+
jr ra
75+
li v0, 1
76+
.end Exec2

0 commit comments

Comments
 (0)