PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
tamtypes.h
Go to the documentation of this file.
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
16#ifndef __TAMTYPES_H__
17#define __TAMTYPES_H__
18
19#if !defined(_EE) && !defined(_IOP)
20#error Either _EE or _IOP must be defined!
21#endif
22
23typedef unsigned char u8;
24typedef unsigned short u16;
25
26typedef volatile u8 vu8;
27typedef volatile u16 vu16;
28
29#ifdef _EE
30typedef unsigned int u32;
31#if __GNUC__ > 3
32typedef unsigned long long u64;
33#else
34typedef unsigned long u64;
35#endif
36typedef unsigned int u128 __attribute__((mode(TI)));
37
38typedef volatile u32 vu32;
39typedef volatile u64 vu64;
40typedef volatile u128 vu128 __attribute__((mode(TI)));
41#endif
42
43#ifdef _IOP
44typedef unsigned long u32;
45typedef unsigned long long u64;
46
47typedef volatile u32 vu32;
48typedef volatile u64 vu64;
49#endif
50
51typedef signed char s8;
52typedef signed short s16;
53
54typedef volatile s8 vs8;
55typedef volatile s16 vs16;
56
57#ifdef _EE
58typedef signed int s32;
59#if __GNUC__ > 3
60typedef signed long long s64;
61#else
62typedef signed long s64;
63#endif
64typedef signed int s128 __attribute__((mode(TI)));
65
66typedef volatile s32 vs32;
67typedef volatile s64 vs64;
68typedef volatile s128 vs128 __attribute__((mode(TI)));
69#endif
70
71#ifdef _IOP
72typedef signed long s32;
73typedef signed long long s64;
74
75typedef volatile s32 vs32;
76typedef volatile s64 vs64;
77#endif
78
79/* Pointers are 32-bit on both EE and IOP. */
80typedef u32 uiptr;
81typedef s32 siptr;
82
83typedef volatile u32 vuiptr;
84typedef volatile s32 vsiptr;
85
86#ifdef _EE
87typedef union
88{
89 u128 qw;
90 u8 b[16];
91 u16 hw[8];
92 u32 sw[4];
93 u64 dw[2];
94} qword_t;
95
96#endif
97
98#ifndef NULL
99#define NULL (void *)0
100#endif
101
102static inline u8 _lb(u32 addr)
103{
104 return *(vu8 *)addr;
105}
106static inline u16 _lh(u32 addr) { return *(vu16 *)addr; }
107static inline u32 _lw(u32 addr) { return *(vu32 *)addr; }
108
109static inline void _sb(u8 val, u32 addr) { *(vu8 *)addr = val; }
110static inline void _sh(u16 val, u32 addr) { *(vu16 *)addr = val; }
111static inline void _sw(u32 val, u32 addr) { *(vu32 *)addr = val; }
112
113#ifdef _EE
114static inline u64 _ld(u32 addr)
115{
116 return *(vu64 *)addr;
117}
118static inline u128 _lq(u32 addr) { return *(vu128 *)addr; }
119static inline void _sd(u64 val, u32 addr) { *(vu64 *)addr = val; }
120static inline void _sq(u128 val, u32 addr) { *(vu128 *)addr = val; }
121#endif
122
123#endif /* __TAMTYPES_H__ */