Skip to content

Commit 9c16b6a

Browse files
committed
move shift & mask macros to gcutil.h
1 parent 151ac57 commit 9c16b6a

19 files changed

Lines changed: 16 additions & 93 deletions

File tree

gc/gcutil.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,13 @@
88
# define ATTRIBUTE_PACKED __attribute__((packed))
99
#endif
1010

11+
#define _SHIFTL(v, s, w) \
12+
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s))) //mask the first w bits of v before lshifting
13+
#define _SHIFTR(v, s, w) \
14+
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1))) //rshift v and mask the first w bits afterwards
15+
16+
#define _ROTL(v,s) \
17+
(((u32)v<<s)|((u32)v>>(0x20-s)))
18+
1119
#endif /* _GCUTIL_H */
1220

libdb/geckousb.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77

88
#include "geckousb.h"
99

10-
#define _SHIFTL(v, s, w) \
11-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
12-
#define _SHIFTR(v, s, w) \
13-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
14-
1510
static struct dbginterface usb_device;
1611

1712
static __inline__ int __send_command(s32 chn,u16 *cmd)

libdb/uIP/bba.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <stdlib.h>
22
#include <stdio.h>
33
#include <string.h>
4+
#include "gcutil.h"
45
#include "asm.h"
56
#include "processor.h"
67
#include "exi.h"
@@ -187,10 +188,6 @@ struct bba_descr {
187188
u32 X(X(next_packet_ptr:12, packet_len:12), status:8);
188189
};
189190

190-
#define _SHIFTL(v, s, w) \
191-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
192-
#define _SHIFTR(v, s, w) \
193-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
194191

195192
/* new functions */
196193
#define bba_select() EXI_Select(EXI_CHANNEL_0,EXI_DEVICE_2,EXI_SPEED32MHZ)

libogc/aram.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ distribution.
3131
#include <stdlib.h>
3232
#include <string.h>
3333
#include <stdio.h>
34+
#include "gcutil.h"
3435
#include "asm.h"
3536
#include "processor.h"
3637
#include "aram.h"
@@ -54,11 +55,6 @@ distribution.
5455

5556
#define AR_ARAMEXPANSION 2
5657

57-
#define _SHIFTL(v, s, w) \
58-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
59-
#define _SHIFTR(v, s, w) \
60-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
61-
6258
static vu16* const _dspReg = (u16*)0xCC005000;
6359

6460
static ARCallback __ARDmaCallback = NULL;

libogc/audio.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ distribution.
3030

3131

3232
#include <stdlib.h>
33+
#include "gcutil.h"
3334
#include "asm.h"
3435
#include "processor.h"
3536
#include "irq.h"
@@ -65,12 +66,6 @@ distribution.
6566
#define AI_SCRESET 0x20
6667
#define AI_DMAFR 0x40
6768

68-
69-
#define _SHIFTL(v, s, w) \
70-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s))) //mask the first w bits of v before lshifting
71-
#define _SHIFTR(v, s, w) \
72-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1))) //rshift v and mask the first w bits afterwards
73-
7469
#if defined(HW_DOL)
7570
static vu32* const _aiReg = (u32*)0xCC006C00;
7671
#elif defined(HW_RVL)

libogc/cache.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,11 @@ distribution.
2828
-------------------------------------------------------------*/
2929

3030

31-
#include <asm.h>
32-
#include <processor.h>
31+
#include "gcutil.h"
32+
#include "asm.h"
33+
#include "processor.h"
3334
#include "cache.h"
3435

35-
#define _SHIFTL(v, s, w) \
36-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
37-
#define _SHIFTR(v, s, w) \
38-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
39-
4036
extern void __LCEnable(void);
4137
extern void L2GlobalInvalidate(void);
4238
extern void L2Enable(void);

libogc/card.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ distribution.
5252
#define CARD_SYSBAT 0x6000
5353
#define CARD_SYSBAT_BACK 0x8000
5454

55-
#define _SHIFTL(v, s, w) \
56-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
57-
#define _SHIFTR(v, s, w) \
58-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
59-
#define _ROTL(v,s) \
60-
(((u32)v<<s)|((u32)v>>(0x20-s)))
61-
6255
#define CARD_STATUS_UNLOCKED 0x40
6356

6457
struct card_header {

libogc/dsp.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ distribution.
3131

3232
#include <stdlib.h>
3333
#include <stdio.h>
34+
#include "gcutil.h"
3435
#include "asm.h"
3536
#include "processor.h"
3637
#include "irq.h"
@@ -51,10 +52,6 @@ distribution.
5152
#define DSPCR_PIINT 0x0002 // assert DSP PI interrupt
5253
#define DSPCR_RES 0x0001 // reset DSP
5354

54-
#define _SHIFTL(v, s, w) \
55-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
56-
#define _SHIFTR(v, s, w) \
57-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
5855

5956
static u32 __dsp_inited = FALSE;
6057
static u32 __dsp_rudetask_pend = FALSE;

libogc/dvd.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ distribution.
131131
#define cpu_to_le32(x) (((x>>24)&0x000000ff) | ((x>>8)&0x0000ff00) | ((x<<8)&0x00ff0000) | ((x<<24)&0xff000000))
132132
#define dvd_may_retry(s) (DVD_STATUS(s) == DVD_STATUS_READY || DVD_STATUS(s) == DVD_STATUS_DISK_ID_NOT_READ)
133133

134-
#define _SHIFTL(v, s, w) \
135-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
136-
#define _SHIFTR(v, s, w) \
137-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
138-
139134
typedef void (*dvdcallbacklow)(s32);
140135
typedef void (*dvdstatecb)(dvdcmdblk *);
141136

libogc/exi.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ distribution.
3636
#include "processor.h"
3737
#include "spinlock.h"
3838
#include "exi.h"
39+
#include "gcutil.h"
3940

4041
//#define _EXI_DEBUG
4142

@@ -53,11 +54,6 @@ distribution.
5354
#define EXI_EXT_IRQ 0x0800
5455
#define EXI_EXT_BIT 0x1000
5556

56-
#define _SHIFTL(v, s, w) \
57-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
58-
#define _SHIFTR(v, s, w) \
59-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
60-
6157

6258
struct _lck_dev {
6359
lwp_node node;

0 commit comments

Comments
 (0)