aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2010-07-26 13:57:34 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2010-07-26 13:57:34 -0700
commit9d9525aba8b8aece54b4c3b45245eb050e961ed5 (patch)
tree62979ab912a7dd8131c89af296e7e92f7e15734b
parent0e2cc408f60fbafecd853751c8638dfe9a9f7c84 (diff)
downloadhdt-pierre-9d9525aba8b8aece54b4c3b45245eb050e961ed5.tar.gz
hdt-pierre-9d9525aba8b8aece54b4c3b45245eb050e961ed5.tar.xz
hdt-pierre-9d9525aba8b8aece54b4c3b45245eb050e961ed5.zip
core: define and use set_flags() helper
Rather than opencoding the arithmetic flag mask, define an inline to make that happen properly. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--core/fs/fs.c3
-rw-r--r--core/fs/loadhigh.c9
-rw-r--r--core/include/core.h13
3 files changed, 18 insertions, 7 deletions
diff --git a/core/fs/fs.c b/core/fs/fs.c
index d10f6a83..ad2fb370 100644
--- a/core/fs/fs.c
+++ b/core/fs/fs.c
@@ -86,8 +86,7 @@ void pm_load_config(com32sys_t *regs)
if (err)
printf("ERROR: No configuration file found\n");
- regs->eflags.l &= ~(EFLAGS_ZF | EFLAGS_CF);
- regs->eflags.l |= err ? EFLAGS_ZF : 0;
+ set_flags(regs, err ? EFLAGS_ZF : 0);
}
void pm_mangle_name(com32sys_t *regs)
diff --git a/core/fs/loadhigh.c b/core/fs/loadhigh.c
index e365b1a3..bd9d3535 100644
--- a/core/fs/loadhigh.c
+++ b/core/fs/loadhigh.c
@@ -50,6 +50,7 @@ void pm_load_high(com32sys_t *regs)
struct file *file;
uint32_t sector_mask;
size_t pad;
+ uint32_t retflags = 0;
bytes = regs->eax.l;
zero_mask = regs->edx.w[0];
@@ -58,9 +59,6 @@ void pm_load_high(com32sys_t *regs)
file = handle_to_file(regs->esi.w[0]);
fs = file->fs;
- regs->eflags.l &= ~(EFLAGS_CF|EFLAGS_OF|EFLAGS_AF|
- EFLAGS_PF|EFLAGS_ZF|EFLAGS_SF);
-
sector_mask = SECTOR_SIZE(fs) - 1;
while (bytes) {
@@ -69,7 +67,7 @@ void pm_load_high(com32sys_t *regs)
if (buf + SECTOR_SIZE(fs) > limit) {
/* Can't fit even one more sector in... */
- regs->eflags.l |= EFLAGS_OF;
+ retflags = EFLAGS_OF;
break;
}
@@ -99,7 +97,7 @@ void pm_load_high(com32sys_t *regs)
*/
_close_file(file);
regs->esi.w[0] = 0;
- regs->eflags.l |= EFLAGS_CF;
+ retflags = EFLAGS_CF;
break;
}
}
@@ -110,4 +108,5 @@ void pm_load_high(com32sys_t *regs)
regs->ebx.l = (size_t)buf;
regs->edi.l = (size_t)buf + pad;
+ set_flags(regs, retflags);
}
diff --git a/core/include/core.h b/core/include/core.h
index 7db5dafe..114b049a 100644
--- a/core/include/core.h
+++ b/core/include/core.h
@@ -75,4 +75,17 @@ static inline uint32_t ms_timer(void)
return __ms_timer;
}
+/*
+ * Helper routine to return a specific set of flags
+ */
+static inline void set_flags(com32sys_t *regs, uint32_t flags)
+{
+ uint32_t eflags;
+
+ eflags = regs->eflags.l;
+ eflags &= ~(EFLAGS_CF|EFLAGS_PF|EFLAGS_AF|EFLAGS_ZF|EFLAGS_SF|EFLAGS_OF);
+ eflags |= flags;
+ regs->eflags.l = eflags;
+}
+
#endif /* CORE_H */