* Add old UFS compatibility code to alpha/boot1.

* Fix a raft of warnings, printf and otherwise.
* Allocate the correct amount in mod_searchmodule to prevent an overflow.
* Fix the makefiles so they work outside my home directory (oops).
This commit is contained in:
Doug Rabson 1998-09-26 10:51:38 +00:00
parent f069bf5a2c
commit e24168e6c3
18 changed files with 98 additions and 58 deletions

View File

@ -2,6 +2,9 @@
PRIMARY_LOAD_ADDRESS= 20000000 # "Region 1 start"
SECONDARY_LOAD_ADDRESS= 2000c000 # "Region 1 start" + 48k
HEAP_LIMIT= 20040000 # "Region 1 start" + 256k
DPADD+= ${DESTDIR}/${LIBDIR}/libstand.a
DPADD+= ${DESTDIR}/${LIBDIR}/libstand.a
LIBSTANDDIR= ${.CURDIR}/../../../../lib/libstand
LIBSTAND= -lstand
LIBALPHA= ${.OBJDIR}/../libalpha/libalpha.a
BINDIR= /usr/mdec

View File

@ -10,10 +10,7 @@ PROG = boot1
SRCS= start.S boot1.c sys.c
CFLAGS+= -mno-fp-regs
CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}
LIBSTANDDIR= /home/dfr/FreeBSD/alpha/src/lib/libstand
LIBSTAND= -lstand
CFLAGS+= -I${LIBSTANDDIR}
LIBALPHA= ${.OBJDIR}/../libalpha/libalpha.a
CFLAGS+= -I${.CURDIR}/..
CFLAGS+= -DSECONDARY_LOAD_ADDRESS=0x${SECONDARY_LOAD_ADDRESS} -DMINIMAL
NOMAN=1

View File

@ -1,5 +1,5 @@
/*
* $Id$
* $Id: boot1.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $
* From $NetBSD: bootxx.c,v 1.4 1997/09/06 14:08:29 drochner Exp $
*/
@ -162,7 +162,7 @@ loadfile(char *name, char *addr)
}
do {
n = read(addr, 1024);
n = readit(addr, 1024);
addr += n;
twiddle();
} while (n > 0);

View File

@ -25,7 +25,7 @@
*
* from: Mach, Revision 2.2 92/04/04 11:36:34 rpd
* fromL Id: sys.c,v 1.21 1997/06/09 05:10:56 bde Exp
* $Id$
* $Id: sys.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $
*/
#include <sys/param.h>
@ -37,6 +37,8 @@
#include <sys/dirent.h>
#define COMPAT_UFS
struct fs *fs;
struct inode inode;
int boff = 0;
@ -65,7 +67,7 @@ static int block_map(int file_block);
static int find(char *path);
int
read(char *buffer, int count)
readit(char *buffer, int count)
{
int logno, off, size;
int cnt2, bnum2;
@ -160,11 +162,44 @@ block_map(int file_block)
return (((int *)mapbuf)[(file_block - NDADDR) % NINDIR(fs)]);
}
#ifdef COMPAT_UFS
#define max(a, b) ((a) > (b) ? (a) : (b))
/*
* Sanity checks for old file systems.
*
* XXX - goes away some day.
*/
static void
ffs_oldfscompat(fs)
struct fs *fs;
{
int i;
fs->fs_npsect = max(fs->fs_npsect, fs->fs_nsect); /* XXX */
fs->fs_interleave = max(fs->fs_interleave, 1); /* XXX */
if (fs->fs_postblformat == FS_42POSTBLFMT) /* XXX */
fs->fs_nrpos = 8; /* XXX */
if (fs->fs_inodefmt < FS_44INODEFMT) { /* XXX */
quad_t sizepb = fs->fs_bsize; /* XXX */
/* XXX */
fs->fs_maxfilesize = fs->fs_bsize * NDADDR - 1; /* XXX */
for (i = 0; i < NIADDR; i++) { /* XXX */
sizepb *= NINDIR(fs); /* XXX */
fs->fs_maxfilesize += sizepb; /* XXX */
} /* XXX */
fs->fs_qbmask = ~fs->fs_bmask; /* XXX */
fs->fs_qfmask = ~fs->fs_fmask; /* XXX */
} /* XXX */
}
#endif
int
openrd(char *name)
{
int ret;
char namecopy[128];
if (devopen())
return 1;
@ -174,10 +209,16 @@ openrd(char *name)
*/
devread((char *)(fs = (struct fs *)fsbuf), SBLOCK + boff, SBSIZE);
#ifdef COMPAT_UFS
ffs_oldfscompat(fs);
#endif
/*
* Find the actual FILE on the mounted device.
* Make a copy of the name since find() is destructive.
*/
ret = find(name);
strcpy(namecopy, name);
ret = find(namecopy);
if (ret == 0)
return 1;
if (ret < 0)

View File

@ -15,6 +15,7 @@ SRCS+= main.c conf.c
.include <${.CURDIR}/../../common/Makefile.inc>
CFLAGS+= -mno-fp-regs
CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}
CFLAGS+= -I${.OBJDIR}
# Verbose ls causes extra heap usage
CFLAGS+= -DVERBOSE_LS
@ -24,11 +25,7 @@ CLEANFILES+= ${BASE} ${BASE}.sym ${BASE}.list
CFLAGS+= -Wall
# XXX fix to use "standard" versions
LIBSTANDDIR= /home/dfr/FreeBSD/alpha/src/lib/libstand
LIBSTAND= -lstand
CFLAGS+= -I${LIBSTANDDIR}
LIBALPHA= ${.OBJDIR}/../libalpha/libalpha.a
CFLAGS+= -I${.CURDIR}/..
CRT= start.o
STRIP=

View File

@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: main.c,v 1.3 1998/08/31 21:10:40 msmith Exp $
* $Id: main.c,v 1.4 1998/09/03 02:10:02 msmith Exp $
*/
@ -127,7 +127,7 @@ main(void)
* we must close it eventually since otherwise the firmware leaves
* the ncr hardware in a broken state (at least it does on my EB164).
*/
open("/", O_RDONLY);
open("/boot", O_RDONLY);
interact(); /* doesn't return */
}

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.2 1998/08/22 10:31:01 dfr Exp $
# $Id: Makefile,v 1.3 1998/08/31 21:10:40 msmith Exp $
LIB= alpha
NOPIC= true
@ -6,8 +6,9 @@ NOPROFILE= true
INTERNALLIB= true
# XXX hack to pick up stand.h
CFLAGS= -I/home/dfr/FreeBSD/alpha/src/lib/libstand
CFLAGS+= -DDEBUG
LIBSTANDDIR= ${.CURDIR}/../../../../lib/libstand
CFLAGS= -I${LIBSTANDDIR}
CFLAGS+= -DDEBUG
# Pick up the bootstrap header for some interface items
CFLAGS+= -I${.CURDIR}/../../common -mno-fp-regs

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: devicename.c,v 1.1.1.1 1998/08/21 03:17:42 msmith Exp $
* $Id: devicename.c,v 1.2 1998/08/22 10:31:01 dfr Exp $
*/
#include <stand.h>
@ -32,7 +32,7 @@
#include "bootstrap.h"
#include "libalpha.h"
static int alpha_parsedev(struct alpha_devdesc **dev, char *devspec, char **path);
static int alpha_parsedev(struct alpha_devdesc **dev, const char *devspec, const char **path);
/*
* Point (dev) at an allocated device specifier for the device matching the
@ -40,7 +40,7 @@ static int alpha_parsedev(struct alpha_devdesc **dev, char *devspec, char **path
* use that. If not, use the default device.
*/
int
alpha_getdev(void **vdev, char *devspec, char **path)
alpha_getdev(void **vdev, const char *devspec, const char **path)
{
struct alpha_devdesc **dev = (struct alpha_devdesc **)vdev;
int rv;
@ -80,12 +80,13 @@ alpha_getdev(void **vdev, char *devspec, char **path)
*
*/
static int
alpha_parsedev(struct alpha_devdesc **dev, char *devspec, char **path)
alpha_parsedev(struct alpha_devdesc **dev, const char *devspec, const char **path)
{
struct alpha_devdesc *idev;
struct devsw *dv;
int i, unit, slice, partition, err;
char *cp, *np;
char *cp;
const char *np;
/* minimum length check */
if (strlen(devspec) < 2)

View File

@ -1,4 +1,4 @@
/* $Id: libalpha.h,v 1.2 1998/08/31 21:10:40 msmith Exp $ */
/* $Id: libalpha.h,v 1.3 1998/09/20 21:46:19 dfr Exp $ */
/*
* Copyright (c) 1996
@ -58,7 +58,7 @@ struct alpha_devdesc
} d_kind;
};
extern int alpha_getdev(void **vdev, char *devspec, char **path);
extern int alpha_getdev(void **vdev, const char *devspec, const char **path);
extern char *alpha_fmtdev(void *vdev);
extern int alpha_setcurrdev(struct env_var *ev, int flags, void *value);

View File

@ -15,6 +15,7 @@ SRCS+= main.c conf.c dev_net.c
.include <${.CURDIR}/../../common/Makefile.inc>
CFLAGS+= -mno-fp-regs
CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}
CFLAGS+= -I${.OBJDIR}
# Verbose ls causes extra heap usage
CFLAGS+= -DVERBOSE_LS
@ -24,11 +25,7 @@ CLEANFILES+= ${BASE} ${BASE}.sym ${BASE}.list
CFLAGS+= -Wall
# XXX fix to use "standard" versions
LIBSTANDDIR= /home/dfr/FreeBSD/alpha/src/lib/libstand
LIBSTAND= -lstand
CFLAGS+= -I${LIBSTANDDIR}
LIBALPHA= ${.OBJDIR}/../libalpha/libalpha.a
CFLAGS+= -I${.CURDIR}/..
CRT= start.o
STRIP=

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bootstrap.h,v 1.6 1998/09/19 01:31:28 msmith Exp $
* $Id: bootstrap.h,v 1.7 1998/09/20 21:46:19 dfr Exp $
*/
#include <sys/types.h>
@ -219,6 +219,7 @@ extern vm_offset_t aout_findsym(char *name, struct loaded_module *mp);
__asm(".previous")
#else
#define MAKE_SET(set, sym) \
static void const * const __set_##set##_sym_##sym = &sym; \
__asm(".section .set." #set ",\"aw\""); \
__asm(".long " #sym); \
__asm(".previous")
@ -280,7 +281,7 @@ struct arch_switch
/* Automatically load modules as required by detected hardware */
int (* arch_autoload)();
/* Locate the device for (name), return pointer to tail in (*path) */
int (*arch_getdev)(void **dev, char *name, char **path);
int (*arch_getdev)(void **dev, const char *name, const char **path);
/* Copy from local address space to module address space, similar to bcopy() */
int (*arch_copyin)(void *src, vm_offset_t dest, size_t len);
/* Copy to local address space from module address space, similar to bcopy() */

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: devopen.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $
*/
@ -33,7 +33,7 @@
#include "bootstrap.h"
int
devopen(struct open_file *f, const char *fname, char **file)
devopen(struct open_file *f, const char *fname, const char **file)
{
struct devdesc *dev;
int result;

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: load_aout.c,v 1.4 1998/09/17 23:52:02 msmith Exp $
* $Id: load_aout.c,v 1.5 1998/09/18 01:12:23 msmith Exp $
*/
#include <sys/param.h>
@ -139,7 +139,7 @@ aout_loadmodule(char *filename, vm_offset_t dest, struct loaded_module **result)
addr += pad;
}
mp->m_addr = addr; /* save the aligned load address */
printf("%s at 0x%x\n", filename, addr);
printf("%s at %p\n", filename, (void *) addr);
mp->m_size = aout_loadimage(fd, addr, &ehdr, kernel);
if (mp->m_size == 0)
@ -212,7 +212,7 @@ aout_loadimage(int fd, vm_offset_t loadaddr, struct exec *ehdr, int kernel)
addr += sizeof(ehdr->a_syms);
/* symbol table */
printf("symbols=[0x%x+0x%lx", sizeof(ehdr->a_syms), ehdr->a_syms);
printf("symbols=[0x%lx+0x%lx", sizeof(ehdr->a_syms), ehdr->a_syms);
if (archsw.arch_readin(fd, addr, ehdr->a_syms) != ehdr->a_syms)
return(0);
addr += ehdr->a_syms;
@ -222,7 +222,7 @@ aout_loadimage(int fd, vm_offset_t loadaddr, struct exec *ehdr, int kernel)
archsw.arch_copyin(&ss, addr, sizeof(ss));
addr += sizeof(ss);
ss -= sizeof(ss);
printf("+0x%x+0x%x]", sizeof(ss), ss);
printf("+0x%lx+0x%x]", sizeof(ss), ss);
if (archsw.arch_readin(fd, addr, ss) != ss)
return(0);
printf(" \n");

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: misc.c,v 1.2 1998/09/03 02:10:07 msmith Exp $
* $Id: misc.c,v 1.3 1998/09/19 01:31:28 msmith Exp $
*/
#include <string.h>
@ -101,7 +101,7 @@ hexdump(caddr_t region, size_t len)
pager_open();
for (line = region; line < (region + len); line += 16) {
emit("%08x ", line);
emit("%08lx ", (long) line);
for (x = 0; x < 16; x++) {
if ((line + x) < (region + len)) {

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: module.c,v 1.3 1998/09/03 02:10:08 msmith Exp $
* $Id: module.c,v 1.4 1998/09/14 18:27:04 msmith Exp $
*/
/*
@ -145,8 +145,8 @@ command_lsmod(int argc, char *argv[])
pager_open();
for (am = loaded_modules; (am != NULL); am = am->m_next) {
sprintf(lbuf, " %x: %s (%s, 0x%x)\n",
am->m_addr, am->m_name, am->m_type, am->m_size);
sprintf(lbuf, " %p: %s (%s, 0x%lx)\n",
(void *) am->m_addr, am->m_name, am->m_type, (long) am->m_size);
pager_output(lbuf);
if (am->m_args != NULL) {
pager_output(" args: ");
@ -156,7 +156,7 @@ command_lsmod(int argc, char *argv[])
if (verbose)
/* XXX could add some formatting smarts here to display some better */
for (md = am->m_metadata; md != NULL; md = md->md_next) {
sprintf(lbuf, " 0x%04x, 0x%x\n", md->md_type, md->md_size);
sprintf(lbuf, " 0x%04x, 0x%lx\n", md->md_type, (long) md->md_size);
pager_output(lbuf);
}
}
@ -444,8 +444,8 @@ static char *
mod_searchfile(char *name)
{
static char *result = NULL;
char *path;
char *cp, *sp;
char *path, *sp;
const char *cp;
struct stat sb;
/* Don't look for nothing */
@ -501,7 +501,7 @@ mod_searchmodule(char *name)
char *tn, *result;
/* Look for (name).ko */
tn = malloc(strlen(name) + 3);
tn = malloc(strlen(name) + 3 + 1);
strcpy(tn, name);
strcat(tn, ".ko");
result = mod_searchfile(tn);

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: devicename.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $
* $Id: devicename.c,v 1.2 1998/09/26 01:30:20 msmith Exp $
*/
#include <stand.h>
@ -32,7 +32,7 @@
#include "bootstrap.h"
#include "libi386.h"
static int i386_parsedev(struct i386_devdesc **dev, char *devspec, char **path);
static int i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path);
/*
* Point (dev) at an allocated device specifier for the device matching the
@ -40,7 +40,7 @@ static int i386_parsedev(struct i386_devdesc **dev, char *devspec, char **path);
* use that. If not, use the default device.
*/
int
i386_getdev(void **vdev, char *devspec, char **path)
i386_getdev(void **vdev, const char *devspec, const char **path)
{
struct i386_devdesc **dev = (struct i386_devdesc **)vdev;
int rv;
@ -80,12 +80,13 @@ i386_getdev(void **vdev, char *devspec, char **path)
*
*/
static int
i386_parsedev(struct i386_devdesc **dev, char *devspec, char **path)
i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path)
{
struct i386_devdesc *idev;
struct devsw *dv;
int i, unit, slice, partition, err;
char *cp, *np;
char *cp;
const char *np;
/* minimum length check */
if (strlen(devspec) < 2)

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: libi386.h,v 1.4 1998/09/14 18:27:05 msmith Exp $
* $Id: libi386.h,v 1.5 1998/09/17 23:52:10 msmith Exp $
*/
@ -52,7 +52,7 @@ struct i386_devdesc
} d_kind;
};
extern int i386_getdev(void **vdev, char *devspec, char **path);
extern int i386_getdev(void **vdev, const char *devspec, const char **path);
extern char *i386_fmtdev(void *vdev);
extern int i386_setcurrdev(struct env_var *ev, int flags, void *value);

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: devicename.c,v 1.1.1.1 1998/08/21 03:17:42 msmith Exp $
* $Id: devicename.c,v 1.2 1998/08/22 10:31:01 dfr Exp $
*/
#include <stand.h>
@ -32,7 +32,7 @@
#include "bootstrap.h"
#include "libalpha.h"
static int alpha_parsedev(struct alpha_devdesc **dev, char *devspec, char **path);
static int alpha_parsedev(struct alpha_devdesc **dev, const char *devspec, const char **path);
/*
* Point (dev) at an allocated device specifier for the device matching the
@ -40,7 +40,7 @@ static int alpha_parsedev(struct alpha_devdesc **dev, char *devspec, char **path
* use that. If not, use the default device.
*/
int
alpha_getdev(void **vdev, char *devspec, char **path)
alpha_getdev(void **vdev, const char *devspec, const char **path)
{
struct alpha_devdesc **dev = (struct alpha_devdesc **)vdev;
int rv;
@ -80,12 +80,13 @@ alpha_getdev(void **vdev, char *devspec, char **path)
*
*/
static int
alpha_parsedev(struct alpha_devdesc **dev, char *devspec, char **path)
alpha_parsedev(struct alpha_devdesc **dev, const char *devspec, const char **path)
{
struct alpha_devdesc *idev;
struct devsw *dv;
int i, unit, slice, partition, err;
char *cp, *np;
char *cp;
const char *np;
/* minimum length check */
if (strlen(devspec) < 2)