Misc KNF and cosmetics.
This commit is contained in:
parent
1b840b2df1
commit
8f232399f0
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: disksubr.c,v 1.41 2009/10/20 19:10:10 snj Exp $ */
|
/* $NetBSD: disksubr.c,v 1.42 2010/03/31 14:12:55 tsutsui Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1995 Leo Weppelman.
|
* Copyright (c) 1995 Leo Weppelman.
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.41 2009/10/20 19:10:10 snj Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.42 2010/03/31 14:12:55 tsutsui Exp $");
|
||||||
|
|
||||||
#ifndef DISKLABEL_NBDA
|
#ifndef DISKLABEL_NBDA
|
||||||
#define DISKLABEL_NBDA /* required */
|
#define DISKLABEL_NBDA /* required */
|
||||||
|
@ -69,13 +69,15 @@ static u_int ahdi_getparts(dev_t, void (*)(struct buf *), u_int,
|
||||||
* Returns NULL on success and an error string on failure.
|
* Returns NULL on success and an error string on failure.
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *clp)
|
readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
|
||||||
|
struct cpu_disklabel *clp)
|
||||||
{
|
{
|
||||||
int e;
|
int e;
|
||||||
|
|
||||||
if (clp != NULL)
|
if (clp != NULL)
|
||||||
memset(clp, 0, sizeof *clp);
|
memset(clp, 0, sizeof *clp);
|
||||||
else printf("Warning: clp == NULL\n");
|
else
|
||||||
|
printf("Warning: clp == NULL\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Give some guaranteed validity to the disk label.
|
* Give some guaranteed validity to the disk label.
|
||||||
|
@ -85,7 +87,7 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, stru
|
||||||
if (lp->d_secperunit == 0)
|
if (lp->d_secperunit == 0)
|
||||||
lp->d_secperunit = 0x1fffffff;
|
lp->d_secperunit = 0x1fffffff;
|
||||||
if (lp->d_secpercyl == 0)
|
if (lp->d_secpercyl == 0)
|
||||||
return("Zero secpercyl");
|
return "Zero secpercyl";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some parts of the kernel (see scsipi/cd.c for an example)
|
* Some parts of the kernel (see scsipi/cd.c for an example)
|
||||||
|
@ -117,39 +119,41 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, stru
|
||||||
e = ahdi_label(dev, strat, lp, clp);
|
e = ahdi_label(dev, strat, lp, clp);
|
||||||
#endif
|
#endif
|
||||||
if (e < 0)
|
if (e < 0)
|
||||||
return("I/O error");
|
return "I/O error";
|
||||||
|
|
||||||
/* Unknown format or uninitialized volume? */
|
/* Unknown format or uninitialized volume? */
|
||||||
if (e > 0)
|
if (e > 0)
|
||||||
uprintf("Warning: unknown disklabel format"
|
uprintf("Warning: unknown disklabel format"
|
||||||
"- assuming empty disk\n");
|
"- assuming empty disk\n");
|
||||||
|
|
||||||
/* Calulate new checksum. */
|
/* Calulate new checksum. */
|
||||||
lp->d_magic = lp->d_magic2 = DISKMAGIC;
|
lp->d_magic = lp->d_magic2 = DISKMAGIC;
|
||||||
lp->d_checksum = 0;
|
lp->d_checksum = 0;
|
||||||
lp->d_checksum = dkcksum(lp);
|
lp->d_checksum = dkcksum(lp);
|
||||||
|
|
||||||
return(NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check new disk label for sensibility before setting it.
|
* Check new disk label for sensibility before setting it.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask, struct cpu_disklabel *clp)
|
setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask,
|
||||||
|
struct cpu_disklabel *clp)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* special case to allow disklabel to be invalidated */
|
/* special case to allow disklabel to be invalidated */
|
||||||
if (nlp->d_magic == 0xffffffff) {
|
if (nlp->d_magic == 0xffffffff) {
|
||||||
*olp = *nlp;
|
*olp = *nlp;
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sanity clause */
|
/* sanity clause */
|
||||||
if (nlp->d_secpercyl == 0 || nlp->d_npartitions > MAXPARTITIONS
|
if (nlp->d_secpercyl == 0 || nlp->d_npartitions > MAXPARTITIONS ||
|
||||||
|| nlp->d_secsize == 0 || (nlp->d_secsize % DEV_BSIZE) != 0
|
nlp->d_secsize == 0 || (nlp->d_secsize % DEV_BSIZE) != 0 ||
|
||||||
|| nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC
|
nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
|
||||||
|| dkcksum(nlp) != 0)
|
dkcksum(nlp) != 0)
|
||||||
return(EINVAL);
|
return EINVAL;
|
||||||
|
|
||||||
#ifdef DISKLABEL_AHDI
|
#ifdef DISKLABEL_AHDI
|
||||||
if (clp && clp->cd_bblock)
|
if (clp && clp->cd_bblock)
|
||||||
|
@ -160,11 +164,11 @@ setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask, stru
|
||||||
int i = ffs(openmask) - 1;
|
int i = ffs(openmask) - 1;
|
||||||
openmask &= ~(1 << i);
|
openmask &= ~(1 << i);
|
||||||
if (i >= nlp->d_npartitions)
|
if (i >= nlp->d_npartitions)
|
||||||
return(EBUSY);
|
return EBUSY;
|
||||||
op = &olp->d_partitions[i];
|
op = &olp->d_partitions[i];
|
||||||
np = &nlp->d_partitions[i];
|
np = &nlp->d_partitions[i];
|
||||||
if (np->p_offset != op->p_offset || np->p_size < op->p_size)
|
if (np->p_offset != op->p_offset || np->p_size < op->p_size)
|
||||||
return(EBUSY);
|
return EBUSY;
|
||||||
/*
|
/*
|
||||||
* Copy internally-set partition information
|
* Copy internally-set partition information
|
||||||
* if new label doesn't include it. XXX
|
* if new label doesn't include it. XXX
|
||||||
|
@ -179,22 +183,23 @@ setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask, stru
|
||||||
nlp->d_checksum = 0;
|
nlp->d_checksum = 0;
|
||||||
nlp->d_checksum = dkcksum(nlp);
|
nlp->d_checksum = dkcksum(nlp);
|
||||||
*olp = *nlp;
|
*olp = *nlp;
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write disk label back to device after modification.
|
* Write disk label back to device after modification.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *clp)
|
writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
|
||||||
|
struct cpu_disklabel *clp)
|
||||||
{
|
{
|
||||||
struct buf *bp;
|
struct buf *bp;
|
||||||
u_int blk;
|
u_int blk;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
blk = clp->cd_bblock;
|
blk = clp->cd_bblock;
|
||||||
if (blk == NO_BOOT_BLOCK)
|
if (blk == NO_BOOT_BLOCK)
|
||||||
return(ENXIO);
|
return ENXIO;
|
||||||
|
|
||||||
bp = geteblk(BBMINSIZE);
|
bp = geteblk(BBMINSIZE);
|
||||||
bp->b_dev = MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART);
|
bp->b_dev = MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART);
|
||||||
|
@ -204,7 +209,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, str
|
||||||
bp->b_cylinder = blk / lp->d_secpercyl;
|
bp->b_cylinder = blk / lp->d_secpercyl;
|
||||||
(*strat)(bp);
|
(*strat)(bp);
|
||||||
rv = biowait(bp);
|
rv = biowait(bp);
|
||||||
if (!rv) {
|
if (rv == 0) {
|
||||||
struct bootblock *bb = (struct bootblock *)bp->b_data;
|
struct bootblock *bb = (struct bootblock *)bp->b_data;
|
||||||
/*
|
/*
|
||||||
* Allthough the disk pack label may appear anywhere
|
* Allthough the disk pack label may appear anywhere
|
||||||
|
@ -228,7 +233,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, str
|
||||||
rv = biowait(bp);
|
rv = biowait(bp);
|
||||||
}
|
}
|
||||||
brelse(bp, 0);
|
brelse(bp, 0);
|
||||||
return(rv);
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -240,15 +245,11 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, str
|
||||||
* +1 if no valid label was found.
|
* +1 if no valid label was found.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
bsd_label(dev, strat, label, blkno, offsetp)
|
bsd_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *label,
|
||||||
dev_t dev;
|
u_int blkno, u_int *offsetp)
|
||||||
void (*strat)(struct buf *);
|
|
||||||
struct disklabel *label;
|
|
||||||
u_int blkno,
|
|
||||||
*offsetp;
|
|
||||||
{
|
{
|
||||||
struct buf *bp;
|
struct buf *bp;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
bp = geteblk(BBMINSIZE);
|
bp = geteblk(BBMINSIZE);
|
||||||
bp->b_dev = MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART);
|
bp->b_dev = MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART);
|
||||||
|
@ -261,29 +262,28 @@ bsd_label(dev, strat, label, blkno, offsetp)
|
||||||
rv = -1;
|
rv = -1;
|
||||||
if (!biowait(bp)) {
|
if (!biowait(bp)) {
|
||||||
struct bootblock *bb;
|
struct bootblock *bb;
|
||||||
u_int32_t *p, *end;
|
uint32_t *p, *end;
|
||||||
|
|
||||||
rv = 1;
|
rv = 1;
|
||||||
bb = (struct bootblock *)bp->b_data;
|
bb = (struct bootblock *)bp->b_data;
|
||||||
end = (u_int32_t *)((char *)&bb[1] - sizeof(struct disklabel));
|
end = (uint32_t *)((char *)&bb[1] - sizeof(struct disklabel));
|
||||||
for (p = (u_int32_t *)bb; p < end; ++p) {
|
for (p = (uint32_t *)bb; p < end; ++p) {
|
||||||
struct disklabel *dl = (struct disklabel *)&p[1];
|
struct disklabel *dl = (struct disklabel *)&p[1];
|
||||||
/*
|
/*
|
||||||
* Compatibility kludge: the boot block magic number is
|
* Compatibility kludge: the boot block magic number is
|
||||||
* new in 1.1A, in previous versions the disklabel was
|
* new in 1.1A, in previous versions the disklabel was
|
||||||
* stored at the end of the boot block (offset 7168).
|
* stored at the end of the boot block (offset 7168).
|
||||||
*/
|
*/
|
||||||
if ( ( (p[0] == NBDAMAGIC && blkno == 0)
|
if (((p[0] == NBDAMAGIC && blkno == 0) ||
|
||||||
|| (p[0] == AHDIMAGIC && blkno != 0)
|
(p[0] == AHDIMAGIC && blkno != 0)
|
||||||
#ifdef COMPAT_11
|
#ifdef COMPAT_11
|
||||||
|| (char *)dl - (char *)bb == 7168
|
|| (char *)dl - (char *)bb == 7168
|
||||||
#endif
|
#endif
|
||||||
)
|
) &&
|
||||||
&& dl->d_npartitions <= MAXPARTITIONS
|
dl->d_npartitions <= MAXPARTITIONS &&
|
||||||
&& dl->d_magic2 == DISKMAGIC
|
dl->d_magic2 == DISKMAGIC &&
|
||||||
&& dl->d_magic == DISKMAGIC
|
dl->d_magic == DISKMAGIC &&
|
||||||
&& dkcksum(dl) == 0
|
dkcksum(dl) == 0) {
|
||||||
) {
|
|
||||||
if (offsetp != NULL)
|
if (offsetp != NULL)
|
||||||
*offsetp = (char *)dl - (char *)bb;
|
*offsetp = (char *)dl - (char *)bb;
|
||||||
*label = *dl;
|
*label = *dl;
|
||||||
|
@ -293,7 +293,7 @@ bsd_label(dev, strat, label, blkno, offsetp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
brelse(bp, 0);
|
brelse(bp, 0);
|
||||||
return(rv);
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DISKLABEL_AHDI
|
#ifdef DISKLABEL_AHDI
|
||||||
|
@ -307,24 +307,24 @@ bsd_label(dev, strat, label, blkno, offsetp)
|
||||||
static void
|
static void
|
||||||
ck_label(struct disklabel *dl, struct cpu_disklabel *cdl)
|
ck_label(struct disklabel *dl, struct cpu_disklabel *cdl)
|
||||||
{
|
{
|
||||||
u_int *rp, i;
|
u_int *rp, i;
|
||||||
|
|
||||||
for (i = 0; i < dl->d_npartitions; ++i) {
|
for (i = 0; i < dl->d_npartitions; ++i) {
|
||||||
struct partition *p = &dl->d_partitions[i];
|
struct partition *p = &dl->d_partitions[i];
|
||||||
if (i == RAW_PART || p->p_size == 0)
|
if (i == RAW_PART || p->p_size == 0)
|
||||||
continue;
|
continue;
|
||||||
if ( (p->p_offset >= cdl->cd_bslst
|
if ((p->p_offset >= cdl->cd_bslst &&
|
||||||
&& p->p_offset <= cdl->cd_bslend)
|
p->p_offset <= cdl->cd_bslend) ||
|
||||||
|| (cdl->cd_bslst >= p->p_offset
|
(cdl->cd_bslst >= p->p_offset &&
|
||||||
&& cdl->cd_bslst < p->p_offset + p->p_size)) {
|
cdl->cd_bslst < p->p_offset + p->p_size)) {
|
||||||
uprintf("Warning: NetBSD partition %c includes"
|
uprintf("Warning: NetBSD partition %c includes"
|
||||||
" AHDI bad sector list\n", 'a'+i);
|
" AHDI bad sector list\n", 'a'+i);
|
||||||
}
|
}
|
||||||
for (rp = &cdl->cd_roots[0]; *rp; ++rp) {
|
for (rp = &cdl->cd_roots[0]; *rp; ++rp) {
|
||||||
if (*rp >= p->p_offset
|
if (*rp >= p->p_offset &&
|
||||||
&& *rp < p->p_offset + p->p_size) {
|
*rp < p->p_offset + p->p_size) {
|
||||||
uprintf("Warning: NetBSD partition %c"
|
uprintf("Warning: NetBSD partition %c"
|
||||||
" includes AHDI auxiliary root\n", 'a'+i);
|
" includes AHDI auxiliary root\n", 'a' + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -340,17 +340,18 @@ ck_label(struct disklabel *dl, struct cpu_disklabel *cdl)
|
||||||
* +1 if no valid AHDI label was found.
|
* +1 if no valid AHDI label was found.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl, struct cpu_disklabel *cdl)
|
ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl,
|
||||||
|
struct cpu_disklabel *cdl)
|
||||||
{
|
{
|
||||||
struct ahdi_ptbl apt;
|
struct ahdi_ptbl apt;
|
||||||
u_int i;
|
u_int i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The AHDI format requires a specific block size.
|
* The AHDI format requires a specific block size.
|
||||||
*/
|
*/
|
||||||
if (dl->d_secsize != AHDI_BSIZE)
|
if (dl->d_secsize != AHDI_BSIZE)
|
||||||
return(1);
|
return 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fetch the AHDI partition descriptors.
|
* Fetch the AHDI partition descriptors.
|
||||||
|
@ -358,11 +359,12 @@ ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl, struct
|
||||||
apt.at_cdl = cdl;
|
apt.at_cdl = cdl;
|
||||||
apt.at_nroots = apt.at_nparts = 0;
|
apt.at_nroots = apt.at_nparts = 0;
|
||||||
i = ahdi_getparts(dev, strat, dl->d_secpercyl,
|
i = ahdi_getparts(dev, strat, dl->d_secpercyl,
|
||||||
AHDI_BBLOCK, AHDI_BBLOCK, &apt);
|
AHDI_BBLOCK, AHDI_BBLOCK, &apt);
|
||||||
if (i) {
|
if (i) {
|
||||||
if (i < dl->d_secperunit)
|
if (i < dl->d_secperunit)
|
||||||
return(-1); /* disk read error */
|
return -1; /* disk read error */
|
||||||
else return(1); /* reading past end of medium */
|
else
|
||||||
|
return 1; /* reading past end of medium */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -376,31 +378,31 @@ ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl, struct
|
||||||
*/
|
*/
|
||||||
apt.at_bslst = apt.at_bslend = 0;
|
apt.at_bslst = apt.at_bslend = 0;
|
||||||
uprintf("Warning: Illegal 'bad sector list' format"
|
uprintf("Warning: Illegal 'bad sector list' format"
|
||||||
"- assuming non exists\n");
|
"- assuming non exists\n");
|
||||||
}
|
}
|
||||||
if (apt.at_hdsize == 0 || apt.at_nparts == 0) /* unlikely */
|
if (apt.at_hdsize == 0 || apt.at_nparts == 0) /* unlikely */
|
||||||
return(1);
|
return 1;
|
||||||
if (apt.at_nparts > AHDI_MAXPARTS) /* XXX kludge */
|
if (apt.at_nparts > AHDI_MAXPARTS) /* XXX kludge */
|
||||||
return(-1);
|
return -1;
|
||||||
for (i = 0; i < apt.at_nparts; ++i) {
|
for (i = 0; i < apt.at_nparts; ++i) {
|
||||||
struct ahdi_part *p1 = &apt.at_parts[i];
|
struct ahdi_part *p1 = &apt.at_parts[i];
|
||||||
|
|
||||||
for (j = 0; j < apt.at_nroots; ++j) {
|
for (j = 0; j < apt.at_nroots; ++j) {
|
||||||
u_int aux = apt.at_roots[j];
|
u_int aux = apt.at_roots[j];
|
||||||
if (aux >= p1->ap_st && aux <= p1->ap_end)
|
if (aux >= p1->ap_st && aux <= p1->ap_end)
|
||||||
return(1);
|
return 1;
|
||||||
}
|
}
|
||||||
for (j = i + 1; j < apt.at_nparts; ++j) {
|
for (j = i + 1; j < apt.at_nparts; ++j) {
|
||||||
struct ahdi_part *p2 = &apt.at_parts[j];
|
struct ahdi_part *p2 = &apt.at_parts[j];
|
||||||
if (p1->ap_st >= p2->ap_st && p1->ap_st <= p2->ap_end)
|
if (p1->ap_st >= p2->ap_st && p1->ap_st <= p2->ap_end)
|
||||||
return(1);
|
return 1;
|
||||||
if (p2->ap_st >= p1->ap_st && p2->ap_st <= p1->ap_end)
|
if (p2->ap_st >= p1->ap_st && p2->ap_st <= p1->ap_end)
|
||||||
return(1);
|
return 1;
|
||||||
}
|
}
|
||||||
if (p1->ap_st >= apt.at_bslst && p1->ap_st <= apt.at_bslend)
|
if (p1->ap_st >= apt.at_bslst && p1->ap_st <= apt.at_bslend)
|
||||||
return(1);
|
return 1;
|
||||||
if (apt.at_bslst >= p1->ap_st && apt.at_bslst <= p1->ap_end)
|
if (apt.at_bslst >= p1->ap_st && apt.at_bslst <= p1->ap_end)
|
||||||
return(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -409,17 +411,17 @@ ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl, struct
|
||||||
apt.at_bblock = NO_BOOT_BLOCK;
|
apt.at_bblock = NO_BOOT_BLOCK;
|
||||||
for (i = 0; i < apt.at_nparts; ++i) {
|
for (i = 0; i < apt.at_nparts; ++i) {
|
||||||
struct ahdi_part *pd = &apt.at_parts[i];
|
struct ahdi_part *pd = &apt.at_parts[i];
|
||||||
u_int id = *((u_int32_t *)&pd->ap_flg);
|
u_int id = *((uint32_t *)&pd->ap_flg);
|
||||||
if (id == AHDI_PID_NBD || id == AHDI_PID_RAW) {
|
if (id == AHDI_PID_NBD || id == AHDI_PID_RAW) {
|
||||||
u_int blkno = pd->ap_st;
|
u_int blkno = pd->ap_st;
|
||||||
j = bsd_label(dev, strat, dl, blkno, &apt.at_label);
|
j = bsd_label(dev, strat, dl, blkno, &apt.at_label);
|
||||||
if (j < 0) {
|
if (j < 0) {
|
||||||
return(j); /* I/O error */
|
return j; /* I/O error */
|
||||||
}
|
}
|
||||||
if (!j) {
|
if (j == 0) {
|
||||||
apt.at_bblock = blkno; /* got it */
|
apt.at_bblock = blkno; /* got it */
|
||||||
ck_label(dl, cdl);
|
ck_label(dl, cdl);
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Not yet, but if this is the first NBD partition
|
* Not yet, but if this is the first NBD partition
|
||||||
|
@ -428,8 +430,8 @@ ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl, struct
|
||||||
* in case there is no valid disk label on any of the
|
* in case there is no valid disk label on any of the
|
||||||
* other AHDI partitions.
|
* other AHDI partitions.
|
||||||
*/
|
*/
|
||||||
if (id == AHDI_PID_NBD
|
if (id == AHDI_PID_NBD &&
|
||||||
&& apt.at_bblock == NO_BOOT_BLOCK)
|
apt.at_bblock == NO_BOOT_BLOCK)
|
||||||
apt.at_bblock = blkno;
|
apt.at_bblock = blkno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -441,7 +443,7 @@ ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl, struct
|
||||||
* writedisklabel() calls will fail.
|
* writedisklabel() calls will fail.
|
||||||
*/
|
*/
|
||||||
ahdi_to_bsd(dl, &apt);
|
ahdi_to_bsd(dl, &apt);
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -459,16 +461,16 @@ ahdi_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *dl, struct
|
||||||
static void
|
static void
|
||||||
ahdi_to_bsd(struct disklabel *dl, struct ahdi_ptbl *apt)
|
ahdi_to_bsd(struct disklabel *dl, struct ahdi_ptbl *apt)
|
||||||
{
|
{
|
||||||
int i, have_root, user_part;
|
int i, have_root, user_part;
|
||||||
|
|
||||||
user_part = RAW_PART;
|
user_part = RAW_PART;
|
||||||
have_root = (apt->at_bblock != NO_BOOT_BLOCK);
|
have_root = (apt->at_bblock != NO_BOOT_BLOCK);
|
||||||
|
|
||||||
for (i = 0; i < apt->at_nparts; ++i) {
|
for (i = 0; i < apt->at_nparts; ++i) {
|
||||||
struct ahdi_part *pd = &apt->at_parts[i];
|
struct ahdi_part *pd = &apt->at_parts[i];
|
||||||
int fst, pno = -1;
|
int fst, pno = -1;
|
||||||
|
|
||||||
switch (*((u_int32_t *)&pd->ap_flg)) {
|
switch (*((uint32_t *)&pd->ap_flg)) {
|
||||||
case AHDI_PID_NBD:
|
case AHDI_PID_NBD:
|
||||||
/*
|
/*
|
||||||
* If this partition has been marked as the
|
* If this partition has been marked as the
|
||||||
|
@ -526,17 +528,13 @@ ahdi_to_bsd(struct disklabel *dl, struct ahdi_ptbl *apt)
|
||||||
* number of the offending block is returned.
|
* number of the offending block is returned.
|
||||||
*/
|
*/
|
||||||
static u_int
|
static u_int
|
||||||
ahdi_getparts(dev, strat, secpercyl, rsec, esec, apt)
|
ahdi_getparts(dev_t dev, void (*strat)(struct buf *), u_int secpercyl,
|
||||||
dev_t dev;
|
u_int rsec, u_int esec, struct ahdi_ptbl *apt)
|
||||||
void (*strat)(struct buf *);
|
|
||||||
u_int secpercyl,
|
|
||||||
rsec, esec;
|
|
||||||
struct ahdi_ptbl *apt;
|
|
||||||
{
|
{
|
||||||
struct ahdi_part *part, *end;
|
struct ahdi_part *part, *end;
|
||||||
struct ahdi_root *root;
|
struct ahdi_root *root;
|
||||||
struct buf *bp;
|
struct buf *bp;
|
||||||
u_int rv;
|
u_int rv;
|
||||||
|
|
||||||
bp = geteblk(AHDI_BSIZE);
|
bp = geteblk(AHDI_BSIZE);
|
||||||
bp->b_dev = MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART);
|
bp->b_dev = MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART);
|
||||||
|
@ -553,25 +551,26 @@ ahdi_getparts(dev, strat, secpercyl, rsec, esec, apt)
|
||||||
|
|
||||||
if (rsec == AHDI_BBLOCK)
|
if (rsec == AHDI_BBLOCK)
|
||||||
end = &root->ar_parts[AHDI_MAXRPD];
|
end = &root->ar_parts[AHDI_MAXRPD];
|
||||||
else end = &root->ar_parts[AHDI_MAXARPD];
|
else
|
||||||
|
end = &root->ar_parts[AHDI_MAXARPD];
|
||||||
for (part = root->ar_parts; part < end; ++part) {
|
for (part = root->ar_parts; part < end; ++part) {
|
||||||
u_int id = *((u_int32_t *)&part->ap_flg);
|
u_int id = *((uint32_t *)&part->ap_flg);
|
||||||
if (!(id & 0x01000000))
|
if (!(id & 0x01000000))
|
||||||
continue;
|
continue;
|
||||||
if ((id &= 0x00ffffff) == AHDI_PID_XGM) {
|
if ((id &= 0x00ffffff) == AHDI_PID_XGM) {
|
||||||
u_int offs = part->ap_st + esec;
|
u_int offs = part->ap_st + esec;
|
||||||
if (apt->at_nroots < AHDI_MAXROOTS)
|
if (apt->at_nroots < AHDI_MAXROOTS)
|
||||||
apt->at_roots[apt->at_nroots] = offs;
|
apt->at_roots[apt->at_nroots] = offs;
|
||||||
apt->at_nroots += 1;
|
apt->at_nroots += 1;
|
||||||
rv = ahdi_getparts(dev, strat, secpercyl, offs,
|
rv = ahdi_getparts(dev, strat, secpercyl, offs,
|
||||||
(esec == AHDI_BBLOCK) ? offs : esec, apt);
|
(esec == AHDI_BBLOCK) ? offs : esec, apt);
|
||||||
if (rv)
|
if (rv != 0)
|
||||||
goto done;
|
goto done;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (apt->at_nparts < AHDI_MAXPARTS) {
|
else if (apt->at_nparts < AHDI_MAXPARTS) {
|
||||||
struct ahdi_part *p = &apt->at_parts[apt->at_nparts];
|
struct ahdi_part *p = &apt->at_parts[apt->at_nparts];
|
||||||
*((u_int32_t *)&p->ap_flg) = id;
|
*((uint32_t *)&p->ap_flg) = id;
|
||||||
p->ap_st = part->ap_st + rsec;
|
p->ap_st = part->ap_st + rsec;
|
||||||
p->ap_end = p->ap_st + part->ap_size - 1;
|
p->ap_end = p->ap_st + part->ap_size - 1;
|
||||||
}
|
}
|
||||||
|
@ -583,6 +582,6 @@ ahdi_getparts(dev, strat, secpercyl, rsec, esec, apt)
|
||||||
rv = 0;
|
rv = 0;
|
||||||
done:
|
done:
|
||||||
brelse(bp, 0);
|
brelse(bp, 0);
|
||||||
return(rv);
|
return rv;
|
||||||
}
|
}
|
||||||
#endif /* DISKLABEL_AHDI */
|
#endif /* DISKLABEL_AHDI */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: intr.c,v 1.20 2010/02/09 23:05:16 wiz Exp $ */
|
/* $NetBSD: intr.c,v 1.21 2010/03/31 14:12:55 tsutsui Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1996 The NetBSD Foundation, Inc.
|
* Copyright (c) 1996 The NetBSD Foundation, Inc.
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.20 2010/02/09 23:05:16 wiz Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.21 2010/03/31 14:12:55 tsutsui Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -132,25 +132,25 @@ intr_establish(int vector, int type, int pri, hw_ifun_t ih_fun, void *ih_arg)
|
||||||
* Do some validity checking on the 'vector' argument and determine
|
* Do some validity checking on the 'vector' argument and determine
|
||||||
* vector list this interrupt should be on.
|
* vector list this interrupt should be on.
|
||||||
*/
|
*/
|
||||||
switch(type & (AUTO_VEC|USER_VEC)) {
|
switch (type & (AUTO_VEC|USER_VEC)) {
|
||||||
case AUTO_VEC:
|
case AUTO_VEC:
|
||||||
if (vector < AVEC_MIN || vector > AVEC_MAX)
|
if (vector < AVEC_MIN || vector > AVEC_MAX)
|
||||||
return (NULL);
|
return NULL;
|
||||||
vec_list = &autovec_list[vector-1];
|
vec_list = &autovec_list[vector-1];
|
||||||
hard_vec = &autovects[vector-1];
|
hard_vec = &autovects[vector-1];
|
||||||
ih->ih_intrcnt = &intrcnt_auto[vector-1];
|
ih->ih_intrcnt = &intrcnt_auto[vector-1];
|
||||||
break;
|
break;
|
||||||
case USER_VEC:
|
case USER_VEC:
|
||||||
if (vector < UVEC_MIN || vector > UVEC_MAX)
|
if (vector < UVEC_MIN || vector > UVEC_MAX)
|
||||||
return (NULL);
|
return NULL;
|
||||||
vec_list = &uservec_list[vector];
|
vec_list = &uservec_list[vector];
|
||||||
hard_vec = &uservects[vector];
|
hard_vec = &uservects[vector];
|
||||||
ih->ih_intrcnt = &intrcnt_user[vector];
|
ih->ih_intrcnt = &intrcnt_user[vector];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("intr_establish: bogus vector type\n");
|
printf("intr_establish: bogus vector type\n");
|
||||||
free(ih, M_DEVBUF);
|
free(ih, M_DEVBUF);
|
||||||
return(NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -163,7 +163,7 @@ intr_establish(int vector, int type, int pri, hw_ifun_t ih_fun, void *ih_arg)
|
||||||
LIST_INSERT_HEAD(vec_list, ih, ih_link);
|
LIST_INSERT_HEAD(vec_list, ih, ih_link);
|
||||||
if (type & FAST_VEC)
|
if (type & FAST_VEC)
|
||||||
*hard_vec = (u_long)ih->ih_fun;
|
*hard_vec = (u_long)ih->ih_fun;
|
||||||
else if(*hard_vec != (u_long)intr_glue) {
|
else if (*hard_vec != (u_long)intr_glue) {
|
||||||
/*
|
/*
|
||||||
* Normally, all settable vectors are already
|
* Normally, all settable vectors are already
|
||||||
* re-routed to the intr_glue() function. The
|
* re-routed to the intr_glue() function. The
|
||||||
|
@ -187,7 +187,7 @@ intr_establish(int vector, int type, int pri, hw_ifun_t ih_fun, void *ih_arg)
|
||||||
if (cur_vec->ih_type & FAST_VEC) {
|
if (cur_vec->ih_type & FAST_VEC) {
|
||||||
free(ih, M_DEVBUF);
|
free(ih, M_DEVBUF);
|
||||||
printf("intr_establish: vector cannot be shared\n");
|
printf("intr_establish: vector cannot be shared\n");
|
||||||
return (NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -202,7 +202,7 @@ intr_establish(int vector, int type, int pri, hw_ifun_t ih_fun, void *ih_arg)
|
||||||
LIST_INSERT_BEFORE(cur_vec, ih, ih_link);
|
LIST_INSERT_BEFORE(cur_vec, ih, ih_link);
|
||||||
splx(s);
|
splx(s);
|
||||||
|
|
||||||
return (ih);
|
return ih;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,21 +227,21 @@ intr_disestablish(struct intrhand *ih)
|
||||||
|
|
||||||
vector = ih->ih_vector;
|
vector = ih->ih_vector;
|
||||||
switch(ih->ih_type & (AUTO_VEC|USER_VEC)) {
|
switch(ih->ih_type & (AUTO_VEC|USER_VEC)) {
|
||||||
case AUTO_VEC:
|
case AUTO_VEC:
|
||||||
if (vector < AVEC_MIN || vector > AVEC_MAX)
|
if (vector < AVEC_MIN || vector > AVEC_MAX)
|
||||||
return 0;
|
return 0;
|
||||||
vec_list = &autovec_list[vector-1];
|
vec_list = &autovec_list[vector-1];
|
||||||
hard_vec = &autovects[vector-1];
|
hard_vec = &autovects[vector-1];
|
||||||
break;
|
break;
|
||||||
case USER_VEC:
|
case USER_VEC:
|
||||||
if (vector < UVEC_MIN || vector > UVEC_MAX)
|
if (vector < UVEC_MIN || vector > UVEC_MAX)
|
||||||
return 0;
|
return 0;
|
||||||
vec_list = &uservec_list[vector];
|
vec_list = &uservec_list[vector];
|
||||||
hard_vec = &uservects[vector];
|
hard_vec = &uservects[vector];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("intr_disestablish: bogus vector type\n");
|
printf("intr_disestablish: bogus vector type\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -286,27 +286,28 @@ intr_dispatch(struct clockframe frame)
|
||||||
vec_list = &autovec_list[vector - AVEC_LOC];
|
vec_list = &autovec_list[vector - AVEC_LOC];
|
||||||
else if (vector <= (UVEC_LOC+UVEC_MAX) && vector >= UVEC_LOC)
|
else if (vector <= (UVEC_LOC+UVEC_MAX) && vector >= UVEC_LOC)
|
||||||
vec_list = &uservec_list[vector - UVEC_LOC];
|
vec_list = &uservec_list[vector - UVEC_LOC];
|
||||||
else panic("intr_dispatch: Bogus vector %d", vector);
|
else
|
||||||
|
panic("intr_dispatch: Bogus vector %d", vector);
|
||||||
|
|
||||||
if ((ih = vec_list->lh_first) == NULL) {
|
if ((ih = vec_list->lh_first) == NULL) {
|
||||||
printf("intr_dispatch: vector %d unexpected\n", vector);
|
printf("intr_dispatch: vector %d unexpected\n", vector);
|
||||||
if (++unexpected > 10)
|
if (++unexpected > 10)
|
||||||
panic("intr_dispatch: too many unexpected interrupts");
|
panic("intr_dispatch: too many unexpected interrupts");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ih->ih_intrcnt[0]++;
|
ih->ih_intrcnt[0]++;
|
||||||
|
|
||||||
/* Give all the handlers a chance. */
|
/* Give all the handlers a chance. */
|
||||||
for ( ; ih != NULL; ih = ih->ih_link.le_next)
|
for (; ih != NULL; ih = ih->ih_link.le_next)
|
||||||
handled |= (*ih->ih_fun)((ih->ih_type & ARG_CLOCKFRAME)
|
handled |= (*ih->ih_fun)((ih->ih_type & ARG_CLOCKFRAME) ?
|
||||||
? &frame : ih->ih_arg, frame.cf_sr);
|
&frame : ih->ih_arg, frame.cf_sr);
|
||||||
|
|
||||||
if (handled)
|
if (handled)
|
||||||
straycount = 0;
|
straycount = 0;
|
||||||
else if (++straycount > 50)
|
else if (++straycount > 50)
|
||||||
panic("intr_dispatch: too many stray interrupts");
|
panic("intr_dispatch: too many stray interrupts");
|
||||||
else
|
else
|
||||||
printf("intr_dispatch: stray level %d interrupt\n", vector);
|
printf("intr_dispatch: stray level %d interrupt\n", vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: machdep.c,v 1.165 2010/02/08 19:02:26 joerg Exp $ */
|
/* $NetBSD: machdep.c,v 1.166 2010/03/31 14:12:55 tsutsui Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
|
* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.165 2010/02/08 19:02:26 joerg Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.166 2010/03/31 14:12:55 tsutsui Exp $");
|
||||||
|
|
||||||
#include "opt_ddb.h"
|
#include "opt_ddb.h"
|
||||||
#include "opt_compat_netbsd.h"
|
#include "opt_compat_netbsd.h"
|
||||||
|
@ -173,7 +173,7 @@ struct cpu_info cpu_info_store;
|
||||||
void
|
void
|
||||||
consinit(void)
|
consinit(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize error message buffer. pmap_bootstrap() has
|
* Initialize error message buffer. pmap_bootstrap() has
|
||||||
|
@ -206,7 +206,7 @@ consinit(void)
|
||||||
ksyms_addsyms_elf(*(int *)&end, ((int *)&end) + 1, esym);
|
ksyms_addsyms_elf(*(int *)&end, ((int *)&end) + 1, esym);
|
||||||
#else
|
#else
|
||||||
ksyms_addsyms_elf((int)esym - (int)&end - sizeof(Elf32_Ehdr),
|
ksyms_addsyms_elf((int)esym - (int)&end - sizeof(Elf32_Ehdr),
|
||||||
(void *)&end, esym);
|
(void *)&end, esym);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -223,15 +223,14 @@ consinit(void)
|
||||||
void
|
void
|
||||||
cpu_startup(void)
|
cpu_startup(void)
|
||||||
{
|
{
|
||||||
extern int iomem_malloc_safe;
|
extern int iomem_malloc_safe;
|
||||||
char pbuf[9];
|
char pbuf[9];
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
extern int pmapdebug;
|
extern int pmapdebug;
|
||||||
int opmapdebug = pmapdebug;
|
int opmapdebug = pmapdebug;
|
||||||
#endif
|
#endif
|
||||||
vaddr_t minaddr, maxaddr;
|
vaddr_t minaddr, maxaddr;
|
||||||
extern vsize_t mem_size; /* from pmap.c */
|
extern vsize_t mem_size; /* from pmap.c */
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
pmapdebug = 0;
|
pmapdebug = 0;
|
||||||
|
@ -339,13 +338,13 @@ identifycpu(void)
|
||||||
|
|
||||||
case CPU_68060:
|
case CPU_68060:
|
||||||
{
|
{
|
||||||
u_int32_t pcr;
|
uint32_t pcr;
|
||||||
char cputxt[30];
|
char cputxt[30];
|
||||||
|
|
||||||
__asm(".word 0x4e7a,0x0808;"
|
__asm(".word 0x4e7a,0x0808;"
|
||||||
"movl %%d0,%0" : "=d"(pcr) : : "d0");
|
"movl %%d0,%0" : "=d"(pcr) : : "d0");
|
||||||
sprintf(cputxt, "68%s060 rev.%d",
|
sprintf(cputxt, "68%s060 rev.%d",
|
||||||
pcr & 0x10000 ? "LC/EC" : "", (pcr>>8)&0xff);
|
pcr & 0x10000 ? "LC/EC" : "", (pcr >> 8) & 0xff);
|
||||||
cpu = cputxt;
|
cpu = cputxt;
|
||||||
mmu = "/MMU";
|
mmu = "/MMU";
|
||||||
}
|
}
|
||||||
|
@ -454,7 +453,7 @@ reserve_dumppages(vaddr_t p)
|
||||||
return p + BYTES_PER_DUMP;
|
return p + BYTES_PER_DUMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int32_t dumpmag = 0x8fca0101; /* magic number for savecore */
|
uint32_t dumpmag = 0x8fca0101; /* magic number for savecore */
|
||||||
int dumpsize = 0; /* also for savecore (pages) */
|
int dumpsize = 0; /* also for savecore (pages) */
|
||||||
long dumplo = 0; /* (disk blocks) */
|
long dumplo = 0; /* (disk blocks) */
|
||||||
|
|
||||||
|
@ -571,7 +570,7 @@ dumpsys(void)
|
||||||
* Print Mb's to go
|
* Print Mb's to go
|
||||||
*/
|
*/
|
||||||
n = nbytes - i;
|
n = nbytes - i;
|
||||||
if (n && (n % (1024*1024)) == 0)
|
if (n && (n % (1024 * 1024)) == 0)
|
||||||
printf_nolog("%d ", n / (1024 * 1024));
|
printf_nolog("%d ", n / (1024 * 1024));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -625,16 +624,16 @@ dumpsys(void)
|
||||||
void
|
void
|
||||||
straytrap(int pc, u_short evec)
|
straytrap(int pc, u_short evec)
|
||||||
{
|
{
|
||||||
static int prev_evec;
|
static int prev_evec;
|
||||||
|
|
||||||
printf("unexpected trap (vector offset 0x%x) from 0x%x\n",
|
printf("unexpected trap (vector offset 0x%x) from 0x%x\n",
|
||||||
evec & 0xFFF, pc);
|
evec & 0xFFF, pc);
|
||||||
|
|
||||||
if(prev_evec == evec) {
|
if (prev_evec == evec) {
|
||||||
delay(1000000);
|
delay(1000000);
|
||||||
prev_evec = 0;
|
prev_evec = 0;
|
||||||
}
|
} else
|
||||||
else prev_evec = evec;
|
prev_evec = evec;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -663,18 +662,18 @@ badbaddr(void *addr, int size)
|
||||||
}
|
}
|
||||||
switch (size) {
|
switch (size) {
|
||||||
case 1:
|
case 1:
|
||||||
i = *(volatile char *)addr;
|
i = *(volatile uint8_t *)addr;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
i = *(volatile short *)addr;
|
i = *(volatile uint16_t *)addr;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
i = *(volatile long *)addr;
|
i = *(volatile uint32_t *)addr;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
panic("badbaddr: unknown size");
|
panic("badbaddr: unknown size");
|
||||||
}
|
}
|
||||||
nofault = (int *) 0;
|
nofault = (int *)0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,25 +713,25 @@ init_sicallback(void)
|
||||||
void
|
void
|
||||||
add_sicallback(void (*function)(void *, void *), void *rock1, void *rock2)
|
add_sicallback(void (*function)(void *, void *), void *rock1, void *rock2)
|
||||||
{
|
{
|
||||||
struct si_callback *si;
|
struct si_callback *si;
|
||||||
int s;
|
int s;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* this function may be called from high-priority interrupt handlers.
|
* this function may be called from high-priority interrupt handlers.
|
||||||
* We may NOT block for memory-allocation in here!.
|
* We may NOT block for memory-allocation in here!.
|
||||||
*/
|
*/
|
||||||
s = splhigh();
|
s = splhigh();
|
||||||
if ((si = si_free) != NULL)
|
if ((si = si_free) != NULL)
|
||||||
si_free = si->next;
|
si_free = si->next;
|
||||||
splx(s);
|
splx(s);
|
||||||
|
|
||||||
if(si == NULL) {
|
if (si == NULL) {
|
||||||
si = malloc(sizeof(*si), M_TEMP, M_NOWAIT);
|
si = malloc(sizeof(*si), M_TEMP, M_NOWAIT);
|
||||||
#ifdef DIAGNOSTIC
|
#ifdef DIAGNOSTIC
|
||||||
if (si)
|
if (si)
|
||||||
++ncbd; /* count # dynamically allocated */
|
++ncbd; /* count # dynamically allocated */
|
||||||
#endif
|
#endif
|
||||||
if (!si)
|
if (si == NULL)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -764,8 +763,8 @@ add_sicallback(void (*function)(void *, void *), void *rock1, void *rock2)
|
||||||
void
|
void
|
||||||
rem_sicallback(void (*function)(void *rock1, void *rock2))
|
rem_sicallback(void (*function)(void *rock1, void *rock2))
|
||||||
{
|
{
|
||||||
struct si_callback *si, *psi, *nsi;
|
struct si_callback *si, *psi, *nsi;
|
||||||
int s;
|
int s;
|
||||||
|
|
||||||
s = splhigh();
|
s = splhigh();
|
||||||
for (psi = 0, si = si_callbacks; si; ) {
|
for (psi = 0, si = si_callbacks; si; ) {
|
||||||
|
@ -776,7 +775,7 @@ rem_sicallback(void (*function)(void *rock1, void *rock2))
|
||||||
else {
|
else {
|
||||||
si->next = si_free;
|
si->next = si_free;
|
||||||
si_free = si;
|
si_free = si;
|
||||||
if (psi)
|
if (psi != NULL)
|
||||||
psi->next = nsi;
|
psi->next = nsi;
|
||||||
else
|
else
|
||||||
si_callbacks = nsi;
|
si_callbacks = nsi;
|
||||||
|
@ -790,10 +789,10 @@ rem_sicallback(void (*function)(void *rock1, void *rock2))
|
||||||
static void
|
static void
|
||||||
call_sicallbacks(void)
|
call_sicallbacks(void)
|
||||||
{
|
{
|
||||||
struct si_callback *si;
|
struct si_callback *si;
|
||||||
int s;
|
int s;
|
||||||
void *rock1, *rock2;
|
void *rock1, *rock2;
|
||||||
void (*function)(void *, void *);
|
void (*function)(void *, void *);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
s = splhigh ();
|
s = splhigh ();
|
||||||
|
@ -801,7 +800,7 @@ call_sicallbacks(void)
|
||||||
si_callbacks = si->next;
|
si_callbacks = si->next;
|
||||||
splx(s);
|
splx(s);
|
||||||
|
|
||||||
if (si) {
|
if (si != NULL) {
|
||||||
function = si->function;
|
function = si->function;
|
||||||
rock1 = si->rock1;
|
rock1 = si->rock1;
|
||||||
rock2 = si->rock2;
|
rock2 = si->rock2;
|
||||||
|
@ -826,7 +825,7 @@ call_sicallbacks(void)
|
||||||
function(rock1, rock2);
|
function(rock1, rock2);
|
||||||
splx(s);
|
splx(s);
|
||||||
}
|
}
|
||||||
} while (si);
|
} while (si != NULL);
|
||||||
#ifdef DIAGNOSTIC
|
#ifdef DIAGNOSTIC
|
||||||
if (ncbd) {
|
if (ncbd) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -873,7 +872,7 @@ cpu_exec_aout_makecmds(struct lwp *l, struct exec_package *epp)
|
||||||
#ifdef COMPAT_NOMID
|
#ifdef COMPAT_NOMID
|
||||||
if (!((execp->a_midmag >> 16) & 0x0fff)
|
if (!((execp->a_midmag >> 16) & 0x0fff)
|
||||||
&& execp->a_midmag == ZMAGIC)
|
&& execp->a_midmag == ZMAGIC)
|
||||||
return(exec_aout_prep_zmagic(l->l_proc, epp));
|
return exec_aout_prep_zmagic(l->l_proc, epp);
|
||||||
#endif
|
#endif
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue