FreeBSD Bugzilla – Attachment 164376 Details for
Bug 205424
i386/boot: use macros from <machine/psl.h> to represent eflags's bits
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
i386/boot: use macros from <machine/psl.h> to represent eflags's bits
0001-i386-boot-use-macros-from-machine-psl.h-to-represent.patch (text/plain), 13.70 KB, created by
Alexander Kuleshov
on 2015-12-19 06:53:16 UTC
(
hide
)
Description:
i386/boot: use macros from <machine/psl.h> to represent eflags's bits
Filename:
MIME Type:
Creator:
Alexander Kuleshov
Created:
2015-12-19 06:53:16 UTC
Size:
13.70 KB
patch
obsolete
>From ff84743413a02b75e7d70e14654ed75c56738f1d Mon Sep 17 00:00:00 2001 >From: Alexander Kuleshov <kuleshovmail@gmail.com> >Date: Sat, 19 Dec 2015 12:37:54 +0600 >Subject: [PATCH] i386/boot: use macros from <machine/psl.h> to represent > eflags's bits > >Some i386/boot's source code contains some checks of the EFLAGS's bits. In >the same time the <machine/psl.h> header file provides macros which >represents these bits. Let's use human readable names instead of >numbers. > >Additionally indentation fixed and empty lines removed. >--- > sys/boot/i386/libi386/biosdisk.c | 10 ++--- > sys/boot/i386/zfsboot/zfsboot.c | 15 ++++---- > sys/boot/pc98/boot2/boot2.c | 3 +- > sys/boot/pc98/libpc98/biosdisk.c | 79 ++++++++++++++++++++-------------------- > 4 files changed, 55 insertions(+), 52 deletions(-) > >diff --git a/sys/boot/i386/libi386/biosdisk.c b/sys/boot/i386/libi386/biosdisk.c >index 2a71d64..66eb68d 100644 >--- a/sys/boot/i386/libi386/biosdisk.c >+++ b/sys/boot/i386/libi386/biosdisk.c >@@ -30,7 +30,7 @@ __FBSDID("$FreeBSD$"); > > /* > * BIOS disk device handling. >- * >+ * > * Ideas and algorithms from: > * > * - NetBSD libi386/biosdisk.c >@@ -486,7 +486,7 @@ bd_io(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest, int write) > { > u_int x, sec, result, resid, retry, maxfer; > caddr_t p, xp, bbuf, breg; >- >+ > /* Just in case some idiot actually tries to read/write -1 blocks... */ > if (blks < 0) > return (-1); >@@ -499,7 +499,7 @@ bd_io(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest, int write) > (VTOP(dest) >> 16) != (VTOP(dest + > blks * BD(dev).bd_sectorsize) >> 16))) { > >- /* >+ /* > * There is a 64k physical boundary somewhere in the > * destination buffer, or the destination buffer is above > * first 1MB of physical memory so we have to arrange a >@@ -520,7 +520,7 @@ bd_io(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest, int write) > breg = bbuf = NULL; > maxfer = 0; > } >- >+ > while (resid > 0) { > /* > * Play it safe and don't cross track boundaries. >@@ -536,7 +536,7 @@ bd_io(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest, int write) > > /* > * Put your Data In, Put your Data out, >- * Put your Data In, and shake it all about >+ * Put your Data In, and shake it all about > */ > if (write && bbuf != NULL) > bcopy(p, breg, x * BD(dev).bd_sectorsize); >diff --git a/sys/boot/i386/zfsboot/zfsboot.c b/sys/boot/i386/zfsboot/zfsboot.c >index afb77b2..2bbe623 100644 >--- a/sys/boot/i386/zfsboot/zfsboot.c >+++ b/sys/boot/i386/zfsboot/zfsboot.c >@@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); > #include <machine/bootinfo.h> > #include <machine/elf.h> > #include <machine/pc/bios.h> >+#include <machine/psl.h> > > #include <stdarg.h> > #include <stddef.h> >@@ -163,7 +164,7 @@ zfs_read(spa_t *spa, const dnode_phys_t *dnode, off_t *offp, void *start, size_t > n = size; > if (*offp + n > zp->zp_size) > n = zp->zp_size - *offp; >- >+ > rc = dnode_read(spa, dnode, *offp, start, n); > if (rc) > return (-1); >@@ -238,7 +239,7 @@ bios_getmem(void) > v86.es = VTOPSEG(&smap); > v86.edi = VTOPOFF(&smap); > v86int(); >- if ((v86.efl & 1) || (v86.eax != SMAP_SIG)) >+ if ((v86.efl & PCL_C) || (v86.eax != SMAP_SIG)) > break; > /* look for a low-memory segment that's large enough */ > if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base == 0) && >@@ -275,7 +276,7 @@ bios_getmem(void) > v86.ctl = 0; > v86.addr = 0x12; /* int 0x12 */ > v86int(); >- >+ > bios_basemem = (v86.eax & 0xffff) * 1024; > } > >@@ -285,7 +286,7 @@ bios_getmem(void) > v86.addr = 0x15; /* int 0x15 function 0xe801*/ > v86.eax = 0xe801; > v86int(); >- if (!(v86.efl & 1)) { >+ if (!(v86.efl & PSL_C)) { > bios_extmem = ((v86.ecx & 0xffff) + ((v86.edx & 0xffff) * 64)) * 1024; > } > } >@@ -306,7 +307,7 @@ bios_getmem(void) > high_heap_size = HEAP_MIN; > high_heap_base = bios_extmem + 0x100000 - HEAP_MIN; > } >-} >+} > > /* > * Try to detect a device supported by the legacy int13 BIOS >@@ -319,8 +320,8 @@ int13probe(int drive) > v86.eax = 0x800; > v86.edx = drive; > v86int(); >- >- if (!(v86.efl & 0x1) && /* carry clear */ >+ >+ if (!(v86.efl & PSL_C) && /* carry clear */ > ((v86.edx & 0xff) != (drive & DRV_MASK))) { /* unit # OK */ > if ((v86.ecx & 0x3f) == 0) { /* absurd sector size */ > return(0); /* skip device */ >diff --git a/sys/boot/pc98/boot2/boot2.c b/sys/boot/pc98/boot2/boot2.c >index 83af085..c351ef9 100644 >--- a/sys/boot/pc98/boot2/boot2.c >+++ b/sys/boot/pc98/boot2/boot2.c >@@ -26,6 +26,7 @@ __FBSDID("$FreeBSD$"); > #include <machine/bootinfo.h> > #include <machine/cpufunc.h> > #include <machine/elf.h> >+#include <machine/psl.h> > > #include <stdarg.h> > >@@ -327,7 +328,7 @@ bd_getbigeom(int bunit) > v86.addr = 0x1b; > v86.eax = 0x8400 | unit; > v86int(); >- if (v86.efl & 0x1) >+ if (v86.efl & PSL_C) > return 0x4F020F; /* 1200KB FD C:80 H:2 S:15 */ > return ((v86.ecx & 0xffff) << 16) | (v86.edx & 0xffff); > } >diff --git a/sys/boot/pc98/libpc98/biosdisk.c b/sys/boot/pc98/libpc98/biosdisk.c >index 96dbd1f..0349ef9 100644 >--- a/sys/boot/pc98/libpc98/biosdisk.c >+++ b/sys/boot/pc98/libpc98/biosdisk.c >@@ -29,7 +29,7 @@ __FBSDID("$FreeBSD$"); > > /* > * BIOS disk device handling. >- * >+ * > * Ideas and algorithms from: > * > * - NetBSD libi386/biosdisk.c >@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); > #include <sys/disklabel.h> > #include <sys/diskpc98.h> > #include <machine/bootinfo.h> >+#include <machine/psl.h> > > #include <stdarg.h> > >@@ -122,12 +123,12 @@ static int bd_close(struct open_file *f); > static void bd_print(int verbose); > > struct devsw biosdisk = { >- "disk", >- DEVT_DISK, >+ "disk", >+ DEVT_DISK, > bd_init, >- bd_strategy, >- bd_open, >- bd_close, >+ bd_strategy, >+ bd_open, >+ bd_close, > noioctl, > bd_print, > NULL >@@ -146,7 +147,7 @@ int > bd_bios2unit(int biosdev) > { > int i; >- >+ > DEBUG("looking for bios device 0x%x", biosdev); > for (i = 0; i < nbdinfo; i++) { > DEBUG("bd unit %d is BIOS device 0x%x", i, bdinfo[i].bd_unit); >@@ -164,11 +165,11 @@ bd_unit2bios(int unit) > return(-1); > } > >-/* >+/* > * Quiz the BIOS for disk devices, save a little info about them. > */ > static int >-bd_init(void) >+bd_init(void) > { > int base, unit; > int da_drive=0, n=-0x10; >@@ -200,7 +201,7 @@ bd_init(void) > bdinfo[nbdinfo].bd_da_unit = da_drive++; > } > /* XXX we need "disk aliases" to make this simpler */ >- printf("BIOS drive %c: is disk%d\n", >+ printf("BIOS drive %c: is disk%d\n", > 'A' + nbdinfo, nbdinfo); > nbdinfo++; > } >@@ -250,7 +251,7 @@ bd_print(int verbose) > struct i386_devdesc dev; > struct open_disk *od; > struct pc98_partition *dptr; >- >+ > for (i = 0; i < nbdinfo; i++) { > sprintf(line, " disk%d: BIOS drive %c:\n", i, 'A' + i); > pager_output(line); >@@ -259,7 +260,7 @@ bd_print(int verbose) > dev.d_unit = i; > dev.d_kind.biosdisk.slice = -1; > dev.d_kind.biosdisk.partition = -1; >- >+ > if (!bd_opendisk(&od, &dev)) { > > /* Do we have a partition table? */ >@@ -368,7 +369,7 @@ bd_printbsdslice(struct open_disk *od, daddr_t offset, char *prefix, > pager_output(line); > return; > } >- >+ > /* Print partitions */ > for (i = 0; i < lp->d_npartitions; i++) { > /* >@@ -380,13 +381,13 @@ bd_printbsdslice(struct open_disk *od, daddr_t offset, char *prefix, > if ((lp->d_partitions[i].p_fstype == FS_BSDFFS) || > (lp->d_partitions[i].p_fstype == FS_SWAP) || > (lp->d_partitions[i].p_fstype == FS_VINUM) || >- ((lp->d_partitions[i].p_fstype == FS_UNUSED) && >+ ((lp->d_partitions[i].p_fstype == FS_UNUSED) && > (od->od_flags & BD_FLOPPY) && (i == 0))) { > > /* Only print out statistics in verbose mode */ > if (verbose) > sprintf(line, " %s%c: %s %s (%d - %d)\n", prefix, 'a' + i, >- (lp->d_partitions[i].p_fstype == FS_SWAP) ? "swap " : >+ (lp->d_partitions[i].p_fstype == FS_SWAP) ? "swap " : > (lp->d_partitions[i].p_fstype == FS_VINUM) ? "vinum" : > "FFS ", > display_size(lp->d_partitions[i].p_size), >@@ -394,7 +395,7 @@ bd_printbsdslice(struct open_disk *od, daddr_t offset, char *prefix, > lp->d_partitions[i].p_offset + lp->d_partitions[i].p_size); > else > sprintf(line, " %s%c: %s\n", prefix, 'a' + i, >- (lp->d_partitions[i].p_fstype == FS_SWAP) ? "swap" : >+ (lp->d_partitions[i].p_fstype == FS_SWAP) ? "swap" : > (lp->d_partitions[i].p_fstype == FS_VINUM) ? "vinum" : > "FFS"); > pager_output(line); >@@ -413,7 +414,7 @@ bd_printbsdslice(struct open_disk *od, daddr_t offset, char *prefix, > * sliced - are they after the first BSD slice, or the DOS > * slice before it?) > */ >-static int >+static int > bd_open(struct open_file *f, ...) > { > va_list ap; >@@ -426,7 +427,7 @@ bd_open(struct open_file *f, ...) > va_end(ap); > if ((error = bd_opendisk(&od, dev))) > return(error); >- >+ > /* > * Save our context > */ >@@ -445,7 +446,7 @@ bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev) > DEBUG("attempt to open nonexistent disk"); > return(ENXIO); > } >- >+ > od = (struct open_disk *)malloc(sizeof(struct open_disk)); > if (!od) { > DEBUG("no memory"); >@@ -459,7 +460,7 @@ bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev) > od->od_boff = 0; > error = 0; > DEBUG("open '%s', unit 0x%x slice %d partition %d", >- i386_fmtdev(dev), dev->d_unit, >+ i386_fmtdev(dev), dev->d_unit, > dev->d_kind.biosdisk.slice, dev->d_kind.biosdisk.partition); > > /* Get geometry for this open (removable device may have changed) */ >@@ -471,7 +472,7 @@ bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev) > > /* Determine disk layout. */ > error = bd_open_pc98(od, dev); >- >+ > out: > if (error) { > free(od); >@@ -508,7 +509,7 @@ bd_open_pc98(struct open_disk *od, struct i386_devdesc *dev) > return (EIO); > } > >- /* >+ /* > * Check the slice table magic. > */ > if (((u_char)buf[0x1fe] != 0x55) || ((u_char)buf[0x1ff] != 0xaa)) { >@@ -582,7 +583,7 @@ bd_open_pc98(struct open_disk *od, struct i386_devdesc *dev) > dev->d_kind.biosdisk.partition = 0; > > unsliced: >- /* >+ /* > * Now we have the slice offset, look for the partition in the disklabel if we have > * a partition to start with. > * >@@ -592,7 +593,7 @@ bd_open_pc98(struct open_disk *od, struct i386_devdesc *dev) > od->od_boff = sector; /* no partition, must be after the slice */ > DEBUG("opening raw slice"); > } else { >- >+ > if (bd_read(od, sector + LABELSECTOR, 1, buf)) { > DEBUG("error reading disklabel"); > return (EIO); >@@ -618,8 +619,8 @@ bd_open_pc98(struct open_disk *od, struct i386_devdesc *dev) > !(od->od_flags & BD_FLOPPY)) > DEBUG("warning, partition marked as unused"); > #endif >- >- od->od_boff = >+ >+ od->od_boff = > lp->d_partitions[dev->d_kind.biosdisk.partition].p_offset - > lp->d_partitions[RAW_PART].p_offset + > sector; >@@ -655,7 +656,7 @@ bd_bestslice(struct open_disk *od) > struct pc98_partition *dp; > int pref, preflevel; > int i, prefslice; >- >+ > prefslice = 0; > preflevel = PREF_NONE; > >@@ -692,8 +693,8 @@ bd_bestslice(struct open_disk *od) > } > return (prefslice); > } >- >-static int >+ >+static int > bd_close(struct open_file *f) > { > struct open_disk *od = (struct open_disk *)(((struct i386_devdesc *)(f->f_devdata))->d_kind.biosdisk.data); >@@ -714,7 +715,7 @@ bd_closedisk(struct open_disk *od) > free(od); > } > >-static int >+static int > bd_strategy(void *devdata, int rw, daddr_t dblk, size_t size, char *buf, size_t *rsize) > { > struct bcache_devdata bcd; >@@ -725,7 +726,7 @@ bd_strategy(void *devdata, int rw, daddr_t dblk, size_t size, char *buf, size_t > return(bcache_strategy(&bcd, od->od_unit, rw, dblk+od->od_boff, size, buf, rsize)); > } > >-static int >+static int > bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size, char *buf, size_t *rsize) > { > struct open_disk *od = (struct open_disk *)(((struct i386_devdesc *)devdata)->d_kind.biosdisk.data); >@@ -824,7 +825,7 @@ bd_chs_io(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest, int write) > v86.es = VTOPSEG(dest); > v86.ebp = VTOPOFF(dest); > v86int(); >- return (v86.efl & 0x1); >+ return (v86.efl & PSL_C); > } > > static int >@@ -832,7 +833,7 @@ bd_io(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest, int write) > { > u_int x, sec, result, resid, retry, maxfer; > caddr_t p, xp, bbuf, breg; >- >+ > /* Just in case some idiot actually tries to read/write -1 blocks... */ > if (blks < 0) > return (-1); >@@ -844,7 +845,7 @@ bd_io(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest, int write) > if (VTOP(dest) >> 20 != 0 || > ((VTOP(dest) >> 16) != (VTOP(dest + blks * BIOSDISK_SECSIZE) >> 16))) { > >- /* >+ /* > * There is a 64k physical boundary somewhere in the > * destination buffer, or the destination buffer is above > * first 1MB of physical memory so we have to arrange a >@@ -865,7 +866,7 @@ bd_io(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest, int write) > breg = bbuf = NULL; > maxfer = 0; > } >- >+ > while (resid > 0) { > /* > * Play it safe and don't cross track boundaries. >@@ -881,7 +882,7 @@ bd_io(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest, int write) > > /* > * Put your Data In, Put your Data out, >- * Put your Data In, and shake it all about >+ * Put your Data In, and shake it all about > */ > if (write && bbuf != NULL) > bcopy(p, breg, x * BIOSDISK_SECSIZE); >@@ -955,11 +956,11 @@ bd_getgeom(struct open_disk *od) > v86.addr = 0x1b; > v86.eax = 0x8400 | od->od_unit; > v86int(); >- >+ > od->od_cyl = v86.ecx; > od->od_hds = (v86.edx >> 8) & 0xff; > od->od_sec = v86.edx & 0xff; >- if (v86.efl & 0x1) >+ if (v86.efl & PSL_C) > return(1); > } > >@@ -1010,7 +1011,7 @@ bd_getbigeom(int bunit) > v86.addr = 0x1b; > v86.eax = 0x8400 | unit; > v86int(); >- if (v86.efl & 0x1) >+ if (v86.efl & PSL_C) > return 0x4F020F; /* 1200KB FD C:80 H:2 S:15 */ > return ((v86.ecx & 0xffff) << 16) | (v86.edx & 0xffff); > } >-- >2.5.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 205424
: 164376