Skip to content

Commit cd5b5c2

Browse files
committed
Fixes to sioload and common.mk
1 parent 6ef8eee commit cd5b5c2

32 files changed

+1289
-1445
lines changed

src/mips/common.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ all: $(TARGET)
3131
$(MAKE) -C ../ps1sdk all
3232

3333
clean:
34-
rm -f $(OBJS) $(TARGETBASE).psx $(TARGETBASE).elf $(TARGET).map $(TARGETBASE).bin $(TARGET)
34+
rm -f $(OBJS) $(TARGETBASE).psx $(TARGETBASE).elf $(TARGETBASE).map $(TARGETBASE).bin $(TARGET)
3535

3636
$(TARGETBASE).bin: $(TARGETBASE).elf
3737
$(PREFIX)-objcopy -O binary $< $@

src/mips/hello/src/main.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,4 @@
1919

2020
#include "common/hardware/cop0.h"
2121

22-
int main()
23-
{
24-
return 0;
25-
}
22+
int main() { return 0; }

src/mips/ps1sdk/include/ario.h

100755100644
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
/*
1+
/*
22
* File: ario.h
33
* Author: aric
44
*
55
* Created on February 10, 2009, 1:13 AM
66
*/
77

88
#ifndef _ARIO_H
9-
#define _ARIO_H
9+
#define _ARIO_H
1010

11-
#ifdef __cplusplus
11+
#ifdef __cplusplus
1212
extern "C" {
1313
#endif
1414

1515
/* prototypes */
1616

17-
int ar12_peek(uint8_t *ch, int timeout);
17+
int ar12_peek(uint8_t* ch, int timeout);
1818
int ar12_poke(uint8_t ch, int timeout);
1919
int ar12_reset(void);
2020

21-
int ar3_peek(uint8_t *ch, int timeout);
21+
int ar3_peek(uint8_t* ch, int timeout);
2222
int ar3_poke(uint8_t ch, int timeout);
2323
int ar3_reset(void);
2424

25-
#ifdef __cplusplus
25+
#ifdef __cplusplus
2626
}
2727
#endif
2828

29-
#endif /* _ARIO_H */
30-
29+
#endif /* _ARIO_H */

src/mips/ps1sdk/include/assert.h

100755100644
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
*/
1010

1111
#ifndef _ASSERT_H
12-
#define _ASSERT_H
12+
#define _ASSERT_H
1313

14-
#ifdef __cplusplus
14+
#ifdef __cplusplus
1515
extern "C" {
1616
#endif
1717

@@ -20,15 +20,14 @@ extern "C" {
2020
#endif
2121

2222
#ifndef NDEBUG
23-
void __assert(const char *, const char *, int);
24-
#define assert(e) ((e) ? (void) 0 : __assert(#e, __FILE__, __LINE__))
23+
void __assert(const char*, const char*, int);
24+
#define assert(e) ((e) ? (void)0 : __assert(#e, __FILE__, __LINE__))
2525
#else
26-
#define assert(ignore) ((void) 0)
26+
#define assert(ignore) ((void)0)
2727
#endif
2828

29-
#ifdef __cplusplus
29+
#ifdef __cplusplus
3030
}
3131
#endif
3232

33-
#endif /* _ASSERT_H */
34-
33+
#endif /* _ASSERT_H */

src/mips/ps1sdk/include/ctype.h

100755100644
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
extern unsigned char __ctype_table[];
1515

16-
enum
17-
{
16+
enum {
1817
// uppercase alphabetic
1918
CTYPE_UCASE = (1 << 0),
2019
// lowercase alphabetic
@@ -33,23 +32,24 @@ enum
3332
CTYPE_BLANK = (1 << 7)
3433
};
3534

36-
#define __isctype(___ch, ___type) ((__ctype_table[(int) ___ch] & (___type)) != 0)
35+
#define __isctype(___ch, ___type) ((__ctype_table[(int)___ch] & (___type)) != 0)
3736

38-
#define isalnum(___ch) (isalpha(___ch) || isdigit(___ch))
39-
#define isalpha(___ch) (isupper(___ch) || islower(___ch))
40-
#define isascii(___ch) (((unsigned char) ___ch) <= 127)
41-
#define isblank(___ch) (__isctype(___ch, CTYPE_BLANK))
42-
#define iscntrl(___ch) (__isctype(___ch, CTYPE_CNTRL))
43-
#define isdigit(___ch) (__isctype(___ch, CTYPE_NUMER))
44-
#define isgraph(___ch) (isprint(___ch) && !isspace(___ch))
45-
#define islower(___ch) (__isctype(___ch, CTYPE_LCASE))
46-
#define isprint(___ch) (__isctype(___ch, (CTYPE_UCASE | CTYPE_LCASE | CTYPE_NUMER | CTYPE_WSPAC | CTYPE_PUNCT | CTYPE_BLANK)))
47-
#define ispunct(___ch) (__isctype(___ch, CTYPE_PUNCT))
48-
#define isspace(___ch) (__isctype(___ch, (CTYPE_WSPAC | CTYPE_BLANK)))
49-
#define isupper(___ch) (__isctype(___ch, CTYPE_UCASE))
37+
#define isalnum(___ch) (isalpha(___ch) || isdigit(___ch))
38+
#define isalpha(___ch) (isupper(___ch) || islower(___ch))
39+
#define isascii(___ch) (((unsigned char)___ch) <= 127)
40+
#define isblank(___ch) (__isctype(___ch, CTYPE_BLANK))
41+
#define iscntrl(___ch) (__isctype(___ch, CTYPE_CNTRL))
42+
#define isdigit(___ch) (__isctype(___ch, CTYPE_NUMER))
43+
#define isgraph(___ch) (isprint(___ch) && !isspace(___ch))
44+
#define islower(___ch) (__isctype(___ch, CTYPE_LCASE))
45+
#define isprint(___ch) \
46+
(__isctype(___ch, (CTYPE_UCASE | CTYPE_LCASE | CTYPE_NUMER | CTYPE_WSPAC | CTYPE_PUNCT | CTYPE_BLANK)))
47+
#define ispunct(___ch) (__isctype(___ch, CTYPE_PUNCT))
48+
#define isspace(___ch) (__isctype(___ch, (CTYPE_WSPAC | CTYPE_BLANK)))
49+
#define isupper(___ch) (__isctype(___ch, CTYPE_UCASE))
5050
#define isxdigit(___ch) (__isctype(___ch, CTYPE_HEXAD))
5151

52-
#define _toupper(___ch) (islower(___ch) ? ((___ch) - 0x20) : (___ch))
52+
#define _toupper(___ch) (islower(___ch) ? ((___ch)-0x20) : (___ch))
5353
#define _tolower(___ch) (isupper(___ch) ? ((___ch) + 0x20) : (___ch))
5454

5555
#endif // _PS1_CTYPE_H_

src/mips/ps1sdk/include/defs.h

100755100644
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
#include "types.h"
1515

1616
#ifndef NULL
17-
#define NULL ((void *)0)
17+
#define NULL ((void*)0)
1818
#endif
1919

20-
#define ALIGN(x, align) (((x)+((align)-1))&~((align)-1))
20+
#define ALIGN(x, align) (((x) + ((align)-1)) & ~((align)-1))
2121

22-
#define PHYSADDR(a) (((uint32_t)(a)) & 0x1fffffff)
22+
#define PHYSADDR(a) (((uint32_t)(a)) & 0x1fffffff)
2323

24-
#define KSEG1 0xa0000000
25-
#define KSEG1ADDR(a) ((__typeof__(a))(((uint32_t)(a) & 0x1fffffff) | KSEG1))
24+
#define KSEG1 0xa0000000
25+
#define KSEG1ADDR(a) ((__typeof__(a))(((uint32_t)(a)&0x1fffffff) | KSEG1))
2626

2727
#endif /* PS1_DEFS_H */

src/mips/ps1sdk/include/endian.h

100755100644
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef _ENDIAN_H
22
#define _ENDIAN_H
33

4-
#define __LITTLE_ENDIAN 1234
5-
#define __BIG_ENDIAN 4321
6-
#define __PDP_ENDIAN 3412
4+
#define __LITTLE_ENDIAN 1234
5+
#define __BIG_ENDIAN 4321
6+
#define __PDP_ENDIAN 3412
77

88
/* PlayStation 1 is little-endian */
99
#define __BYTE_ORDER __LITTLE_ENDIAN

src/mips/ps1sdk/include/exec.h

100755100644
Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,62 +9,53 @@
99
*/
1010

1111
#ifndef _EXEC_H
12-
#define _EXEC_H
12+
#define _EXEC_H
1313

14-
#ifdef __cplusplus
14+
#ifdef __cplusplus
1515
extern "C" {
1616
#endif
1717

1818
/* Executable file types returned by LoadEx() */
19-
enum
20-
{
21-
ExecTypeUNK = 0,
22-
ExecTypePSX = 1,
23-
ExecTypeSCE = 2,
24-
ExecTypeECO = 3,
25-
ExecTypeCPE = 4
26-
};
19+
enum { ExecTypeUNK = 0, ExecTypePSX = 1, ExecTypeSCE = 2, ExecTypeECO = 3, ExecTypeCPE = 4 };
2720

2821
// sizeof() == 0x3C(60)
29-
typedef struct st_ExecInfo
30-
{
31-
uint32_t entry; // 0x00 : Address of program entry-point.
32-
uint32_t init_gp; // 0x04 : SCE only. Initial value the "gp" register is set to. 0 for PS-X EXE.
33-
uint32_t text_addr; // 0x08 : Memory address to which the .text section is loaded.
34-
uint32_t text_size; // 0x0C : Size of the .text section in the file and memory.
35-
uint32_t data_addr; // 0x10 : SCE only. Memory address to which the .data section is loaded. 0 for PS-X EXE.
36-
uint32_t data_size; // 0x14 : SCE only. Size of the .data section in the file and memory. 0 for PS-X EXE.
37-
uint32_t bss_addr; // 0x18 : Memory address of the .bss section. .bss is initialized by Exec().
38-
uint32_t bss_size; // 0x1C : Size of the .bss section in memory.
39-
uint32_t stack_addr; // 0x20 : Memory address pointing to the bottom(lowest address) of the stack. BIOS replaces with "STACK" parameter of "SYSTEM.CNF" file.
22+
typedef struct st_ExecInfo {
23+
uint32_t entry; // 0x00 : Address of program entry-point.
24+
uint32_t init_gp; // 0x04 : SCE only. Initial value the "gp" register is set to. 0 for PS-X EXE.
25+
uint32_t text_addr; // 0x08 : Memory address to which the .text section is loaded.
26+
uint32_t text_size; // 0x0C : Size of the .text section in the file and memory.
27+
uint32_t data_addr; // 0x10 : SCE only. Memory address to which the .data section is loaded. 0 for PS-X EXE.
28+
uint32_t data_size; // 0x14 : SCE only. Size of the .data section in the file and memory. 0 for PS-X EXE.
29+
uint32_t bss_addr; // 0x18 : Memory address of the .bss section. .bss is initialized by Exec().
30+
uint32_t bss_size; // 0x1C : Size of the .bss section in memory.
31+
uint32_t stack_addr; // 0x20 : Memory address pointing to the bottom(lowest address) of the stack. BIOS replaces
32+
// with "STACK" parameter of "SYSTEM.CNF" file.
4033
uint32_t stack_size; // 0x24 : Size of the stack. Can be 0.
41-
uint32_t saved_sp; // 0x28 : Used by BIOS Exec() function to preserve the "sp" register.
42-
uint32_t saved_fp; // 0x2C : Used by BIOS Exec() function to preserve the "fp" register.
43-
uint32_t saved_gp; // 0x30 : Used by BIOS Exec() function to preserve the "gp" register.
44-
uint32_t saved_ra; // 0x34 : Used by BIOS Exec() function to preserve the "ra" register.
45-
uint32_t saved_s0; // 0x38 : Used by BIOS Exec() function to preserve the "s0" register.
34+
uint32_t saved_sp; // 0x28 : Used by BIOS Exec() function to preserve the "sp" register.
35+
uint32_t saved_fp; // 0x2C : Used by BIOS Exec() function to preserve the "fp" register.
36+
uint32_t saved_gp; // 0x30 : Used by BIOS Exec() function to preserve the "gp" register.
37+
uint32_t saved_ra; // 0x34 : Used by BIOS Exec() function to preserve the "ra" register.
38+
uint32_t saved_s0; // 0x38 : Used by BIOS Exec() function to preserve the "s0" register.
4639
} ExecInfo;
4740

4841
// sizeof() == 0x88(136)
49-
typedef struct st_EXE_Header
50-
{
51-
uint8_t magic[8]; // 0x00-0x07 : "PS-X EXE"(retail) or "SCE EXE"(???)
52-
uint32_t text_off; // 0x08 : SCE only. Offset of the start of the .text section in the file. 0 for PS-X EXE.
53-
uint32_t data_off; // 0x0C : SCE only. Offset of the start of the .text section in the file. 0 for PS-X EXE.
42+
typedef struct st_EXE_Header {
43+
uint8_t magic[8]; // 0x00-0x07 : "PS-X EXE"(retail) or "SCE EXE"(???)
44+
uint32_t text_off; // 0x08 : SCE only. Offset of the start of the .text section in the file. 0 for PS-X EXE.
45+
uint32_t data_off; // 0x0C : SCE only. Offset of the start of the .text section in the file. 0 for PS-X EXE.
5446
struct st_ExecInfo exec; // 0x10-0x4B
5547
char license[60]; // 0x4C-0x87
5648
} EXE_Header;
5749

58-
int ParseExecHeader(const void *hdr, ExecInfo *exec);
59-
int ReadExecHeader(int fd, ExecInfo *exec);
60-
int LoadEx(const char *fname, ExecInfo *exec);
61-
int LoadExBuffer(const void *fbuf, ExecInfo *exec);
62-
void LoadExecEx(const void *f, uint32_t stack_addr, int stack_size);
63-
int ExecEx(ExecInfo *exec, int arg1, int arg2);
50+
int ParseExecHeader(const void* hdr, ExecInfo* exec);
51+
int ReadExecHeader(int fd, ExecInfo* exec);
52+
int LoadEx(const char* fname, ExecInfo* exec);
53+
int LoadExBuffer(const void* fbuf, ExecInfo* exec);
54+
void LoadExecEx(const void* f, uint32_t stack_addr, int stack_size);
55+
int ExecEx(ExecInfo* exec, int arg1, int arg2);
6456

65-
#ifdef __cplusplus
57+
#ifdef __cplusplus
6658
}
6759
#endif
6860

69-
#endif /* _EXEC_H */
70-
61+
#endif /* _EXEC_H */

0 commit comments

Comments
 (0)