Skip to content

Commit a02d982

Browse files
committed
refactor: move s file contents to referenced c files
1 parent 9f4bb4b commit a02d982

9 files changed

Lines changed: 323 additions & 301 deletions

File tree

ee/libprofglue/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
EE_LIB = libprofglue.a
1010

11-
EE_OBJS = prof.o mcount.o
11+
EE_OBJS = prof.o
1212

1313
include $(PS2SDKSRC)/Defs.make
1414
include $(PS2SDKSRC)/ee/Rules.lib.make

ee/libprofglue/src/mcount.S

Lines changed: 0 additions & 39 deletions
This file was deleted.

ee/libprofglue/src/prof.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,46 @@ void __mcount(unsigned int frompc, unsigned int selfpc)
245245
arc->count++;
246246
}
247247
}
248+
249+
__asm__
250+
(
251+
"\t" ".set push" "\n"
252+
"\t" ".set noreorder" "\n"
253+
"\t" ".set noat" "\n"
254+
255+
"\t" ".global _mcount" "\n"
256+
"\t" ".ent _mcount" "\n"
257+
258+
"\t" "_mcount:" "\n"
259+
260+
// Generated code already substracts 8 bytes
261+
// We store our ra, at and a0-a3
262+
"\t" "\t" "daddiu $sp, $sp, -56" "\n" // Adjust stack pointer for 64-bit registers, 7 registers * 8 bytes each
263+
"\t" "\t" "sd $ra, 0($sp)" "\n" // store ra
264+
"\t" "\t" "sd $at, 8($sp)" "\n" // at = ra of caller
265+
"\t" "\t" "sd $a0, 16($sp)" "\n"
266+
"\t" "\t" "sd $a1, 24($sp)" "\n"
267+
"\t" "\t" "sd $a2, 32($sp)" "\n"
268+
"\t" "\t" "sd $a3, 40($sp)" "\n"
269+
270+
// Call internal C handler
271+
"\t" "\t" "move $a0, $at" "\n"
272+
"\t" "\t" "move $a1, $ra" "\n"
273+
"\t" "\t" "jal __mcount" "\n"
274+
"\t" "\t" "nop" "\n"
275+
276+
// Restore registers
277+
"\t" "\t" "ld $ra, 0($sp)" "\n"
278+
"\t" "\t" "ld $at, 8($sp)" "\n"
279+
"\t" "\t" "ld $a0, 16($sp)" "\n"
280+
"\t" "\t" "ld $a1, 24($sp)" "\n"
281+
"\t" "\t" "ld $a2, 32($sp)" "\n"
282+
"\t" "\t" "ld $a3, 40($sp)" "\n"
283+
"\t" "\t" "daddiu $sp, $sp, 56" "\n" // Adjust stack pointer back
284+
"\t" "\t" "jr $ra" "\n"
285+
"\t" "\t" "move $ra, $at" "\n" // restore caller's ra
286+
287+
"\t" ".end _mcount" "\n"
288+
289+
"\t" ".set pop" "\n"
290+
);

iop/debug/iop_sbusdbg/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ IOP_INCS += \
2222
-I$(PS2SDKSRC)/iop/system/sysmem/include \
2323
-I$(PS2SDKSRC)/iop/system/threadman/include
2424

25-
IOP_OBJS = main.o sbus_dbg_low.o sbus_tty.o sbus_dbg.o imports.o
25+
IOP_OBJS = main.o sbus_tty.o sbus_dbg.o imports.o
2626

2727
include $(PS2SDKSRC)/Defs.make
2828
include $(PS2SDKSRC)/iop/Rules.bin.make

iop/debug/iop_sbusdbg/src/main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,24 @@ void _iop_ex_handler(IOP_RegFrame *frame)
4646
int tid;
4747

4848
extern void soft_break(void);
49+
__asm__
50+
(
51+
"\t" ".set push" "\n"
52+
"\t" ".set noreorder" "\n"
53+
"\t" ".set noat" "\n"
54+
55+
"\t" ".global soft_break" "\n"
56+
"\t" ".ent soft_break" "\n"
57+
"\t" "soft_break:" "\n"
58+
"\t" "\t" "nop" "\n"
59+
"\t" "\t" "break" "\n"
60+
"\t" "\t" "nop" "\n"
61+
"\t" "\t" "jr $ra" "\n"
62+
"\t" "\t" "nop" "\n"
63+
"\t" ".end soft_break" "\n"
64+
65+
"\t" ".set pop" "\n"
66+
);
4967

5068
void _controller_thread(void)
5169
{

iop/debug/iop_sbusdbg/src/sbus_dbg_low.S

Lines changed: 0 additions & 15 deletions
This file was deleted.

iop/system/udnl/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ IOP_INCS += \
1616
-I$(PS2SDKSRC)/iop/system/sysmem/include \
1717
-I$(PS2SDKSRC)/iop/system/threadman/include
1818

19-
IOP_OBJS = udnl.o udnl_asm.o imports.o
19+
IOP_OBJS = udnl.o imports.o
2020

2121
include $(PS2SDKSRC)/Defs.make
2222
include $(PS2SDKSRC)/iop/Rules.bin.make

0 commit comments

Comments
 (0)