From: H. Peter Anvin Date: Mon, 26 Jul 2010 20:57:34 +0000 (-0700) Subject: core: define and use set_flags() helper X-Git-Tag: syslinux-4.03-pre1~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d9525aba8b8aece54b4c3b45245eb050e961ed5;p=platform%2Fupstream%2Fsyslinux.git 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 --- diff --git a/core/fs/fs.c b/core/fs/fs.c index d10f6a8..ad2fb37 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 e365b1a..bd9d353 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 7db5daf..114b049 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 */