- full ansi prototypes

- turn WARNS=3 on
This commit is contained in:
christos 2004-06-30 15:43:57 +00:00
parent 737ab05bf9
commit 45879fd71c
9 changed files with 192 additions and 186 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: Locore.c,v 1.1 2002/02/10 01:58:15 thorpej Exp $ */
/* $NetBSD: Locore.c,v 1.2 2004/06/30 15:43:57 christos Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -38,13 +38,14 @@
#include <arm/armreg.h>
#include "cache.h"
#include "extern.h"
#include "openfirm.h"
static int (*openfirmware_entry) __P((void *));
static int openfirmware __P((void *));
static int (*openfirmware_entry)(void *);
static int openfirmware(void *);
void startup __P((int (*)(void *), char *, int));
static void setup __P((void));
void startup(int (*)(void *), char *, int);
static void setup(void);
void (*cache_syncI)(void);
@ -53,7 +54,8 @@ void abort(void)
{
/* Stupid compiler (__dead). */
for (;;) ;
for (;;)
continue;
}
static int
@ -61,7 +63,8 @@ openfirmware(arg)
void *arg;
{
openfirmware_entry(arg);
(*openfirmware_entry)(arg);
return 0;
}
static vaddr_t
@ -82,10 +85,7 @@ ofw_getcleaninfo(void)
}
void
startup(openfirm, arg, argl)
int (*openfirm)(void *);
char *arg;
int argl;
startup(int (*openfirm)(void *), char *arg, int argl)
{
u_int cputype = cpufunc_id() & CPU_ID_CPU_MASK;
@ -120,10 +120,10 @@ of_decode_int(const u_char *p)
}
__dead void
OF_exit()
OF_exit(void)
{
static struct {
char *name;
const char *name;
int nargs;
int nreturns;
} args = {
@ -137,14 +137,13 @@ OF_exit()
}
int
OF_finddevice(name)
char *name;
OF_finddevice(const char *name)
{
static struct {
char *name;
const char *name;
int nargs;
int nreturns;
char *device;
const char *device;
int phandle;
} args = {
"finddevice",
@ -159,11 +158,10 @@ OF_finddevice(name)
}
int
OF_instance_to_package(ihandle)
int ihandle;
OF_instance_to_package(int ihandle)
{
static struct {
char *name;
const char *name;
int nargs;
int nreturns;
int ihandle;
@ -181,18 +179,14 @@ OF_instance_to_package(ihandle)
}
int
OF_getprop(handle, prop, buf, buflen)
int handle;
char *prop;
void *buf;
int buflen;
OF_getprop(int handle, const char *prop, void *buf, int buflen)
{
static struct {
char *name;
const char *name;
int nargs;
int nreturns;
int phandle;
char *prop;
const char *prop;
void *buf;
int buflen;
int size;
@ -213,18 +207,14 @@ OF_getprop(handle, prop, buf, buflen)
#ifdef __notyet__ /* Has a bug on FirePower */
int
OF_setprop(handle, prop, buf, len)
int handle;
char *prop;
void *buf;
int len;
OF_setprop(int handle, const char *prop, void *buf, int len)
{
static struct {
char *name;
const char *name;
int nargs;
int nreturns;
int phandle;
char *prop;
const char *prop;
void *buf;
int len;
int size;
@ -245,11 +235,10 @@ OF_setprop(handle, prop, buf, len)
#endif
int
OF_open(dname)
char *dname;
OF_open(char *dname)
{
static struct {
char *name;
const char *name;
int nargs;
int nreturns;
char *dname;
@ -278,11 +267,10 @@ OF_open(dname)
}
void
OF_close(handle)
int handle;
OF_close(int handle)
{
static struct {
char *name;
const char *name;
int nargs;
int nreturns;
int handle;
@ -300,13 +288,10 @@ OF_close(handle)
}
int
OF_write(handle, addr, len)
int handle;
void *addr;
int len;
OF_write(int handle, void *addr, int len)
{
static struct {
char *name;
const char *name;
int nargs;
int nreturns;
int ihandle;
@ -340,13 +325,10 @@ OF_write(handle, addr, len)
}
int
OF_read(handle, addr, len)
int handle;
void *addr;
int len;
OF_read(int handle, void *addr, int len)
{
static struct {
char *name;
const char *name;
int nargs;
int nreturns;
int ihandle;
@ -380,12 +362,10 @@ OF_read(handle, addr, len)
}
int
OF_seek(handle, pos)
int handle;
u_quad_t pos;
OF_seek(int handle, u_quad_t pos)
{
static struct {
char *name;
const char *name;
int nargs;
int nreturns;
int handle;
@ -417,13 +397,10 @@ OF_seek(handle, pos)
}
void *
OF_claim(virt, size, align)
void *virt;
u_int size;
u_int align;
OF_claim(void *virt, u_int size, u_int align)
{
static struct {
char *name;
const char *name;
int nargs;
int nreturns;
void *virt;
@ -455,12 +432,10 @@ OF_claim(virt, size, align)
}
void
OF_release(virt, size)
void *virt;
u_int size;
OF_release(void *virt, u_int size)
{
static struct {
char *name;
const char *name;
int nargs;
int nreturns;
void *virt;
@ -480,10 +455,10 @@ OF_release(virt, size)
}
int
OF_milliseconds()
OF_milliseconds(void)
{
static struct {
char *name;
const char *name;
int nargs;
int nreturns;
int ms;
@ -498,20 +473,16 @@ OF_milliseconds()
}
void
OF_chain(virt, size, entry, arg, len)
void *virt;
u_int size;
void (*entry)();
void *arg;
u_int len;
OF_chain(void *virt, u_int size, void (*entry)(int (*)(void *), void *, u_int),
void *arg, u_int len)
{
struct {
char *name;
const char *name;
int nargs;
int nreturns;
void *virt;
u_int size;
void (*entry)();
void (*entry)(int (*)(void *), void *, u_int);
void *arg;
u_int len;
} args;
@ -535,7 +506,7 @@ static int stdin;
static int stdout;
static void
setup()
setup(void)
{
u_char buf[sizeof(int)];
int chosen;
@ -553,8 +524,7 @@ setup()
}
void
putchar(c)
int c;
putchar(int c)
{
char ch = c;
@ -564,7 +534,7 @@ putchar(c)
}
int
getchar()
getchar(void)
{
unsigned char ch = '\0';
int l;

View File

@ -1,7 +1,8 @@
# $NetBSD: Makefile,v 1.5 2003/10/26 07:25:37 lukem Exp $
# $NetBSD: Makefile,v 1.6 2004/06/30 15:43:57 christos Exp $
S= ${.CURDIR}/../../../..
WARNS= 3
PROG= ofwboot
SRCS= srt0.S Locore.c alloc.c boot.c ofdev.c net.c netif_of.c vers.c
CFLAGS+= -Wno-main

View File

@ -1,4 +1,4 @@
/* $NetBSD: alloc.c,v 1.1 2002/02/10 01:58:16 thorpej Exp $ */
/* $NetBSD: alloc.c,v 1.2 2004/06/30 15:43:57 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -89,6 +89,7 @@
#include <lib/libsa/stand.h>
#include "openfirm.h"
#include "extern.h"
/*
* Each block actually has ALIGN(struct ml) + ALIGN(size) bytes allocated
@ -233,7 +234,7 @@ free(ptr, size)
}
void
freeall()
freeall(void)
{
struct ml *m;

View File

@ -1,5 +1,5 @@
#define DEBUG
/* $NetBSD: boot.c,v 1.2 2002/02/10 18:28:13 wiz Exp $ */
/* $NetBSD: boot.c,v 1.3 2004/06/30 15:43:57 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -91,6 +91,7 @@
#include <machine/cpu.h>
#include "cache.h"
#include "extern.h"
#include "ofdev.h"
#include "openfirm.h"
@ -105,12 +106,15 @@ char bootfile[128];
int boothowto;
int debug;
#ifdef notyet
static int ofw_version = 0;
static char *kernels[] = { "/netbsd", "/netbsd.gz", "/netbsd.shark", NULL };
#endif
static const char *kernels[] = {
"/netbsd", "/netbsd.gz", "/netbsd.shark", NULL
};
static void
prom2boot(dev)
char *dev;
prom2boot(char *dev)
{
char *cp, *ocp;
@ -125,9 +129,7 @@ prom2boot(dev)
}
static void
parseargs(str, howtop)
char *str;
int *howtop;
parseargs(char *str, int *howtop)
{
char *cp;
@ -150,12 +152,10 @@ parseargs(str, howtop)
}
static void
chain(entry, args, ssym, esym)
void (*entry)();
char *args;
void *ssym, *esym;
chain(void (*entry)(int (*)(void *), void *, u_int), char *args, void *ssym,
void *esym)
{
extern char end[], *cp;
extern char end[];
u_int l, magic = 0x19730224;
freeall();
@ -184,18 +184,18 @@ chain(entry, args, ssym, esym)
}
__dead void
_rtt()
_rtt(void)
{
OF_exit();
}
void
main()
main(void)
{
extern char bootprog_name[], bootprog_rev[],
bootprog_maker[], bootprog_date[];
int chosen, options;
int chosen;
char bootline[512]; /* Should check size? */
char *cp, *startbuf, *endbuf;
u_long marks[MARK_MAX], size;

View File

@ -0,0 +1,50 @@
/* $NetBSD: extern.h,v 1.1 2004/06/30 15:43:57 christos Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``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 FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _OFWBOOT_EXTERN_H_
#define _OFWBOOT_EXTERN_H_
void freeall(void);
void main(void);
struct of_dev;
int net_open(struct of_dev *);
int net_close(struct of_dev *);
int net_mountroot(void);
#endif /* _OFWBOOT_EXTERN_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: net.c,v 1.2 2003/03/13 15:36:07 drochner Exp $ */
/* $NetBSD: net.c,v 1.3 2004/06/30 15:43:57 christos Exp $ */
/*
* Copyright (C) 1995 Wolfgang Solfrank.
@ -59,9 +59,12 @@
#include <lib/libsa/stand.h>
#include <lib/libsa/net.h>
#include <lib/libsa/bootp.h>
#include <lib/libsa/nfs.h>
#include <lib/libkern/libkern.h>
#include "extern.h"
#include "ofdev.h"
#include "netif_of.h"
@ -75,8 +78,7 @@ static int open_count;
* This opens the low-level device and sets f->f_devdata.
*/
int
net_open(op)
struct of_dev *op;
net_open(struct of_dev *op)
{
int error = 0;
@ -102,8 +104,7 @@ bad:
}
int
net_close(op)
struct of_dev *op;
net_close(struct of_dev *op)
{
/*
* On last close, do netif close, etc.
@ -113,10 +114,11 @@ net_close(op)
netif_of_close(netdev_sock);
netdev_sock = -1;
}
return 0;
}
int
net_mountroot()
net_mountroot(void)
{
#ifdef DEBUG

View File

@ -1,4 +1,4 @@
/* $NetBSD: netif_of.c,v 1.2 2003/03/13 15:36:07 drochner Exp $ */
/* $NetBSD: netif_of.c,v 1.3 2004/06/30 15:43:57 christos Exp $ */
/*
* Copyright (C) 1995 Wolfgang Solfrank.
@ -59,8 +59,7 @@
static struct iodesc sdesc;
struct iodesc *
socktodesc(sock)
int sock;
socktodesc(int sock)
{
if (sock != 0)
return NULL;
@ -68,12 +67,9 @@ socktodesc(sock)
}
int
netif_of_open(op)
struct of_dev *op;
netif_of_open(struct of_dev *op)
{
struct iodesc *io;
int fd, error;
char addr[32];
#ifdef NETIF_DEBUG
printf("netif_open...");
@ -87,7 +83,7 @@ netif_of_open(op)
errno = ENFILE;
return -1;
}
memset(io, 0, sizeof *io);
(void)memset(io, 0, sizeof *io);
io->io_netif = (void *)op;
@ -102,8 +98,7 @@ netif_of_open(op)
}
void
netif_of_close(fd)
int fd;
netif_of_close(int fd)
{
struct iodesc *io;
@ -131,10 +126,7 @@ netif_of_close(fd)
* Return the length sent (or -1 on error).
*/
ssize_t
netif_put(desc, pkt, len)
struct iodesc *desc;
void *pkt;
size_t len;
netif_put(struct iodesc *desc, void *pkt, size_t len)
{
struct of_dev *op;
ssize_t rv;
@ -177,11 +169,7 @@ netif_put(desc, pkt, len)
* Return the total length received (or -1 on error).
*/
ssize_t
netif_get(desc, pkt, maxlen, timo)
struct iodesc *desc;
void *pkt;
size_t maxlen;
time_t timo;
netif_get(struct iodesc *desc, void *pkt, size_t maxlen, time_t timo)
{
struct of_dev *op;
int tick0, tmo_ms;
@ -226,7 +214,7 @@ netif_get(desc, pkt, maxlen, timo)
* Shouldn't really be here, but is used solely for networking, so...
*/
time_t
getsecs()
getsecs(void)
{
return OF_milliseconds() / 1000;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ofdev.c,v 1.3 2003/10/08 04:25:46 lukem Exp $ */
/* $NetBSD: ofdev.c,v 1.4 2004/06/30 15:43:57 christos Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -40,13 +40,17 @@
#include <netinet/in.h>
#include <lib/libsa/stand.h>
#include <lib/libkern/libkern.h>
#include <lib/libsa/byteorder.h>
#include <lib/libsa/ufs.h>
#include <lib/libsa/cd9660.h>
#include <lib/libsa/dosfs.h>
#include <lib/libsa/nfs.h>
#include "extern.h"
#include "ofdev.h"
#include "openfirm.h"
extern char bootdev[];
@ -57,9 +61,7 @@ extern char bootdev[];
#endif
static char *
filename(str, ppart)
char *str;
char *ppart;
filename(char *str, char *ppart)
{
char *cp, *lp;
char savec;
@ -100,13 +102,8 @@ filename(str, ppart)
}
static int
strategy(devdata, rw, blk, size, buf, rsize)
void *devdata;
int rw;
daddr_t blk;
size_t size;
void *buf;
size_t *rsize;
strategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf,
size_t *rsize)
{
struct of_dev *dev = devdata;
u_quad_t pos;
@ -134,8 +131,7 @@ strategy(devdata, rw, blk, size, buf, rsize)
}
static int
devclose(of)
struct open_file *of;
devclose(struct open_file *of)
{
struct of_dev *op = of->f_devdata;
@ -143,14 +139,19 @@ devclose(of)
net_close(op);
OF_close(op->handle);
op->handle = -1;
return 0;
}
static char ofw[] = "OpenFirmware";
static struct devsw devsw[1] = {
"OpenFirmware",
strategy,
(int (*)__P((struct open_file *, ...)))nodev,
devclose,
noioctl
{
ofw,
strategy,
(int (*)(struct open_file *, ...))nodev,
devclose,
noioctl
}
};
int ndevs = sizeof devsw / sizeof devsw[0];
@ -180,8 +181,7 @@ char opened_name[256];
int floppyboot;
static u_long
get_long(p)
const void *p;
get_long(const void *p)
{
const unsigned char *cp = p;
@ -192,21 +192,17 @@ get_long(p)
* Find a valid disklabel.
*/
static int
search_label(devp, off, buf, lp, off0)
struct of_dev *devp;
u_long off;
char *buf;
struct disklabel *lp;
u_long off0;
search_label(struct of_dev *devp, u_long off, char *buf, struct disklabel *lp,
u_long off0)
{
size_t read;
size_t nread;
struct mbr_partition *p;
int i;
u_long poff;
static int recursion;
if (strategy(devp, F_READ, off, DEV_BSIZE, buf, &read)
|| read != DEV_BSIZE)
if (strategy(devp, F_READ, off, DEV_BSIZE, buf, &nread)
|| nread != DEV_BSIZE)
return ERDLAB;
if (*(u_int16_t *)&buf[MBR_MAGIC_OFFSET] != sa_htole16(MBR_MAGIC))
@ -225,15 +221,15 @@ search_label(devp, off, buf, lp, off0)
) {
poff = get_long(&p->mbrp_start) + off0;
if (strategy(devp, F_READ, poff + LABELSECTOR,
DEV_BSIZE, buf, &read) == 0
&& read == DEV_BSIZE) {
DEV_BSIZE, buf, &nread) == 0
&& nread == DEV_BSIZE) {
if (!getdisklabel(buf, lp)) {
recursion--;
return 0;
}
}
if (strategy(devp, F_READ, off, DEV_BSIZE, buf, &read)
|| read != DEV_BSIZE) {
if (strategy(devp, F_READ, off, DEV_BSIZE, buf, &nread)
|| nread != DEV_BSIZE) {
recursion--;
return ERDLAB;
}
@ -243,8 +239,8 @@ search_label(devp, off, buf, lp, off0)
recursion--;
return 0;
}
if (strategy(devp, F_READ, off, DEV_BSIZE, buf, &read)
|| read != DEV_BSIZE) {
if (strategy(devp, F_READ, off, DEV_BSIZE, buf, &nread)
|| nread != DEV_BSIZE) {
recursion--;
return ERDLAB;
}
@ -255,10 +251,7 @@ search_label(devp, off, buf, lp, off0)
}
int
devopen(of, name, file)
struct open_file *of;
const char *name;
char **file;
devopen(struct open_file *of, const char *name, char **file)
{
char *cp;
char partition;
@ -266,14 +259,14 @@ devopen(of, name, file)
char buf[DEV_BSIZE];
struct disklabel label;
int handle, part;
size_t read;
size_t nread;
int error = 0;
if (ofdev.handle != -1)
panic("devopen");
if (of->f_flags != F_READ)
return EPERM;
strcpy(fname, name);
(void)strcpy(fname, name);
cp = filename(fname, &partition);
if (cp) {
DPRINTF("filename=%s\n", cp);
@ -293,8 +286,8 @@ devopen(of, name, file)
*cp = 0;
}
if (*buf != '/')
strcat(opened_name, "/");
strcat(opened_name, buf);
(void)strcat(opened_name, "/");
(void)strcat(opened_name, buf);
*file = opened_name + strlen(fname) + 1;
if ((handle = OF_finddevice(fname)) == -1) {
DPRINTF("OF_finddevice(\"%s\") failed\n", fname);
@ -307,18 +300,18 @@ devopen(of, name, file)
return ENXIO;
if (!strcmp(buf, "block"))
/* For block devices, indicate raw partition (:0 in OpenFirmware) */
strcat(fname, ":0");
(void)strcat(fname, ":0");
if ((handle = OF_open(fname)) == -1)
return ENXIO;
memset(&ofdev, 0, sizeof ofdev);
(void)memset(&ofdev, 0, sizeof ofdev);
ofdev.handle = handle;
if (!strcmp(buf, "block")) {
ofdev.type = OFDEV_DISK;
ofdev.bsize = DEV_BSIZE;
/* First try to find a disklabel without MBR partitions */
if (strategy(&ofdev, F_READ,
LABELSECTOR, DEV_BSIZE, buf, &read) != 0
|| read != DEV_BSIZE
LABELSECTOR, DEV_BSIZE, buf, &nread) != 0
|| nread != DEV_BSIZE
|| getdisklabel(buf, &label)) {
/* Else try MBR partitions */
error = search_label(&ofdev, 0, buf, &label, 0);
@ -351,7 +344,7 @@ devopen(of, name, file)
of->f_devdata = &ofdev;
file_system[0] = file_system_nfs;
nfsys = 1;
if (error = net_open(&ofdev))
if ((error = net_open(&ofdev)) != 0)
goto bad;
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: openfirm.h,v 1.1 2002/02/10 01:58:19 thorpej Exp $ */
/* $NetBSD: openfirm.h,v 1.2 2004/06/30 15:43:57 christos Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -37,21 +37,22 @@
#include <sys/cdefs.h>
#include <sys/types.h>
__dead void OF_exit __P((void)) __attribute__((noreturn));
int OF_finddevice __P((char *name));
int OF_instance_to_package __P((int ihandle));
int OF_getprop __P((int handle, char *prop, void *buf, int buflen));
void OF_exit(void) __attribute__((__noreturn__));
int OF_finddevice(const char *);
int OF_instance_to_package(int);
int OF_getprop(int, const char *, void *, int);
#ifdef __notyet__
int OF_setprop __P((int handle, char *prop, void *buf, int len));
int OF_setprop(int, const char *, void *, int);
#endif
int OF_open __P((char *dname));
void OF_close __P((int handle));
int OF_write __P((int handle, void *addr, int len));
int OF_read __P((int handle, void *addr, int len));
int OF_seek __P((int handle, u_quad_t pos));
void *OF_claim __P((void *virt, u_int size, u_int align));
void OF_release __P((void *virt, u_int size));
int OF_milliseconds __P((void));
void OF_chain __P((void *addr, u_int size, void (*entry)(), void *parm, u_int parmlen));
int OF_open(char *);
void OF_close(int);
int OF_write(int, void *, int);
int OF_read(int, void *, int);
int OF_seek(int, u_quad_t);
void *OF_claim(void *, u_int, u_int);
void OF_release(void *, u_int);
int OF_milliseconds(void);
void OF_chain(void *, u_int, void (*)(int (*)(void *), void *, u_int),
void *, u_int);
int of_decode_int(const u_char *p);
int of_decode_int(const u_char *);