diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2012-10-30 14:06:30 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2012-10-30 14:06:30 +0000 |
commit | 73b501f9e7b72dd509a9b8d60ced65be3db8742b (patch) | |
tree | e40fc6ac31e5a0ca4a03181deaebbbe70ae1cdcd /sys/arch | |
parent | 2f004055b83f45bdf36995e319dea3b4435d14d0 (diff) |
Apply a bunch of style(9) and whitespace fixes to i386/amd64 libsa, making
the code actually diffable. No binary change.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/stand/libsa/bioscons.c | 7 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/biosprobe.c | 38 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/cmd_i386.c | 46 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/dev_i386.c | 31 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/diskprobe.c | 44 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/exec_i386.c | 12 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/libsa.h | 4 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/memprobe.c | 148 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/time.c | 43 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/bioscons.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/cmd_i386.c | 6 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/dev_i386.c | 10 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/exec_i386.c | 9 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/memprobe.c | 31 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/pxeboot.h | 2 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/time.c | 12 |
16 files changed, 239 insertions, 208 deletions
diff --git a/sys/arch/amd64/stand/libsa/bioscons.c b/sys/arch/amd64/stand/libsa/bioscons.c index 5913b5f2eb8..a3e1425b894 100644 --- a/sys/arch/amd64/stand/libsa/bioscons.c +++ b/sys/arch/amd64/stand/libsa/bioscons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bioscons.c,v 1.7 2012/06/10 21:02:42 kettenis Exp $ */ +/* $OpenBSD: bioscons.c,v 1.8 2012/10/30 14:06:29 jsing Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -90,6 +90,7 @@ pc_getc(dev_t dev) __asm __volatile(DOINT(0x16) : "=a" (rv) : "0" (0x000) : "%ecx", "%edx", "cc" ); + return (rv & 0xff); } @@ -130,7 +131,7 @@ com_probe(struct consdev *cn) cn->cn_dev = makedev(8, 0); } -int com_speed = -1; /* default speed is 9600 baud */ +int com_speed = -1; int com_addr = -1; void @@ -140,7 +141,7 @@ com_init(struct consdev *cn) outb(port + com_ier, 0); if (com_speed == -1) - comspeed(cn->cn_dev, 9600); + comspeed(cn->cn_dev, 9600); /* default speed is 9600 baud */ outb(port + com_mcr, MCR_DTR | MCR_RTS); outb(port + com_fifo, FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_1); diff --git a/sys/arch/amd64/stand/libsa/biosprobe.c b/sys/arch/amd64/stand/libsa/biosprobe.c index 8e57907ffb8..f82360a0e54 100644 --- a/sys/arch/amd64/stand/libsa/biosprobe.c +++ b/sys/arch/amd64/stand/libsa/biosprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: biosprobe.c,v 1.1 2004/02/03 12:09:47 mickey Exp $ */ +/* $OpenBSD: biosprobe.c,v 1.2 2012/10/30 14:06:29 jsing Exp $ */ /* * Copyright (c) 2002 Tobias Weingartner @@ -38,22 +38,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 * @@ -63,18 +63,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/amd64/stand/libsa/cmd_i386.c b/sys/arch/amd64/stand/libsa/cmd_i386.c index f2a4ddd2ea9..7fbdca1b0fa 100644 --- a/sys/arch/amd64/stand/libsa/cmd_i386.c +++ b/sys/arch/amd64/stand/libsa/cmd_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd_i386.c,v 1.4 2012/06/03 13:18:33 kettenis Exp $ */ +/* $OpenBSD: cmd_i386.c,v 1.5 2012/10/30 14:06:29 jsing 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,12 +50,12 @@ int Xregs(void); int bootbuf(void *, int); const struct cmd_table cmd_machine[] = { - { "boot", CMDT_CMD, Xboot }, - { "comaddr", CMDT_CMD, Xcomaddr }, - { "diskinfo", CMDT_CMD, Xdiskinfo }, - { "memory", CMDT_CMD, Xmemory }, + { "boot", CMDT_CMD, Xboot }, + { "comaddr", CMDT_CMD, Xcomaddr }, + { "diskinfo", CMDT_CMD, Xdiskinfo }, + { "memory", CMDT_CMD, Xmemory }, #ifdef DEBUG - { "regs", CMDT_CMD, Xregs }, + { "regs", CMDT_CMD, Xregs }, #endif { NULL, 0 } }; @@ -86,21 +86,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]); @@ -117,14 +118,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; @@ -155,7 +157,7 @@ Xmemory(void) size = strtoll(p + 1, &p, 0); /* Size the size */ - switch(*p) { + switch (*p) { case 'G': size *= 1024; case 'M': @@ -166,7 +168,7 @@ Xmemory(void) } /* Handle (possibly non-existant) address part */ - switch(*p) { + switch (*p) { case '@': addr = strtoll(p + 1, NULL, 0); break; @@ -180,7 +182,7 @@ Xmemory(void) } if (addr == 0 || size == 0) { - printf ("bad language\n"); + printf("bad language\n"); return 0; } else { switch (cmd.argv[i][0]) { @@ -194,7 +196,7 @@ Xmemory(void) mem_limit(size); break; default : - printf ("bad OP\n"); + printf("bad OP\n"); return 0; } } diff --git a/sys/arch/amd64/stand/libsa/dev_i386.c b/sys/arch/amd64/stand/libsa/dev_i386.c index 342454a25d3..9a26a6cbdee 100644 --- a/sys/arch/amd64/stand/libsa/dev_i386.c +++ b/sys/arch/amd64/stand/libsa/dev_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev_i386.c,v 1.12 2012/10/27 15:43:42 jsing Exp $ */ +/* $OpenBSD: dev_i386.c,v 1.13 2012/10/30 14:06:29 jsing Exp $ */ /* * Copyright (c) 1996-1999 Michael Shalayeff @@ -30,14 +30,14 @@ #include <sys/queue.h> #include <sys/disklabel.h> #include <dev/cons.h> -#include <dev/biovar.h> -#include <dev/softraidvar.h> #include "libsa.h" #include "biosdev.h" #include "disk.h" #ifdef SOFTRAID +#include <dev/biovar.h> +#include <dev/softraidvar.h> #include "softraid.h" #endif @@ -83,7 +83,7 @@ devopen(struct open_file *f, const char *fname, char **file) else if (debug) printf("%d", rc); #endif - + } #ifdef DEBUG if (debug) @@ -165,7 +165,7 @@ int pch_pos = 0; void putchar(int c) { - switch(c) { + switch (c) { case '\177': /* DEL erases */ cnputc('\b'); cnputc(' '); @@ -175,9 +175,9 @@ putchar(int c) pch_pos--; break; case '\t': - do + do { cnputc(' '); - while(++pch_pos % 8); + } while (++pch_pos % 8); break; case '\n': case '\r': @@ -200,11 +200,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]; @@ -213,9 +213,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 @@ -227,11 +227,11 @@ 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 makedev(i, unit); + return NODEV; } int @@ -239,6 +239,7 @@ cnspeed(dev_t dev, int sp) { if (major(dev) == 8) /* comN */ return comspeed(dev, sp); + /* pc0 and anything else */ return 9600; } diff --git a/sys/arch/amd64/stand/libsa/diskprobe.c b/sys/arch/amd64/stand/libsa/diskprobe.c index 6b0af6f103b..581bcac749c 100644 --- a/sys/arch/amd64/stand/libsa/diskprobe.c +++ b/sys/arch/amd64/stand/libsa/diskprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diskprobe.c,v 1.11 2012/10/27 15:43:42 jsing Exp $ */ +/* $OpenBSD: diskprobe.c,v 1.12 2012/10/30 14:06:29 jsing Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -70,11 +70,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); @@ -117,7 +117,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); @@ -129,7 +129,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 */ @@ -158,7 +158,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); @@ -198,18 +199,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); } @@ -294,11 +298,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 @@ -337,10 +341,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; } /* @@ -357,7 +361,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 */ @@ -372,8 +376,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) && @@ -382,5 +386,5 @@ disksum(int blk) } } - return (reprobe); + return reprobe; } diff --git a/sys/arch/amd64/stand/libsa/exec_i386.c b/sys/arch/amd64/stand/libsa/exec_i386.c index cdce6ac2cd4..4da5dad8062 100644 --- a/sys/arch/amd64/stand/libsa/exec_i386.c +++ b/sys/arch/amd64/stand/libsa/exec_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_i386.c,v 1.11 2012/10/27 15:43:42 jsing Exp $ */ +/* $OpenBSD: exec_i386.c,v 1.12 2012/10/30 14:06:29 jsing Exp $ */ /* * Copyright (c) 1997-1998 Michael Shalayeff @@ -44,7 +44,7 @@ #endif typedef void (*startfuncp)(int, int, int, int, int, int, int, int) - __attribute__ ((noreturn)); + __attribute__ ((noreturn)); char *bootmac = NULL; @@ -112,9 +112,11 @@ run_loadfile(u_long *marks, int howto) entry = marks[MARK_ENTRY] & 0x0fffffff; printf("entry point at 0x%lx [%x, %x, %x, %x]\n", entry, - ((int *)entry)[0], ((int *)entry)[1], ((int *)entry)[2], ((int *)entry)[3]); + ((int *)entry)[0], ((int *)entry)[1], + ((int *)entry)[2], ((int *)entry)[3]); + /* 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); + (*(startfuncp)entry)(howto, bootdev, BOOTARG_APIVER, marks[MARK_END], + extmem, cnvmem, ac, (int)av); /* not reached */ } diff --git a/sys/arch/amd64/stand/libsa/libsa.h b/sys/arch/amd64/stand/libsa/libsa.h index 32cd2fa2fbb..fc65c6f8ccd 100644 --- a/sys/arch/amd64/stand/libsa/libsa.h +++ b/sys/arch/amd64/stand/libsa/libsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libsa.h,v 1.6 2010/07/02 00:36:52 weingart Exp $ */ +/* $OpenBSD: libsa.h,v 1.7 2012/10/30 14:06:29 jsing Exp $ */ /* * Copyright (c) 1996-1999 Michael Shalayeff @@ -74,6 +74,6 @@ extern void (*devboot_p)(dev_t, char *); extern bios_diskinfo_t bios_diskinfo[]; extern u_int32_t bios_cksumlen; -#define MACHINE_CMD cmd_machine /* we have i386 specific sommands */ +#define MACHINE_CMD cmd_machine /* we have i386-specific commands */ #define CHECK_SKIP_CONF check_skip_conf /* we can skip boot.conf with Ctrl */ diff --git a/sys/arch/amd64/stand/libsa/memprobe.c b/sys/arch/amd64/stand/libsa/memprobe.c index d87968c8b1a..a890bea4695 100644 --- a/sys/arch/amd64/stand/libsa/memprobe.c +++ b/sys/arch/amd64/stand/libsa/memprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: memprobe.c,v 1.10 2010/12/06 22:51:45 jasper Exp $ */ +/* $OpenBSD: memprobe.c,v 1.11 2012/10/30 14:06:29 jsing 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 @@ -37,7 +37,8 @@ u_int cnvmem, extmem; /* XXX - compatibility */ -/* Check gateA20 +/* + * Check gateA20 * * A sanity check. */ @@ -49,18 +50,19 @@ 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 +/* + * BIOS int 15, AX=E820 * * This is the "preferred" method. */ @@ -72,30 +74,31 @@ 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 -/* BIOS int 15, AX=E801 +/* + * BIOS int 15, AX=E801 * * Only used if int 15, AX=E820 does not work. * This should work for more than 64MB on most @@ -111,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; } @@ -150,7 +155,8 @@ bios_E801(bios_memmap_t *mp) } #endif -/* BIOS int 15, AX=8800 +/* + * BIOS int 15, AX=8800 * * Only used if int 15, AX=E801 does not work. * Machines with this are restricted to 64MB. @@ -161,10 +167,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 @@ -176,7 +182,8 @@ bios_8800(bios_memmap_t *mp) return ++mp; } -/* BIOS int 0x12 Get Conventional Memory +/* + * BIOS int 0x12 Get Conventional Memory * * Only used if int 15, AX=E820 does not work. */ @@ -198,7 +205,8 @@ bios_int12(bios_memmap_t *mp) } -/* addrprobe(kloc): Probe memory at address kloc * 1024. +/* + * addrprobe(kloc): Probe memory at address kloc * 1024. * * This is a hack, but it seems to work ok. Maybe this is * the *real* way that you are supposed to do probing??? @@ -228,23 +236,23 @@ addrprobe(u_int kloc) save[0] = *loc; /* Probe address */ - for(i = 0; i < nitems(addrprobe_pat); i++){ + for (i = 0; i < nitems(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 < nitems(addrprobe_pat); i++) { + for (i = 0; i < nitems(addrprobe_pat); i++) { save[i] = loc[i]; loc[i] = addrprobe_pat[i]; } /* Read address */ - for(i = 0; i < nitems(addrprobe_pat); i++) { - if(loc[i] != addrprobe_pat[i]) + for (i = 0; i < nitems(addrprobe_pat); i++) { + if (loc[i] != addrprobe_pat[i]) ret++; loc[i] = save[i]; } @@ -253,7 +261,8 @@ addrprobe(u_int kloc) return ret; } -/* Probe for all extended memory. +/* + * Probe for all extended memory. * * This is only used as a last resort. If we resort to this * routine, we are getting pretty desperate. Hopefully nobody @@ -269,13 +278,14 @@ badprobe(bios_memmap_t *mp) #ifdef DEBUG printf("scan "); #endif - /* probe extended memory + /* + * probe extended memory * * 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; @@ -298,17 +308,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; } } @@ -322,9 +332,9 @@ 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->type == BIOS_MAP_FREE) && (im->size >= 12 * 1024)) { if (im->size > 1024 * 1024) printf("%uM ", (u_int)(im->size / (1024 * 1024))); @@ -341,17 +351,17 @@ 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 - && (im->addr/1024) == (extmem + 1024)) { + if (im->addr >= IOM_END && + (im->addr / 1024) == (extmem + 1024)) extmem += im->size / 1024; - } } } - /* Adjust extmem to be no more than 4G (which it usually is not + /* + * Adjust extmem to be no more than 4G (which it usually is not * anyways). In order for an x86 type machine (amd64/etc) to use * more than 4GB of memory, it will need to grok and use the bios * memory map we pass it. Note that above we only count CONTIGUOUS @@ -359,8 +369,8 @@ memprobe(void) * * extmem is in KB, and we have 4GB - 1MB (base/io hole) worth of it. */ - if(extmem > 4*1024*1024 - 1024) - extmem = 4*1024*1024 - 1024; + if (extmem > 4 * 1024 * 1024 - 1024) + extmem = 4 * 1024 * 1024 - 1024; /* Check if gate A20 is on */ printf("a20=o%s] ", checkA20()? "n" : "ff!"); @@ -373,15 +383,15 @@ dump_biosmem(bios_memmap_t *tm) register bios_memmap_t *p; register u_int total = 0; - if (!tm) + if (tm == NULL) tm = bios_memmap; - for(p = tm; p->type != BIOS_MAP_END; p++) { - printf("Region %ld: type %u at 0x%llx for %uKB\n", + for (p = tm; p->type != BIOS_MAP_END; p++) { + printf("Region %ld: type %u at 0x%llx for %uKB\n", (long)(p - tm), p->type, p->addr, (u_int)(p->size / 1024)); - if(p->type == BIOS_MAP_FREE) + if (p->type == BIOS_MAP_FREE) total += p->size / 1024; } @@ -422,8 +432,8 @@ mem_delete(long long sa, long 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) { @@ -435,9 +445,9 @@ mem_delete(long long sa, long 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; @@ -470,8 +480,8 @@ mem_add(long long sa, long 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/amd64/stand/libsa/time.c b/sys/arch/amd64/stand/libsa/time.c index 04917cff10a..42c00737565 100644 --- a/sys/arch/amd64/stand/libsa/time.c +++ b/sys/arch/amd64/stand/libsa/time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: time.c,v 1.2 2004/08/18 19:13:07 tom Exp $ */ +/* $OpenBSD: time.c,v 1.3 2012/10/30 14:06:29 jsing Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -42,7 +42,6 @@ static __inline u_int8_t bcdtoint(u_int8_t c) { - return ((c & 0xf0) / 8) * 5 + (c & 0x0f); } @@ -50,8 +49,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 +63,8 @@ compute(int year, u_int8_t month, u_int8_t day, u_int8_t hour, tt = (year - 1970) * 365 + monthcount[month] + day - 1; /* 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 +77,14 @@ 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,19 @@ 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,9 +137,12 @@ sleep(u_int i) { register time_t t; - /* loop for that number of seconds, polling BIOS, - so that it may handle interrupts */ - for (t = getsecs() + i; getsecs() < t; cnischar()); + /* + * Loop for the requested number of seconds, polling BIOS, + * so that it may handle interrupts. + */ + for (t = getsecs() + i; getsecs() < t; cnischar()) + ; return 0; } diff --git a/sys/arch/i386/stand/libsa/bioscons.c b/sys/arch/i386/stand/libsa/bioscons.c index b785cf7d4e8..ff057733b6c 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.33 2012/06/10 21:03:35 kettenis Exp $ */ +/* $OpenBSD: bioscons.c,v 1.34 2012/10/30 14:06:29 jsing Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -228,6 +228,6 @@ com_putc(dev_t dev, int c) while ((inb(port + com_lsr) & LSR_TXRDY) == 0) ; - + outb(port + com_data, c); } diff --git a/sys/arch/i386/stand/libsa/cmd_i386.c b/sys/arch/i386/stand/libsa/cmd_i386.c index 4a2f6f938d0..c0a22fd47c6 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.31 2012/06/03 13:17:47 kettenis Exp $ */ +/* $OpenBSD: cmd_i386.c,v 1.32 2012/10/30 14:06:29 jsing Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -158,7 +158,7 @@ Xmemory(void) size = strtoll(p + 1, &p, 0); /* Size the size */ - switch(*p) { + switch (*p) { case 'G': size *= 1024; case 'M': @@ -169,7 +169,7 @@ Xmemory(void) } /* Handle (possibly non-existant) address part */ - switch(*p) { + switch (*p) { case '@': addr = strtoll(p + 1, NULL, 0); break; diff --git a/sys/arch/i386/stand/libsa/dev_i386.c b/sys/arch/i386/stand/libsa/dev_i386.c index 5ff1e162a5b..e855b579bbf 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.35 2011/06/26 23:19:11 tedu Exp $ */ +/* $OpenBSD: dev_i386.c,v 1.36 2012/10/30 14:06:29 jsing Exp $ */ /* * Copyright (c) 1996-1999 Michael Shalayeff @@ -128,9 +128,9 @@ putchar(int c) pch_pos--; break; case '\t': - do + do { cnputc(' '); - while (++pch_pos % 8); + } while (++pch_pos % 8); break; case '\n': case '\r': @@ -183,7 +183,7 @@ ttydev(char *name) return NODEV; for (i = 0; i < ncdevs; i++) if (strncmp(name, cdevs[i], no - name + 1) == 0) - return (makedev(i, unit)); + return makedev(i, unit); return NODEV; } @@ -191,7 +191,7 @@ 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/exec_i386.c b/sys/arch/i386/stand/libsa/exec_i386.c index d88b2df1d01..d587e4be4a1 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.36 2012/06/03 13:17:47 kettenis Exp $ */ +/* $OpenBSD: exec_i386.c,v 1.37 2012/10/30 14:06:29 jsing Exp $ */ /* * Copyright (c) 1997-1998 Michael Shalayeff @@ -84,10 +84,11 @@ run_loadfile(u_long *marks, int howto) entry = marks[MARK_ENTRY] & 0x0fffffff; - printf("entry point at 0x%x\n", (int) entry); + 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); + (*(startfuncp)entry)(howto, bootdev, BOOTARG_APIVER, 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 aece9b001fb..74c43c4d169 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.50 2010/12/06 22:51:46 jasper Exp $ */ +/* $OpenBSD: memprobe.c,v 1.51 2012/10/30 14:06:29 jsing Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -37,7 +37,8 @@ u_int cnvmem, extmem; /* XXX - compatibility */ -/* Check gateA20 +/* + * Check gateA20 * * A sanity check. */ @@ -60,7 +61,8 @@ checkA20(void) return st; } -/* BIOS int 15, AX=E820 +/* + * BIOS int 15, AX=E820 * * This is the "preferred" method. */ @@ -71,11 +73,10 @@ 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) + "c" (sizeof(*mp)), "D" (((u_int)mp) & 0xf) : "cc", "memory"); off = BIOS_regs.biosr_bx; @@ -96,7 +97,8 @@ bios_E820(bios_memmap_t *mp) } #if 0 -/* BIOS int 15, AX=E801 +/* + * BIOS int 15, AX=E801 * * Only used if int 15, AX=E820 does not work. * This should work for more than 64MB on most @@ -153,7 +155,8 @@ bios_E801(bios_memmap_t *mp) } #endif -/* BIOS int 15, AX=8800 +/* + * BIOS int 15, AX=8800 * * Only used if int 15, AX=E801 does not work. * Machines with this are restricted to 64MB. @@ -179,7 +182,8 @@ bios_8800(bios_memmap_t *mp) return ++mp; } -/* BIOS int 0x12 Get Conventional Memory +/* + * BIOS int 0x12 Get Conventional Memory * * Only used if int 15, AX=E820 does not work. */ @@ -201,7 +205,8 @@ bios_int12(bios_memmap_t *mp) } -/* addrprobe(kloc): Probe memory at address kloc * 1024. +/* + * addrprobe(kloc): Probe memory at address kloc * 1024. * * This is a hack, but it seems to work ok. Maybe this is * the *real* way that you are supposed to do probing??? @@ -256,7 +261,8 @@ addrprobe(u_int kloc) return ret; } -/* Probe for all extended memory. +/* + * Probe for all extended memory. * * This is only used as a last resort. If we resort to this * routine, we are getting pretty desperate. Hopefully nobody @@ -272,7 +278,8 @@ badprobe(bios_memmap_t *mp) #ifdef DEBUG printf("scan "); #endif - /* probe extended memory + /* + * probe extended memory * * There is no need to do this in assembly language. This is * much easier to debug in C anyways. @@ -330,7 +337,7 @@ memprobe(void) extmem = cnvmem = 0; 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->type == BIOS_MAP_FREE) && (im->size >= 12 * 1024)) { if (im->size > 1024 * 1024) printf("%uM ", (u_int)(im->size / (1024 * 1024))); diff --git a/sys/arch/i386/stand/libsa/pxeboot.h b/sys/arch/i386/stand/libsa/pxeboot.h index e2a6a28f05c..a4d3dfe925a 100644 --- a/sys/arch/i386/stand/libsa/pxeboot.h +++ b/sys/arch/i386/stand/libsa/pxeboot.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pxeboot.h,v 1.1 2004/03/19 13:48:18 tom Exp $ */ +/* $OpenBSD: pxeboot.h,v 1.2 2012/10/30 14:06:29 jsing Exp $ */ /* $NetBSD$ */ /* diff --git a/sys/arch/i386/stand/libsa/time.c b/sys/arch/i386/stand/libsa/time.c index eca29d3c6ac..581e2f8b87e 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.16 2004/08/17 15:11:31 tom Exp $ */ +/* $OpenBSD: time.c,v 1.17 2012/10/30 14:06:29 jsing Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -42,7 +42,6 @@ static __inline u_int8_t bcdtoint(u_int8_t c) { - return ((c & 0xf0) / 8) * 5 + (c & 0x0f); } @@ -85,6 +84,7 @@ bios_time_date(int f, u_int8_t *b) "movb %%dl, 3(%2)\n\t" : "=a" (f) : "0" (f), "p" (b) : "%ecx", "%edx", "cc"); + if (f & 0xff) return -1; else { @@ -124,9 +124,8 @@ getsecs(void) 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; @@ -142,7 +141,8 @@ sleep(u_int i) * Loop for the requested number of seconds, polling BIOS, * so that it may handle interrupts. */ - for (t = getsecs() + i; getsecs() < t; cnischar()); + for (t = getsecs() + i; getsecs() < t; cnischar()) + ; return 0; } |