Skip to content

Commit

Permalink
Remove Endian Switches
Browse files Browse the repository at this point in the history
Plat code will always run on big endian

Change-Id: I858cf8d217534414716de81f20227d9ad30756bd
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/41090
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Shakeeb A. Pasha B K <shakeebbk@in.ibm.com>
Reviewed-by: Santosh S. Puranik <santosh.puranik@in.ibm.com>
  • Loading branch information
Santosh Puranik committed Jun 1, 2017
1 parent e97705e commit 6ec048d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 90 deletions.
11 changes: 1 addition & 10 deletions src/hwpf/plat_target.H
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/* OpenPOWER sbe Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
Expand Down Expand Up @@ -69,23 +70,13 @@ namespace fapi2
typedef union plat_target_handle {
uint32_t value;
struct {
#ifdef _BIG_ENDIAN
uint32_t chiplet_num : 8;
uint32_t type_target_num : 8;
uint32_t present : 1;
uint32_t functional : 1;
uint32_t is_multicast : 1;
uint32_t valid : 1;
uint32_t type : 12;
#else
uint32_t type : 12;
uint32_t valid : 1;
uint32_t is_multicast : 1;
uint32_t functional : 1;
uint32_t present : 1;
uint32_t type_target_num : 8;
uint32_t chiplet_num : 8;
#endif
} fields;
///
/// @brief Plat target handle constructor
Expand Down
58 changes: 1 addition & 57 deletions src/hwpf/plat_utils.C
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/* OpenPOWER sbe Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
Expand Down Expand Up @@ -137,60 +138,3 @@ namespace fapi2
}
};

#ifndef _BIG_ENDIAN

/// Byte-reverse a 16-bit integer if on a little-endian machine

uint16_t
revle16(uint16_t i_x)
{
uint16_t rx;
uint8_t *pix = (uint8_t*)(&i_x);
uint8_t *prx = (uint8_t*)(&rx);

prx[0] = pix[1];
prx[1] = pix[0];

return rx;
}

/// Byte-reverse a 32-bit integer if on a little-endian machine

uint32_t
revle32(uint32_t i_x)
{
uint32_t rx;
uint8_t *pix = (uint8_t*)(&i_x);
uint8_t *prx = (uint8_t*)(&rx);

prx[0] = pix[3];
prx[1] = pix[2];
prx[2] = pix[1];
prx[3] = pix[0];

return rx;
}


/// Byte-reverse a 64-bit integer if on a little-endian machine

uint64_t
revle64(const uint64_t i_x)
{
uint64_t rx;
uint8_t *pix = (uint8_t*)(&i_x);
uint8_t *prx = (uint8_t*)(&rx);

prx[0] = pix[7];
prx[1] = pix[6];
prx[2] = pix[5];
prx[3] = pix[4];
prx[4] = pix[3];
prx[5] = pix[2];
prx[6] = pix[1];
prx[7] = pix[0];

return rx;
}
#endif

15 changes: 1 addition & 14 deletions src/hwpf/plat_utils.H
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/* OpenPOWER sbe Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2016,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
Expand Down Expand Up @@ -48,18 +49,4 @@
#ifndef BIT
#define BIT(b) BITS((b), 1)
#endif

#ifdef _BIG_ENDIAN

#define revle16(x) x
#define revle32(x) x
#define revle64(x) x

#else

uint16_t revle16(uint16_t i_x);
uint32_t revle32(uint32_t i_x);
uint64_t revle64(uint64_t i_x);

#endif
#endif //_PLAT_UTILS_H_
19 changes: 10 additions & 9 deletions src/hwpf/target.C
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/* OpenPOWER sbe Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
Expand Down Expand Up @@ -492,7 +493,7 @@ fapi_try_exit:
l_beginning_offset = CHIP_TARGET_OFFSET;

fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> chip_target((createPlatTargetHandle<fapi2::TARGET_TYPE_PROC_CHIP>(0)));
G_vec_targets.at(l_beginning_offset) = revle32((fapi2::plat_target_handle_t)(chip_target.get()));
G_vec_targets.at(l_beginning_offset) = (fapi2::plat_target_handle_t)(chip_target.get());

// Initialize platform attributes. Needs to be after the chip target is
// created.
Expand All @@ -510,7 +511,7 @@ fapi_try_exit:
// via partial good attributes
FAPI_TRY(plat_TargetPresent(target_name, b_present));

G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(target_name.get()));
G_vec_targets.at(l_beginning_offset+i) = (fapi2::plat_target_handle_t)(target_name.get());
}

/*
Expand All @@ -527,7 +528,7 @@ fapi_try_exit:
// via partial good attributes
FAPI_TRY(plat_TargetPresent(l_perv, b_present));

G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(l_perv.get()));
G_vec_targets.at(l_beginning_offset+i) = (fapi2::plat_target_handle_t)(l_perv.get());

}

Expand All @@ -544,7 +545,7 @@ fapi_try_exit:
// via partial good attributes
FAPI_TRY(plat_TargetPresent(target_name, b_present));

G_vec_targets.at(i) = revle32((fapi2::plat_target_handle_t)(target_name.get()));
G_vec_targets.at(i) = (fapi2::plat_target_handle_t)(target_name.get());
}

/*
Expand All @@ -560,7 +561,7 @@ fapi_try_exit:
// via partial good attributes
FAPI_TRY(plat_TargetPresent(l_perv, b_present));

G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(l_perv.get()));
G_vec_targets.at(l_beginning_offset+i) = (fapi2::plat_target_handle_t)(l_perv.get());
}

/*
Expand All @@ -577,7 +578,7 @@ fapi_try_exit:
// via partial good attributes
FAPI_TRY(plat_TargetPresent(l_perv, b_present));

G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(l_perv.get()));
G_vec_targets.at(l_beginning_offset+i) = (fapi2::plat_target_handle_t)(l_perv.get());
}

/*
Expand Down Expand Up @@ -612,7 +613,7 @@ fapi_try_exit:
static_cast<plat_target_handle_t&>(target_name.operator ()()).setPresent();
static_cast<plat_target_handle_t&>(target_name.operator ()()).setFunctional(true);
}
G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(target_name.get()));
G_vec_targets.at(l_beginning_offset+i) = (fapi2::plat_target_handle_t)(target_name.get());
}

/*
Expand Down Expand Up @@ -648,7 +649,7 @@ fapi_try_exit:
static_cast<plat_target_handle_t&>(target_name.operator ()()).setFunctional(true);
}

G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(target_name.get()));
G_vec_targets.at(l_beginning_offset+i) = (fapi2::plat_target_handle_t)(target_name.get());
}

/*
Expand All @@ -673,7 +674,7 @@ fapi_try_exit:
static_cast<plat_target_handle_t&>(target_name.operator ()()).setFunctional(true);
}

G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(target_name.get()));
G_vec_targets.at(l_beginning_offset+i) = (fapi2::plat_target_handle_t)(target_name.get());
}


Expand Down

0 comments on commit 6ec048d

Please sign in to comment.