Skip to content

Commit 1920189

Browse files
authored
Merge pull request #885 from uyjulian/sif_align_cleanup
SIF DMA alignment cleanup
2 parents 7434a18 + 4fe4a06 commit 1920189

64 files changed

Lines changed: 243 additions & 225 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

common/include/fileXio.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <tamtypes.h>
2323
#include <iox_stat.h>
24+
#include <sifrpc.h>
2425

2526
#ifdef _EE
2627
#ifndef NEWLIB_PORT_AWARE
@@ -101,7 +102,7 @@ struct fileXioDirEntry
101102
u32 fileSize;
102103
u8 fileProperties;
103104
char filename[128 + 1];
104-
} __attribute__((aligned(64)));
105+
} ALIGNED_FOR_SIFDMA;
105106

106107
struct fileXioDevice
107108
{
@@ -110,7 +111,7 @@ struct fileXioDevice
110111
/** Not so sure about this one. */
111112
unsigned int version;
112113
char desc[128];
113-
} __attribute__((aligned(64)));
114+
} ALIGNED_FOR_SIFDMA;
114115

115116
struct fxio_devlist_packet
116117
{

common/include/fileio-common.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <tamtypes.h>
2020
#include <io_common.h>
21+
#include <sifrpc.h>
2122

2223
// fileio common definitions
2324

@@ -51,23 +52,23 @@ struct _fio_read_data
5152
void *dest2;
5253
u8 buf1[16];
5354
u8 buf2[16];
54-
};
55+
} ALIGNED_FOR_SIFDMA;
5556

5657
#define FIO_PATH_MAX 256
5758

5859
struct _fio_open_arg
5960
{
6061
int mode;
6162
char name[FIO_PATH_MAX];
62-
} __attribute__((aligned(16)));
63+
} ALIGNED_FOR_SIFDMA;
6364

6465
struct _fio_read_arg
6566
{
6667
int fd;
6768
void *ptr;
6869
int size;
6970
struct _fio_read_data *read_data;
70-
} __attribute__((aligned(16)));
71+
} ALIGNED_FOR_SIFDMA;
7172

7273
struct _fio_write_arg
7374
{
@@ -76,7 +77,7 @@ struct _fio_write_arg
7677
u32 size;
7778
u32 mis;
7879
u8 aligned[16];
79-
} __attribute__((aligned(16)));
80+
} ALIGNED_FOR_SIFDMA;
8081

8182
struct _fio_lseek_arg
8283
{
@@ -87,7 +88,7 @@ struct _fio_lseek_arg
8788
} p;
8889
int offset;
8990
int whence;
90-
} __attribute__((aligned(16)));
91+
} ALIGNED_FOR_SIFDMA;
9192

9293
struct _fio_ioctl_arg
9394
{
@@ -98,7 +99,7 @@ struct _fio_ioctl_arg
9899
} p;
99100
int request;
100101
u8 data[1024]; // Will this be ok ?
101-
} __attribute__((aligned(16)));
102+
} ALIGNED_FOR_SIFDMA;
102103

103104
struct _fio_dread_arg
104105
{
@@ -108,7 +109,7 @@ struct _fio_dread_arg
108109
int result;
109110
} p;
110111
io_dirent_t *buf;
111-
} __attribute__((aligned(16)));
112+
} ALIGNED_FOR_SIFDMA;
112113

113114
struct _fio_getstat_arg
114115
{
@@ -118,7 +119,7 @@ struct _fio_getstat_arg
118119
int result;
119120
} p;
120121
char name[FIO_PATH_MAX];
121-
} __attribute__((aligned(16)));
122+
} ALIGNED_FOR_SIFDMA;
122123

123124
struct _fio_chstat_arg
124125
{

common/include/librm-common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define __LIBRM_COMMON_H__
1818

1919
#include <tamtypes.h>
20+
#include <sifrpc.h>
2021

2122
struct rmRpcPacket
2223
{
@@ -42,7 +43,7 @@ struct rmRpcPacket
4243
} cmd;
4344
u8 buffer[128];
4445
};
45-
};
46+
} ALIGNED_FOR_SIFDMA;
4647

4748
struct rmEEData
4849
{

common/include/loadfile-common.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define __LOADFILE_COMMON_H__
1818

1919
#include <tamtypes.h>
20+
#include <sifrpc.h>
2021

2122
// loadfile common definitions
2223

@@ -72,7 +73,7 @@ struct _lf_iop_val_arg
7273
u16 s;
7374
u32 l;
7475
} val;
75-
} __attribute__((aligned(16)));
76+
} ALIGNED_FOR_SIFDMA;
7677

7778
struct _lf_module_load_arg
7879
{
@@ -84,7 +85,7 @@ struct _lf_module_load_arg
8485
int modres;
8586
char path[LF_PATH_MAX];
8687
char args[LF_ARG_MAX];
87-
} __attribute__((aligned(16)));
88+
} ALIGNED_FOR_SIFDMA;
8889

8990
struct _lf_module_stop_arg
9091
{
@@ -100,21 +101,21 @@ struct _lf_module_stop_arg
100101
} q;
101102
char dummy[LF_PATH_MAX];
102103
char args[LF_ARG_MAX];
103-
} __attribute__((aligned(16)));
104+
} ALIGNED_FOR_SIFDMA;
104105

105106
union _lf_module_unload_arg
106107
{
107108
int id;
108109
int result;
109-
} __attribute__((aligned(16)));
110+
} ALIGNED_FOR_SIFDMA;
110111

111112
struct _lf_search_module_by_name_arg
112113
{
113114
int id;
114115
int dummy1;
115116
char name[LF_PATH_MAX];
116117
char dummy2[LF_ARG_MAX];
117-
} __attribute__((aligned(16)));
118+
} ALIGNED_FOR_SIFDMA;
118119

119120
struct _lf_search_module_by_address_arg
120121
{
@@ -123,15 +124,15 @@ struct _lf_search_module_by_address_arg
123124
const void *ptr;
124125
int id;
125126
} p;
126-
} __attribute__((aligned(16)));
127+
} ALIGNED_FOR_SIFDMA;
127128

128129
struct _lf_elf_load_arg
129130
{
130131
u32 epc;
131132
u32 gp;
132133
char path[LF_PATH_MAX];
133134
char secname[LF_ARG_MAX];
134-
} __attribute__((aligned(16)));
135+
} ALIGNED_FOR_SIFDMA;
135136

136137
struct _lf_module_buffer_load_arg
137138
{
@@ -147,6 +148,6 @@ struct _lf_module_buffer_load_arg
147148
} q;
148149
char unused[LF_PATH_MAX];
149150
char args[LF_ARG_MAX];
150-
} __attribute__((aligned(16)));
151+
} ALIGNED_FOR_SIFDMA;
151152

152153
#endif

common/include/sifcmd-common.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818

1919
#include <tamtypes.h>
2020

21+
#ifdef _IOP
22+
/* 16 byte alignment (4 byte if accessing through uncached segment), 16 byte size multiple */
23+
#define ALIGNED_FOR_SIFDMA __attribute__((__aligned__((16))))
24+
#define ALIGNED_FOR_SIFDMA_UNCACHED __attribute__((__aligned__((4))))
25+
#else
26+
/* 64 byte alignment (16 byte if accessing through uncached segment), 16 byte size multiple */
27+
#define ALIGNED_FOR_SIFDMA __attribute__((__aligned__((64))))
28+
#define ALIGNED_FOR_SIFDMA_UNCACHED __attribute__((__aligned__((16))))
29+
#endif
30+
2131
/** SIF command. */
2232
typedef struct t_SifCmdHeader
2333
{
@@ -31,7 +41,7 @@ typedef struct t_SifCmdHeader
3141
int cid;
3242
/** Can be freely used. */
3343
u32 opt;
34-
} SifCmdHeader_t;
44+
} ALIGNED_FOR_SIFDMA SifCmdHeader_t;
3545

3646
/** System functions */
3747
#define SIF_CMD_ID_SYSTEM 0x80000000
@@ -81,7 +91,7 @@ typedef struct t_SifCmdSysHandlerData
8191

8292
typedef struct _iop_reset_pkt
8393
{
84-
struct t_SifCmdHeader header;
94+
SifCmdHeader_t header;
8595
int arglen;
8696
int mode;
8797
char arg[RESET_ARG_MAX + 1];

common/include/sifrpc-common.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ typedef void (*SifRpcEndFunc_t)(void *end_param);
3737

3838
typedef struct t_SifRpcPktHeader
3939
{
40-
struct t_SifCmdHeader sifcmd;
40+
SifCmdHeader_t sifcmd;
4141
int rec_id;
4242
void *pkt_addr;
4343
int rpc_id;
4444
} SifRpcPktHeader_t;
4545

4646
typedef struct t_SifRpcRendPkt
4747
{
48-
struct t_SifCmdHeader sifcmd;
48+
SifCmdHeader_t sifcmd;
4949
int rec_id; /* 04 */
5050
void *pkt_addr; /* 05 */
5151
int rpc_id; /* 06 */
@@ -59,7 +59,7 @@ typedef struct t_SifRpcRendPkt
5959

6060
typedef struct t_SifRpcOtherDataPkt
6161
{
62-
struct t_SifCmdHeader sifcmd;
62+
SifCmdHeader_t sifcmd;
6363
int rec_id; /* 04 */
6464
void *pkt_addr; /* 05 */
6565
int rpc_id; /* 06 */
@@ -72,7 +72,7 @@ typedef struct t_SifRpcOtherDataPkt
7272

7373
typedef struct t_SifRpcBindPkt
7474
{
75-
struct t_SifCmdHeader sifcmd;
75+
SifCmdHeader_t sifcmd;
7676
int rec_id; /* 04 */
7777
void *pkt_addr; /* 05 */
7878
int rpc_id; /* 06 */
@@ -82,7 +82,7 @@ typedef struct t_SifRpcBindPkt
8282

8383
typedef struct t_SifRpcCallPkt
8484
{
85-
struct t_SifCmdHeader sifcmd;
85+
SifCmdHeader_t sifcmd;
8686
int rec_id; /* 04 */
8787
void *pkt_addr; /* 05 */
8888
int rpc_id; /* 06 */
@@ -119,7 +119,7 @@ typedef struct t_SifRpcServerData
119119
struct t_SifRpcServerData *link; /* 18 14 */
120120
struct t_SifRpcServerData *next; /* 19 15 */
121121
struct t_SifRpcDataQueue *base; /* 20 16 */
122-
} SifRpcServerData_t;
122+
} ALIGNED_FOR_SIFDMA SifRpcServerData_t;
123123

124124

125125
typedef struct t_SifRpcHeader
@@ -128,12 +128,12 @@ typedef struct t_SifRpcHeader
128128
u32 rpc_id; /* 05 01 */
129129
int sema_id; /* 06 02 */
130130
u32 mode; /* 07 03 */
131-
} SifRpcHeader_t;
131+
} ALIGNED_FOR_SIFDMA SifRpcHeader_t;
132132

133133

134134
typedef struct t_SifRpcClientData
135135
{
136-
struct t_SifRpcHeader hdr;
136+
SifRpcHeader_t hdr;
137137
u32 command; /* 04 08 */
138138
void *buf, /* 05 09 */
139139
*cbuf; /* 06 10 */
@@ -144,7 +144,7 @@ typedef struct t_SifRpcClientData
144144

145145
typedef struct t_SifRpcReceiveData
146146
{
147-
struct t_SifRpcHeader hdr;
147+
SifRpcHeader_t hdr;
148148
void *src, /* 04 */
149149
*dest; /* 05 */
150150
int size; /* 06 */
@@ -158,7 +158,7 @@ typedef struct t_SifRpcDataQueue
158158
*start, /* 03 */
159159
*end; /* 04 */
160160
struct t_SifRpcDataQueue *next; /* 05 */
161-
} SifRpcDataQueue_t;
161+
} ALIGNED_FOR_SIFDMA SifRpcDataQueue_t;
162162

163163
#ifdef __cplusplus
164164
extern "C" {

ee/iopreboot/src/SifIopRebootBuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ extern int imgdrv_offset_ioprpsiz;
3737
extern void init_imgdrv_offsets(void);
3838

3939
#ifdef F__iopcontrol_special_internals
40-
u8 iopbtconf_img[IOPBTCONF_IOP_MAX_SIZE] __attribute__((aligned(64)));
40+
u8 iopbtconf_img[IOPBTCONF_IOP_MAX_SIZE] ALIGNED_FOR_SIFDMA;
4141
int imgdrv_offset_ioprpimg = 0;
4242
int imgdrv_offset_ioprpsiz = 0;
4343

ee/kernel/src/fileio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ void _fio_intr();
3838

3939
#ifdef F___fio_internals
4040
SifRpcClientData_t _fio_cd;
41-
int _fio_recv_data[512] __attribute__((aligned(64)));
42-
int _fio_intr_data[32] __attribute__((aligned(64)));
41+
int _fio_recv_data[512] ALIGNED_FOR_SIFDMA;
42+
int _fio_intr_data[32] ALIGNED_FOR_SIFDMA;
4343
int _fio_block_mode;
4444
int _fio_io_sema;
4545
int _fio_completion_sema;

ee/kernel/src/iopcontrol.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ extern int _iop_reboot_count;
3333

3434
int SifIopReset(const char *arg, int mode)
3535
{
36-
static SifCmdResetData_t reset_pkt __attribute__((aligned(64)));
37-
struct t_SifDmaTransfer dmat;
36+
static SifCmdResetData_t reset_pkt;
37+
SifDmaTransfer_t dmat;
3838
int arglen;
3939

4040
_iop_reboot_count++; // increment reboot counter to allow RPC clients to detect unbinding!

ee/kernel/src/rom0_info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void SetupRomInfo(void)
3939
{
4040
void *iop_addr;
4141
SifRpcReceiveData_t rdata;
42-
u8 buf[64] __attribute__((__aligned__(64)));
42+
u8 buf[64] ALIGNED_FOR_SIFDMA;
4343

4444
/* ROMVER needs to be read from the IOP due to PPCIOP region patching. */
4545
/* only read in the romname the first time */

0 commit comments

Comments
 (0)