diff options
author | Tom Cosgrove <tom@cvs.openbsd.org> | 2004-03-09 19:12:14 +0000 |
---|---|---|
committer | Tom Cosgrove <tom@cvs.openbsd.org> | 2004-03-09 19:12:14 +0000 |
commit | 1eec929b8151bf84e60efda0cc18cfab302cbb2e (patch) | |
tree | 18dd28ac39b0e4b5199d6fd5cf90e70e5ef5dcf7 /sys/arch/i386 | |
parent | 8742fa1b73f46d9fc2298a45289d510c3956ac86 (diff) |
Spacing and KNF. Partly from Joris Vink <nimadeus at pandora dot be>.
ok henning@, deraadt@
Diffstat (limited to 'sys/arch/i386')
-rw-r--r-- | sys/arch/i386/stand/libsa/apmprobe.c | 99 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/bioscons.c | 8 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/biosdev.c | 155 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/biosprobe.c | 38 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/cmd_i386.c | 40 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/debug.c | 13 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/debug_i386.S | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/debug_md.h | 3 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/dev_i386.c | 25 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/disk.h | 3 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/diskprobe.c | 53 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/exec_i386.c | 10 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/memprobe.c | 113 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/pciprobe.c | 5 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/smpprobe.c | 37 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/time.c | 39 |
16 files changed, 332 insertions, 313 deletions
diff --git a/sys/arch/i386/stand/libsa/apmprobe.c b/sys/arch/i386/stand/libsa/apmprobe.c index 4278f2baadb..5069d081d5d 100644 --- a/sys/arch/i386/stand/libsa/apmprobe.c +++ b/sys/arch/i386/stand/libsa/apmprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apmprobe.c,v 1.11 2003/08/11 06:23:09 deraadt Exp $ */ +/* $OpenBSD: apmprobe.c,v 1.12 2004/03/09 19:12:12 tom Exp $ */ /* * Copyright (c) 1997-2000 Michael Shalayeff @@ -35,7 +35,7 @@ * If you want to know the specification of APM BIOS, see the following * documentations, * - * [1] Intel Corporation and Microsoft Corporation, "Advanced Power + * [1] Intel Corporation and Microsoft Corporation, "Advanced Power * Management, The Next Generation, Version 1.0", Feb.,1992. * * [2] Intel Corporation and Microsoft Corporation, "Advanced Power @@ -46,7 +46,7 @@ * or contact * * APM Support Desk (Intel Corporation, US) - * TEL: (800)628-8686 + * TEL: (800)628-8686 * FAX: (916)356-6100. */ @@ -68,14 +68,16 @@ apm_check(void) { register u_int detail; register u_int8_t f; + __asm __volatile(DOINT(0x15) "\n\t" - "setc %b1\n\t" - "movzwl %%ax, %0\n\t" - "shll $16, %%ecx\n\t" - "orl %%ecx, %0" - : "=a" (detail), "=b" (f) - : "0" (APM_INSTCHECK), "1" (APM_DEV_APM_BIOS) - : "%ecx", "cc"); + "setc %b1\n\t" + "movzwl %%ax, %0\n\t" + "shll $16, %%ecx\n\t" + "orl %%ecx, %0" + : "=a" (detail), "=b" (f) + : "0" (APM_INSTCHECK), "1" (APM_DEV_APM_BIOS) + : "%ecx", "cc"); + if (f || BIOS_regs.biosr_bx != 0x504d /* "PM" */ ) { #ifdef DEBUG if (debug) @@ -91,32 +93,36 @@ static __inline int apm_disconnect(void) { register u_int16_t rv; + __asm __volatile(DOINT(0x15) "\n\t" - "setc %b0" - : "=a" (rv) - : "0" (APM_DISCONNECT), "b" (APM_DEV_APM_BIOS) - : "%ecx", "%edx", "cc"); - return (rv & 0xff)? rv >> 8 : 0; + "setc %b0" + : "=a" (rv) + : "0" (APM_DISCONNECT), "b" (APM_DEV_APM_BIOS) + : "%ecx", "%edx", "cc"); + + return ((rv & 0xff)? rv >> 8 : 0); } static __inline int apm_connect(bios_apminfo_t *ai) { register u_int16_t f; + __asm __volatile (DOINT(0x15) "\n\t" - "setc %b1\n\t" - "movb %%ah, %h1\n\t" - "movzwl %%ax, %%eax\n\tshll $4, %0\n\t" - "movzwl %%cx, %%ecx\n\tshll $4, %2\n\t" - "movzwl %%dx, %%edx\n\tshll $4, %3\n\t" - : "=a" (ai->apm_code32_base), - "=b" (f), - "=c" (ai->apm_code16_base), - "=d" (ai->apm_data_base) - : "0" (APM_PROT32_CONNECT), "1" (APM_DEV_APM_BIOS) - : "cc"); + "setc %b1\n\t" + "movb %%ah, %h1\n\t" + "movzwl %%ax, %%eax\n\tshll $4, %0\n\t" + "movzwl %%cx, %%ecx\n\tshll $4, %2\n\t" + "movzwl %%dx, %%edx\n\tshll $4, %3\n\t" + : "=a" (ai->apm_code32_base), + "=b" (f), + "=c" (ai->apm_code16_base), + "=d" (ai->apm_data_base) + : "0" (APM_PROT32_CONNECT), "1" (APM_DEV_APM_BIOS) + : "cc"); + if (f & 0xff) - return f >> 8; + return (f >> 8); ai->apm_entry = BIOS_regs.biosr_bx; #if 0 @@ -129,25 +135,24 @@ apm_connect(bios_apminfo_t *ai) ai->apm_data_len = 0xffff - (ai->apm_data_base & 0xffff); #endif if (ai->apm_data_base < BOOTARG_OFF) - ai->apm_data_len = - NBPG - (ai->apm_data_base & PGOFSET) - 1; + ai->apm_data_len = NBPG - (ai->apm_data_base & PGOFSET) - 1; #ifdef DEBUG if (debug) - printf ("cs=%x:%x/%x:%x, ds=%x:%x\n", - ai->apm_code32_base, ai->apm_code_len, - ai->apm_code16_base, ai->apm_code16_len, - ai->apm_data_base, ai->apm_data_len); + printf("cs=%x:%x/%x:%x, ds=%x:%x\n", + ai->apm_code32_base, ai->apm_code_len, + ai->apm_code16_base, ai->apm_code16_len, + ai->apm_data_base, ai->apm_data_len); #endif /* inform apm bios about our driver version */ __asm __volatile (DOINT(0x15) "\n\t" - "setc %b1\n\t" - "movb %%ah, %h1" - : "=b" (f) - : "a" (APM_DRIVER_VERSION), - "0" (APM_DEV_APM_BIOS), - "c" (APM_VERSION) - : "cc"); + "setc %b1\n\t" + "movb %%ah, %h1" + : "=b" (f) + : "a" (APM_DRIVER_VERSION), + "0" (APM_DEV_APM_BIOS), + "c" (APM_VERSION) + : "cc"); return 0; } @@ -160,16 +165,17 @@ apmprobe(void) if ((ai.apm_detail = apm_check())) { apm_disconnect(); + if (apm_connect(&ai) != 0) printf(": connect error\n"); #ifdef DEBUG if (debug) printf("apm[%x cs=%x[%x]/%x[%x] ds=%x[%x] @ %x]", - ai.apm_detail, - ai.apm_code32_base, ai.apm_code_len, - ai.apm_code16_base, ai.apm_code16_len, - ai.apm_data_base, ai.apm_data_len, - ai.apm_entry); + ai.apm_detail, + ai.apm_code32_base, ai.apm_code_len, + ai.apm_code16_base, ai.apm_code16_len, + ai.apm_data_base, ai.apm_data_len, + ai.apm_entry); else printf(" apm"); #else @@ -187,6 +193,5 @@ apmfixmem(void) #endif if (ai.apm_detail) mem_delete(i386_trunc_page(ai.apm_data_base), - i386_round_page(ai.apm_data_base + ai.apm_data_len)); + i386_round_page(ai.apm_data_base + ai.apm_data_len)); } - diff --git a/sys/arch/i386/stand/libsa/bioscons.c b/sys/arch/i386/stand/libsa/bioscons.c index 825de88ea5d..ba423c41e6a 100644 --- a/sys/arch/i386/stand/libsa/bioscons.c +++ b/sys/arch/i386/stand/libsa/bioscons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bioscons.c,v 1.26 2003/12/16 03:10:18 deraadt Exp $ */ +/* $OpenBSD: bioscons.c,v 1.27 2004/03/09 19:12:12 tom Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -82,6 +82,7 @@ pc_getc(dev_t dev) __asm __volatile(DOINT(0x16) : "=a" (rv) : "0" (0x000) : "%ecx", "%edx", "cc" ); + return (rv & 0xff); } @@ -147,7 +148,7 @@ int comspeed(dev_t dev, int sp) { int i, newsp; - int err; + int err; if (sp <= 0) return com_speed; @@ -204,11 +205,10 @@ com_putc(dev_t dev, int c) /* check online (DSR) */ __asm __volatile(DOINT(0x14) : "=a" (rv) : "0" (0x300), "d" (dev) : "%ecx", "cc" ); - if ( !(rv & 0x20) ) + if ( (rv & 0x20) == 0) return; /* send character */ __asm __volatile(DOINT(0x14) : "=a" (rv) : "0" (c | 0x100), "d" (dev) : "%ecx", "cc" ); } - diff --git a/sys/arch/i386/stand/libsa/biosdev.c b/sys/arch/i386/stand/libsa/biosdev.c index 68bb2f40339..4ad9aaa1f15 100644 --- a/sys/arch/i386/stand/libsa/biosdev.c +++ b/sys/arch/i386/stand/libsa/biosdev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: biosdev.c,v 1.67 2003/11/27 00:33:24 espie Exp $ */ +/* $OpenBSD: biosdev.c,v 1.68 2004/03/09 19:12:12 tom Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -14,8 +14,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL @@ -57,13 +57,13 @@ struct biosdisk { #endif struct EDD_CB { - u_int8_t edd_len; /* size of packet */ - u_int8_t edd_res1; /* reserved */ - u_int8_t edd_nblk; /* # of blocks to transfer */ - u_int8_t edd_res2; /* reserved */ - u_int16_t edd_off; /* address of buffer (offset) */ - u_int16_t edd_seg; /* address of buffer (segment) */ - u_int64_t edd_daddr; /* starting block */ + u_int8_t edd_len; /* size of packet */ + u_int8_t edd_res1; /* reserved */ + u_int8_t edd_nblk; /* # of blocks to transfer */ + u_int8_t edd_res2; /* reserved */ + u_int16_t edd_off; /* address of buffer (offset) */ + u_int16_t edd_seg; /* address of buffer (segment) */ + u_int64_t edd_daddr; /* starting block */ }; /* @@ -73,9 +73,11 @@ static int biosdreset(int dev) { int rv; + __asm __volatile (DOINT(0x13) "; setc %b0" : "=a" (rv) - : "0" (0), "d" (dev) : "%ecx", "cc"); - return (rv & 0xff)? rv >> 8 : 0; + : "0" (0), "d" (dev) : "%ecx", "cc"); + + return ((rv & 0xff)? rv >> 8 : 0); } /* @@ -96,23 +98,23 @@ bios_getdiskinfo(int dev, bios_diskinfo_t *pdi) printf("getinfo: try #8, 0x%x, %p\n", dev, pdi); #endif __asm __volatile (DOINT(0x13) "\n\t" - "setc %b0; movzbl %h1, %1\n\t" - "movzbl %%cl, %3; andb $0x3f, %b3\n\t" - "xchgb %%cl, %%ch; rolb $2, %%ch" - : "=a" (rv), "=d" (pdi->bios_heads), - "=c" (pdi->bios_cylinders), - "=b" (pdi->bios_sectors) - : "0" (0x0800), "1" (dev) : "cc"); + "setc %b0; movzbl %h1, %1\n\t" + "movzbl %%cl, %3; andb $0x3f, %b3\n\t" + "xchgb %%cl, %%ch; rolb $2, %%ch" + : "=a" (rv), "=d" (pdi->bios_heads), + "=c" (pdi->bios_cylinders), + "=b" (pdi->bios_sectors) + : "0" (0x0800), "1" (dev) : "cc"); #ifdef BIOS_DEBUG if (debug) { printf("getinfo: got #8\n"); printf("disk 0x%x: %d,%d,%d\n", dev, pdi->bios_cylinders, - pdi->bios_heads, pdi->bios_sectors); + pdi->bios_heads, pdi->bios_sectors); } #endif if (rv & 0xff) - return (1); + return 1; /* Fix up info */ pdi->bios_number = dev; @@ -122,11 +124,11 @@ bios_getdiskinfo(int dev, bios_diskinfo_t *pdi) /* Sanity check */ if (!pdi->bios_cylinders || !pdi->bios_heads || !pdi->bios_sectors) - return(1); + return 1; /* CD-ROMs sometimes return heads == 1 */ if (pdi->bios_heads < 2) - return(1); + return 1; /* NOTE: * This currently hangs/reboots some machines @@ -169,7 +171,7 @@ bios_getdiskinfo(int dev, bios_diskinfo_t *pdi) } else pdi->bios_edd = -1; - return(0); + return 0; } /* @@ -183,22 +185,22 @@ CHS_rw(int rw, int dev, int cyl, int head, int sect, int nsect, void *buf) rw = rw == F_READ ? 2 : 3; BIOS_regs.biosr_es = (u_int32_t)buf >> 4; __asm __volatile ("movb %b7, %h1\n\t" - "movb %b6, %%dh\n\t" - "andl $0xf, %4\n\t" - /* cylinder; the highest 2 bits of cyl is in %cl */ - "xchgb %%ch, %%cl\n\t" - "rorb $2, %%cl\n\t" - "orb %b5, %%cl\n\t" - "inc %%cx\n\t" - DOINT(0x13) "\n\t" - "setc %b0" - : "=a" (rv) - : "0" (nsect), "d" (dev), "c" (cyl), - "b" (buf), "m" (sect), "m" (head), - "m" (rw) - : "cc", "memory"); - - return (rv & 0xff)? rv >> 8 : 0; + "movb %b6, %%dh\n\t" + "andl $0xf, %4\n\t" + /* cylinder; the highest 2 bits of cyl is in %cl */ + "xchgb %%ch, %%cl\n\t" + "rorb $2, %%cl\n\t" + "orb %b5, %%cl\n\t" + "inc %%cx\n\t" + DOINT(0x13) "\n\t" + "setc %b0" + : "=a" (rv) + : "0" (nsect), "d" (dev), "c" (cyl), + "b" (buf), "m" (sect), "m" (head), + "m" (rw) + : "cc", "memory"); + + return ((rv & 0xff)? rv >> 8 : 0); } static __inline int @@ -220,14 +222,14 @@ EDD_rw(int rw, int dev, u_int64_t daddr, u_int32_t nblk, void *buf) /* if offset/segment are zero, punt */ if (!cb.edd_seg && !cb.edd_off) - return (1); + return 1; /* Call extended read/write (with disk packet) */ BIOS_regs.biosr_ds = (u_int32_t)&cb >> 4; __asm __volatile (DOINT(0x13) "; setc %b0" : "=a" (rv) - : "0" ((rw == F_READ)? 0x4200: 0x4300), - "d" (dev), "S" ((int) (&cb) & 0xf) : "%ecx", "cc"); - return (rv & 0xff)? rv >> 8 : 0; + : "0" ((rw == F_READ)? 0x4200: 0x4300), + "d" (dev), "S" ((int) (&cb) & 0xf) : "%ecx", "cc"); + return ((rv & 0xff)? rv >> 8 : 0); } /* @@ -249,12 +251,12 @@ biosd_io(int rw, bios_diskinfo_t *bd, daddr_t off, int nsect, void *buf) */ bb = alloca(nsect * DEV_BSIZE); if (rw != F_READ) - bcopy (buf, bb, nsect * DEV_BSIZE); + bcopy(buf, bb, nsect * DEV_BSIZE); } else bb = buf; /* Try to do operation up to 5 times */ - for (error = 1, j = 5; j-- && error;) { + for (error = 1, j = 5; j-- && error; ) { /* CHS or LBA access? */ if (bd->bios_edd != -1) { error = EDD_rw(rw, dev, off, nsect, bb); @@ -265,9 +267,11 @@ biosd_io(int rw, bios_diskinfo_t *bd, daddr_t off, int nsect, void *buf) /* Handle track boundaries */ for (error = i = 0; error == 0 && i < nsect; - i += n, off += n, p += n * DEV_BSIZE) { + i += n, off += n, p += n * DEV_BSIZE) { + + btochs(off, cyl, head, sect, bd->bios_heads, + bd->bios_sectors); - btochs(off, cyl, head, sect, bd->bios_heads, bd->bios_sectors); if ((sect + (nsect - i)) >= bd->bios_sectors) n = bd->bios_sectors - sect; else @@ -290,7 +294,7 @@ biosd_io(int rw, bios_diskinfo_t *bd, daddr_t off, int nsect, void *buf) #ifdef BIOS_DEBUG if (debug) printf("\nBIOS error 0x%x (%s)\n", - error, biosdisk_err(error)); + error, biosdisk_err(error)); #endif biosdreset(dev); break; @@ -298,7 +302,7 @@ biosd_io(int rw, bios_diskinfo_t *bd, daddr_t off, int nsect, void *buf) } if (bb != buf && rw == F_READ) - bcopy (bb, buf, nsect * DEV_BSIZE); + bcopy(bb, buf, nsect * DEV_BSIZE); #ifdef BIOS_DEBUG if (debug) { @@ -308,7 +312,7 @@ biosd_io(int rw, bios_diskinfo_t *bd, daddr_t off, int nsect, void *buf) } #endif - return (error); + return error; } /* @@ -323,19 +327,19 @@ bios_getdisklabel(bios_diskinfo_t *bd, struct disklabel *label) int error, i; /* Sanity check */ - if(bd->bios_heads == 0 || bd->bios_sectors == 0) - return("failed to read disklabel"); + if (bd->bios_heads == 0 || bd->bios_sectors == 0) + return "failed to read disklabel"; /* MBR is a harddisk thing */ if (bd->bios_number & 0x80) { /* Read MBR */ error = biosd_io(F_READ, bd, DOSBBSECTOR, 1, &mbr); if (error) - return(biosdisk_err(error)); + return (biosdisk_err(error)); /* check mbr signature */ if (mbr.dmbr_sign != DOSMBR_SIGNATURE) - return("bad MBR signature\n"); + return "bad MBR signature\n"; /* Search for OpenBSD partition */ for (off = 0, i = 0; off == 0 && i < NDOSPART; i++) @@ -346,10 +350,11 @@ bios_getdisklabel(bios_diskinfo_t *bd, struct disklabel *label) if (off == 0) for (off = 0, i = 0; off == 0 && i < NDOSPART; i++) if (mbr.dmbr_parts[i].dp_typ == DOSPTYP_NETBSD) - off = mbr.dmbr_parts[i].dp_start + LABELSECTOR; + off = mbr.dmbr_parts[i].dp_start + + LABELSECTOR; if (off == 0) - return("no BSD partition\n"); + return "no BSD partition\n"; } else off = LABELSECTOR; @@ -362,8 +367,8 @@ bios_getdisklabel(bios_diskinfo_t *bd, struct disklabel *label) /* read disklabel */ error = biosd_io(F_READ, bd, off, 1, buf); - if(error) - return("failed to read disklabel"); + if (error) + return "failed to read disklabel"; /* Fill in disklabel */ return (getdisklabel(buf, label)); @@ -374,7 +379,7 @@ biosopen(struct open_file *f, ...) { va_list ap; register char *cp, **file; - dev_t maj, unit, part; + dev_t maj, unit, part; struct diskinfo *dip; int biosdev; @@ -397,8 +402,8 @@ biosopen(struct open_file *f, ...) cp++; } - for (maj = 0; maj < nbdevs && - strncmp(*file, bdevs[maj], cp - *file); maj++); + for (maj = 0; maj < nbdevs && strncmp(*file, bdevs[maj], cp - *file); ) + maj++; if (maj >= nbdevs) { printf("Unknown device: "); for (cp = *file; *cp != ':'; cp++) @@ -421,7 +426,7 @@ biosopen(struct open_file *f, ...) printf("Bad partition id\n"); return EPART; } - + cp++; /* skip ':' */ if (*cp != 0) *file = cp; @@ -448,9 +453,9 @@ biosopen(struct open_file *f, ...) { dev_t bsd_dev; bsd_dev = dip->bios_info.bsd_dev; dip->bsddev = MAKEBOOTDEV(B_TYPE(bsd_dev), B_ADAPTOR(bsd_dev), - B_CONTROLLER(bsd_dev), unit, part); + B_CONTROLLER(bsd_dev), unit, part); dip->bootdev = MAKEBOOTDEV(B_TYPE(bsd_dev), B_ADAPTOR(bsd_dev), - B_CONTROLLER(bsd_dev), B_UNIT(bsd_dev), part); + B_CONTROLLER(bsd_dev), B_UNIT(bsd_dev), part); } #if 0 @@ -461,13 +466,13 @@ biosopen(struct open_file *f, ...) #ifdef BIOS_DEBUG if (debug) { printf("BIOS geometry: heads=%u, s/t=%u; EDD=%d\n", - dip->bios_info.bios_heads, dip->bios_info.bios_sectors, - dip->bios_info.bios_edd); + dip->bios_info.bios_heads, dip->bios_info.bios_sectors, + dip->bios_info.bios_edd); } #endif /* Try for disklabel again (might be removable media) */ - if(dip->bios_info.flags & BDI_BADLABEL){ + if (dip->bios_info.flags & BDI_BADLABEL){ const char *st = bios_getdisklabel(&dip->bios_info, &dip->disklabel); #ifdef BIOS_DEBUG @@ -478,7 +483,7 @@ biosopen(struct open_file *f, ...) dip->bios_info.flags &= ~BDI_BADLABEL; dip->bios_info.flags |= BDI_GOODLABEL; } else - return (ERDLAB); + return ERDLAB; } f->f_devdata = dip; @@ -486,7 +491,7 @@ biosopen(struct open_file *f, ...) return 0; } -const u_char bidos_errs[] = +const u_char bidos_errs[] = /* ignored "\x00" "successful completion\0" */ "\x01" "invalid function/parameter\0" "\x02" "address mark not found\0" @@ -528,7 +533,7 @@ biosdisk_err(u_int error) register const u_char *p = bidos_errs; while (*p && *p != error) - while(*p++); + while (*p++); return ++p; } @@ -546,7 +551,7 @@ const struct biosdisk_errors { { 0x0C, ENXIO }, { 0x0D, EINVAL }, { 0x10, EECC }, - { 0x20, EHER }, + { 0x20, EHER }, { 0x31, ENXIO }, { 0x32, ENXIO }, { 0x00, EIO } @@ -557,7 +562,7 @@ biosdisk_errno(u_int error) { register const struct biosdisk_errors *p; - if (!error) + if (error == 0) return 0; for (p = tab; p->error && p->error != error; p++); @@ -593,13 +598,14 @@ biosstrategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf, if (rsize != NULL) *rsize = nsect * DEV_BSIZE; - return biosdisk_errno(error); + return (biosdisk_errno(error)); } int biosclose(struct open_file *f) { f->f_devdata = NULL; + return 0; } @@ -608,4 +614,3 @@ biosioctl(struct open_file *f, u_long cmd, void *data) { return 0; } - diff --git a/sys/arch/i386/stand/libsa/biosprobe.c b/sys/arch/i386/stand/libsa/biosprobe.c index dba47471e4b..fddb84bb78d 100644 --- a/sys/arch/i386/stand/libsa/biosprobe.c +++ b/sys/arch/i386/stand/libsa/biosprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: biosprobe.c,v 1.3 2003/08/11 06:23:09 deraadt Exp $ */ +/* $OpenBSD: biosprobe.c,v 1.4 2004/03/09 19:12:12 tom Exp $ */ /* * Copyright (c) 2002 Tobias Weingartner @@ -39,22 +39,22 @@ void * getSYSCONFaddr(void) { - u_int32_t status; + u_int32_t status; u_int8_t *vers; - __asm __volatile(DOINT(0x15) "\n\t" - "setc %%al\n\t" - : "=a" (status) - : "0" (0xC000) - : "%ebx", "%ecx", "%edx", "%esi", "%edi", "cc"); + __asm __volatile(DOINT(0x15) "\n\t" + "setc %%al\n\t" + : "=a" (status) + : "0" (0xC000) + : "%ebx", "%ecx", "%edx", "%esi", "%edi", "cc"); /* On failure we go for a NULL */ - if(status) - return(NULL); + if (status) + return NULL; /* Calculate where the version bytes are */ vers = (void*)((BIOS_regs.biosr_es << 4) | BIOS_regs.biosr_bx); - return(vers); + return vers; } void * @@ -64,18 +64,20 @@ getEBDAaddr(void) u_int8_t *info; info = getSYSCONFaddr(); - if(!info) return(NULL); + + if (!info) + return NULL; __asm __volatile(DOINT(0x15) "\n\t" - "setc %%al" - : "=a" (status) - : "0" (0xC100) - : "%ebx", "%ecx", "%edx", "%esi", "%edi", "cc"); + "setc %%al" + : "=a" (status) + : "0" (0xC100) + : "%ebx", "%ecx", "%edx", "%esi", "%edi", "cc"); - if(status) return(NULL); + if (status) + return NULL; info = (void *)(BIOS_regs.biosr_es << 4); - return(info); + return info; } - diff --git a/sys/arch/i386/stand/libsa/cmd_i386.c b/sys/arch/i386/stand/libsa/cmd_i386.c index 66da87e50ae..8e10cb50725 100644 --- a/sys/arch/i386/stand/libsa/cmd_i386.c +++ b/sys/arch/i386/stand/libsa/cmd_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd_i386.c,v 1.27 2003/08/11 06:23:09 deraadt Exp $ */ +/* $OpenBSD: cmd_i386.c,v 1.28 2004/03/09 19:12:12 tom Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -14,8 +14,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL @@ -50,11 +50,11 @@ int Xregs(void); int bootbuf(void *, int); const struct cmd_table cmd_machine[] = { - { "boot", CMDT_CMD, Xboot }, - { "diskinfo", CMDT_CMD, Xdiskinfo }, - { "memory", CMDT_CMD, Xmemory }, + { "boot", CMDT_CMD, Xboot }, + { "diskinfo", CMDT_CMD, Xdiskinfo }, + { "memory", CMDT_CMD, Xmemory }, #ifdef DEBUG - { "regs", CMDT_CMD, Xregs }, + { "regs", CMDT_CMD, Xregs }, #endif { NULL, 0 } }; @@ -85,21 +85,22 @@ Xboot(void) bios_diskinfo_t *bd = NULL; char buf[DEV_BSIZE], *dest = (void *)BOOTBIOS_ADDR; - if(cmd.argc != 2) { + if (cmd.argc != 2) { printf("machine boot {fd,hd}<0123>[abcd]\n"); printf("Where [0123] is the disk number," - " and [abcd] is the partition.\n"); + " and [abcd] is the partition.\n"); return 0; } /* Check arg */ - if(cmd.argv[1][0] != 'f' && cmd.argv[1][0] != 'h') + if (cmd.argv[1][0] != 'f' && cmd.argv[1][0] != 'h') goto bad; - if(cmd.argv[1][1] != 'd') + if (cmd.argv[1][1] != 'd') goto bad; - if(cmd.argv[1][2] < '0' || cmd.argv[1][2] > '3') + if (cmd.argv[1][2] < '0' || cmd.argv[1][2] > '3') goto bad; - if((cmd.argv[1][3] < 'a' || cmd.argv[1][3] > 'd') && cmd.argv[1][3] != '\0') + if ((cmd.argv[1][3] < 'a' || cmd.argv[1][3] > 'd') && + cmd.argv[1][3] != '\0') goto bad; printf("Booting from %s ", cmd.argv[1]); @@ -116,14 +117,15 @@ Xboot(void) /* Read boot sector from device */ bd = bios_dklookup(dev); st = biosd_io(F_READ, bd, 0, 1, buf); - if(st) goto bad; + if (st) + goto bad; /* Frob boot flag in buffer from HD */ - if((dev & 0x80) && (part > 0)){ + if ((dev & 0x80) && (part > 0)){ int i, j; - for(i = 0, j = DOSPARTOFF; i < 4; i++, j += 16) - if(part == i) + for (i = 0, j = DOSPARTOFF; i < 4; i++, j += 16) + if (part == i) buf[j] |= 0x80; else buf[j] &= ~0x80; @@ -158,7 +160,7 @@ Xmemory(void) else addr = 0; if (addr == 0 && (*p != '@' || size == 0)) { - printf ("bad language\n"); + printf("bad language\n"); return 0; } else { switch (cmd.argv[i][0]) { @@ -169,7 +171,7 @@ Xmemory(void) mem_add(addr, addr + size); break; default : - printf ("bad OP\n"); + printf("bad OP\n"); return 0; } } diff --git a/sys/arch/i386/stand/libsa/debug.c b/sys/arch/i386/stand/libsa/debug.c index ea6e7868290..23472281b0d 100644 --- a/sys/arch/i386/stand/libsa/debug.c +++ b/sys/arch/i386/stand/libsa/debug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: debug.c,v 1.12 2004/02/10 00:41:44 tom Exp $ */ +/* $OpenBSD: debug.c,v 1.13 2004/03/09 19:12:12 tom Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -13,8 +13,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL @@ -71,7 +71,7 @@ dump_regs(u_int trapno, u_int arg) trapno, arg, trap_names[trapno], save_cons); /* Register dump */ - for(i = 1; i <= nreg; i++) + for (i = 1; i <= nreg; i++) printf("%s\t%x%c", reg_names[i-1], *reg_values[i-1], ((i%4)? ' ': '\n')); @@ -88,11 +88,12 @@ void dump_mem(char *l, void *p, size_t n) { register int i; + printf("%s [%p]:%s", l, p, (n > 6? "\n":" ")); - for(i = 1; i <= n; i++) + for (i = 1; i <= n; i++) printf("%x%c", *(u_int32_t *)p++, ((i%8)? ' ': '\n')); if (n % 8) - printf ("\n"); + printf("\n"); } diff --git a/sys/arch/i386/stand/libsa/debug_i386.S b/sys/arch/i386/stand/libsa/debug_i386.S index f37d6340ebb..e4005b10cd7 100644 --- a/sys/arch/i386/stand/libsa/debug_i386.S +++ b/sys/arch/i386/stand/libsa/debug_i386.S @@ -1,4 +1,4 @@ -/* $OpenBSD: debug_i386.S,v 1.11 2003/06/03 20:22:11 mickey Exp $ */ +/* $OpenBSD: debug_i386.S,v 1.12 2004/03/09 19:12:12 tom Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -122,5 +122,3 @@ ENTRY(check_regs) movl $0x47374736, (%edi) #endif ret - - diff --git a/sys/arch/i386/stand/libsa/debug_md.h b/sys/arch/i386/stand/libsa/debug_md.h index 3bc08662ac5..fa08cf1ab02 100644 --- a/sys/arch/i386/stand/libsa/debug_md.h +++ b/sys/arch/i386/stand/libsa/debug_md.h @@ -1,4 +1,4 @@ -/* $OpenBSD: debug_md.h,v 1.5 2003/06/03 20:22:11 mickey Exp $ */ +/* $OpenBSD: debug_md.h,v 1.6 2004/03/09 19:12:12 tom Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -54,4 +54,3 @@ #define DUMP_REGS __asm("int $2") extern struct reg reg; #endif - diff --git a/sys/arch/i386/stand/libsa/dev_i386.c b/sys/arch/i386/stand/libsa/dev_i386.c index 30b1cc6fa6d..45afe2243c7 100644 --- a/sys/arch/i386/stand/libsa/dev_i386.c +++ b/sys/arch/i386/stand/libsa/dev_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev_i386.c,v 1.27 2003/08/11 06:23:09 deraadt Exp $ */ +/* $OpenBSD: dev_i386.c,v 1.28 2004/03/09 19:12:12 tom Exp $ */ /* * Copyright (c) 1996-1999 Michael Shalayeff @@ -73,7 +73,7 @@ devopen(struct open_file *f, const char *fname, char **file) else if (debug) printf("%d", rc); #endif - + } #ifdef DEBUG if (debug) @@ -112,7 +112,7 @@ int pch_pos = 0; void putchar(int c) { - switch(c) { + switch (c) { case '\177': /* DEL erases */ cnputc('\b'); cnputc(' '); @@ -124,7 +124,7 @@ putchar(int c) case '\t': do cnputc(' '); - while(++pch_pos % 8); + while (++pch_pos % 8); break; case '\n': case '\r': @@ -147,11 +147,11 @@ getchar(void) c = '\n'; if ((c < ' ' && c != '\n') || c == '\177') - return(c); + return c; putchar(c); - return(c); + return c; } char ttyname_buf[8]; @@ -160,9 +160,9 @@ char * ttyname(int fd) { snprintf(ttyname_buf, sizeof ttyname_buf, "%s%d", - cdevs[major(cn_tab->cn_dev)], - minor(cn_tab->cn_dev)); - return (ttyname_buf); + cdevs[major(cn_tab->cn_dev)], minor(cn_tab->cn_dev)); + + return ttyname_buf; } dev_t @@ -174,18 +174,19 @@ ttydev(char *name) while (no >= name && *no >= '0' && *no <= '9') unit = (unit < 0 ? 0 : (unit * 10)) + *no-- - '0'; if (no < name || unit < 0) - return (NODEV); + return NODEV; for (i = 0; i < ncdevs; i++) if (strncmp(name, cdevs[i], no - name + 1) == 0) return (makedev(i, unit)); - return (NODEV); + return NODEV; } int cnspeed(dev_t dev, int sp) { if (major(dev) == 8) /* comN */ - return comspeed(dev, sp); + return (comspeed(dev, sp)); + /* pc0 and anything else */ return 9600; } diff --git a/sys/arch/i386/stand/libsa/disk.h b/sys/arch/i386/stand/libsa/disk.h index 469c4d9aec1..a9633ca7294 100644 --- a/sys/arch/i386/stand/libsa/disk.h +++ b/sys/arch/i386/stand/libsa/disk.h @@ -1,4 +1,4 @@ -/* $OpenBSD: disk.h,v 1.3 2003/06/04 17:04:05 deraadt Exp $ */ +/* $OpenBSD: disk.h,v 1.4 2004/03/09 19:12:13 tom Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -49,4 +49,3 @@ extern struct diskinfo *bootdev_dip; void dump_diskinfo(void); #endif /* _DISKPROBE_H */ - diff --git a/sys/arch/i386/stand/libsa/diskprobe.c b/sys/arch/i386/stand/libsa/diskprobe.c index 48e462dc6e1..b2bbf03a091 100644 --- a/sys/arch/i386/stand/libsa/diskprobe.c +++ b/sys/arch/i386/stand/libsa/diskprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diskprobe.c,v 1.24 2003/12/16 22:53:13 deraadt Exp $ */ +/* $OpenBSD: diskprobe.c,v 1.25 2004/03/09 19:12:13 tom Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -13,8 +13,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL @@ -62,11 +62,11 @@ floppyprobe(void) int i; /* Floppies */ - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { dip = alloc(sizeof(struct diskinfo)); bzero(dip, sizeof(*dip)); - if(bios_getdiskinfo(i, &dip->bios_info)) { + if (bios_getdiskinfo(i, &dip->bios_info)) { #ifdef BIOS_DEBUG if (debug) printf(" <!fd%u>", i); @@ -109,7 +109,7 @@ hardprobe(void) dip = alloc(sizeof(struct diskinfo)); bzero(dip, sizeof(*dip)); - if(bios_getdiskinfo(i, &dip->bios_info)) { + if (bios_getdiskinfo(i, &dip->bios_info)) { #ifdef BIOS_DEBUG if (debug) printf(" <!hd%u>", i&0x7f); @@ -121,7 +121,7 @@ hardprobe(void) printf(" hd%u%s", i&0x7f, (dip->bios_info.bios_edd > 0?"+":"")); /* Try to find the label, to figure out device type */ - if((bios_getdisklabel(&dip->bios_info, &dip->disklabel)) ) { + if ((bios_getdisklabel(&dip->bios_info, &dip->disklabel)) ) { printf("*"); bsdunit = ide++; type = 0; /* XXX let it be IDE */ @@ -150,7 +150,8 @@ hardprobe(void) dip->bios_info.checksum = 0; /* just in case */ /* Fill out best we can */ - dip->bios_info.bsd_dev = MAKEBOOTDEV(type, 0, 0, bsdunit, RAW_PART); + dip->bios_info.bsd_dev = + MAKEBOOTDEV(type, 0, 0, bsdunit, RAW_PART); /* Add to queue of disks */ TAILQ_INSERT_TAIL(&disklist, dip, list); @@ -187,18 +188,21 @@ diskprobe(void) bios_cksumlen = i; /* Get space for passing bios_diskinfo stuff to kernel */ - for(i = 0, dip = TAILQ_FIRST(&disklist); dip; dip = TAILQ_NEXT(dip, list)) + for (i = 0, dip = TAILQ_FIRST(&disklist); dip; + dip = TAILQ_NEXT(dip, list)) i++; bios_diskinfo = alloc(++i * sizeof(bios_diskinfo_t)); /* Copy out the bios_diskinfo stuff */ - for(i = 0, dip = TAILQ_FIRST(&disklist); dip; dip = TAILQ_NEXT(dip, list)) + for (i = 0, dip = TAILQ_FIRST(&disklist); dip; + dip = TAILQ_NEXT(dip, list)) bios_diskinfo[i++] = dip->bios_info; bios_diskinfo[i++].bios_number = -1; /* Register for kernel use */ addbootarg(BOOTARG_CKSUMLEN, sizeof(u_int32_t), &bios_cksumlen); - addbootarg(BOOTARG_DISKINFO, i * sizeof(bios_diskinfo_t), bios_diskinfo); + addbootarg(BOOTARG_DISKINFO, i * sizeof(bios_diskinfo_t), + bios_diskinfo); printf("\n"); } @@ -210,11 +214,11 @@ dklookup(int dev) { struct diskinfo *dip; - for(dip = TAILQ_FIRST(&disklist); dip; dip = TAILQ_NEXT(dip, list)) - if(dip->bios_info.bios_number == dev) - return(dip); + for (dip = TAILQ_FIRST(&disklist); dip; dip = TAILQ_NEXT(dip, list)) + if (dip->bios_info.bios_number == dev) + return dip; - return(NULL); + return NULL; } void @@ -223,13 +227,13 @@ dump_diskinfo(void) struct diskinfo *dip; printf("Disk\tBIOS#\tType\tCyls\tHeads\tSecs\tFlags\tChecksum\n"); - for(dip = TAILQ_FIRST(&disklist); dip; dip = TAILQ_NEXT(dip, list)){ + for (dip = TAILQ_FIRST(&disklist); dip; dip = TAILQ_NEXT(dip, list)) { bios_diskinfo_t *bdi = &dip->bios_info; int d = bdi->bios_number; printf("%cd%d\t0x%x\t%s\t%d\t%d\t%d\t0x%x\t0x%x\n", (d & 0x80)?'h':'f', d & 0x7F, d, - (bdi->flags & BDI_BADLABEL)?"*none*":"label", + (bdi->flags & BDI_BADLABEL)?"*none*":"label", bdi->bios_cylinders, bdi->bios_heads, bdi->bios_sectors, bdi->flags, bdi->checksum); } @@ -244,10 +248,10 @@ bios_dklookup(int dev) struct diskinfo *dip; dip = dklookup(dev); - if(dip) - return(&dip->bios_info); + if (dip) + return &dip->bios_info; - return(NULL); + return NULL; } /* @@ -264,7 +268,7 @@ disksum(int blk) char *buf; buf = alloca(DEV_BSIZE); - for(dip = TAILQ_FIRST(&disklist); dip; dip = TAILQ_NEXT(dip, list)){ + for (dip = TAILQ_FIRST(&disklist); dip; dip = TAILQ_NEXT(dip, list)) { bios_diskinfo_t *bdi = &dip->bios_info; /* Skip this disk if it is not a HD or has had an I/O error */ @@ -279,8 +283,8 @@ disksum(int blk) } bdi->checksum = adler32(bdi->checksum, buf, DEV_BSIZE); - for(dip2 = TAILQ_FIRST(&disklist); dip2 != dip; - dip2 = TAILQ_NEXT(dip2, list)){ + for (dip2 = TAILQ_FIRST(&disklist); dip2 != dip; + dip2 = TAILQ_NEXT(dip2, list)) { bios_diskinfo_t *bd = &dip2->bios_info; if ((bd->bios_number & 0x80) && !(bd->flags & BDI_INVALID) && @@ -289,6 +293,5 @@ disksum(int blk) } } - return (reprobe); + return reprobe; } - diff --git a/sys/arch/i386/stand/libsa/exec_i386.c b/sys/arch/i386/stand/libsa/exec_i386.c index a331dda32de..2274278b864 100644 --- a/sys/arch/i386/stand/libsa/exec_i386.c +++ b/sys/arch/i386/stand/libsa/exec_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_i386.c,v 1.28 2003/06/03 20:22:11 mickey Exp $ */ +/* $OpenBSD: exec_i386.c,v 1.29 2004/03/09 19:12:13 tom Exp $ */ /* * Copyright (c) 1997-1998 Michael Shalayeff @@ -14,8 +14,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL @@ -38,7 +38,7 @@ #include <lib/libsa/loadfile.h> typedef void (*startfuncp)(int, int, int, int, int, int, int, int) - __attribute__ ((noreturn)); + __attribute__ ((noreturn)); void run_loadfile(u_long *marks, int howto) @@ -68,7 +68,7 @@ run_loadfile(u_long *marks, int howto) printf("entry point at 0x%x\n", (int) entry); /* stack and the gung is ok at this point, so, no need for asm setup */ (*(startfuncp)entry)(howto, bootdev, BOOTARG_APIVER, - marks[MARK_END], extmem, cnvmem, ac, (int)av); + marks[MARK_END], extmem, cnvmem, ac, (int)av); /* not reached */ #endif } diff --git a/sys/arch/i386/stand/libsa/memprobe.c b/sys/arch/i386/stand/libsa/memprobe.c index 274d317c4ab..d17507daf4e 100644 --- a/sys/arch/i386/stand/libsa/memprobe.c +++ b/sys/arch/i386/stand/libsa/memprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: memprobe.c,v 1.41 2004/01/09 21:15:00 deraadt Exp $ */ +/* $OpenBSD: memprobe.c,v 1.42 2004/03/09 19:12:13 tom Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -14,8 +14,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL @@ -49,15 +49,15 @@ checkA20(void) int st; /* Simple check */ - if(*p != *q) - return(1); + if (*p != *q) + return 1; /* Complex check */ *p = ~(*p); st = (*p != *q); *p = ~(*p); - return(st); + return st; } /* BIOS int 15, AX=E820 @@ -73,27 +73,28 @@ bios_E820(bios_memmap_t *mp) do { BIOS_regs.biosr_es = ((u_int)(mp) >> 4); + __asm __volatile(DOINT(0x15) "; setc %b1" - : "=a" (sig), "=d" (rc), "=b" (off) - : "0" (0xE820), "1" (0x534d4150), "b" (off), - "c" (sizeof(*mp)), "D" (((u_int)mp) & 0xF) - : "cc", "memory"); - off = BIOS_regs.biosr_bx; + : "=a" (sig), "=d" (rc), "=b" (off) + : "0" (0xE820), "1" (0x534d4150), "b" (off), + "c" (sizeof(*mp)), "D" (((u_int)mp) & 0xF) + : "cc", "memory"); + off = BIOS_regs.biosr_bx; - if (rc & 0xff || sig != 0x534d4150) - break; - gotcha++; - if (!mp->type) - mp->type = BIOS_MAP_RES; - mp++; + if (rc & 0xff || sig != 0x534d4150) + break; + gotcha++; + if (!mp->type) + mp->type = BIOS_MAP_RES; + mp++; } while (off); if (!gotcha) - return (NULL); + return NULL; #ifdef DEBUG printf("0x15[E820] "); #endif - return (mp); + return mp; } #if 0 @@ -113,25 +114,27 @@ bios_E801(bios_memmap_t *mp) /* Test for possibility of 0xE801 */ info = getSYSCONFaddr(); - if(!info) return(NULL); + if (!info) + return NULL; /* XXX - Should test model/submodel/rev here */ printf("model(%d,%d,%d)", info[2], info[3], info[4]); /* Check for 94 or later bios */ info = (void *)0xFFFFB; - if(info[0] == '9' && info[1] <= '3') return(NULL); + if (info[0] == '9' && info[1] <= '3') + return NULL; /* We might have this call */ __asm __volatile(DOINT(0x15) "; mov %%ax, %%si; setc %b0" - : "=a" (rc), "=S" (m1), "=b" (m2), "=c" (m3), "=d" (m4) - : "0" (0xE801)); + : "=a" (rc), "=S" (m1), "=b" (m2), "=c" (m3), "=d" (m4) + : "0" (0xE801)); /* Test for failure */ - if(rc & 0xff) - return (NULL); + if (rc & 0xff) + return NULL; /* Fixup for screwed up machines */ - if(m1 == 0){ + if (m1 == 0) { m1 = m3; m2 = m4; } @@ -163,10 +166,10 @@ bios_8800(bios_memmap_t *mp) int rc, mem; __asm __volatile(DOINT(0x15) "; setc %b0" - : "=c" (rc), "=a" (mem) : "a" (0x8800)); + : "=c" (rc), "=a" (mem) : "a" (0x8800)); - if(rc & 0xff) - return (NULL); + if (rc & 0xff) + return NULL; #ifdef DEBUG printf("0x15[8800] "); #endif @@ -230,23 +233,23 @@ addrprobe(u_int kloc) save[0] = *loc; /* Probe address */ - for(i = 0; i < NENTS(addrprobe_pat); i++){ + for (i = 0; i < NENTS(addrprobe_pat); i++) { *loc = addrprobe_pat[i]; - if(*loc != addrprobe_pat[i]) + if (*loc != addrprobe_pat[i]) ret++; } *loc = save[0]; if (!ret) { /* Write address */ - for(i = 0; i < NENTS(addrprobe_pat); i++) { + for (i = 0; i < NENTS(addrprobe_pat); i++) { save[i] = loc[i]; loc[i] = addrprobe_pat[i]; } /* Read address */ - for(i = 0; i < NENTS(addrprobe_pat); i++) { - if(loc[i] != addrprobe_pat[i]) + for (i = 0; i < NENTS(addrprobe_pat); i++) { + if (loc[i] != addrprobe_pat[i]) ret++; loc[i] = save[i]; } @@ -276,8 +279,8 @@ badprobe(bios_memmap_t *mp) * There is no need to do this in assembly language. This is * much easier to debug in C anyways. */ - for(ram = 1024; ram < 512 * 1024; ram += 4) - if(addrprobe(ram)) + for (ram = 1024; ram < 512 * 1024; ram += 4) + if (addrprobe(ram)) break; mp->addr = 1024 * 1024; @@ -300,17 +303,17 @@ memprobe(void) printf(" mem["); #endif - if(!(pm = bios_E820(bios_memmap))) { + if ((pm = bios_E820(bios_memmap)) == NULL) { im = bios_int12(bios_memmap); #if 0 pm = bios_E801(im); - if (!pm) + if (pm == NULL) #endif pm = bios_8800(im); - if (!pm) + if (pm == NULL) pm = badprobe(im); - if (!pm) { - printf (" No Extended memory detected."); + if (pm == NULL) { + printf(" No Extended memory detected."); pm = im; } } @@ -327,7 +330,7 @@ memprobe(void) /* XXX - Compatibility, remove later (smpprobe() relies on it) */ extmem = cnvmem = 0; - for(im = bios_memmap; im->type != BIOS_MAP_END; im++) { + for (im = bios_memmap; im->type != BIOS_MAP_END; im++) { /* Count only "good" memory chunks 12K and up in size */ if ((im->type == BIOS_MAP_FREE) && (im->size >= 12*1024)) { if (im->size > 1024 * 1024) @@ -345,10 +348,10 @@ memprobe(void) * We ignore "good" memory in the 640K-1M hole. * We drop "machine {cnvmem,extmem}" commands. */ - if(im->addr < IOM_BEGIN) + if (im->addr < IOM_BEGIN) cnvmem = max(cnvmem, im->addr + im->size) / 1024; - if(im->addr >= IOM_END) + if (im->addr >= IOM_END) extmem += im->size / 1024; } } @@ -364,7 +367,7 @@ dump_biosmem(bios_memmap_t *tm) register bios_memmap_t *p; register u_int total = 0; - if (!tm) + if (tm == NULL) tm = bios_memmap; /* libsa printf does not handle quad args, so we use long @@ -372,12 +375,12 @@ dump_biosmem(bios_memmap_t *tm) * 4G of RAM on a x86 box, this not likely to cause a problem. * If/when we do, libsa may need to be updated some... */ - for(p = tm; p->type != BIOS_MAP_END; p++) { - printf("Region %ld: type %u at 0x%x for %uKB\n", + for (p = tm; p->type != BIOS_MAP_END; p++) { + printf("Region %ld: type %u at 0x%x for %uKB\n", (long)(p - tm), p->type, (u_int)p->addr, (u_int)(p->size / 1024)); - if(p->type == BIOS_MAP_FREE) + if (p->type == BIOS_MAP_FREE) total += p->size / 1024; } @@ -396,8 +399,8 @@ mem_delete(long sa, long ea) /* can we eat it as a whole? */ if ((sa - sp) <= NBPG && (ep - ea) <= NBPG) { - bcopy (p + 1, p, (char *)bios_memmap + - sizeof(bios_memmap) - (char *)p); + bcopy(p + 1, p, (char *)bios_memmap + + sizeof(bios_memmap) - (char *)p); break; /* eat head or legs */ } else if (sa <= sp && sp < ea) { @@ -409,9 +412,9 @@ mem_delete(long sa, long ea) break; } else if (sp < sa && ea < ep) { /* bite in half */ - bcopy (p, p + 1, (char *)bios_memmap + - sizeof(bios_memmap) - (char *)p - - sizeof(bios_memmap[0])); + bcopy(p, p + 1, (char *)bios_memmap + + sizeof(bios_memmap) - (char *)p - + sizeof(bios_memmap[0])); p[1].addr = ea; p[1].size = ep - ea; p->size = sa - sp; @@ -444,8 +447,8 @@ mem_add(long sa, long ea) break; } else if (ea < sp) { /* insert before */ - bcopy (p, p + 1, (char *)bios_memmap + - sizeof(bios_memmap) - (char *)(p - 1)); + bcopy(p, p + 1, (char *)bios_memmap + + sizeof(bios_memmap) - (char *)(p - 1)); p->addr = sa; p->size = ea - sa; break; diff --git a/sys/arch/i386/stand/libsa/pciprobe.c b/sys/arch/i386/stand/libsa/pciprobe.c index bbf9dd15b60..4b7634ffa9b 100644 --- a/sys/arch/i386/stand/libsa/pciprobe.c +++ b/sys/arch/i386/stand/libsa/pciprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pciprobe.c,v 1.7 2003/08/11 06:23:09 deraadt Exp $ */ +/* $OpenBSD: pciprobe.c,v 1.8 2004/03/09 19:12:13 tom Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -42,7 +42,7 @@ pciprobe(void) u_int32_t entry32; /* PCI BIOS v2.0c+ - Installation Check */ - __asm __volatile(DOINT(0x1A) ";shll $8,%2; setc %b2" + __asm __volatile(DOINT(0x1A) "; shll $8,%2; setc %b2" : "=a" (hw_chars), "=b" (rev), "=c" (rc), "=d" (sig), "=D" (entry32) : "0" (0xB101), "4" (0x0) @@ -66,4 +66,3 @@ pciprobe(void) addbootarg(BOOTARG_PCIINFO, sizeof(bios_pciinfo_t), &bpi); } - diff --git a/sys/arch/i386/stand/libsa/smpprobe.c b/sys/arch/i386/stand/libsa/smpprobe.c index 8b7f059cea1..7131c3b3377 100644 --- a/sys/arch/i386/stand/libsa/smpprobe.c +++ b/sys/arch/i386/stand/libsa/smpprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smpprobe.c,v 1.5 2003/08/11 06:23:09 deraadt Exp $ */ +/* $OpenBSD: smpprobe.c,v 1.6 2004/03/09 19:12:13 tom Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -13,8 +13,8 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL @@ -73,27 +73,28 @@ mp_probefloat(u_int8_t *ptr, int len) if (debug) printf("Checking %p for %d\n", ptr, len); #endif - for(i = 0; i < 1024; i++){ + for (i = 0; i < 1024; i++) { mp_float_t *tmp = (mp_float_t*)(ptr + i); - if(tmp->signature == MP_FLOAT_SIG){ + if (tmp->signature == MP_FLOAT_SIG) { printf("Found possible MP signature at: %p\n", ptr); mpp = tmp; break; } - if((tmp->signature == MP_FLOAT_SIG) && - mp_checksum((u_int8_t *)tmp, tmp->length*16)){ + if ((tmp->signature == MP_FLOAT_SIG) && + mp_checksum((u_int8_t *)tmp, tmp->length*16)) { #ifdef DEBUG if (debug) - printf("Found valid MP signature at: %p\n", ptr); + printf("Found valid MP signature at: %p\n", + ptr); #endif mpp = tmp; break; } } - return (mpp); + return mpp; } @@ -120,17 +121,17 @@ smpprobe(void) /* Valid MP signature found */ printf(" smp"); + #if DEBUG if (debug) printf("Floating Structure:\n" - "\tSignature: %x\n" - "\tConfig at: %x\n" - "\tLength: %d\n" - "\tRev: 1.%d\n" - "\tFeature: %x %x %x %x %x\n", - mp->signature, mp->conf_addr, mp->length, mp->spec_rev, - mp->feature[0], mp->feature[1], mp->feature[2], - mp->feature[3], mp->feature[4]); + "\tSignature: %x\n" + "\tConfig at: %x\n" + "\tLength: %d\n" + "\tRev: 1.%d\n" + "\tFeature: %x %x %x %x %x\n", + mp->signature, mp->conf_addr, mp->length, mp->spec_rev, + mp->feature[0], mp->feature[1], mp->feature[2], + mp->feature[3], mp->feature[4]); #endif } - diff --git a/sys/arch/i386/stand/libsa/time.c b/sys/arch/i386/stand/libsa/time.c index b097a08a96e..fe6096a7e6d 100644 --- a/sys/arch/i386/stand/libsa/time.c +++ b/sys/arch/i386/stand/libsa/time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: time.c,v 1.14 2003/08/11 06:23:09 deraadt Exp $ */ +/* $OpenBSD: time.c,v 1.15 2004/03/09 19:12:13 tom Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -50,8 +50,7 @@ bcdtoint(u_int8_t c) * Quick compute of time in seconds since the Epoch */ const u_short monthcount[] = { - 0, 0, 31, 59, 90, 120, 151, 181, - 212, 243, 273, 304, 334, 365 + 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }; static __inline time_t @@ -65,8 +64,8 @@ compute(int year, u_int8_t month, u_int8_t day, u_int8_t hour, tt = (year - 1970) * 365 + monthcount[month] + day; /* Compute for leap year */ - for(month <= 2? year--:0;year >= 1970;year--) - if(isleap(year)) + for (month <= 2 ? year-- : 0; year >= 1970; year--) + if (isleap(year)) tt++; /* Plus the time */ @@ -79,13 +78,13 @@ static int bios_time_date(int f, u_int8_t *b) { __asm __volatile(DOINT(0x1a) "\n\t" - "setc %b0\n\t" - "movb %%ch, 0(%2)\n\t" - "movb %%cl, 1(%2)\n\t" - "movb %%dh, 2(%2)\n\t" - "movb %%dl, 3(%2)\n\t" - : "=a" (f) - : "0" (f), "p" (b) : "%ecx", "%edx", "cc"); + "setc %b0\n\t" + "movb %%ch, 0(%2)\n\t" + "movb %%cl, 1(%2)\n\t" + "movb %%dh, 2(%2)\n\t" + "movb %%dl, 3(%2)\n\t" + : "=a" (f) + : "0" (f), "p" (b) : "%ecx", "%edx", "cc"); if (f & 0xff) return -1; else { @@ -118,20 +117,20 @@ getsecs(void) u_int8_t timebuf[4], datebuf[4]; /* Query BIOS for time & date */ - if(!biostime(timebuf) && !biosdate(datebuf)) { + if (!biostime(timebuf) && !biosdate(datebuf)) { #ifdef notdef int dst; dst = timebuf[3]; #endif /* Convert to seconds since Epoch */ - return compute(datebuf[0] * 100 + datebuf[1], - datebuf[2], datebuf[3], - timebuf[0], timebuf[1], timebuf[2]); + return (compute(datebuf[0] * 100 + datebuf[1], + datebuf[2], datebuf[3], + timebuf[0], timebuf[1], timebuf[2])); } else errno = EIO; - return(1); + return 1; } u_int @@ -139,8 +138,10 @@ sleep(u_int i) { register time_t t; - /* loop for that number of seconds, polling BIOS, - so that it may handle interrupts */ + /* + * Loop for the requested number of seconds, polling BIOS, + * so that it may handle interrupts. + */ for (t = getsecs() + i; getsecs() < t; cnischar()); return 0; |