summaryrefslogtreecommitdiff
path: root/cgpt/cgpt_common.c
diff options
context:
space:
mode:
authorvbendeb <vbendeb@chromium.org>2010-06-21 08:44:16 -0700
committervbendeb <vbendeb@chromium.org>2010-06-21 08:44:16 -0700
commitf7a45cc01d7e4056482b2cdc23080bfabbbffc76 (patch)
tree15e826191fb3359c621903be6dd5405c90199c04 /cgpt/cgpt_common.c
parent6216f5abe9901e9c47789d55ae90243c6cc50aeb (diff)
downloadvboot-f7a45cc01d7e4056482b2cdc23080bfabbbffc76.tar.gz
Reduce attributes size to comply with msc limitations.
It turned out that shared verified boot library fails to work properly when compiled by msc in BIOS environment. The culprit was identified as failing 64 bit logical operations by preprocessor. It is probably possible to come up with a certain compile flag set to fix the operations, but it is not easy to modify and control the BIOS compilation environment. The alternative solution is to limit the size of the field in question to 16 bits (especially since this is the only part of the attributes field which is supposed to be altered by firmware. A union is being introduced in firmware/lib/cgptlib/include/gpt.h:GptEntry to allow accessing the field both as a 64 bit entity and a top 16 bit field. All places where this field is used are being modified appropriately. tests/Makefile is being fixed to allow controlling test run from the top level directory. Tested by building everything and running tests. All tests pass. Review URL: http://codereview.chromium.org/2799019
Diffstat (limited to 'cgpt/cgpt_common.c')
-rw-r--r--cgpt/cgpt_common.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/cgpt/cgpt_common.c b/cgpt/cgpt_common.c
index f165f7a7..8e8196b4 100644
--- a/cgpt/cgpt_common.c
+++ b/cgpt/cgpt_common.c
@@ -522,15 +522,15 @@ void SetPriority(GptData *gpt, int secondary, int entry_index, int priority) {
entry = GetEntry(gpt, secondary, entry_index);
assert(priority >= 0 && priority <= CGPT_ATTRIBUTE_MAX_PRIORITY);
- entry->attributes &= ~CGPT_ATTRIBUTE_PRIORITY_MASK;
- entry->attributes |= (uint64_t)priority << CGPT_ATTRIBUTE_PRIORITY_OFFSET;
+ entry->attrs.fields.gpt_att &= ~CGPT_ATTRIBUTE_PRIORITY_MASK;
+ entry->attrs.fields.gpt_att |= priority << CGPT_ATTRIBUTE_PRIORITY_OFFSET;
}
int GetPriority(GptData *gpt, int secondary, int entry_index) {
GptEntry *entry;
entry = GetEntry(gpt, secondary, entry_index);
- return (entry->attributes & CGPT_ATTRIBUTE_PRIORITY_MASK) >>
- CGPT_ATTRIBUTE_PRIORITY_OFFSET;
+ return (entry->attrs.fields.gpt_att & CGPT_ATTRIBUTE_PRIORITY_MASK) >>
+ CGPT_ATTRIBUTE_PRIORITY_OFFSET;
}
void SetTries(GptData *gpt, int secondary, int entry_index, int tries) {
@@ -538,15 +538,15 @@ void SetTries(GptData *gpt, int secondary, int entry_index, int tries) {
entry = GetEntry(gpt, secondary, entry_index);
assert(tries >= 0 && tries <= CGPT_ATTRIBUTE_MAX_TRIES);
- entry->attributes &= ~CGPT_ATTRIBUTE_TRIES_MASK;
- entry->attributes |= (uint64_t)tries << CGPT_ATTRIBUTE_TRIES_OFFSET;
+ entry->attrs.fields.gpt_att &= ~CGPT_ATTRIBUTE_TRIES_MASK;
+ entry->attrs.fields.gpt_att |= tries << CGPT_ATTRIBUTE_TRIES_OFFSET;
}
int GetTries(GptData *gpt, int secondary, int entry_index) {
GptEntry *entry;
entry = GetEntry(gpt, secondary, entry_index);
- return (entry->attributes & CGPT_ATTRIBUTE_TRIES_MASK) >>
- CGPT_ATTRIBUTE_TRIES_OFFSET;
+ return (entry->attrs.fields.gpt_att & CGPT_ATTRIBUTE_TRIES_MASK) >>
+ CGPT_ATTRIBUTE_TRIES_OFFSET;
}
void SetSuccessful(GptData *gpt, int secondary, int entry_index, int success) {
@@ -554,14 +554,14 @@ void SetSuccessful(GptData *gpt, int secondary, int entry_index, int success) {
entry = GetEntry(gpt, secondary, entry_index);
assert(success >= 0 && success <= CGPT_ATTRIBUTE_MAX_SUCCESSFUL);
- entry->attributes &= ~CGPT_ATTRIBUTE_SUCCESSFUL_MASK;
- entry->attributes |= (uint64_t)success << CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET;
+ entry->attrs.fields.gpt_att &= ~CGPT_ATTRIBUTE_SUCCESSFUL_MASK;
+ entry->attrs.fields.gpt_att |= success << CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET;
}
int GetSuccessful(GptData *gpt, int secondary, int entry_index) {
GptEntry *entry;
entry = GetEntry(gpt, secondary, entry_index);
- return (entry->attributes & CGPT_ATTRIBUTE_SUCCESSFUL_MASK) >>
+ return (entry->attrs.fields.gpt_att & CGPT_ATTRIBUTE_SUCCESSFUL_MASK) >>
CGPT_ATTRIBUTE_SUCCESSFUL_OFFSET;
}