aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/tidspbridge
diff options
context:
space:
mode:
authorArmando Uribe <x0095078@ti.com>2010-07-22 21:25:29 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-07-26 18:32:19 -0400
commita563510fb2f18f0d7f2fbf815e7d7052f280a61d (patch)
tree8a392d997eaa80529c8b3e1351032034dc7d8ddc /drivers/staging/tidspbridge
parentc18c9c910dbcc4cc55a440c38fad300f1ecf8dbb (diff)
staging: tidspbridge: Change macros to static inline functions used in cload
This patch changes the macros to static inline function used in cload as well adds two definition of const to avoid using magic numbers Signed-off-by: Armando Uribe <x0095078@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/tidspbridge')
-rw-r--r--drivers/staging/tidspbridge/dynload/cload.c16
-rw-r--r--drivers/staging/tidspbridge/dynload/doff.h31
-rw-r--r--drivers/staging/tidspbridge/dynload/tramp.c2
3 files changed, 31 insertions, 18 deletions
diff --git a/drivers/staging/tidspbridge/dynload/cload.c b/drivers/staging/tidspbridge/dynload/cload.c
index e48e91b9315..32150f0c5e5 100644
--- a/drivers/staging/tidspbridge/dynload/cload.c
+++ b/drivers/staging/tidspbridge/dynload/cload.c
@@ -528,7 +528,7 @@ static void allocate_sections(struct dload_state *dlthis)
528 } 528 }
529#endif 529#endif
530 /* allocate target storage for sections that require it */ 530 /* allocate target storage for sections that require it */
531 if (DS_NEEDS_ALLOCATION(shp)) { 531 if (ds_needs_allocation(shp)) {
532 *asecs = *DOFFSEC_IS_LDRSEC(shp); 532 *asecs = *DOFFSEC_IS_LDRSEC(shp);
533 asecs->context = 0; /* zero the context field */ 533 asecs->context = 0; /* zero the context field */
534#if BITS_PER_AU > BITS_PER_BYTE 534#if BITS_PER_AU > BITS_PER_BYTE
@@ -540,7 +540,7 @@ static void allocate_sections(struct dload_state *dlthis)
540 if (dlthis->myalloc != NULL) { 540 if (dlthis->myalloc != NULL) {
541 if (!dlthis->myalloc-> 541 if (!dlthis->myalloc->
542 dload_allocate(dlthis->myalloc, asecs, 542 dload_allocate(dlthis->myalloc, asecs,
543 DS_ALIGNMENT(asecs->type))) { 543 ds_alignment(asecs->type))) {
544 dload_error(dlthis, tgtalloc, 544 dload_error(dlthis, tgtalloc,
545 asecs->name, asecs->size); 545 asecs->name, asecs->size);
546 return; 546 return;
@@ -1155,7 +1155,7 @@ static void dload_data(struct dload_state *dlthis)
1155 */ 1155 */
1156 for (curr_sect = 0; curr_sect < dlthis->dfile_hdr.df_no_scns; 1156 for (curr_sect = 0; curr_sect < dlthis->dfile_hdr.df_no_scns;
1157 curr_sect += 1) { 1157 curr_sect += 1) {
1158 if (DS_NEEDS_DOWNLOAD(sptr)) { 1158 if (ds_needs_download(sptr)) {
1159 s32 nip; 1159 s32 nip;
1160 ldr_addr image_offset = 0; 1160 ldr_addr image_offset = 0;
1161 /* set relocation info for this section */ 1161 /* set relocation info for this section */
@@ -1201,7 +1201,7 @@ static void dload_data(struct dload_state *dlthis)
1201 dest = ibuf.bufr; 1201 dest = ibuf.bufr;
1202#ifdef OPT_ZERO_COPY_LOADER 1202#ifdef OPT_ZERO_COPY_LOADER
1203 zero_copy = false; 1203 zero_copy = false;
1204 if (DLOAD_SECT_TYPE(sptr) != DLOAD_CINIT) { 1204 if (!dload_check_type(sptr, DLOAD_CINIT) {
1205 dlthis->myio->writemem(dlthis->myio, 1205 dlthis->myio->writemem(dlthis->myio,
1206 &dest, 1206 &dest,
1207 lptr->load_addr + 1207 lptr->load_addr +
@@ -1267,8 +1267,8 @@ static void dload_data(struct dload_state *dlthis)
1267 1267
1268 /* stuff the result into target 1268 /* stuff the result into target
1269 * memory */ 1269 * memory */
1270 if (DLOAD_SECT_TYPE(sptr) == 1270 if (dload_check_type(sptr,
1271 DLOAD_CINIT) { 1271 DLOAD_CINIT)) {
1272 cload_cinit(dlthis, 1272 cload_cinit(dlthis,
1273 &ibuf.ipacket); 1273 &ibuf.ipacket);
1274 cinit_processed = true; 1274 cinit_processed = true;
@@ -1306,7 +1306,7 @@ static void dload_data(struct dload_state *dlthis)
1306 BYTE_TO_TADDR(ibuf.ipacket.packet_size); 1306 BYTE_TO_TADDR(ibuf.ipacket.packet_size);
1307 } /* process packets */ 1307 } /* process packets */
1308 /* if this is a BSS section, we may want to fill it */ 1308 /* if this is a BSS section, we may want to fill it */
1309 if (DLOAD_SECT_TYPE(sptr) != DLOAD_BSS) 1309 if (!dload_check_type(sptr, DLOAD_BSS))
1310 goto loop_cont; 1310 goto loop_cont;
1311 1311
1312 if (!(dlthis->myoptions & DLOAD_INITBSS)) 1312 if (!(dlthis->myoptions & DLOAD_INITBSS))
@@ -1330,7 +1330,7 @@ static void dload_data(struct dload_state *dlthis)
1330 } 1330 }
1331 /* if DS_DOWNLOAD_MASK */ 1331 /* if DS_DOWNLOAD_MASK */
1332 /* If not loading, but BSS, zero initialize */ 1332 /* If not loading, but BSS, zero initialize */
1333 if (DLOAD_SECT_TYPE(sptr) != DLOAD_BSS) 1333 if (!dload_check_type(sptr, DLOAD_BSS))
1334 goto loop_cont; 1334 goto loop_cont;
1335 1335
1336 if (!(dlthis->myoptions & DLOAD_INITBSS)) 1336 if (!(dlthis->myoptions & DLOAD_INITBSS))
diff --git a/drivers/staging/tidspbridge/dynload/doff.h b/drivers/staging/tidspbridge/dynload/doff.h
index 5bf99240f9f..c00d18985a7 100644
--- a/drivers/staging/tidspbridge/dynload/doff.h
+++ b/drivers/staging/tidspbridge/dynload/doff.h
@@ -326,19 +326,32 @@ struct reloc_record_t {
326/**************************************************************************** */ 326/**************************************************************************** */
327 327
328/* Enum for DOFF section types (bits 0-3 of flag): See dynamic_loader.h */ 328/* Enum for DOFF section types (bits 0-3 of flag): See dynamic_loader.h */
329 329#define DS_SECTION_TYPE_MASK 0xF
330/* Macros to help processing of sections */
331#define DLOAD_SECT_TYPE(s_hdr) ((s_hdr)->ds_flags & 0xF)
332
333/* DS_ALLOCATE indicates whether a section needs space on the target */ 330/* DS_ALLOCATE indicates whether a section needs space on the target */
334#define DS_ALLOCATE_MASK 0x10 331#define DS_ALLOCATE_MASK 0x10
335#define DS_NEEDS_ALLOCATION(s_hdr) ((s_hdr)->ds_flags & DS_ALLOCATE_MASK)
336
337/* DS_DOWNLOAD indicates that the loader needs to copy bits */ 332/* DS_DOWNLOAD indicates that the loader needs to copy bits */
338#define DS_DOWNLOAD_MASK 0x20 333#define DS_DOWNLOAD_MASK 0x20
339#define DS_NEEDS_DOWNLOAD(s_hdr) ((s_hdr)->ds_flags & DS_DOWNLOAD_MASK)
340
341/* Section alignment requirement in AUs */ 334/* Section alignment requirement in AUs */
342#define DS_ALIGNMENT(ds_flags) (1 << (((ds_flags) >> 8) & 0xF)) 335#define DS_ALIGNMENT_SHIFT 8
336
337static inline bool dload_check_type(struct doff_scnhdr_t *sptr, u32 flag)
338{
339 return (sptr->ds_flags & DS_SECTION_TYPE_MASK) == flag;
340}
341static inline bool ds_needs_allocation(struct doff_scnhdr_t *sptr)
342{
343 return sptr->ds_flags & DS_ALLOCATE_MASK;
344}
345
346static inline bool ds_needs_download(struct doff_scnhdr_t *sptr)
347{
348 return sptr->ds_flags & DS_DOWNLOAD_MASK;
349}
350
351static inline int ds_alignment(u16 ds_flags)
352{
353 return 1 << ((ds_flags >> DS_ALIGNMENT_SHIFT) & DS_SECTION_TYPE_MASK);
354}
355
343 356
344#endif /* _DOFF_H */ 357#endif /* _DOFF_H */
diff --git a/drivers/staging/tidspbridge/dynload/tramp.c b/drivers/staging/tidspbridge/dynload/tramp.c
index 7b593fc2b69..81314d2fd44 100644
--- a/drivers/staging/tidspbridge/dynload/tramp.c
+++ b/drivers/staging/tidspbridge/dynload/tramp.c
@@ -48,7 +48,7 @@ static int priv_tramp_sect_tgt_alloc(struct dload_state *dlthis)
48 sect_info->load_addr = 0; 48 sect_info->load_addr = 0;
49 ret_val = dlthis->myalloc->dload_allocate(dlthis->myalloc, 49 ret_val = dlthis->myalloc->dload_allocate(dlthis->myalloc,
50 sect_info, 50 sect_info,
51 DS_ALIGNMENT 51 ds_alignment
52 (sect_info->type)); 52 (sect_info->type));
53 53
54 if (ret_val == 0) 54 if (ret_val == 0)