diff options
author | jhb <jhb@FreeBSD.org> | 2011-10-25 19:45:12 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2011-10-25 19:45:12 +0000 |
commit | 465469fc74999a15659ae97644b7fcd86a664cd5 (patch) | |
tree | 9833dc925193f64e764ad4b4a8923355e787b17b /sys/boot | |
parent | 332e83efa6d41a05f6d3c987ba946b36dce78ab0 (diff) | |
download | FreeBSD-src-465469fc74999a15659ae97644b7fcd86a664cd5.zip FreeBSD-src-465469fc74999a15659ae97644b7fcd86a664cd5.tar.gz |
Consolidate duplicate definitions of V86_CY() and V86_ZR() which check for
the carry and zero flags being set, respectively, in <btxv86.h> and use
them throughout the x86 boot code.
Diffstat (limited to 'sys/boot')
-rw-r--r-- | sys/boot/i386/boot2/boot2.c | 3 | ||||
-rw-r--r-- | sys/boot/i386/btx/lib/btxv86.h | 4 | ||||
-rw-r--r-- | sys/boot/i386/common/cons.c | 2 | ||||
-rw-r--r-- | sys/boot/i386/common/drv.c | 5 | ||||
-rw-r--r-- | sys/boot/i386/libi386/bioscd.c | 4 | ||||
-rw-r--r-- | sys/boot/i386/libi386/biosdisk.c | 16 | ||||
-rw-r--r-- | sys/boot/i386/libi386/biosmem.c | 4 | ||||
-rw-r--r-- | sys/boot/i386/libi386/biospci.c | 9 | ||||
-rw-r--r-- | sys/boot/i386/libi386/biossmap.c | 3 | ||||
-rw-r--r-- | sys/boot/i386/libi386/vidconsole.c | 2 | ||||
-rw-r--r-- | sys/boot/pc98/boot2/boot2.c | 3 | ||||
-rw-r--r-- | sys/boot/pc98/btx/lib/btxv86.h | 4 | ||||
-rw-r--r-- | sys/boot/pc98/libpc98/bioscd.c | 3 | ||||
-rw-r--r-- | sys/boot/pc98/libpc98/vidconsole.c | 1 | ||||
-rw-r--r-- | sys/boot/pc98/loader/main.c | 1 |
15 files changed, 27 insertions, 37 deletions
diff --git a/sys/boot/i386/boot2/boot2.c b/sys/boot/i386/boot2/boot2.c index 4d1a2a0..3603924 100644 --- a/sys/boot/i386/boot2/boot2.c +++ b/sys/boot/i386/boot2/boot2.c @@ -24,7 +24,6 @@ __FBSDID("$FreeBSD$"); #include <machine/bootinfo.h> #include <machine/elf.h> -#include <machine/psl.h> #include <stdarg.h> @@ -85,8 +84,6 @@ __FBSDID("$FreeBSD$"); #define NDEV 3 #define MEM_BASE 0x12 #define MEM_EXT 0x15 -#define V86_CY(x) ((x) & PSL_C) -#define V86_ZR(x) ((x) & PSL_Z) #define DRV_HARD 0x80 #define DRV_MASK 0x7f diff --git a/sys/boot/i386/btx/lib/btxv86.h b/sys/boot/i386/btx/lib/btxv86.h index 1152f8b..27f6b34 100644 --- a/sys/boot/i386/btx/lib/btxv86.h +++ b/sys/boot/i386/btx/lib/btxv86.h @@ -21,6 +21,7 @@ #define _BTXV86_H_ #include <sys/types.h> +#include <machine/psl.h> #define V86_ADDR 0x10000 /* Segment:offset address */ #define V86_CALLF 0x20000 /* Emulate far call */ @@ -57,6 +58,9 @@ extern u_int32_t __args; #define VTOPSEG(va) (u_int16_t)(VTOP((caddr_t)va) >> 4) #define VTOPOFF(va) (u_int16_t)(VTOP((caddr_t)va) & 0xf) +#define V86_CY(x) ((x) & PSL_C) +#define V86_ZR(x) ((x) & PSL_Z) + void __exit(int) __attribute__((__noreturn__)); void __exec(caddr_t, ...); diff --git a/sys/boot/i386/common/cons.c b/sys/boot/i386/common/cons.c index 9384f43..97019c6 100644 --- a/sys/boot/i386/common/cons.c +++ b/sys/boot/i386/common/cons.c @@ -27,8 +27,6 @@ __FBSDID("$FreeBSD$"); #include "util.h" #include "cons.h" -#define V86_ZR(x) ((x) & PSL_Z) - #define SECOND 18 /* Circa that many ticks in a second. */ uint8_t ioctrl = IO_KEYBOARD; diff --git a/sys/boot/i386/common/drv.c b/sys/boot/i386/common/drv.c index 11f6628..661047c 100644 --- a/sys/boot/i386/common/drv.c +++ b/sys/boot/i386/common/drv.c @@ -19,8 +19,6 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> -#include <machine/psl.h> - #include <btxv86.h> #include "rbx.h" @@ -30,9 +28,6 @@ __FBSDID("$FreeBSD$"); #include "xreadorg.h" #endif -#define V86_CY(x) ((x) & PSL_C) -#define V86_ZR(x) ((x) & PSL_Z) - #ifdef GPT uint64_t drvsize(struct dsk *dskp) diff --git a/sys/boot/i386/libi386/bioscd.c b/sys/boot/i386/libi386/bioscd.c index a3abf34..3c2c211 100644 --- a/sys/boot/i386/libi386/bioscd.c +++ b/sys/boot/i386/libi386/bioscd.c @@ -42,12 +42,12 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <machine/bootinfo.h> -#include <machine/psl.h> #include <stdarg.h> #include <bootstrap.h> #include <btxv86.h> +#include <edd.h> #include "libi386.h" #define BIOSCD_SECSIZE 2048 @@ -337,7 +337,7 @@ bc_read(int unit, daddr_t dblk, int blks, caddr_t dest) v86.ds = VTOPSEG(&packet); v86.esi = VTOPOFF(&packet); v86int(); - result = (v86.efl & PSL_C); + result = V86_CY(v86.efl); if (result == 0) break; } diff --git a/sys/boot/i386/libi386/biosdisk.c b/sys/boot/i386/libi386/biosdisk.c index a67a7ef..340dd6f 100644 --- a/sys/boot/i386/libi386/biosdisk.c +++ b/sys/boot/i386/libi386/biosdisk.c @@ -250,7 +250,7 @@ bd_int13probe(struct bdinfo *bd) v86.edx = bd->bd_unit; v86int(); - if (!(v86.efl & 0x1) && /* carry clear */ + if (!(V86_CY(v86.efl)) && /* carry clear */ ((v86.edx & 0xff) > ((unsigned)bd->bd_unit & 0x7f))) { /* unit # OK */ if ((v86.ecx & 0x3f) == 0) { /* absurd sector size */ DEBUG("Invalid geometry for unit %d", bd->bd_unit); @@ -264,11 +264,11 @@ bd_int13probe(struct bdinfo *bd) v86.edx = bd->bd_unit; v86.ebx = 0x55aa; v86int(); - if (!(v86.efl & 0x1) && /* carry clear */ + if (!(V86_CY(v86.efl)) && /* carry clear */ ((v86.ebx & 0xffff) == 0xaa55) && /* signature */ (v86.ecx & 0x1)) { /* packets mode ok */ bd->bd_flags |= BD_MODEEDD1; - if((v86.eax & 0xff00) >= 0x3000) + if ((v86.eax & 0xff00) >= 0x3000) bd->bd_flags |= BD_MODEEDD3; } return(1); @@ -562,7 +562,7 @@ bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev) return (ENOMEM); } - /* Look up BIOS unit number, intialise open_disk structure */ + /* Look up BIOS unit number, initalise open_disk structure */ od->od_dkunit = dev->d_unit; od->od_unit = bdinfo[od->od_dkunit].bd_unit; od->od_flags = bdinfo[od->od_dkunit].bd_flags; @@ -1150,7 +1150,7 @@ bd_edd_io(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest, int write) v86.ds = VTOPSEG(&packet); v86.esi = VTOPOFF(&packet); v86int(); - return (v86.efl & 0x1); + return (V86_CY(v86.efl)); } static int @@ -1183,7 +1183,7 @@ bd_chs_io(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest, int write) v86.es = VTOPSEG(dest); v86.ebx = VTOPOFF(dest); v86int(); - return (v86.efl & 0x1); + return (V86_CY(v86.efl)); } static int @@ -1311,7 +1311,7 @@ bd_getgeom(struct open_disk *od) v86.edx = od->od_unit; v86int(); - if ((v86.efl & 0x1) || /* carry set */ + if ((V86_CY(v86.efl)) || /* carry set */ ((v86.edx & 0xff) <= (unsigned)(od->od_unit & 0x7f))) /* unit # bad */ return(1); @@ -1348,7 +1348,7 @@ bd_getbigeom(int bunit) v86.eax = 0x800; v86.edx = 0x80 + bunit; v86int(); - if (v86.efl & 0x1) + if (V86_CY(v86.efl)) return 0x4f010f; return ((v86.ecx & 0xc0) << 18) | ((v86.ecx & 0xff00) << 8) | (v86.edx & 0xff00) | (v86.ecx & 0x3f); diff --git a/sys/boot/i386/libi386/biosmem.c b/sys/boot/i386/libi386/biosmem.c index bae6813..f437c6c 100644 --- a/sys/boot/i386/libi386/biosmem.c +++ b/sys/boot/i386/libi386/biosmem.c @@ -61,7 +61,7 @@ bios_getmem(void) v86.es = VTOPSEG(&smap); v86.edi = VTOPOFF(&smap); v86int(); - if ((v86.efl & 1) || (v86.eax != SMAP_SIG)) + if ((V86_CY(v86.efl)) || (v86.eax != SMAP_SIG)) break; /* look for a low-memory segment that's large enough */ if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base == 0) && @@ -108,7 +108,7 @@ bios_getmem(void) v86.addr = 0x15; /* int 0x15 function 0xe801*/ v86.eax = 0xe801; v86int(); - if (!(v86.efl & 1)) { + if (!(V86_CY(v86.efl))) { bios_extmem = ((v86.ecx & 0xffff) + ((v86.edx & 0xffff) * 64)) * 1024; } } diff --git a/sys/boot/i386/libi386/biospci.c b/sys/boot/i386/libi386/biospci.c index b69d8c5..ecbe7db 100644 --- a/sys/boot/i386/libi386/biospci.c +++ b/sys/boot/i386/libi386/biospci.c @@ -218,7 +218,8 @@ biospci_enumerate(void) v86int(); /* Check for OK response */ - if ((v86.efl & 1) || ((v86.eax & 0xff00) != 0) || (v86.edx != 0x20494350)) + if (V86_CY(v86.efl) || ((v86.eax & 0xff00) != 0) || + (v86.edx != 0x20494350)) return; biospci_version = v86.ebx & 0xffff; @@ -295,7 +296,7 @@ biospci_find_devclass(uint32_t class, int index, uint32_t *locator) v86int(); /* error */ - if ((v86.efl & 1) || (v86.eax & 0xff00)) + if (V86_CY(v86.efl) || (v86.eax & 0xff00)) return (-1); *locator = v86.ebx; @@ -317,7 +318,7 @@ biospci_write_config(uint32_t locator, int offset, int width, uint32_t val) v86int(); /* error */ - if ((v86.efl & 1) || (v86.eax & 0xff00)) + if (V86_CY(v86.efl) || (v86.eax & 0xff00)) return (-1); return(0); @@ -334,7 +335,7 @@ biospci_read_config(uint32_t locator, int offset, int width, uint32_t *val) v86int(); /* error */ - if ((v86.efl & 1) || (v86.eax & 0xff00)) + if (V86_CY(v86.efl) || (v86.eax & 0xff00)) return (-1); *val = v86.ecx; diff --git a/sys/boot/i386/libi386/biossmap.c b/sys/boot/i386/libi386/biossmap.c index 5a788c1..e95ea64 100644 --- a/sys/boot/i386/libi386/biossmap.c +++ b/sys/boot/i386/libi386/biossmap.c @@ -36,14 +36,11 @@ __FBSDID("$FreeBSD$"); #include <sys/queue.h> #include <sys/stddef.h> #include <machine/metadata.h> -#include <machine/psl.h> #include <machine/pc/bios.h> #include "bootstrap.h" #include "libi386.h" #include "btxv86.h" -#define V86_CY(x) ((x) & PSL_C) - struct smap_buf { struct bios_smap smap; uint32_t xattr; /* Extended attribute from ACPI 3.0 */ diff --git a/sys/boot/i386/libi386/vidconsole.c b/sys/boot/i386/libi386/vidconsole.c index 1b1e648..d95ce88 100644 --- a/sys/boot/i386/libi386/vidconsole.c +++ b/sys/boot/i386/libi386/vidconsole.c @@ -516,7 +516,7 @@ vidc_ischar(void) v86.addr = 0x16; v86.eax = 0x100; v86int(); - return (!(v86.efl & PSL_Z)); + return (!V86_ZR(v86.efl)); } #if KEYBOARD_PROBE diff --git a/sys/boot/pc98/boot2/boot2.c b/sys/boot/pc98/boot2/boot2.c index bb72c9d..2ef4da6 100644 --- a/sys/boot/pc98/boot2/boot2.c +++ b/sys/boot/pc98/boot2/boot2.c @@ -26,7 +26,6 @@ __FBSDID("$FreeBSD$"); #include <machine/bootinfo.h> #include <machine/cpufunc.h> #include <machine/elf.h> -#include <machine/psl.h> #include <stdarg.h> @@ -85,8 +84,6 @@ __FBSDID("$FreeBSD$"); #define ARGS 0x900 #define NOPT 14 #define NDEV 3 -#define V86_CY(x) ((x) & PSL_C) -#define V86_ZR(x) ((x) & PSL_Z) #define DRV_DISK 0xf0 #define DRV_UNIT 0x0f diff --git a/sys/boot/pc98/btx/lib/btxv86.h b/sys/boot/pc98/btx/lib/btxv86.h index 1152f8b..27f6b34 100644 --- a/sys/boot/pc98/btx/lib/btxv86.h +++ b/sys/boot/pc98/btx/lib/btxv86.h @@ -21,6 +21,7 @@ #define _BTXV86_H_ #include <sys/types.h> +#include <machine/psl.h> #define V86_ADDR 0x10000 /* Segment:offset address */ #define V86_CALLF 0x20000 /* Emulate far call */ @@ -57,6 +58,9 @@ extern u_int32_t __args; #define VTOPSEG(va) (u_int16_t)(VTOP((caddr_t)va) >> 4) #define VTOPOFF(va) (u_int16_t)(VTOP((caddr_t)va) & 0xf) +#define V86_CY(x) ((x) & PSL_C) +#define V86_ZR(x) ((x) & PSL_Z) + void __exit(int) __attribute__((__noreturn__)); void __exec(caddr_t, ...); diff --git a/sys/boot/pc98/libpc98/bioscd.c b/sys/boot/pc98/libpc98/bioscd.c index 3e1ba71..e3df391 100644 --- a/sys/boot/pc98/libpc98/bioscd.c +++ b/sys/boot/pc98/libpc98/bioscd.c @@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <machine/bootinfo.h> -#include <machine/psl.h> #include <stdarg.h> @@ -325,7 +324,7 @@ bc_read(int unit, daddr_t dblk, int blks, caddr_t dest) v86.ebp = VTOPOFF(xp); v86.es = VTOPSEG(xp); v86int(); - result = (v86.efl & PSL_C); + result = V86_CY(v86.efl); if (result == 0) break; } diff --git a/sys/boot/pc98/libpc98/vidconsole.c b/sys/boot/pc98/libpc98/vidconsole.c index 19fb981..7cf81e8 100644 --- a/sys/boot/pc98/libpc98/vidconsole.c +++ b/sys/boot/pc98/libpc98/vidconsole.c @@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$"); #include <stand.h> #include <bootstrap.h> #include <btxv86.h> -#include <machine/psl.h> #include <machine/cpufunc.h> #include "libi386.h" diff --git a/sys/boot/pc98/loader/main.c b/sys/boot/pc98/loader/main.c index 391c5e9..15b132f 100644 --- a/sys/boot/pc98/loader/main.c +++ b/sys/boot/pc98/loader/main.c @@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$"); #include <stand.h> #include <string.h> #include <machine/bootinfo.h> -#include <machine/psl.h> #include <sys/param.h> #include <sys/reboot.h> |