From 8cd6211376e4222f363aa551d576a80dd8410e8f Mon Sep 17 00:00:00 2001 From: Alexander Kuleshov Date: Sat, 19 Dec 2015 00:01:13 +0600 Subject: [PATCH] boot/libi386: use macros from to represent eflags's bits The libi386's source code contains some checks of the EFLAGS's bits. In the same time the header file provides macros which represents these bits. Let's use human readable names instead of numbers. --- sys/boot/pc32/libi386/biosdisk.c | 17 +++++++++-------- sys/boot/pc32/libi386/biosmem.c | 5 +++-- sys/boot/pc32/libi386/biospci.c | 7 ++++--- sys/boot/pc32/libi386/biossmap.c | 5 +++-- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/sys/boot/pc32/libi386/biosdisk.c b/sys/boot/pc32/libi386/biosdisk.c index 2cf9407..d41096d 100644 --- a/sys/boot/pc32/libi386/biosdisk.c +++ b/sys/boot/pc32/libi386/biosdisk.c @@ -43,6 +43,7 @@ #include #include #include +#include #include @@ -215,7 +216,7 @@ bd_int13probe(struct bdinfo *bd) v86.edx = bd->bd_unit; v86int(); - if (!(v86.efl & 0x1) && /* carry clear */ + if (!(v86.efl & PSL_C) && /* carry clear */ ((v86.edx & 0xff) > ((unsigned)bd->bd_unit & 0x7f))) { /* unit # OK */ /* @@ -235,7 +236,7 @@ bd_int13probe(struct bdinfo *bd) v86.edx = bd->bd_unit; v86.ebx = 0x55aa; v86int(); - if (!(v86.efl & 0x1) && /* carry clear */ + if (!(v86.efl & PSL_C) && /* carry clear */ ((v86.ebx & 0xffff) == 0xaa55) && /* signature */ (v86.ecx & 0x1)) { /* packets mode ok */ bd->bd_flags |= BD_MODEEDD1; @@ -1099,7 +1100,7 @@ bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest) v86.ds = VTOPSEG(packet); v86.esi = VTOPOFF(packet); v86int(); - result = (v86.efl & 0x1); + result = (v86.efl & PSL_C); if (result == 0) break; } else if (cyl < 1024) { @@ -1112,7 +1113,7 @@ bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest) v86.es = VTOPSEG(xp); v86.ebx = VTOPOFF(xp); v86int(); - result = (v86.efl & 0x1); + result = (v86.efl & PSL_C); if (result == 0) break; } else { @@ -1250,7 +1251,7 @@ bd_write(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest) v86.ds = VTOPSEG(packet); v86.esi = VTOPOFF(packet); v86int(); - result = (v86.efl & 0x1); + result = (v86.efl & PSL_C); if (result == 0) break; } else if (cyl < 1024) { @@ -1263,7 +1264,7 @@ bd_write(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest) v86.es = VTOPSEG(xp); v86.ebx = VTOPOFF(xp); v86int(); - result = (v86.efl & 0x1); + result = (v86.efl & PSL_C); if (result == 0) break; } else { @@ -1293,7 +1294,7 @@ bd_getgeom(struct open_disk *od) v86.edx = od->od_unit; v86int(); - if ((v86.efl & 0x1) || /* carry set */ + if ((v86.efl & PSL_C) || /* carry set */ ((v86.edx & 0xff) <= (unsigned)(od->od_unit & 0x7f))) /* unit # bad */ return(1); @@ -1330,7 +1331,7 @@ bd_getbigeom(int bunit) v86.eax = 0x800; v86.edx = 0x80 + bunit; v86int(); - if (v86.efl & 0x1) + if (v86.efl & PSL_C) return 0x4f010f; return ((v86.ecx & 0xc0) << 18) | ((v86.ecx & 0xff00) << 8) | (v86.edx & 0xff00) | (v86.ecx & 0x3f); diff --git a/sys/boot/pc32/libi386/biosmem.c b/sys/boot/pc32/libi386/biosmem.c index c284b75..aeb3a07 100644 --- a/sys/boot/pc32/libi386/biosmem.c +++ b/sys/boot/pc32/libi386/biosmem.c @@ -30,6 +30,7 @@ * Obtain memory configuration information from the BIOS */ #include +#include #include "libi386.h" #include "btxv86.h" @@ -74,7 +75,7 @@ bios_getmem(void) (int)(smap.base >> 32), (int)smap.base, (int)(smap.length >> 32), (int)smap.length); #endif - if ((v86.efl & 1) || (v86.eax != SMAPSIG)) + if ((v86.efl & PSL_C) || (v86.eax != SMAPSIG)) break; /* look for a low-memory segment that's large enough */ if ((smap.type == 1) && (smap.base == 0) && (smap.length >= (512 * 1024))) { @@ -103,7 +104,7 @@ bios_getmem(void) v86.addr = 0x15; /* int 0x15 function 0xe801*/ v86.eax = 0xe801; v86int(); - if (!(v86.efl & 1)) { + if (!(v86.efl & PSL_C)) { v = ((v86.ecx & 0xffff) + ((int64_t)(v86.edx & 0xffff) * 64)) * 1024; if (v > 0x40000000) diff --git a/sys/boot/pc32/libi386/biospci.c b/sys/boot/pc32/libi386/biospci.c index f54d835..517345f 100644 --- a/sys/boot/pc32/libi386/biospci.c +++ b/sys/boot/pc32/libi386/biospci.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -212,7 +213,7 @@ biospci_enumerate(void) v86int(); /* Check for OK response */ - if ((v86.efl & 1) || ((v86.eax & 0xff00) != 0) || (v86.edx != 0x20494350)) + if ((v86.efl & PSL_C) || ((v86.eax & 0xff00) != 0) || (v86.edx != 0x20494350)) return; biospci_version = v86.ebx & 0xffff; @@ -240,7 +241,7 @@ biospci_enumerate(void) v86.esi = device_index; v86int(); /* error/end of matches */ - if ((v86.efl & 1) || (v86.eax & 0xff00)) + if ((v86.efl & PSL_C) || (v86.eax & 0xff00)) break; /* Got something */ @@ -254,7 +255,7 @@ biospci_enumerate(void) v86.edi = 0x0; v86int(); /* error */ - if ((v86.efl & 1) || (v86.eax & 0xff00)) + if ((v86.efl & PSL_C) || (v86.eax & 0xff00)) break; /* We have the device ID, create a PnP object and save everything */ diff --git a/sys/boot/pc32/libi386/biossmap.c b/sys/boot/pc32/libi386/biossmap.c index edf130b..99e6878 100644 --- a/sys/boot/pc32/libi386/biossmap.c +++ b/sys/boot/pc32/libi386/biossmap.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "bootstrap.h" #include "libi386.h" #include "btxv86.h" @@ -68,7 +69,7 @@ bios_getsmap(void) v86.es = VTOPSEG(&smap); v86.edi = VTOPOFF(&smap); v86int(); - if ((v86.efl & 1) || (v86.eax != SMAPSIG)) + if ((v86.efl & PSL_C) || (v86.eax != SMAPSIG)) break; n++; } while (v86.ebx != 0); @@ -121,7 +122,7 @@ bios_getsmap(void) smapbase[smaplen] = smap; ++smaplen; } - if ((v86.efl & 1) || (v86.eax != SMAPSIG)) + if ((v86.efl & PSL_C) || (v86.eax != SMAPSIG)) break; } while (v86.ebx != 0 && smaplen < n); } -- 2.6.3