Skip to content

Commit 9c16b6a

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

File tree

19 files changed

+16
-93
lines changed

19 files changed

+16
-93
lines changed

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;

libogc/gx.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@
2525
#define LARGE_NUMBER (-1.0e+18f)
2626
#endif
2727

28-
#define _SHIFTL(v, s, w) \
29-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
30-
#define _SHIFTR(v, s, w) \
31-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
32-
3328
#define GX_LOAD_BP_REG(x) \
3429
do { \
3530
wgPipe->U8 = 0x61; \

libogc/irq.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ distribution.
4343
#define CPU_STACK_ALIGNMENT 8
4444
#define CPU_MINIMUM_STACK_FRAME_SIZE 16
4545

46-
#define _SHIFTL(v, s, w) \
47-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
48-
#define _SHIFTR(v, s, w) \
49-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
50-
5146
struct irq_handler_s {
5247
raw_irq_handler_t pHndl;
5348
void *pCtx;

libogc/pad.c

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

1515
#define PAD_PRODPADS 6
1616

17-
#define _SHIFTL(v, s, w) \
18-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
19-
#define _SHIFTR(v, s, w) \
20-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
21-
2217
#define PAD_ENABLEDMASK(chan) (0x80000000>>chan);
2318

2419
typedef struct _keyinput {

libogc/sdgecko_io.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@
4141
#define CARDIO_OP_IOERR_ILL 0x0001
4242
#define CARDIO_OP_IOERR_FATAL (CARDIO_OP_IOERR_PARAM|CARDIO_OP_IOERR_WRITE|CARDIO_OP_IOERR_ADDR|CARDIO_OP_IOERR_CRC|CARDIO_OP_IOERR_ILL)
4343

44-
#define _SHIFTL(v, s, w) \
45-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
46-
#define _SHIFTR(v, s, w) \
47-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
48-
4944
typedef s32 (*cardiocallback)(s32 drv_no);
5045

5146
u8 g_CID[MAX_DRIVE][16];

libogc/si.c

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

1414
//#define _SI_DEBUG
1515

16-
#define _SHIFTL(v, s, w) \
17-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
18-
#define _SHIFTR(v, s, w) \
19-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
20-
2116
#define SISR_ERRORMASK(chn) (0x0f000000>>((chn)<<3))
2217
#define SIPOLL_ENABLE(chn) (0x80000000>>((chn)+24))
2318

libogc/system.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ distribution.
8585
return NULL; \
8686
}
8787

88-
#define _SHIFTL(v, s, w) \
89-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
90-
#define _SHIFTR(v, s, w) \
91-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
9288

9389
struct _sramcntrl {
9490
u8 srambuf[64];

libogc/usbgecko.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99

1010
#include "usbgecko.h"
1111

12-
#define _SHIFTL(v, s, w) \
13-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
14-
#define _SHIFTR(v, s, w) \
15-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
16-
17-
1812
static u32 usbgecko_inited = 0;
1913
static lwpq_t wait_exi_queue[3];
2014

libogc/video.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ video.c -- VIDEO subsystem
5050

5151
#define VIDEO_MQ 1
5252

53-
#define _SHIFTL(v, s, w) \
54-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
55-
#define _SHIFTR(v, s, w) \
56-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
57-
5853
#define VI_REGCHANGE(_reg) \
5954
((u64)0x01<<(63-_reg))
6055

lwip/arch/gc/netif/gcif.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,6 @@ struct bba_descr {
177177
u32 X(X(next_packet_ptr:12, packet_len:12), status:8);
178178
};
179179

180-
#define _SHIFTL(v, s, w) \
181-
((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
182-
#define _SHIFTR(v, s, w) \
183-
((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
184-
185180

186181
struct bba_priv {
187182
u8 flag;

0 commit comments

Comments
 (0)