summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2019-05-15 11:31:59 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2019-05-15 11:31:59 +0000
commit6bb4da7d9bf3229c392786cff96466c702f9f70b (patch)
tree7803450e91f6222635cb97a50cfcf8805abb97cb
parentde4ec02893492da797c0710325405f96ca3cb868 (diff)
parenta1e3874e014aca455b61f88dadd7b0f0145893e8 (diff)
downloadillumos-joyent-6bb4da7d9bf3229c392786cff96466c702f9f70b.tar.gz
[illumos-gate merge]
commit a1e3874e014aca455b61f88dadd7b0f0145893e8 10951 10895 unfixed 10146 commit 18d216a40f7635825d65521fbec434de192b5014 10933 loader: Make lsdev -v output line up in neat columns commit 7efc4ab5dcfd200d52afe798e576fd15b3ffad2d 10934 loader: improve some debugging experience commit fe20e172e8a2aff4961cf65d6975729eb3582b82 10927 loader: ficlPciBiosReadConfig() error: uninitialized symbol 'value'. commit 868fcfe93b967e5d10b7c95ef2d015c8900d607d 10833 sppptun: cast between incompatible function types commit d9c27481e4cab76c5b1c7abf01b386f487b83573 10831 loader emulator ls command fails to detect file types commit 7edfb5b07f43089085e704c276e1a7a0cb1cd32b 10653 ws: NULL pointer errors commit 391003522adc721450b82df5bf97cf692b1a683d 10763 hook: NULL pointer errors commit 626869622a4eee3f87a6a261787ec8a4d4798724 10649 sysmsg: NULL pointer errors commit 414e964c4d9092ad47a8db437b75edbed8f11ae0 10629 ptm: NULL pointer errors commit 25a5294972c1d74b8257cf0ec6d7a93f2da6a8ca 10615 nsmb: NULL pointer errors commit 1e655ac4fe8285c7994c0e6bd9f7ce23579b85b8 10956 sys-suspend(1M) integration with the x window system needs work
-rw-r--r--usr/src/boot/Makefile.version2
-rw-r--r--usr/src/boot/sys/boot/common/bcache.c10
-rw-r--r--usr/src/boot/sys/boot/common/disk.c81
-rw-r--r--usr/src/boot/sys/boot/common/interp_forth.c8
-rw-r--r--usr/src/boot/sys/boot/common/part.c84
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/biosdisk.c24
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/biospci.c426
-rw-r--r--usr/src/boot/sys/boot/userboot/userboot/elf64_freebsd.c5
-rw-r--r--usr/src/cmd/power/sys-suspend.c48
-rw-r--r--usr/src/common/ficl/emu/loader_emu.c21
-rw-r--r--usr/src/uts/common/fs/smbclnt/netsmb/smb_dev.c2
-rw-r--r--usr/src/uts/common/io/hook.c2
-rw-r--r--usr/src/uts/common/io/ppp/sppptun/sppptun.c34
-rw-r--r--usr/src/uts/common/io/ptm.c2
-rw-r--r--usr/src/uts/common/io/sysmsg.c12
-rw-r--r--usr/src/uts/common/io/wscons.c2
-rw-r--r--usr/src/uts/intel/pcbe/core_pcbe.c3
17 files changed, 393 insertions, 373 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version
index 04e89bb2ad..f7eca4e400 100644
--- a/usr/src/boot/Makefile.version
+++ b/usr/src/boot/Makefile.version
@@ -33,4 +33,4 @@ LOADER_VERSION = 1.1
# Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes.
# The version is processed from left to right, the version number can only
# be increased.
-BOOT_VERSION = $(LOADER_VERSION)-2019.05.05.1
+BOOT_VERSION = $(LOADER_VERSION)-2019.05.09.1
diff --git a/usr/src/boot/sys/boot/common/bcache.c b/usr/src/boot/sys/boot/common/bcache.c
index 9d8e385ab4..3d509efc1a 100644
--- a/usr/src/boot/sys/boot/common/bcache.c
+++ b/usr/src/boot/sys/boot/common/bcache.c
@@ -43,9 +43,9 @@
/* #define BCACHE_DEBUG */
#ifdef BCACHE_DEBUG
-#define DEBUG(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)
+#define DPRINTF(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)
#else
-#define DEBUG(fmt, args...) ((void)0)
+#define DPRINTF(fmt, args...) ((void)0)
#endif
struct bcachectl
@@ -372,7 +372,7 @@ bcache_strategy(void *devdata, int rw, daddr_t blk, size_t size,
/* bypass large requests, or when the cache is inactive */
if (bc == NULL ||
((size * 2 / bcache_blksize) > bcache_nblks)) {
- DEBUG("bypass %zu from %qu", size / bcache_blksize, blk);
+ DPRINTF("bypass %zu from %qu", size / bcache_blksize, blk);
bcache_bypasses++;
rw &= F_MASK;
return (dd->dv_strategy(dd->dv_devdata, rw, blk, size, buf,
@@ -449,7 +449,7 @@ bcache_insert(struct bcache *bc, daddr_t blkno)
cand = BHASH(bc, blkno);
- DEBUG("insert blk %llu -> %u # %d", blkno, cand, bcache_bcount);
+ DPRINTF("insert blk %llu -> %u # %d", blkno, cand, bcache_bcount);
bc->bcache_ctl[cand].bc_blkno = blkno;
bc->bcache_ctl[cand].bc_count = bcache_bcount++;
}
@@ -466,7 +466,7 @@ bcache_invalidate(struct bcache *bc, daddr_t blkno)
if (bc->bcache_ctl[i].bc_blkno == blkno) {
bc->bcache_ctl[i].bc_count = -1;
bc->bcache_ctl[i].bc_blkno = -1;
- DEBUG("invalidate blk %llu", blkno);
+ DPRINTF("invalidate blk %llu", blkno);
}
}
diff --git a/usr/src/boot/sys/boot/common/disk.c b/usr/src/boot/sys/boot/common/disk.c
index e04974270e..f77e4a3a93 100644
--- a/usr/src/boot/sys/boot/common/disk.c
+++ b/usr/src/boot/sys/boot/common/disk.c
@@ -37,9 +37,9 @@
#include "disk.h"
#ifdef DISK_DEBUG
-#define DEBUG(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)
+#define DPRINTF(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)
#else
-#define DEBUG(fmt, args...)
+#define DPRINTF(fmt, args...) ((void)0)
#endif
struct open_disk {
@@ -74,7 +74,7 @@ display_size(uint64_t size, uint_t sectorsize)
size /= 1024;
unit = 'M';
}
- snprintf(buf, sizeof (buf), "%" PRIu64 "%cB", size, unit);
+ snprintf(buf, sizeof (buf), "%4" PRIu64 "%cB", size, unit);
return (buf);
}
@@ -101,7 +101,6 @@ ptblread(void *d, void *buf, size_t blocks, uint64_t offset)
blocks * od->sectorsize, (char *)buf, NULL));
}
-#define PWIDTH 35
static int
ptable_print(void *arg, const char *pname, const struct ptable_entry *part)
{
@@ -110,51 +109,55 @@ ptable_print(void *arg, const char *pname, const struct ptable_entry *part)
struct open_disk *od;
struct ptable *table;
char line[80];
- int ret = 0;
+ int res;
+ uint_t sectsize;
+ uint64_t partsize;
pa = (struct print_args *)arg;
od = (struct open_disk *)pa->dev->dd.d_opendata;
- sprintf(line, " %s%s: %s", pa->prefix, pname,
+ sectsize = od->sectorsize;
+ partsize = part->end - part->start + 1;
+ snprintf(line, sizeof (line), " %s%s: %s", pa->prefix, pname,
parttype2str(part->type));
- if (pa->verbose)
- sprintf(line, "%-*s%s", PWIDTH, line,
- display_size(part->end - part->start + 1,
- od->sectorsize));
- strcat(line, "\n");
- ret = pager_output(line);
- if (ret != 0)
- return (ret);
+ if (pager_output(line))
+ return (1);
+
+ if (pa->verbose) {
+ /* Emit extra tab when the line is shorter than 3 tab stops */
+ if (strlen(line) < 24)
+ (void) pager_output("\t");
+
+ snprintf(line, sizeof (line), "\t%s",
+ display_size(partsize, sectsize));
+ if (pager_output(line))
+ return (1);
+ }
+ if (pager_output("\n"))
+ return (1);
+ res = 0;
if (part->type == PART_FREEBSD || part->type == PART_SOLARIS2) {
/* Open slice with BSD or VTOC label */
dev.dd.d_dev = pa->dev->dd.d_dev;
dev.dd.d_unit = pa->dev->dd.d_unit;
dev.d_slice = part->index;
dev.d_partition = -1;
- if (disk_open(&dev, part->end - part->start + 1,
- od->sectorsize) == 0) {
- enum ptable_type pt = PTABLE_NONE;
-
- table = ptable_open(&dev, part->end - part->start + 1,
- od->sectorsize, ptblread);
- if (table != NULL)
- pt = ptable_gettype(table);
-
- if (pt == PTABLE_BSD ||
- pt == PTABLE_VTOC8 ||
- pt == PTABLE_VTOC) {
- sprintf(line, " %s%s", pa->prefix, pname);
+ if (disk_open(&dev, partsize, sectsize) == 0) {
+ table = ptable_open(&dev, partsize, sectsize, ptblread);
+ if (table != NULL) {
+ snprintf(line, sizeof (line), " %s%s",
+ pa->prefix, pname);
bsd.dev = &dev;
bsd.prefix = line;
bsd.verbose = pa->verbose;
- ret = ptable_iterate(table, &bsd, ptable_print);
+ res = ptable_iterate(table, &bsd, ptable_print);
+ ptable_close(table);
}
- ptable_close(table);
disk_close(&dev);
}
}
- return (ret);
+
+ return (res);
}
-#undef PWIDTH
int
disk_print(struct disk_devdesc *dev, char *prefix, int verbose)
@@ -230,7 +233,7 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize, uint_t sectorsize)
int rc, slice, partition;
if (sectorsize == 0) {
- DEBUG("unknown sector size");
+ DPRINTF("unknown sector size");
return (ENXIO);
}
rc = 0;
@@ -244,21 +247,21 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize, uint_t sectorsize)
partition = dev->d_partition;
od = (struct open_disk *)malloc(sizeof (struct open_disk));
if (od == NULL) {
- DEBUG("no memory");
+ DPRINTF("no memory");
return (ENOMEM);
}
dev->dd.d_opendata = od;
od->entrysize = 0;
od->mediasize = mediasize;
od->sectorsize = sectorsize;
- DEBUG("%s unit %d, slice %d, partition %d => %p", disk_fmtdev(dev),
+ DPRINTF("%s unit %d, slice %d, partition %d => %p", disk_fmtdev(dev),
dev->dd.d_unit, dev->d_slice, dev->d_partition, od);
/* Determine disk layout. */
od->table = ptable_open(dev, mediasize / sectorsize, sectorsize,
ptblread);
if (od->table == NULL) {
- DEBUG("Can't read partition table");
+ DPRINTF("Can't read partition table");
rc = ENXIO;
goto out;
}
@@ -314,7 +317,7 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize, uint_t sectorsize)
table = ptable_open(dev, part.end - part.start + 1,
od->sectorsize, ptblread);
if (table == NULL) {
- DEBUG("Can't read BSD/VTOC label");
+ DPRINTF("Can't read BSD/VTOC label");
rc = ENXIO;
goto out;
}
@@ -343,12 +346,12 @@ out:
if (od->table != NULL)
ptable_close(od->table);
free(od);
- DEBUG("%s could not open", disk_fmtdev(dev));
+ DPRINTF("%s could not open", disk_fmtdev(dev));
} else {
/* Save the slice and partition number to the dev */
dev->d_slice = slice;
dev->d_partition = partition;
- DEBUG("%s offset %" PRIu64 " => %p", disk_fmtdev(dev),
+ DPRINTF("%s offset %" PRIu64 " => %p", disk_fmtdev(dev),
dev->d_offset, od);
}
return (rc);
@@ -360,7 +363,7 @@ disk_close(struct disk_devdesc *dev)
struct open_disk *od;
od = (struct open_disk *)dev->dd.d_opendata;
- DEBUG("%s closed => %p", disk_fmtdev(dev), od);
+ DPRINTF("%s closed => %p", disk_fmtdev(dev), od);
ptable_close(od->table);
free(od);
return (0);
diff --git a/usr/src/boot/sys/boot/common/interp_forth.c b/usr/src/boot/sys/boot/common/interp_forth.c
index 0151c52b49..1f3a92bcb4 100644
--- a/usr/src/boot/sys/boot/common/interp_forth.c
+++ b/usr/src/boot/sys/boot/common/interp_forth.c
@@ -37,9 +37,9 @@ extern unsigned bootprog_rev;
/* #define BFORTH_DEBUG */
#ifdef BFORTH_DEBUG
-#define DEBUG(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)
+#define DPRINTF(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)
#else
-#define DEBUG(fmt, args...)
+#define DPRINTF(fmt, args...) ((void)0)
#endif
/*
@@ -135,7 +135,7 @@ bf_command(ficlVm *vm)
ficlVmUpdateTib(vm, tail + len);
}
}
- DEBUG("cmd '%s'", line);
+ DPRINTF("cmd '%s'", line);
command_errmsg = command_errbuf;
command_errbuf[0] = 0;
@@ -342,7 +342,7 @@ bf_run(char *line)
FICL_STRING_SET_FROM_CSTRING(s, line);
result = ficlVmExecuteString(bf_vm, s);
- DEBUG("ficlExec '%s' = %d", line, result);
+ DPRINTF("ficlExec '%s' = %d", line, result);
switch (result) {
case FICL_VM_STATUS_OUT_OF_TEXT:
case FICL_VM_STATUS_ABORTQ:
diff --git a/usr/src/boot/sys/boot/common/part.c b/usr/src/boot/sys/boot/common/part.c
index 53589f865f..fa3ec75e0f 100644
--- a/usr/src/boot/sys/boot/common/part.c
+++ b/usr/src/boot/sys/boot/common/part.c
@@ -43,9 +43,9 @@
#include <uuid.h>
#ifdef PART_DEBUG
-#define DEBUG(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)
+#define DPRINTF(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)
#else
-#define DEBUG(fmt, args...)
+#define DPRINTF(fmt, args...) ((void)0)
#endif
#ifdef LOADER_GPT_SUPPORT
@@ -178,34 +178,34 @@ gpt_checkhdr(struct gpt_hdr *hdr, uint64_t lba_self,
uint32_t sz, crc;
if (memcmp(hdr->hdr_sig, GPT_HDR_SIG, sizeof (hdr->hdr_sig)) != 0) {
- DEBUG("no GPT signature");
+ DPRINTF("no GPT signature");
return (NULL);
}
sz = le32toh(hdr->hdr_size);
if (sz < 92 || sz > sectorsize) {
- DEBUG("invalid GPT header size: %u", sz);
+ DPRINTF("invalid GPT header size: %u", sz);
return (NULL);
}
crc = le32toh(hdr->hdr_crc_self);
hdr->hdr_crc_self = crc32(0, Z_NULL, 0);
if (crc32(hdr->hdr_crc_self, (const Bytef *)hdr, sz) != crc) {
- DEBUG("GPT header's CRC doesn't match");
+ DPRINTF("GPT header's CRC doesn't match");
return (NULL);
}
hdr->hdr_crc_self = crc;
hdr->hdr_revision = le32toh(hdr->hdr_revision);
if (hdr->hdr_revision < GPT_HDR_REVISION) {
- DEBUG("unsupported GPT revision %u", hdr->hdr_revision);
+ DPRINTF("unsupported GPT revision %u", hdr->hdr_revision);
return (NULL);
}
hdr->hdr_lba_self = le64toh(hdr->hdr_lba_self);
if (hdr->hdr_lba_self != lba_self) {
- DEBUG("self LBA doesn't match");
+ DPRINTF("self LBA doesn't match");
return (NULL);
}
hdr->hdr_lba_alt = le64toh(hdr->hdr_lba_alt);
if (hdr->hdr_lba_alt == hdr->hdr_lba_self) {
- DEBUG("invalid alternate LBA");
+ DPRINTF("invalid alternate LBA");
return (NULL);
}
hdr->hdr_entries = le32toh(hdr->hdr_entries);
@@ -213,7 +213,7 @@ gpt_checkhdr(struct gpt_hdr *hdr, uint64_t lba_self,
if (hdr->hdr_entries == 0 ||
hdr->hdr_entsz < sizeof (struct gpt_ent) ||
sectorsize % hdr->hdr_entsz != 0) {
- DEBUG("invalid entry size or number of entries");
+ DPRINTF("invalid entry size or number of entries");
return (NULL);
}
hdr->hdr_lba_start = le64toh(hdr->hdr_lba_start);
@@ -237,7 +237,7 @@ gpt_checktbl(const struct gpt_hdr *hdr, uint8_t *tbl, size_t size,
/* Check CRC only when buffer size is enough for table. */
if (hdr->hdr_crc_table !=
crc32(0, tbl, hdr->hdr_entries * hdr->hdr_entsz)) {
- DEBUG("GPT table's CRC doesn't match");
+ DPRINTF("GPT table's CRC doesn't match");
return (-1);
}
}
@@ -332,7 +332,7 @@ ptable_gptread(struct ptable *table, void *dev, diskread_t dread)
table->type = PTABLE_NONE;
goto out;
}
- DEBUG("GPT detected");
+ DPRINTF("GPT detected");
size = MIN(hdr.hdr_entries * hdr.hdr_entsz,
MAXTBLSZ * table->sectorsize);
@@ -368,7 +368,7 @@ ptable_gptread(struct ptable *table, void *dev, diskread_t dread)
entry->flags = le64toh(ent->ent_attr);
memcpy(&entry->type.gpt, &ent->ent_type, sizeof (uuid_t));
STAILQ_INSERT_TAIL(&table->entries, entry, entry);
- DEBUG("new GPT partition added");
+ DPRINTF("new GPT partition added");
}
out:
free(buf);
@@ -426,7 +426,7 @@ ptable_ebrread(struct ptable *table, void *dev, diskread_t dread)
buf = malloc(table->sectorsize);
if (buf == NULL)
return (table);
- DEBUG("EBR detected");
+ DPRINTF("EBR detected");
for (i = 0; i < MAXEBRENTRIES; i++) {
#if 0 /* Some BIOSes return an incorrect number of sectors */
if (offset >= table->sectors)
@@ -454,7 +454,7 @@ ptable_ebrread(struct ptable *table, void *dev, diskread_t dread)
entry->flags = dp[0].dp_flag;
entry->type.mbr = dp[0].dp_typ;
STAILQ_INSERT_TAIL(&table->entries, entry, entry);
- DEBUG("new EBR partition added");
+ DPRINTF("new EBR partition added");
if (dp[1].dp_typ == 0)
break;
offset = e1->part.start + le32toh(dp[1].dp_start);
@@ -494,14 +494,14 @@ ptable_bsdread(struct ptable *table, void *dev, diskread_t dread)
int i;
if (table->sectorsize < sizeof (struct disklabel)) {
- DEBUG("Too small sectorsize");
+ DPRINTF("Too small sectorsize");
return (table);
}
buf = malloc(table->sectorsize);
if (buf == NULL)
return (table);
if (dread(dev, buf, 1, 1) != 0) {
- DEBUG("read failed");
+ DPRINTF("read failed");
ptable_close(table);
table = NULL;
goto out;
@@ -511,15 +511,15 @@ ptable_bsdread(struct ptable *table, void *dev, diskread_t dread)
le32toh(dl->d_magic2) != DISKMAGIC)
goto out;
if (le32toh(dl->d_secsize) != table->sectorsize) {
- DEBUG("unsupported sector size");
+ DPRINTF("unsupported sector size");
goto out;
}
dl->d_npartitions = le16toh(dl->d_npartitions);
if (dl->d_npartitions > 20 || dl->d_npartitions < 8) {
- DEBUG("invalid number of partitions");
+ DPRINTF("invalid number of partitions");
goto out;
}
- DEBUG("BSD detected");
+ DPRINTF("BSD detected");
part = &dl->d_partitions[0];
raw_offset = le32toh(part[RAW_PART].p_offset);
for (i = 0; i < dl->d_npartitions; i++, part++) {
@@ -537,7 +537,7 @@ ptable_bsdread(struct ptable *table, void *dev, diskread_t dread)
entry->part.index = i; /* starts from zero */
entry->type.bsd = part->p_fstype;
STAILQ_INSERT_TAIL(&table->entries, entry, entry);
- DEBUG("new BSD partition added");
+ DPRINTF("new BSD partition added");
}
table->type = PTABLE_BSD;
out:
@@ -580,7 +580,7 @@ ptable_vtoc8read(struct ptable *table, void *dev, diskread_t dread)
if (buf == NULL)
return (table);
if (dread(dev, buf, 1, 0) != 0) {
- DEBUG("read failed");
+ DPRINTF("read failed");
ptable_close(table);
table = NULL;
goto out;
@@ -590,20 +590,20 @@ ptable_vtoc8read(struct ptable *table, void *dev, diskread_t dread)
for (i = sum = 0; i < sizeof (struct vtoc8); i += sizeof (sum))
sum ^= be16dec(buf + i);
if (sum != 0) {
- DEBUG("incorrect checksum");
+ DPRINTF("incorrect checksum");
goto out;
}
if (be16toh(dl->nparts) != VTOC8_NPARTS) {
- DEBUG("invalid number of entries");
+ DPRINTF("invalid number of entries");
goto out;
}
sectors = be16toh(dl->nsecs);
heads = be16toh(dl->nheads);
if (sectors * heads == 0) {
- DEBUG("invalid geometry");
+ DPRINTF("invalid geometry");
goto out;
}
- DEBUG("VTOC8 detected");
+ DPRINTF("VTOC8 detected");
for (i = 0; i < VTOC8_NPARTS; i++) {
dl->part[i].tag = be16toh(dl->part[i].tag);
if (i == VTOC_RAW_PART ||
@@ -619,7 +619,7 @@ ptable_vtoc8read(struct ptable *table, void *dev, diskread_t dread)
entry->part.index = i; /* starts from zero */
entry->type.vtoc8 = dl->part[i].tag;
STAILQ_INSERT_TAIL(&table->entries, entry, entry);
- DEBUG("new VTOC8 partition added");
+ DPRINTF("new VTOC8 partition added");
}
table->type = PTABLE_VTOC8;
out:
@@ -663,14 +663,14 @@ ptable_dklabelread(struct ptable *table, void *dev, diskread_t dread)
int i;
if (table->sectorsize < sizeof (struct dk_label)) {
- DEBUG("Too small sectorsize");
+ DPRINTF("Too small sectorsize");
return (table);
}
buf = malloc(table->sectorsize);
if (buf == NULL)
return (table);
if (dread(dev, buf, 1, DK_LABEL_LOC) != 0) {
- DEBUG("read failed");
+ DPRINTF("read failed");
ptable_close(table);
table = NULL;
goto out;
@@ -679,18 +679,18 @@ ptable_dklabelread(struct ptable *table, void *dev, diskread_t dread)
dv = (struct dk_vtoc *)&dl->dkl_vtoc;
if (dl->dkl_magic != VTOC_MAGIC) {
- DEBUG("dk_label magic error");
+ DPRINTF("dk_label magic error");
goto out;
}
if (dv->v_sanity != VTOC_SANITY) {
- DEBUG("this vtoc is not sane");
+ DPRINTF("this vtoc is not sane");
goto out;
}
if (dv->v_nparts != NDKMAP) {
- DEBUG("invalid number of entries");
+ DPRINTF("invalid number of entries");
goto out;
}
- DEBUG("VTOC detected");
+ DPRINTF("VTOC detected");
for (i = 0; i < NDKMAP; i++) {
if (i == VTOC_RAW_PART || /* skip slice 2 and empty */
dv->v_part[i].p_size == 0)
@@ -705,7 +705,7 @@ ptable_dklabelread(struct ptable *table, void *dev, diskread_t dread)
entry->part.index = i; /* starts from zero */
entry->type.vtoc = dv->v_part[i].p_tag;
STAILQ_INSERT_TAIL(&table->entries, entry, entry);
- DEBUG("new VTOC partition added");
+ DPRINTF("new VTOC partition added");
}
table->type = PTABLE_VTOC;
out:
@@ -727,7 +727,7 @@ ptable_iso9660read(struct ptable *table, void *dev, diskread_t dread)
return (table);
if (dread(dev, buf, 1, cdb2devb(16)) != 0) {
- DEBUG("read failed");
+ DPRINTF("read failed");
ptable_close(table);
table = NULL;
goto out;
@@ -770,7 +770,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread)
return (NULL);
/* First, read the MBR. */
if (dread(dev, buf, 1, DOSBBSECTOR) != 0) {
- DEBUG("read failed");
+ DPRINTF("read failed");
goto out;
}
@@ -816,7 +816,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread)
/* Check the MBR magic. */
if (buf[DOSMAGICOFFSET] != 0x55 ||
buf[DOSMAGICOFFSET + 1] != 0xaa) {
- DEBUG("magic sequence not found");
+ DPRINTF("magic sequence not found");
#if defined(LOADER_GPT_SUPPORT)
/* There is no PMBR, check that we have backup GPT */
table->type = PTABLE_GPT;
@@ -828,13 +828,13 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread)
dp = (struct dos_partition *)(buf + DOSPARTOFF);
for (i = 0, count = 0; i < NDOSPART; i++) {
if (dp[i].dp_flag != 0 && dp[i].dp_flag != 0x80) {
- DEBUG("invalid partition flag %x", dp[i].dp_flag);
+ DPRINTF("invalid partition flag %x", dp[i].dp_flag);
goto out;
}
#ifdef LOADER_GPT_SUPPORT
if (dp[i].dp_typ == DOSPTYP_PMBR) {
table->type = PTABLE_GPT;
- DEBUG("PMBR detected");
+ DPRINTF("PMBR detected");
}
#endif
if (dp[i].dp_typ != 0)
@@ -844,9 +844,9 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread)
if (table->type == PTABLE_GPT && count > 1) {
if (dp[1].dp_typ != DOSPTYP_HFS) {
table->type = PTABLE_NONE;
- DEBUG("Incorrect PMBR, ignore it");
+ DPRINTF("Incorrect PMBR, ignore it");
} else {
- DEBUG("Bootcamp detected");
+ DPRINTF("Bootcamp detected");
}
}
#ifdef LOADER_GPT_SUPPORT
@@ -857,7 +857,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread)
#endif
#ifdef LOADER_MBR_SUPPORT
/* Read MBR. */
- DEBUG("MBR detected");
+ DPRINTF("MBR detected");
table->type = PTABLE_MBR;
for (i = has_ext = 0; i < NDOSPART; i++) {
if (dp[i].dp_typ == 0)
@@ -883,7 +883,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread)
entry->flags = dp[i].dp_flag;
entry->type.mbr = dp[i].dp_typ;
STAILQ_INSERT_TAIL(&table->entries, entry, entry);
- DEBUG("new MBR partition added");
+ DPRINTF("new MBR partition added");
}
if (has_ext) {
table = ptable_ebrread(table, dev, dread);
diff --git a/usr/src/boot/sys/boot/i386/libi386/biosdisk.c b/usr/src/boot/sys/boot/i386/libi386/biosdisk.c
index 08d7ac2ffe..0b8e90c4d7 100644
--- a/usr/src/boot/sys/boot/i386/libi386/biosdisk.c
+++ b/usr/src/boot/sys/boot/i386/libi386/biosdisk.c
@@ -64,9 +64,9 @@
#define CDMAJOR 15
#ifdef DISK_DEBUG
-#define DEBUG(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)
+#define DPRINTF(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)
#else
-#define DEBUG(fmt, args...)
+#define DPRINTF(fmt, args...) ((void)0)
#endif
struct specification_packet {
@@ -217,12 +217,12 @@ bd_bios2unit(int biosdev)
bdinfo_t *bd;
int i, unit;
- DEBUG("looking for bios device 0x%x", biosdev);
+ DPRINTF("looking for bios device 0x%x", biosdev);
for (i = 0; bdi[i] != NULL; i++) {
unit = 0;
STAILQ_FOREACH(bd, bdi[i], bd_link) {
if (bd->bd_unit == biosdev) {
- DEBUG("bd unit %d is BIOS device 0x%x", unit,
+ DPRINTF("bd unit %d is BIOS device 0x%x", unit,
bd->bd_unit);
return (unit);
}
@@ -615,7 +615,7 @@ bd_int13probe(bdinfo_t *bd)
if (bd->bd_sectors == 0)
bd->bd_sectors = (uint64_t)bd->bd_cyl * bd->bd_hds * bd->bd_sec;
- DEBUG("unit 0x%x geometry %d/%d/%d\n", bd->bd_unit, bd->bd_cyl,
+ DPRINTF("unit 0x%x geometry %d/%d/%d\n", bd->bd_unit, bd->bd_cyl,
bd->bd_hds, bd->bd_sec);
return (true);
@@ -914,7 +914,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size,
return (EIO);
}
- DEBUG("open_disk %p", dev);
+ DPRINTF("open_disk %p", dev);
offset = dblk * BIOSDISK_SECSIZE;
dblk = offset / bd->bd_sectorsize;
@@ -927,7 +927,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size,
* while translating block count to bytes.
*/
if (size > INT_MAX) {
- DEBUG("too large I/O: %zu bytes", size);
+ DPRINTF("too large I/O: %zu bytes", size);
return (EIO);
}
@@ -967,7 +967,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size,
if (dblk + blks >= d_offset + disk_blocks) {
blks = d_offset + disk_blocks - dblk;
size = blks * bd->bd_sectorsize;
- DEBUG("short I/O %d", blks);
+ DPRINTF("short I/O %d", blks);
}
bio_size = min(BIO_BUFFER_SIZE, size);
@@ -992,7 +992,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size,
switch (rw & F_MASK) {
case F_READ:
- DEBUG("read %d from %lld to %p", x, dblk, buf);
+ DPRINTF("read %d from %lld to %p", x, dblk, buf);
bsize = bd->bd_sectorsize * x - blkoff;
if (rest < bsize)
bsize = rest;
@@ -1005,7 +1005,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size,
bcopy(bbuf + blkoff, buf, bsize);
break;
case F_WRITE :
- DEBUG("write %d from %lld to %p", x, dblk, buf);
+ DPRINTF("write %d from %lld to %p", x, dblk, buf);
if (blkoff != 0) {
/*
* We got offset to sector, read 1 sector to
@@ -1253,7 +1253,7 @@ bd_getdev(struct i386_devdesc *d)
return (-1);
biosdev = bd_unit2bios(d);
- DEBUG("unit %d BIOS device %d", dev->dd.d_unit, biosdev);
+ DPRINTF("unit %d BIOS device %d", dev->dd.d_unit, biosdev);
if (biosdev == -1) /* not a BIOS device */
return (-1);
@@ -1306,6 +1306,6 @@ bd_getdev(struct i386_devdesc *d)
}
rootdev = MAKEBOOTDEV(major, slice, unit, partition);
- DEBUG("dev is 0x%x\n", rootdev);
+ DPRINTF("dev is 0x%x\n", rootdev);
return (rootdev);
}
diff --git a/usr/src/boot/sys/boot/i386/libi386/biospci.c b/usr/src/boot/sys/boot/i386/libi386/biospci.c
index 1f9f86338f..4c75fa310f 100644
--- a/usr/src/boot/sys/boot/i386/libi386/biospci.c
+++ b/usr/src/boot/sys/boot/i386/libi386/biospci.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* Copyright (c) 2016 Netflix, Inc
* All rights reserved.
@@ -48,278 +48,289 @@
* interface.
*/
-struct pci_progif
+struct pci_progif
{
- int pi_code;
- const char *pi_name;
+ int pi_code;
+ const char *pi_name;
};
static struct pci_progif progif_null[] = {
- {0x0, NULL},
- {-1, NULL}
+ {0x0, NULL},
+ {-1, NULL}
};
static struct pci_progif progif_display[] = {
- {0x0, "VGA"},
- {0x1, "8514"},
- {-1, NULL}
+ {0x0, "VGA"},
+ {0x1, "8514"},
+ {-1, NULL}
};
static struct pci_progif progif_ide[] = {
- {0x00, NULL},
- {0x01, NULL},
- {0x02, NULL},
- {0x03, NULL},
- {0x04, NULL},
- {0x05, NULL},
- {0x06, NULL},
- {0x07, NULL},
- {0x08, NULL},
- {0x09, NULL},
- {0x0a, NULL},
- {0x0b, NULL},
- {0x0c, NULL},
- {0x0d, NULL},
- {0x0e, NULL},
- {0x0f, NULL},
- {0x80, NULL},
- {0x81, NULL},
- {0x82, NULL},
- {0x83, NULL},
- {0x84, NULL},
- {0x85, NULL},
- {0x86, NULL},
- {0x87, NULL},
- {0x88, NULL},
- {0x89, NULL},
- {0x8a, NULL},
- {0x8b, NULL},
- {0x8c, NULL},
- {0x8d, NULL},
- {0x8e, NULL},
- {0x8f, NULL},
- {-1, NULL}
+ {0x00, NULL},
+ {0x01, NULL},
+ {0x02, NULL},
+ {0x03, NULL},
+ {0x04, NULL},
+ {0x05, NULL},
+ {0x06, NULL},
+ {0x07, NULL},
+ {0x08, NULL},
+ {0x09, NULL},
+ {0x0a, NULL},
+ {0x0b, NULL},
+ {0x0c, NULL},
+ {0x0d, NULL},
+ {0x0e, NULL},
+ {0x0f, NULL},
+ {0x80, NULL},
+ {0x81, NULL},
+ {0x82, NULL},
+ {0x83, NULL},
+ {0x84, NULL},
+ {0x85, NULL},
+ {0x86, NULL},
+ {0x87, NULL},
+ {0x88, NULL},
+ {0x89, NULL},
+ {0x8a, NULL},
+ {0x8b, NULL},
+ {0x8c, NULL},
+ {0x8d, NULL},
+ {0x8e, NULL},
+ {0x8f, NULL},
+ {-1, NULL}
};
static struct pci_progif progif_serial[] = {
- {0x0, "8250"},
- {0x1, "16450"},
- {0x2, "16550"},
- {-1, NULL}
+ {0x0, "8250"},
+ {0x1, "16450"},
+ {0x2, "16550"},
+ {-1, NULL}
};
static struct pci_progif progif_parallel[] = {
- {0x0, "Standard"},
- {0x1, "Bidirectional"},
- {0x2, "ECP"},
- {-1, NULL}
+ {0x0, "Standard"},
+ {0x1, "Bidirectional"},
+ {0x2, "ECP"},
+ {-1, NULL}
};
static struct pci_progif progif_firewire[] = {
- {0x10, "OHCI"},
- {-1, NULL}
+ {0x10, "OHCI"},
+ {-1, NULL}
};
-struct pci_subclass
+struct pci_subclass
{
- int ps_subclass;
- const char *ps_name;
- struct pci_progif *ps_progif; /* if set, use for programming interface value(s) */
+ int ps_subclass;
+ const char *ps_name;
+ /* if set, use for programming interface value(s) */
+ struct pci_progif *ps_progif;
};
static struct pci_subclass subclass_old[] = {
- {0x0, "Old non-VGA", progif_null},
- {0x1, "Old VGA", progif_null},
- {-1, NULL, NULL}
+ {0x0, "Old non-VGA", progif_null},
+ {0x1, "Old VGA", progif_null},
+ {-1, NULL, NULL}
};
static struct pci_subclass subclass_mass[] = {
- {0x0, "SCSI", progif_null},
- {0x1, "IDE", progif_ide},
- {0x2, "Floppy disk", progif_null},
- {0x3, "IPI", progif_null},
- {0x4, "RAID", progif_null},
- {0x80, "mass storage", progif_null},
- {-1, NULL, NULL}
+ {0x0, "SCSI", progif_null},
+ {0x1, "IDE", progif_ide},
+ {0x2, "Floppy disk", progif_null},
+ {0x3, "IPI", progif_null},
+ {0x4, "RAID", progif_null},
+ {0x80, "mass storage", progif_null},
+ {-1, NULL, NULL}
};
static struct pci_subclass subclass_net[] = {
- {0x0, "Ethernet", progif_null},
- {0x1, "Token ring", progif_null},
- {0x2, "FDDI", progif_null},
- {0x3, "ATM", progif_null},
- {0x80, "network", progif_null},
- {-1, NULL, NULL}
+ {0x0, "Ethernet", progif_null},
+ {0x1, "Token ring", progif_null},
+ {0x2, "FDDI", progif_null},
+ {0x3, "ATM", progif_null},
+ {0x80, "network", progif_null},
+ {-1, NULL, NULL}
};
static struct pci_subclass subclass_display[] = {
- {0x0, NULL, progif_display},
- {0x1, "XGA", progif_null},
- {0x80, "other", progif_null},
- {-1, NULL, NULL}
+ {0x0, NULL, progif_display},
+ {0x1, "XGA", progif_null},
+ {0x80, "other", progif_null},
+ {-1, NULL, NULL}
};
static struct pci_subclass subclass_comms[] = {
- {0x0, "serial", progif_serial},
- {0x1, "parallel", progif_parallel},
- {0x80, "communications", progif_null},
- {-1, NULL, NULL}
+ {0x0, "serial", progif_serial},
+ {0x1, "parallel", progif_parallel},
+ {0x80, "communications", progif_null},
+ {-1, NULL, NULL}
};
static struct pci_subclass subclass_serial[] = {
- {0x0, "FireWire", progif_firewire},
- {0x1, "ACCESS.bus", progif_null},
- {0x2, "SSA", progif_null},
- {0x3, "USB", progif_null},
- {0x4, "Fibrechannel", progif_null},
- {-1, NULL, NULL}
+ {0x0, "FireWire", progif_firewire},
+ {0x1, "ACCESS.bus", progif_null},
+ {0x2, "SSA", progif_null},
+ {0x3, "USB", progif_null},
+ {0x4, "Fibrechannel", progif_null},
+ {-1, NULL, NULL}
};
static struct pci_class
{
- int pc_class;
- const char *pc_name;
- struct pci_subclass *pc_subclass;
+ int pc_class;
+ const char *pc_name;
+ struct pci_subclass *pc_subclass;
} pci_classes[] = {
- {0x0, "device", subclass_old},
- {0x1, "controller", subclass_mass},
- {0x2, "controller", subclass_net},
- {0x3, "display", subclass_display},
- {0x7, "controller", subclass_comms},
- {0xc, "controller", subclass_serial},
- {-1, NULL, NULL}
+ {0x0, "device", subclass_old},
+ {0x1, "controller", subclass_mass},
+ {0x2, "controller", subclass_net},
+ {0x3, "display", subclass_display},
+ {0x7, "controller", subclass_comms},
+ {0xc, "controller", subclass_serial},
+ {-1, NULL, NULL}
};
static void biospci_enumerate(void);
-static void biospci_addinfo(int devid, struct pci_class *pc, struct pci_subclass *psc, struct pci_progif *ppi);
+static void biospci_addinfo(int, struct pci_class *, struct pci_subclass *,
+ struct pci_progif *);
struct pnphandler biospcihandler =
{
- "PCI BIOS",
- biospci_enumerate
+ "PCI BIOS",
+ biospci_enumerate
};
-#define PCI_BIOS_PRESENT 0xb101
-#define FIND_PCI_DEVICE 0xb102
-#define FIND_PCI_CLASS_CODE 0xb103
-#define GENERATE_SPECIAL_CYCLE 0xb106
-#define READ_CONFIG_BYTE 0xb108
-#define READ_CONFIG_WORD 0xb109
-#define READ_CONFIG_DWORD 0xb10a
-#define WRITE_CONFIG_BYTE 0xb10b
-#define WRITE_CONFIG_WORD 0xb10c
-#define WRITE_CONFIG_DWORD 0xb10d
-#define GET_IRQ_ROUTING_OPTIONS 0xb10e
-#define SET_PCI_IRQ 0xb10f
+#define PCI_BIOS_PRESENT 0xb101
+#define FIND_PCI_DEVICE 0xb102
+#define FIND_PCI_CLASS_CODE 0xb103
+#define GENERATE_SPECIAL_CYCLE 0xb106
+#define READ_CONFIG_BYTE 0xb108
+#define READ_CONFIG_WORD 0xb109
+#define READ_CONFIG_DWORD 0xb10a
+#define WRITE_CONFIG_BYTE 0xb10b
+#define WRITE_CONFIG_WORD 0xb10c
+#define WRITE_CONFIG_DWORD 0xb10d
+#define GET_IRQ_ROUTING_OPTIONS 0xb10e
+#define SET_PCI_IRQ 0xb10f
-#define PCI_INT 0x1a
+#define PCI_INT 0x1a
-#define PCI_SIGNATURE 0x20494350 /* AKA "PCI " */
+#define PCI_SIGNATURE 0x20494350 /* AKA "PCI " */
void
biospci_detect(void)
{
- uint16_t version, hwcap, maxbus;
- char buf[24];
-
- /* Find the PCI BIOS */
- v86.ctl = V86_FLAGS;
- v86.addr = PCI_INT;
- v86.eax = PCI_BIOS_PRESENT;
- v86.edi = 0x0;
- v86int();
-
- /* Check for OK response */
- if (V86_CY(v86.efl) || ((v86.eax & 0xff00) != 0) ||
- (v86.edx != PCI_SIGNATURE))
- return;
-
- version = v86.ebx & 0xffff;
- hwcap = v86.eax & 0xff;
- maxbus = v86.ecx & 0xff;
+ uint16_t version, hwcap, maxbus;
+ char buf[24];
+
+ /* Find the PCI BIOS */
+ v86.ctl = V86_FLAGS;
+ v86.addr = PCI_INT;
+ v86.eax = PCI_BIOS_PRESENT;
+ v86.edi = 0x0;
+ v86int();
+
+ /* Check for OK response */
+ if (V86_CY(v86.efl) || ((v86.eax & 0xff00) != 0) ||
+ (v86.edx != PCI_SIGNATURE))
+ return;
+
+ version = v86.ebx & 0xffff;
+ hwcap = v86.eax & 0xff;
+ maxbus = v86.ecx & 0xff;
#if 0
- printf("PCI BIOS %d.%d%s%s maxbus %d\n",
- bcd2bin((version >> 8) & 0xf), bcd2bin(version & 0xf),
- (hwcap & 1) ? " config1" : "", (hwcap & 2) ? " config2" : "",
- maxbus);
+ printf("PCI BIOS %d.%d%s%s maxbus %d\n",
+ bcd2bin((version >> 8) & 0xf), bcd2bin(version & 0xf),
+ (hwcap & 1) ? " config1" : "", (hwcap & 2) ? " config2" : "",
+ maxbus);
#endif
- sprintf(buf, "%d", bcd2bin((version >> 8) & 0xf));
- setenv("pcibios.major", buf, 1);
- sprintf(buf, "%d", bcd2bin(version & 0xf));
- setenv("pcibios.minor", buf, 1);
- sprintf(buf, "%d", !!(hwcap & 1));
- setenv("pcibios.config1", buf, 1);
- sprintf(buf, "%d", !!(hwcap & 2));
- setenv("pcibios.config2", buf, 1);
- sprintf(buf, "%d", maxbus);
- setenv("pcibios.maxbus", buf, 1);
-
+ sprintf(buf, "%d", bcd2bin((version >> 8) & 0xf));
+ setenv("pcibios.major", buf, 1);
+ sprintf(buf, "%d", bcd2bin(version & 0xf));
+ setenv("pcibios.minor", buf, 1);
+ sprintf(buf, "%d", !!(hwcap & 1));
+ setenv("pcibios.config1", buf, 1);
+ sprintf(buf, "%d", !!(hwcap & 2));
+ setenv("pcibios.config2", buf, 1);
+ sprintf(buf, "%d", maxbus);
+ setenv("pcibios.maxbus", buf, 1);
}
static void
biospci_enumerate(void)
{
- int device_index, err;
- uint32_t locator, devid;
- struct pci_class *pc;
- struct pci_subclass *psc;
- struct pci_progif *ppi;
-
- /* Iterate over known classes */
- for (pc = pci_classes; pc->pc_class >= 0; pc++) {
- /* Iterate over subclasses */
- for (psc = pc->pc_subclass; psc->ps_subclass >= 0; psc++) {
- /* Iterate over programming interfaces */
- for (ppi = psc->ps_progif; ppi->pi_code >= 0; ppi++) {
-
- /* Scan for matches */
- for (device_index = 0; ; device_index++) {
- /* Look for a match */
- err = biospci_find_devclass((pc->pc_class << 16)
- + (psc->ps_subclass << 8) + ppi->pi_code,
- device_index, &locator);
- if (err != 0)
- break;
-
- /* Read the device identifier from the nominated device */
- err = biospci_read_config(locator, 0, 2, &devid);
- if (err != 0)
- break;
-
- /* We have the device ID, create a PnP object and save everything */
- biospci_addinfo(devid, pc, psc, ppi);
+ int device_index, err;
+ uint32_t locator, devid;
+ struct pci_class *pc;
+ struct pci_subclass *psc;
+ struct pci_progif *ppi;
+
+ /* Iterate over known classes */
+ for (pc = pci_classes; pc->pc_class >= 0; pc++) {
+ /* Iterate over subclasses */
+ for (psc = pc->pc_subclass; psc->ps_subclass >= 0; psc++) {
+ /* Iterate over programming interfaces */
+ for (ppi = psc->ps_progif; ppi->pi_code >= 0; ppi++) {
+
+ /* Scan for matches */
+ for (device_index = 0; ; device_index++) {
+ /* Look for a match */
+ err = biospci_find_devclass(
+ (pc->pc_class << 16) +
+ (psc->ps_subclass << 8) +
+ ppi->pi_code,
+ device_index, &locator);
+ if (err != 0)
+ break;
+
+ /*
+ * Read the device identifier from
+ * the nominated device
+ */
+ err = biospci_read_config(locator,
+ 0, 2, &devid);
+ if (err != 0)
+ break;
+
+ /*
+ * We have the device ID, create a PnP
+ * object and save everything
+ */
+ biospci_addinfo(devid, pc, psc, ppi);
+ }
+ }
}
- }
}
- }
}
static void
-biospci_addinfo(int devid, struct pci_class *pc, struct pci_subclass *psc, struct pci_progif *ppi)
+biospci_addinfo(int devid, struct pci_class *pc, struct pci_subclass *psc,
+ struct pci_progif *ppi)
{
- struct pnpinfo *pi;
- char desc[80];
-
-
- /* build the description */
- desc[0] = 0;
- if (ppi->pi_name != NULL) {
- strcat(desc, ppi->pi_name);
- strcat(desc, " ");
- }
- if (psc->ps_name != NULL) {
- strcat(desc, psc->ps_name);
- strcat(desc, " ");
- }
- if (pc->pc_name != NULL)
- strcat(desc, pc->pc_name);
-
- pi = pnp_allocinfo();
- pi->pi_desc = strdup(desc);
- sprintf(desc,"0x%08x", devid);
- pnp_addident(pi, desc);
- pnp_addinfo(pi);
+ struct pnpinfo *pi;
+ char desc[80];
+
+
+ /* build the description */
+ desc[0] = 0;
+ if (ppi->pi_name != NULL) {
+ strcat(desc, ppi->pi_name);
+ strcat(desc, " ");
+ }
+ if (psc->ps_name != NULL) {
+ strcat(desc, psc->ps_name);
+ strcat(desc, " ");
+ }
+ if (pc->pc_name != NULL)
+ strcat(desc, pc->pc_name);
+
+ pi = pnp_allocinfo();
+ pi->pi_desc = strdup(desc);
+ sprintf(desc, "0x%08x", devid);
+ pnp_addident(pi, desc);
+ pnp_addinfo(pi);
}
int
@@ -332,7 +343,7 @@ biospci_find_devclass(uint32_t class, int index, uint32_t *locator)
v86.esi = index;
v86int();
- /* error */
+ /* error */
if (V86_CY(v86.efl) || (v86.eax & 0xff00))
return (-1);
@@ -351,7 +362,7 @@ biospci_find_device(uint32_t devid, int index, uint32_t *locator)
v86.esi = index;
v86int();
- /* error */
+ /* error */
if (V86_CY(v86.efl) || (v86.eax & 0xff00))
return (-1);
@@ -373,11 +384,11 @@ biospci_write_config(uint32_t locator, int offset, int width, uint32_t val)
v86.ecx = val;
v86int();
- /* error */
+ /* error */
if (V86_CY(v86.efl) || (v86.eax & 0xff00))
return (-1);
- return(0);
+ return (0);
}
int
@@ -390,7 +401,7 @@ biospci_read_config(uint32_t locator, int offset, int width, uint32_t *val)
v86.edi = offset;
v86int();
- /* error */
+ /* error */
if (V86_CY(v86.efl) || (v86.eax & 0xff00))
return (-1);
@@ -426,7 +437,7 @@ biospci_count_device_type(uint32_t devid)
break;
}
- return i;
+ return (i);
}
/*
@@ -494,7 +505,8 @@ ficlPciBiosReadConfig(ficlVm *pVM)
offset = ficlStackPopInteger(ficlVmGetDataStack(pVM));
locator = ficlStackPopInteger(ficlVmGetDataStack(pVM));
- biospci_read_config(locator, offset, width, &value);
+ value = 0;
+ (void) biospci_read_config(locator, offset, width, &value);
ficlStackPushInteger(ficlVmGetDataStack(pVM), value);
}
diff --git a/usr/src/boot/sys/boot/userboot/userboot/elf64_freebsd.c b/usr/src/boot/sys/boot/userboot/userboot/elf64_freebsd.c
index 36129ef6b7..f7c3984f27 100644
--- a/usr/src/boot/sys/boot/userboot/userboot/elf64_freebsd.c
+++ b/usr/src/boot/sys/boot/userboot/userboot/elf64_freebsd.c
@@ -31,6 +31,9 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/exec.h>
#include <sys/linker.h>
+#ifdef DEBUG
+#include <machine/_inttypes.h>
+#endif
#include <string.h>
#include <i386/include/bootinfo.h>
#include <machine/elf.h>
@@ -136,7 +139,7 @@ elf64_exec(struct preloaded_file *fp)
}
#ifdef DEBUG
- printf("Start @ %#llx ...\n", ehdr->e_entry);
+ printf("Start @ %#" PRIx64 " ...\n", ehdr->e_entry);
#endif
dev_cleanup();
diff --git a/usr/src/cmd/power/sys-suspend.c b/usr/src/cmd/power/sys-suspend.c
index 9d055c7f66..e4c82c44a1 100644
--- a/usr/src/cmd/power/sys-suspend.c
+++ b/usr/src/cmd/power/sys-suspend.c
@@ -64,7 +64,7 @@
#include <sys/cpr.h>
/* STATICUSED */
-struct utmpx utmp;
+struct utmpx utmp;
#define NMAX (sizeof (utmp.ut_name))
/*
@@ -251,7 +251,8 @@ pm_poweroff(void)
* make this function quite easy, though.
*/
static int
-pm_check_suspend(void) {
+pm_check_suspend(void)
+{
/*
* Use the uadmin(2) "CHECK" command to see if suspend is supported
*/
@@ -407,8 +408,8 @@ pm_suspend(void)
*/
static void
-suspend_error(int error) {
-
+suspend_error(int error)
+{
switch (error) {
case EBUSY:
(void) printf(gettext("suspend: "
@@ -481,7 +482,7 @@ refresh_dt()
* otherwise, return "xauthority" as it is.
*/
static char *
-get_xauthority(char *xauthority)
+get_xauthority(char *xauthority, size_t buflen)
{
pid_t uid;
char *home_dir;
@@ -515,10 +516,12 @@ get_xauthority(char *xauthority)
/*
* If there is a .Xauthority file in home directory, reference it.
*/
- /*LINTED*/
- (void) sprintf(filepath, "%s/.Xauthority", home_dir);
- if (stat(filepath, &stat_buf) == 0)
- return (strcat(xauthority, filepath));
+ (void) snprintf(filepath, sizeof (filepath),
+ "%s/.Xauthority", home_dir);
+ if (stat(filepath, &stat_buf) == 0) {
+ (void) strlcpy(xauthority, filepath, buflen);
+ return (xauthority);
+ }
/*
* If Xsession can not access user's home directory, it creates the
@@ -533,21 +536,23 @@ get_xauthority(char *xauthority)
while ((dp = readdir(dirp)) != NULL) {
if (strstr(dp->d_name, ".Xauth") != NULL) {
- /*LINTED*/
- (void) sprintf(filepath, "%s/%s", DT_TMP, dp->d_name);
+ (void) snprintf(filepath, sizeof (filepath),
+ "%s/%s", DT_TMP, dp->d_name);
if (stat(filepath, &stat_buf) == -1)
continue;
if (stat_buf.st_uid != uid)
continue;
if (stat_buf.st_ctime > latest) {
- (void) strcpy(xauth, filepath);
+ (void) strlcpy(xauth, filepath,
+ sizeof (xauth));
latest = stat_buf.st_ctime;
}
}
}
(void) closedir(dirp);
- return (strcat(xauthority, xauth));
+ (void) strlcpy(xauthority, xauth, buflen);
+ return (xauthority);
}
/*
@@ -572,9 +577,8 @@ int
main(int argc, char **argv)
{
int c;
- char display_name[MAXNAMELEN + 9] = "DISPLAY=";
- char xauthority[MAXPATHLEN + 12] = "XAUTHORITY=";
- struct passwd *pw;
+ char xauthority[MAXPATHLEN];
+ struct passwd *pw;
(void) signal(SIGHUP, SIG_IGN);
(void) signal(SIGINT, SIG_IGN);
@@ -619,15 +623,8 @@ main(int argc, char **argv)
flags |= SHUTDOWN;
break;
case 'd':
- /* Needswork */
/* Set the DISPLAY value in the environment */
- if (strlen(optarg) >= MAXNAMELEN) {
- (void) printf(gettext("Error: "
- "display name is too long.\n"));
- return (1);
- }
- (void) strcat(display_name, optarg);
- if (putenv(display_name) != 0) {
+ if (setenv("DISPLAY", optarg, 1) != 0) {
(void) printf(gettext("Error: "
"unable to set DISPLAY "
"environment variable.\n"));
@@ -715,7 +712,8 @@ main(int argc, char **argv)
* one up.
*/
if (getenv("XAUTHORITY") == NULL)
- (void) putenv(get_xauthority(xauthority));
+ (void) setenv("XAUTHORITY",
+ get_xauthority(xauthority, MAXPATHLEN), 1);
/*
* In case of "suspend" being called from daemon "powerd",
diff --git a/usr/src/common/ficl/emu/loader_emu.c b/usr/src/common/ficl/emu/loader_emu.c
index dcb2933b84..c3ebb3f21f 100644
--- a/usr/src/common/ficl/emu/loader_emu.c
+++ b/usr/src/common/ficl/emu/loader_emu.c
@@ -1552,20 +1552,19 @@ command_ls(int argc, char *argv[])
while ((d = readdir(dir)) != NULL) {
if (strcmp(d->d_name, ".") && strcmp(d->d_name, "..")) {
/* stat the file, if possible */
- sb.st_size = 0;
- sb.st_mode = 0;
- buf = malloc(strlen(path) + strlen(d->d_name) + 2);
if (path[0] == '\0') {
- (void) snprintf(buf, sizeof (buf), "%s",
- d->d_name);
+ (void) asprintf(&buf, "%s", d->d_name);
} else {
- (void) snprintf(buf, sizeof (buf), "%s/%s",
- path, d->d_name);
+ (void) asprintf(&buf, "%s/%s", path, d->d_name);
+ }
+ if (buf != NULL) {
+ /* ignore return, could be symlink, etc. */
+ if (stat(buf, &sb)) {
+ sb.st_size = 0;
+ sb.st_mode = 0;
+ }
+ free(buf);
}
- /* ignore return, could be symlink, etc. */
- if (stat(buf, &sb))
- sb.st_size = 0;
- free(buf);
if (verbose) {
(void) snprintf(lbuf, sizeof (lbuf),
" %c %8d %s\n",
diff --git a/usr/src/uts/common/fs/smbclnt/netsmb/smb_dev.c b/usr/src/uts/common/fs/smbclnt/netsmb/smb_dev.c
index 3f00ec24ed..83dd482bc8 100644
--- a/usr/src/uts/common/fs/smbclnt/netsmb/smb_dev.c
+++ b/usr/src/uts/common/fs/smbclnt/netsmb/smb_dev.c
@@ -309,7 +309,7 @@ nsmb_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
return (DDI_FAILURE);
if (ddi_create_minor_node(dip, "nsmb", S_IFCHR, 0, DDI_PSEUDO,
- NULL) == DDI_FAILURE) {
+ 0) == DDI_FAILURE) {
cmn_err(CE_WARN, "nsmb_attach: create minor");
return (DDI_FAILURE);
}
diff --git a/usr/src/uts/common/io/hook.c b/usr/src/uts/common/io/hook.c
index 6726f72147..44af26e7c4 100644
--- a/usr/src/uts/common/io/hook.c
+++ b/usr/src/uts/common/io/hook.c
@@ -1883,7 +1883,7 @@ hook_register(hook_family_int_t *hfi, char *event, hook_t *h)
ASSERT(h != NULL);
if (hfi->hfi_stack->hks_shutdown)
- return (NULL);
+ return (0);
/* Alloc hook_int_t and copy hook */
new = hook_copy(h);
diff --git a/usr/src/uts/common/io/ppp/sppptun/sppptun.c b/usr/src/uts/common/io/ppp/sppptun/sppptun.c
index 08b5693286..b09cc1d694 100644
--- a/usr/src/uts/common/io/ppp/sppptun/sppptun.c
+++ b/usr/src/uts/common/io/ppp/sppptun/sppptun.c
@@ -111,12 +111,12 @@ static const char *tcl_kstats_list[] = { TCL_KSTATS_NAMES };
static int sppptun_open(queue_t *, dev_t *, int, int, cred_t *);
static int sppptun_close(queue_t *, int, cred_t *);
-static void sppptun_urput(queue_t *, mblk_t *);
-static void sppptun_uwput(queue_t *, mblk_t *);
+static int sppptun_urput(queue_t *, mblk_t *);
+static int sppptun_uwput(queue_t *, mblk_t *);
static int sppptun_ursrv(queue_t *);
static int sppptun_uwsrv(queue_t *);
-static void sppptun_lrput(queue_t *, mblk_t *);
-static void sppptun_lwput(queue_t *, mblk_t *);
+static int sppptun_lrput(queue_t *, mblk_t *);
+static int sppptun_lwput(queue_t *, mblk_t *);
/*
* This is the hash table of clients. Clients are the programs that
@@ -171,7 +171,7 @@ static struct module_info sppptun_modinfo = {
};
static struct qinit sppptun_urinit = {
- (int (*)())sppptun_urput, /* qi_putp */
+ sppptun_urput, /* qi_putp */
sppptun_ursrv, /* qi_srvp */
sppptun_open, /* qi_qopen */
sppptun_close, /* qi_qclose */
@@ -1635,7 +1635,7 @@ sppptun_inner_mctl(queue_t *q, mblk_t *mp)
* Description:
* Regular output data and controls pass through here.
*/
-static void
+static int
sppptun_uwput(queue_t *q, mblk_t *mp)
{
queue_t *nextq;
@@ -1672,6 +1672,7 @@ sppptun_uwput(queue_t *q, mblk_t *mp)
putnext(q, mp);
break;
}
+ return (0);
}
/*
@@ -1827,7 +1828,7 @@ sppptun_uwsrv(queue_t *q)
* Lower write-side put procedure. Nothing should be sending
* packets down this stream.
*/
-static void
+static int
sppptun_lwput(queue_t *q, mblk_t *mp)
{
switch (MTYPE(mp)) {
@@ -1838,6 +1839,7 @@ sppptun_lwput(queue_t *q, mblk_t *mp)
freemsg(mp);
break;
}
+ return (0);
}
/*
@@ -1849,7 +1851,7 @@ sppptun_lwput(queue_t *q, mblk_t *mp)
* Description:
* Lower read-side put procedure. Nothing should arrive here.
*/
-static void
+static int
sppptun_lrput(queue_t *q, mblk_t *mp)
{
tuncl_t *tcl;
@@ -1857,7 +1859,7 @@ sppptun_lrput(queue_t *q, mblk_t *mp)
switch (MTYPE(mp)) {
case M_IOCTL:
miocnak(q, mp, 0, EINVAL);
- return;
+ return (0);
case M_FLUSH:
if (*mp->b_rptr & FLUSHR) {
flushq(q, FLUSHDATA);
@@ -1868,7 +1870,7 @@ sppptun_lrput(queue_t *q, mblk_t *mp)
} else {
freemsg(mp);
}
- return;
+ return (0);
}
/*
* Try to forward the message to the put procedure for the upper
@@ -1877,7 +1879,7 @@ sppptun_lrput(queue_t *q, mblk_t *mp)
*/
if ((tcl = (tuncl_t *)q->q_ptr) == NULL || tcl->tcl_rq == NULL) {
freemsg(mp);
- return;
+ return (0);
}
if (queclass(mp) == QPCTL ||
(q->q_first == NULL && canput(tcl->tcl_rq))) {
@@ -1886,6 +1888,7 @@ sppptun_lrput(queue_t *q, mblk_t *mp)
if (!putq(q, mp))
freemsg(mp);
}
+ return (0);
}
/*
@@ -2256,7 +2259,7 @@ sppptun_recv(queue_t *q, mblk_t **mpp, const void *srcaddr)
* lower stream driver arrive here. See sppptun_recv for the
* demultiplexing logic.
*/
-static void
+static int
sppptun_urput(queue_t *q, mblk_t *mp)
{
union DL_primitives *dlprim;
@@ -2320,11 +2323,11 @@ sppptun_urput(queue_t *q, mblk_t *mp)
if (nextq != NULL)
putnext(nextq, mpnext);
freeb(mp);
- return;
+ return (0);
default:
urput_dlpi(q, mp);
- return;
+ return (0);
}
break;
}
@@ -2335,6 +2338,7 @@ sppptun_urput(queue_t *q, mblk_t *mp)
freemsg(mp);
break;
}
+ return (0);
}
/*
@@ -2396,7 +2400,7 @@ tcl_destructor(void *maddr, void *arg)
/*
* Clear all bits of x except the highest bit
*/
-#define truncate(x) ((x) <= 2 ? (x) : (1 << (highbit(x) - 1)))
+#define truncate(x) ((x) <= 2 ? (x) : (1 << (highbit(x) - 1)))
/*
* This function initializes some well-known global variables inside
diff --git a/usr/src/uts/common/io/ptm.c b/usr/src/uts/common/io/ptm.c
index 54bcee88bc..4d24932269 100644
--- a/usr/src/uts/common/io/ptm.c
+++ b/usr/src/uts/common/io/ptm.c
@@ -247,7 +247,7 @@ ptm_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
return (DDI_FAILURE);
if (ddi_create_minor_node(devi, "ptmajor", S_IFCHR,
- 0, DDI_PSEUDO, NULL) == DDI_FAILURE) {
+ 0, DDI_PSEUDO, 0) == DDI_FAILURE) {
ddi_remove_minor_node(devi, NULL);
return (DDI_FAILURE);
}
diff --git a/usr/src/uts/common/io/sysmsg.c b/usr/src/uts/common/io/sysmsg.c
index a82a0786fe..e7108edd2e 100644
--- a/usr/src/uts/common/io/sysmsg.c
+++ b/usr/src/uts/common/io/sysmsg.c
@@ -91,7 +91,7 @@ static struct cb_ops sysm_cb_ops = {
sysmioctl, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
- nodev, /* segmap */
+ nodev, /* segmap */
sysmpoll, /* poll */
ddi_prop_op, /* cb_prop_op */
NULL, /* streamtab */
@@ -198,9 +198,9 @@ sysm_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
ASSERT(sysm_dip == NULL);
if (ddi_create_minor_node(devi, "sysmsg", S_IFCHR,
- SYS_SYSMIN, DDI_PSEUDO, NULL) == DDI_FAILURE ||
+ SYS_SYSMIN, DDI_PSEUDO, 0) == DDI_FAILURE ||
ddi_create_minor_node(devi, "msglog", S_IFCHR,
- SYS_MSGMIN, DDI_PSEUDO, NULL) == DDI_FAILURE) {
+ SYS_MSGMIN, DDI_PSEUDO, 0) == DDI_FAILURE) {
ddi_remove_minor_node(devi, NULL);
return (DDI_FAILURE);
}
@@ -591,7 +591,7 @@ sysmioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cred, int *rvalp)
}
}
- if (infop[0] != NULL) {
+ if (infop[0] != '\0') {
if ((rval = lookupname(infop, UIO_SYSSPACE, FOLLOW,
NULLVPP, &vp)) == 0) {
if (vp->v_type != VCHR) {
@@ -613,7 +613,7 @@ sysmioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cred, int *rvalp)
for (i = 0; i < MAXDEVS; i++) {
rw_enter(&sysmcache[i].dca_lock, RW_READER);
if (sysmcache[i].dca_flags & SYSM_ENABLED) {
- if (infop[0] != NULL)
+ if (infop[0] != '\0')
(void) strcat(infop, " ");
(void) strcat(infop, sysmcache[i].dca_name);
}
@@ -691,7 +691,7 @@ err_exit:
/* ARGSUSED */
static int
sysmpoll(dev_t dev, short events, int anyyet, short *reventsp,
- struct pollhead **phpp)
+ struct pollhead **phpp)
{
return (VOP_POLL(dcvp, events, anyyet, reventsp, phpp, NULL));
}
diff --git a/usr/src/uts/common/io/wscons.c b/usr/src/uts/common/io/wscons.c
index 6ba2c7196b..e6282ec828 100644
--- a/usr/src/uts/common/io/wscons.c
+++ b/usr/src/uts/common/io/wscons.c
@@ -346,7 +346,7 @@ wc_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
{
/* create minor node for workstation hard console */
if (ddi_create_minor_node(devi, "wscons", S_IFCHR,
- 0, DDI_PSEUDO, NULL) == DDI_FAILURE) {
+ 0, DDI_PSEUDO, 0) == DDI_FAILURE) {
ddi_remove_minor_node(devi, NULL);
return (DDI_FAILURE);
}
diff --git a/usr/src/uts/intel/pcbe/core_pcbe.c b/usr/src/uts/intel/pcbe/core_pcbe.c
index 7424e2526b..ad92c2f62f 100644
--- a/usr/src/uts/intel/pcbe/core_pcbe.c
+++ b/usr/src/uts/intel/pcbe/core_pcbe.c
@@ -994,7 +994,8 @@ core_pcbe_event_coverage(char *event)
} else {
if (find_generic_events(event, cmn_generic_events) != NULL) {
bitmap |= BITMASK_XBITS(num_gpc);
- } if (find_generic_events(event, generic_events_pic0) != NULL) {
+ } else if (find_generic_events(event,
+ generic_events_pic0) != NULL) {
bitmap |= 1ULL;
} else if (find_gpcevent_core_uarch(event,
cmn_gpc_events_core_uarch) != NULL) {