PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
defs.h
Go to the documentation of this file.
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright (c) 2003 Marcus R. Brown <mrbrown@0xd6.org>
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
16#ifndef __DEFS_H__
17#define __DEFS_H__
18
19#include <types.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#ifndef NULL
26#define NULL ((void *)0)
27#endif
28
29#define ALIGN(x, align) (((x)+((align)-1))&~((align)-1))
30
31#define PHYSADDR(a) (((u32)(a)) & 0x1fffffff)
32
33#define KSEG1 0xa0000000
34#define KSEG1ADDR(a) ((__typeof__(a))(((u32)(a) & 0x1fffffff) | KSEG1))
35
36#if !defined(USE_GP_REGISTER)
37#define USE_GP_REGISTER 1
38#endif
39
40static __inline__ void SetGP(void *gp)
41{
42 register void *gpReg __asm__("gp");
43
44 gpReg = gp;
45 __asm__ __volatile__(" " ::"r"(gpReg));
46}
47
48extern void *_gp;
49
50static __inline__ void *GetGP(void)
51{
52 register void *gpReg __asm__("gp");
53
54 __asm__ __volatile__(" " : "=r"(gpReg));
55 return gpReg;
56}
57
58static __inline__ void *ChangeGP(void *gp)
59{
60 void *OldGP;
61
62 OldGP = GetGP();
63 SetGP(gp);
64
65 return OldGP;
66}
67
68#define SetModuleGP() ChangeGP(&_gp)
69
70static inline void *iop_memcpy(void *dest, const void *src, int size)
71{
72 u8 *d = (u8 *)dest, *s = (u8 *)src;
73
74 while (size--)
75 *d++ = *s++;
76 return dest;
77}
78
79#ifdef __cplusplus
80}
81#endif
82
83#endif /* __DEFS_H__ */