diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2008-03-08 16:52:29 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2008-03-08 16:52:29 +0000 |
commit | d858cb17f64d3762954e916e6ae1036179de572a (patch) | |
tree | f36aaa1922d8d907172680249967fdc6b82d05f8 | |
parent | 45802bf39881ca072256d5076aee7a6d41b37bf9 (diff) |
Cleanup/style(9) code and comments.
-rw-r--r-- | sys/arch/sgi/stand/boot/arcbios.c | 76 | ||||
-rw-r--r-- | sys/arch/sgi/stand/boot/boot.c | 128 | ||||
-rw-r--r-- | sys/arch/sgi/stand/boot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/sgi/stand/boot/diskio.c | 26 | ||||
-rw-r--r-- | sys/arch/sgi/stand/boot/filesystem.c | 3 | ||||
-rw-r--r-- | sys/arch/sgi/stand/boot/start.S | 4 |
6 files changed, 116 insertions, 125 deletions
diff --git a/sys/arch/sgi/stand/boot/arcbios.c b/sys/arch/sgi/stand/boot/arcbios.c index d012ea5de31..109435c9842 100644 --- a/sys/arch/sgi/stand/boot/arcbios.c +++ b/sys/arch/sgi/stand/boot/arcbios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arcbios.c,v 1.5 2008/02/19 13:18:50 jsing Exp $ */ +/* $OpenBSD: arcbios.c,v 1.6 2008/03/08 16:52:28 jsing Exp $ */ /*- * Copyright (c) 1996 M. Warner Losh. All rights reserved. * Copyright (c) 1996-2004 Opsycon AB. All rights reserved. @@ -34,15 +34,15 @@ #define USE_SGI_PARTITIONS 1 -void bios_configure_memory(void); -int bios_get_system_type(void); +void bios_configure_memory(void); +int bios_get_system_type(void); const char *bios_get_path_component(const char *, char *, int *); -arc_dsp_stat_t displayinfo; /* Save area for display status info. */ +arc_dsp_stat_t displayinfo; /* Save area for display status info. */ static struct systypes { - char *sys_vend; /* Vendor ID if name is ambigous */ - char *sys_name; /* May be left NULL if name is sufficient */ + char *sys_vend; /* Vendor ID if name is ambiguous. */ + char *sys_name; /* May be left NULL if name is sufficient. */ int sys_type; } sys_types[] = { { NULL, "PICA-61", ACER_PICA_61 }, @@ -58,13 +58,13 @@ static struct systypes { { NULL, "SGI-IP22", SGI_INDY }, { NULL, "SGI-IP25", SGI_POWER10 }, { NULL, "SGI-IP26", SGI_POWERI }, - { NULL, "SGI-IP32", SGI_O2 }, + { NULL, "SGI-IP32", SGI_O2 } }; #define KNOWNSYSTEMS (sizeof(sys_types) / sizeof(struct systypes)) /* - * ARC Bios trampoline code. + * ARCBios trampoline code. */ #define ARC_Call(Name,Offset) \ __asm__("\n" \ @@ -119,26 +119,26 @@ ARC_Call(Bios_TestUnicodeCharacter, 0x8c); ARC_Call(Bios_GetDisplayStatus, 0x90); /* - * Simple getchar/putchar interface. + * Simple getchar/putchar interface. */ int getchar() { char buf[4]; - int cnt; + int cnt; if (Bios_Read(0, &buf[0], 1, &cnt) != 0) - return(-1); - return(buf[0] & 255); + return (-1); + + return (buf[0] & 255); } void -putchar(c) -char c; +putchar(int c) { char buf[4]; - int cnt; + int cnt; if (c == '\n') { buf[0] = '\r'; @@ -146,36 +146,34 @@ char c; cnt = 2; if (displayinfo.CursorYPosition < displayinfo.CursorMaxYPosition) displayinfo.CursorYPosition++; - } - else { + } else { buf[0] = c; cnt = 1; } + Bios_Write(1, &buf[0], cnt, &cnt); } void -bios_putstring(s) -char *s; +bios_putstring(char *s) { - while (*s) { + while (*s) putchar(*s++); - } } /* - * Find out system type. + * Identify system type. */ int bios_get_system_type() { - arc_config_t *cf; - arc_sid_t *sid; - int i; + arc_config_t *cf; + arc_sid_t *sid; + int i; if ((ArcBiosBase32->magic != ARC_PARAM_BLK_MAGIC) && (ArcBiosBase32->magic != ARC_PARAM_BLK_MAGIC_BUG)) { - return(-1); /* This is not an ARC system */ + return (-1); /* This is not an ARC system. */ } sid = (arc_sid_t *)Bios_GetSystemId(); @@ -201,7 +199,7 @@ bios_get_system_type() bios_putstring(sid->vendor); bios_putstring("'. Please contact OpenBSD (www.openbsd.org).\n"); bios_putstring("Reset system to restart!\n"); - while(1); + while (1); } /* @@ -209,11 +207,7 @@ bios_get_system_type() * display configuration. */ void -bios_display_info(xpos, ypos, xsize, ysize) - int *xpos; - int *ypos; - int *xsize; - int *ysize; +bios_display_info(int *xpos, int *ypos, int *xsize, int *ysize) { #ifdef __arc__ *xpos = displayinfo.CursorXPosition; @@ -223,7 +217,6 @@ bios_display_info(xpos, ypos, xsize, ysize) #endif } - /* * Decompose the device pathname and find driver. * Returns pointer to remaining filename path in file. @@ -241,7 +234,7 @@ devopen(struct open_file *f, const char *fname, char **file) ecp = cp = fname; /* - * Scan the component list and find device and partition. + * Scan the component list and find device and partition. */ while ((ncp = bios_get_path_component(cp, namebuf, &i)) != NULL) { if (strcmp(namebuf, "partition") == 0) { @@ -251,7 +244,7 @@ devopen(struct open_file *f, const char *fname, char **file) } else ecp = ncp; - /* XXX do this with a table if more devs are added */ + /* XXX Do this with a table if more devs are added. */ if (strcmp(namebuf, "scsi") == 0) strncpy(devname, namebuf, sizeof(devname)); @@ -262,7 +255,7 @@ devopen(struct open_file *f, const char *fname, char **file) namebuf[ecp - fname] = '\0'; /* - * Dig out the driver. + * Dig out the driver. */ dp = devsw; n = ndevs; @@ -278,19 +271,18 @@ devopen(struct open_file *f, const char *fname, char **file) } dp++; } - return ENXIO; + return (ENXIO); } const char * bios_get_path_component(const char *p, char *comp, int *no) { - while (*p && *p != '(') { + while (*p && *p != '(') *comp++ = *p++; - } *comp = '\0'; if (*p == NULL) - return NULL; + return (NULL); *no = 0; p++; @@ -298,7 +290,7 @@ bios_get_path_component(const char *p, char *comp, int *no) if (*p >= '0' && *p <= '9') *no = *no * 10 + *p++ - '0'; else - return NULL; + return (NULL); } - return ++p; + return (++p); } diff --git a/sys/arch/sgi/stand/boot/boot.c b/sys/arch/sgi/stand/boot/boot.c index 0366ab00a9e..0bc0e1b7cc5 100644 --- a/sys/arch/sgi/stand/boot/boot.c +++ b/sys/arch/sgi/stand/boot/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.8 2007/05/11 10:28:20 jj Exp $ */ +/* $OpenBSD: boot.c,v 1.9 2008/03/08 16:52:28 jsing Exp $ */ /* * Copyright (c) 2004 Opsycon AB, www.opsycon.se. @@ -34,17 +34,17 @@ #include <mips64/arcbios.h> -void gets(char *); -ssize_t read(int, void *, size_t); -int close(int); +void gets(char *); +ssize_t read(int, void *, size_t); +int close(int); -int main(int, char **); -void dobootopts(int, char **); +int main(int, char **); +void dobootopts(int, char **); Elf32_Addr loadfile(char *); Elf32_Addr loadfile32(int, Elf32_Ehdr *); Elf32_Addr loadfile64(int, Elf64_Ehdr *); -int loadsymtab32(int, Elf32_Ehdr *, int); -int loadsymtab64(int, Elf64_Ehdr *, int); +int loadsymtab32(int, Elf32_Ehdr *, int); +int loadsymtab64(int, Elf64_Ehdr *, int); enum { AUTO_NONE, @@ -53,6 +53,7 @@ enum { AUTO_MINI, AUTO_DEBUG } bootauto = AUTO_NONE; + char *OSLoadPartition = NULL; char *OSLoadFilename = NULL; @@ -63,10 +64,10 @@ readtable(int fd, int offs, void *base, int size, char *name, int flags) { if (lseek(fd, offs, SEEK_SET) != offs || read(fd, base, size) != size) { - printf("\ncannot read %s table", name); - return 0; + printf("\nCannot read %s table!", name); + return (0); } - return (void *) base; + return ((void *) base); } static void * @@ -74,20 +75,21 @@ gettable(int size, char *name, int flags, size_t align) { long base; - /* Put table after loaded code to support kernel DDB */ + /* Put table after loaded code to support kernel DDB. */ tablebase = roundup(tablebase, align); base = tablebase; tablebase += size; - return (void *) base; + return ((void *) base); } /* + * OpenBSD/sgi boot loader. */ int main(int argc, char *argv[]) { - char line[1024]; - int i; + char line[1024]; + int i; Elf32_Addr entry; dobootopts(argc, argv); @@ -95,25 +97,28 @@ main(int argc, char *argv[]) strlcpy(line, OSLoadPartition, sizeof(line)); i = strlen(line); if (OSLoadFilename != NULL) - strlcpy(&line[i], OSLoadFilename, sizeof(line) - i -1); + strlcpy(&line[i], OSLoadFilename, sizeof(line) - i - 1); } else strlcpy("invalid argument setup", line, sizeof(line)); for (entry = 0; entry < argc; entry++) printf("arg %d: %s\n", entry, argv[entry]); - printf("\nOpenBSD/sgi Arcbios boot\n"); + + printf("\nOpenBSD/sgi ARCBios boot\n"); printf("Boot: %s\n", line); entry = loadfile(line); if (entry != NULL) ((void (*)())entry)(argc, argv); + + /* We failed to load the kernel. */ printf("Boot FAILED!\n "); Bios_Restart(); } /* - * Decode boot options. + * Decode boot options. */ void dobootopts(int argc, char **argv) @@ -142,7 +147,8 @@ dobootopts(int argc, char **argv) else if (strncmp(cp, "SystemPartition=", 16) == 0) SystemPartition = &cp[16]; } - /* If "OSLoadOptions=" is missing, see if any arg was given */ + + /* If "OSLoadOptions=" is missing, see if any arg was given. */ if (bootauto == AUTO_NONE && *argv[1] == '/') OSLoadFilename = argv[1]; @@ -165,41 +171,39 @@ dobootopts(int argc, char **argv) * Open 'filename', read in program and return the entry point or -1 if error. */ Elf32_Addr -loadfile(fname) - register char *fname; +loadfile(register char *fname) { union { Elf32_Ehdr eh32; Elf64_Ehdr eh64; } eh; int fd; - Elf32_Addr entry; + Elf32_Addr entry = NULL; if ((fd = open(fname, 0)) < 0) { - printf("can't open file %s\n", fname); - return NULL; + printf("Cannot open file %s!\n", fname); + return (NULL); } - /* read the ELF header and check that it IS an ELF header */ + /* Read the ELF header and check that it IS an ELF header. */ if (read(fd, (char *)&eh, sizeof(eh)) != sizeof(eh)) { - printf("error: ELF header read error\n"); - return NULL; + printf("Error: ELF header read error.\n"); + return (NULL); } if (!IS_ELF(eh.eh32)) { - printf("not an elf file\n"); - return NULL; + printf("Not an ELF file.\n"); + return (NULL); } - /* Determine CLASS */ + /* Determine CLASS. */ if (eh.eh32.e_ident[EI_CLASS] == ELFCLASS32) entry = loadfile32(fd, (void *)&eh); else if (eh.eh32.e_ident[EI_CLASS] == ELFCLASS64) entry = loadfile64(fd, (void *)&eh); - else { - printf("unknown ELF class\n"); - return NULL; - } - return entry; + else + printf("Unknown ELF class.\n"); + + return (entry); } Elf32_Addr @@ -212,8 +216,8 @@ loadfile32(int fd, Elf32_Ehdr *eh) ph = (Elf32_Phdr *) buf; lseek(fd, eh->e_phoff, 0); if (read(fd, (char *)ph, 4096) != 4096) { - printf("unexpected EOF\n"); - return NULL; + printf("Unexpected EOF!\n"); + return (NULL); } tablebase = 0; @@ -225,17 +229,17 @@ loadfile32(int fd, Elf32_Ehdr *eh) printf("0x%x:0x%x, ",(long)ph->p_paddr, (long)ph->p_filesz); if (read(fd, (char *)ph->p_paddr, ph->p_filesz) != ph->p_filesz) { - printf("unexpected EOF\n"); - return NULL; + printf("Unexpected EOF!\n"); + return (NULL); } - if(ph->p_memsz > ph->p_filesz) { + if (ph->p_memsz > ph->p_filesz) { printf("Zero 0x%x:0x%x, ", (long)(ph->p_paddr + ph->p_filesz), (long)(ph->p_memsz - ph->p_filesz)); bzero((void *)(ph->p_paddr + ph->p_filesz), ph->p_memsz - ph->p_filesz); } - if((ph->p_paddr + ph->p_memsz) > tablebase) + if ((ph->p_paddr + ph->p_memsz) > tablebase) tablebase = ph->p_paddr + ph->p_memsz; } } @@ -255,8 +259,8 @@ loadfile64(int fd, Elf64_Ehdr *eh) ph = (Elf64_Phdr *) buf; lseek(fd, eh->e_phoff, 0); if (read(fd, (char *)ph, 4096) != 4096) { - printf("unexpected EOF\n"); - return NULL; + printf("Unexpected EOF!\n"); + return (NULL); } tablebase = 0; @@ -268,17 +272,17 @@ loadfile64(int fd, Elf64_Ehdr *eh) printf("0x%llx:0x%llx, ",ph->p_paddr, ph->p_filesz); if (read(fd, (char *)(long)ph->p_paddr, ph->p_filesz) != ph->p_filesz) { - printf("unexpected EOF\n"); - return NULL; + printf("Unexpected EOF!\n"); + return (NULL); } - if(ph->p_memsz > ph->p_filesz) { + if (ph->p_memsz > ph->p_filesz) { printf("Zero 0x%llx:0x%llx, ", ph->p_paddr + ph->p_filesz, ph->p_memsz - ph->p_filesz); bzero((void *)(long)(ph->p_paddr + ph->p_filesz), ph->p_memsz - ph->p_filesz); } - if((ph->p_paddr + ph->p_memsz) > tablebase) + if ((ph->p_paddr + ph->p_memsz) > tablebase) tablebase = ph->p_paddr + ph->p_memsz; } } @@ -305,7 +309,7 @@ loadsymtab32(int fd, Elf32_Ehdr *eh, int flags) if (lseek (fd, eh->e_shoff, SEEK_SET) != eh->e_shoff || read (fd, shtab, size) != size) { printf("Seek to section headers failed.\n"); - return -1; + return (-1); } tablebase = roundup(tablebase, sizeof(long)); @@ -327,7 +331,7 @@ loadsymtab32(int fd, Elf32_Ehdr *eh, int flags) } if (i >= eh->e_shnum) { printf("No symbol table found!\n"); - return -1; + return (-1); } strh = &ksh[sh->sh_link]; @@ -336,8 +340,8 @@ loadsymtab32(int fd, Elf32_Ehdr *eh, int flags) size = sh->sh_size; /* - * Allocate tables in correct order so the kernel groks it. - * Then we read them in the order they are in the ELF file. + * Allocate tables in correct order so that the kernel groks it. + * Then we read them in the order they are in the ELF file. */ shstrtab = gettable(shstrh->sh_size, "shstrtab", flags, sizeof(long)); strtab = gettable(strh->sh_size, "strtab", flags, sizeof(long)); @@ -384,10 +388,10 @@ loadsymtab32(int fd, Elf32_Ehdr *eh, int flags) if (offs == 0x7fffffff && strh->sh_offset == 0x7fffffff && shstrh->sh_offset == 0x7fffffff) break; - } while(1); + } while (1); /* - * Update the kernel headers with the current info. + * Update the kernel headers with the current info. */ shstrh->sh_offset = (Elf32_Off)shstrtab - (Elf32_Off)keh; strh->sh_offset = (Elf32_Off)strtab - (Elf32_Off)keh; @@ -402,7 +406,6 @@ loadsymtab32(int fd, Elf32_Ehdr *eh, int flags) symptr[1] = roundup((int)symend, sizeof(int)); return(0); - } int @@ -424,7 +427,7 @@ loadsymtab64(int fd, Elf64_Ehdr *eh, int flags) if (lseek (fd, (int)eh->e_shoff, SEEK_SET) != (int)eh->e_shoff || read (fd, shtab, size) != size) { printf("Seek to section headers failed.\n"); - return -1; + return (-1); } tablebase = roundup(tablebase, sizeof(u_int64_t)); @@ -448,7 +451,7 @@ loadsymtab64(int fd, Elf64_Ehdr *eh, int flags) } if (i >= eh->e_shnum) { printf("No symbol table found!\n"); - return -1; + return (-1); } strh = &ksh[sh->sh_link]; @@ -457,8 +460,8 @@ loadsymtab64(int fd, Elf64_Ehdr *eh, int flags) size = sh->sh_size; /* - * Allocate tables in correct order so the kernel groks it. - * Then we read them in the order they are in the ELF file. + * Allocate tables in correct order so that the kernel groks it. + * Then we read them in the order they are in the ELF file. */ shstrtab = gettable(shstrh->sh_size, "shstrtab", flags, sizeof(u_int64_t)); strtab = gettable(strh->sh_size, "strtab", flags, sizeof(u_int64_t)); @@ -479,7 +482,7 @@ loadsymtab64(int fd, Elf64_Ehdr *eh, int flags) */ if (!readtable (shstrh->sh_offset, (void *)shstrtab, shstrh->sh_size, "shstring", flags)) - return(0); + return (0); #else memset(shstrtab, 0, shstrh->sh_size); strncpy(shstrtab + shstrh->sh_name, ".shstrtab", 10); @@ -506,10 +509,10 @@ loadsymtab64(int fd, Elf64_Ehdr *eh, int flags) if (offs == 0x7fffffff && strh->sh_offset == 0x7fffffff && shstrh->sh_offset == 0x7fffffff) break; - } while(1); + } while (1); /* - * Update the kernel headers with the current info. + * Update the kernel headers with the current info. */ shstrh->sh_offset = (Elf64_Off)(long)shstrtab - (Elf64_Off)(long)keh; strh->sh_offset = (Elf64_Off)(long)strtab - (Elf64_Off)(long)keh; @@ -523,6 +526,5 @@ loadsymtab64(int fd, Elf64_Ehdr *eh, int flags) symptr[0] = (Elf64_Off)keh; symptr[1] = (Elf64_Off)roundup((Elf64_Off)symend, sizeof(u_int64_t)); - return(0); - + return (0); } diff --git a/sys/arch/sgi/stand/boot/conf.c b/sys/arch/sgi/stand/boot/conf.c index 645283c946b..683f526e293 100644 --- a/sys/arch/sgi/stand/boot/conf.c +++ b/sys/arch/sgi/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.1 2004/08/23 14:22:40 pefo Exp $ */ +/* $OpenBSD: conf.c,v 1.2 2008/03/08 16:52:28 jsing Exp $ */ /* * Copyright (c) 1997 Per Fogelstrom @@ -40,7 +40,7 @@ int dioclose(struct open_file *); #define dioioctl noioctl struct devsw devsw[] = { - { "scsi", diostrategy, dioopen, dioclose, dioioctl }, /*0*/ + { "scsi", diostrategy, dioopen, dioclose, dioioctl } }; int ndevs = (sizeof(devsw)/sizeof(devsw[0])); diff --git a/sys/arch/sgi/stand/boot/diskio.c b/sys/arch/sgi/stand/boot/diskio.c index ddf49211bdd..a1a151c8fd8 100644 --- a/sys/arch/sgi/stand/boot/diskio.c +++ b/sys/arch/sgi/stand/boot/diskio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diskio.c,v 1.2 2004/09/16 18:54:48 pefo Exp $ */ +/* $OpenBSD: diskio.c,v 1.3 2008/03/08 16:52:28 jsing Exp $ */ /* * Copyright (c) 2000 Opsycon AB (www.opsycon.se) @@ -38,16 +38,15 @@ #include <sys/disklabel.h> #include <mips64/arcbios.h> - struct dio_softc { - int sc_fd; /* PROM file id */ - int sc_part; /* disk partition number */ - struct disklabel sc_label; /* disk label for this disk */ + int sc_fd; /* PROM file ID */ + int sc_part; /* Disk partition number. */ + struct disklabel sc_label; /* Disk label for this disk. */ }; int -diostrategy(void *devdata, int rw, daddr_t bn, u_int reqcnt, - char *addr, u_int *cnt) +diostrategy(void *devdata, int rw, daddr_t bn, u_int reqcnt, char *addr, + u_int *cnt) { struct dio_softc *sc = (struct dio_softc *)devdata; struct partition *pp = &sc->sc_label.d_partitions[sc->sc_part]; @@ -58,7 +57,7 @@ diostrategy(void *devdata, int rw, daddr_t bn, u_int reqcnt, if ((Bios_Seek(sc->sc_fd, &offset, 0) < 0) || (Bios_Read(sc->sc_fd, addr, reqcnt, &result) < 0)) - return EIO; + return (EIO); *cnt = result; return (0); @@ -103,7 +102,7 @@ dioopen(struct open_file *f, ...) labelsector = LABELSECTOR; #if 0 - /* try to read disk label and partition table information */ + /* Try to read disk label and partition table information. */ i = diostrategy(sc, F_READ, (daddr_t)labelsector, DEV_BSIZE, buf, &cnt); if (i == 0 && cnt == DEV_BSIZE) @@ -113,19 +112,18 @@ dioopen(struct open_file *f, ...) if (msg) { printf("%s: %s\n", ctlr, msg); - return ENXIO; + return (ENXIO); } #endif - return 0; + return (0); } int -dioclose(f) - struct open_file *f; +dioclose(struct open_file *f) { Bios_Close(((struct dio_softc *)f->f_devdata)->sc_fd); free(f->f_devdata, sizeof(struct dio_softc)); f->f_devdata = NULL; - return 0; + return (0); } diff --git a/sys/arch/sgi/stand/boot/filesystem.c b/sys/arch/sgi/stand/boot/filesystem.c index b35709b9ad2..e4f0fce6f00 100644 --- a/sys/arch/sgi/stand/boot/filesystem.c +++ b/sys/arch/sgi/stand/boot/filesystem.c @@ -37,8 +37,7 @@ #include <ufs.h> struct fs_ops file_system[] = { - { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }, + { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat } }; int nfsys = sizeof(file_system)/sizeof(struct fs_ops); - diff --git a/sys/arch/sgi/stand/boot/start.S b/sys/arch/sgi/stand/boot/start.S index 36f6fcccf9b..e2866f521b8 100644 --- a/sys/arch/sgi/stand/boot/start.S +++ b/sys/arch/sgi/stand/boot/start.S @@ -1,4 +1,4 @@ -/* $OpenBSD: start.S,v 1.1 2004/08/23 14:22:40 pefo Exp $ */ +/* $OpenBSD: start.S,v 1.2 2008/03/08 16:52:28 jsing Exp $ */ /* * Copyright (c) 2001 Opsycon AB (www.opsycon.se) @@ -38,7 +38,7 @@ #include <machine/asm.h> /* - * Frame required for the debugger (if we have any) + * Frame required for the debugger (if we have any). */ #define START_FRAME ((4 * 4) + 4 + 4) |