diff options
author | jhb <jhb@FreeBSD.org> | 2008-08-08 19:41:20 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2008-08-08 19:41:20 +0000 |
commit | be7768ee547fe4a77c33f19daacc0809cb8a4cf3 (patch) | |
tree | ce6fb74fb05aadcb31e17f160c652179fa26a463 | |
parent | 5e78f5a5d442f5ce7d5362a4770610b13320bf7c (diff) | |
download | FreeBSD-src-be7768ee547fe4a77c33f19daacc0809cb8a4cf3.zip FreeBSD-src-be7768ee547fe4a77c33f19daacc0809cb8a4cf3.tar.gz |
- Initialize the vm86 structure to a known-good state. Specifically, always
set the %eflags used during a BIOS call via BTX to 0x202. Previously
the flags field was uninitialized garbage, and thus it was "random" if
interrupts were enabled or not during BIOS calls.
- Use constants from <machine/psl.h> for fields in %eflags.
MFC after: 3 days
-rw-r--r-- | sys/boot/i386/boot2/boot2.c | 6 | ||||
-rw-r--r-- | sys/boot/i386/gptboot/gptboot.c | 6 | ||||
-rw-r--r-- | sys/boot/i386/loader/main.c | 5 | ||||
-rw-r--r-- | sys/boot/pc98/loader/main.c | 5 |
4 files changed, 18 insertions, 4 deletions
diff --git a/sys/boot/i386/boot2/boot2.c b/sys/boot/i386/boot2/boot2.c index 753f0b1..58f2175 100644 --- a/sys/boot/i386/boot2/boot2.c +++ b/sys/boot/i386/boot2/boot2.c @@ -24,6 +24,7 @@ __FBSDID("$FreeBSD$"); #include <machine/bootinfo.h> #include <machine/elf.h> +#include <machine/psl.h> #include <stdarg.h> @@ -83,8 +84,8 @@ __FBSDID("$FreeBSD$"); #define NDEV 3 #define MEM_BASE 0x12 #define MEM_EXT 0x15 -#define V86_CY(x) ((x) & 1) -#define V86_ZR(x) ((x) & 0x40) +#define V86_CY(x) ((x) & PSL_C) +#define V86_ZR(x) ((x) & PSL_Z) #define DRV_HARD 0x80 #define DRV_MASK 0x7f @@ -237,6 +238,7 @@ main(void) dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base); v86.ctl = V86_FLAGS; + v86.efl = PSL_RESERVED_DEFAULT | PSL_I; dsk.drive = *(uint8_t *)PTOV(ARGS); dsk.type = dsk.drive & DRV_HARD ? TYPE_AD : TYPE_FD; dsk.unit = dsk.drive & DRV_MASK; diff --git a/sys/boot/i386/gptboot/gptboot.c b/sys/boot/i386/gptboot/gptboot.c index e9a183e..405b92e 100644 --- a/sys/boot/i386/gptboot/gptboot.c +++ b/sys/boot/i386/gptboot/gptboot.c @@ -23,6 +23,7 @@ __FBSDID("$FreeBSD$"); #include <machine/bootinfo.h> #include <machine/elf.h> +#include <machine/psl.h> #include <stdarg.h> @@ -81,8 +82,8 @@ __FBSDID("$FreeBSD$"); #define NDEV 3 #define MEM_BASE 0x12 #define MEM_EXT 0x15 -#define V86_CY(x) ((x) & 1) -#define V86_ZR(x) ((x) & 0x40) +#define V86_CY(x) ((x) & PSL_C) +#define V86_ZR(x) ((x) & PSL_Z) #define DRV_HARD 0x80 #define DRV_MASK 0x7f @@ -235,6 +236,7 @@ main(void) dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base); v86.ctl = V86_FLAGS; + v86.efl = PSL_RESERVED_DEFAULT | PSL_I; dsk.drive = *(uint8_t *)PTOV(ARGS); dsk.type = dsk.drive & DRV_HARD ? TYPE_AD : TYPE_FD; dsk.unit = dsk.drive & DRV_MASK; diff --git a/sys/boot/i386/loader/main.c b/sys/boot/i386/loader/main.c index 2083456..5b23670 100644 --- a/sys/boot/i386/loader/main.c +++ b/sys/boot/i386/loader/main.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <stand.h> #include <string.h> #include <machine/bootinfo.h> +#include <machine/psl.h> #include <sys/reboot.h> #include "bootstrap.h" @@ -86,6 +87,10 @@ main(void) initial_bootdev = kargs->bootdev; initial_bootinfo = kargs->bootinfo ? (struct bootinfo *)PTOV(kargs->bootinfo) : NULL; + /* Initialize the v86 register set to a known-good state. */ + bzero(&v86, sizeof(v86)); + v86.efl = PSL_RESERVED_DEFAULT | PSL_I; + /* * Initialise the heap as early as possible. Once this is done, malloc() is usable. */ diff --git a/sys/boot/pc98/loader/main.c b/sys/boot/pc98/loader/main.c index eee4638..83e9bdf 100644 --- a/sys/boot/pc98/loader/main.c +++ b/sys/boot/pc98/loader/main.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <stand.h> #include <string.h> #include <machine/bootinfo.h> +#include <machine/psl.h> #include <sys/reboot.h> #include "bootstrap.h" @@ -86,6 +87,10 @@ main(void) initial_bootdev = kargs->bootdev; initial_bootinfo = kargs->bootinfo ? (struct bootinfo *)PTOV(kargs->bootinfo) : NULL; + /* Initialize the v86 register set to a known-good state. */ + bzero(&v86, sizeof(v86)); + v86.efl = PSL_RESERVED_DEFAULT | PSL_I; + /* * Initialise the heap as early as possible. Once this is done, malloc() is usable. */ |