svn commit: r353983 - in stable/12/stand: common efi/libefi i386/libi386 powerpc userboot/userboot
Kyle Evans
kevans at FreeBSD.org
Thu Oct 24 03:01:43 UTC 2019
Author: kevans
Date: Thu Oct 24 03:01:40 2019
New Revision: 353983
URL: https://svnweb.freebsd.org/changeset/base/353983
Log:
MFC r345066, r347219-r347220, r347223, r347388-r347389, r347391, r347393,
r347553, r348040
r345066:
stand: Improve some debugging experience
Some of these files using <FOO>_DEBUG defined a DEBUG() macro to serve as a
debug-printf. -DDEBUG is useful to enable some debugging output across
multiple ELF/common parts, so switch the DEBUG-as-printf macros over to
something more like DPRINTF that is more commonly used for this kind of
thing and less likely to conflict.
userboot/elf64_freebsd debugging also assumed %llx for uint64; use PRIx64
instead.
r347219:
loader: use safer DPRINTF body for non-debug case
r347220:
loader: bcache code does not need to check argument for free()
r347223:
command_bcache() does not use argv
Therefore mark argv __unused.
r347388:
loader: implement proper 8 char tab stops
The current console code is printing out 8 spaces for tab, calculate
the amount of spaces based on tab stops.
r347389:
loader: ptable_print() needs two tabs sometimes
Since the partition/slice names do vary in length, check the length
of the fixed part of the line against 3 * 8, if the lenth is less than
3 tab stops, print out extra tab.
use snprintf() instead of sprintf.
r347391:
loader: no-TERM_EMU is broken now
If TERM_EMU is not defined, we do not have curx variable. Use conout mode
for efi and expose get_pos() for i386.
r347393:
loader: use DPRINTF in biosdisk.c and define safe DPRINTF
r345066 did miss biosdisk.c.
Also define DPRINTF as ((void)0) for case we do not want debug printouts.
r347553:
loader: fix memory handling errors in module.c
file_loadraw():
check for file_alloc() and strdup() results.
we leak 'name'.
mod_load() does leak 'filename'.
mod_loadkld() does not need to check fp, file_discard() does check.
r348040:
stand: TARGET_ARCH is spelled MACHINE_ARCH in Makefiles
Modified:
stable/12/stand/common/bcache.c
stable/12/stand/common/disk.c
stable/12/stand/common/interp_forth.c
stable/12/stand/common/module.c
stable/12/stand/common/part.c
stable/12/stand/efi/libefi/efi_console.c
stable/12/stand/i386/libi386/biosdisk.c
stable/12/stand/i386/libi386/vidconsole.c
stable/12/stand/powerpc/Makefile
stable/12/stand/userboot/userboot/elf64_freebsd.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/stand/common/bcache.c
==============================================================================
--- stable/12/stand/common/bcache.c Thu Oct 24 02:53:07 2019 (r353982)
+++ stable/12/stand/common/bcache.c Thu Oct 24 03:01:40 2019 (r353983)
@@ -44,9 +44,9 @@ __FBSDID("$FreeBSD$");
/* #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...)
+# define DPRINTF(fmt, args...) ((void)0)
#endif
struct bcachectl
@@ -384,7 +384,7 @@ bcache_strategy(void *devdata, int rw, daddr_t blk, si
/* 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, rsize));
@@ -441,10 +441,8 @@ static void
bcache_free_instance(struct bcache *bc)
{
if (bc != NULL) {
- if (bc->bcache_ctl)
- free(bc->bcache_ctl);
- if (bc->bcache_data)
- free(bc->bcache_data);
+ free(bc->bcache_ctl);
+ free(bc->bcache_data);
free(bc);
}
}
@@ -459,7 +457,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++;
}
@@ -476,7 +474,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);
}
}
@@ -484,7 +482,7 @@ bcache_invalidate(struct bcache *bc, daddr_t blkno)
COMMAND_SET(bcachestat, "bcachestat", "get disk block cache stats", command_bcache);
static int
-command_bcache(int argc, char *argv[])
+command_bcache(int argc, char *argv[] __unused)
{
if (argc != 1) {
command_errmsg = "wrong number of arguments";
Modified: stable/12/stand/common/disk.c
==============================================================================
--- stable/12/stand/common/disk.c Thu Oct 24 02:53:07 2019 (r353982)
+++ stable/12/stand/common/disk.c Thu Oct 24 03:01:40 2019 (r353983)
@@ -38,9 +38,9 @@ __FBSDID("$FreeBSD$");
#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 {
@@ -75,7 +75,7 @@ display_size(uint64_t size, u_int sectorsize)
size /= 1024;
unit = 'M';
}
- sprintf(buf, "%4ld%cB", (long)size, unit);
+ snprintf(buf, sizeof(buf), "%4ld%cB", (long)size, unit);
return (buf);
}
@@ -118,11 +118,24 @@ ptable_print(void *arg, const char *pname, const struc
od = (struct open_disk *)pa->dev->dd.d_opendata;
sectsize = od->sectorsize;
partsize = part->end - part->start + 1;
- sprintf(line, " %s%s: %s\t%s\n", pa->prefix, pname,
- parttype2str(part->type),
- pa->verbose ? display_size(partsize, sectsize) : "");
+ snprintf(line, sizeof(line), " %s%s: %s", pa->prefix, pname,
+ parttype2str(part->type));
if (pager_output(line))
- return 1;
+ 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) {
/* Open slice with BSD label */
@@ -140,7 +153,8 @@ ptable_print(void *arg, const char *pname, const struc
dev.d_offset = part->start;
table = ptable_open(&dev, partsize, sectsize, ptblread);
if (table != NULL) {
- sprintf(line, " %s%s", pa->prefix, pname);
+ snprintf(line, sizeof(line), " %s%s",
+ pa->prefix, pname);
bsd.dev = pa->dev;
bsd.prefix = line;
bsd.verbose = pa->verbose;
@@ -229,13 +243,13 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize
int rc, slice, partition;
if (sectorsize == 0) {
- DEBUG("unknown sector size");
+ DPRINTF("unknown sector size");
return (ENXIO);
}
rc = 0;
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;
@@ -256,14 +270,14 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize
slice = dev->d_slice;
partition = dev->d_partition;
- DEBUG("%s unit %d, slice %d, partition %d => %p",
+ 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(&partdev, mediasize / sectorsize, sectorsize,
ptblread);
if (od->table == NULL) {
- DEBUG("Can't read partition table");
+ DPRINTF("Can't read partition table");
rc = ENXIO;
goto out;
}
@@ -319,7 +333,7 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize
table = ptable_open(dev, part.end - part.start + 1,
od->sectorsize, ptblread);
if (table == NULL) {
- DEBUG("Can't read BSD label");
+ DPRINTF("Can't read BSD label");
rc = ENXIO;
goto out;
}
@@ -347,12 +361,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 %lld => %p", disk_fmtdev(dev),
+ DPRINTF("%s offset %lld => %p", disk_fmtdev(dev),
(long long)dev->d_offset, od);
}
return (rc);
@@ -364,7 +378,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);
Modified: stable/12/stand/common/interp_forth.c
==============================================================================
--- stable/12/stand/common/interp_forth.c Thu Oct 24 02:53:07 2019 (r353982)
+++ stable/12/stand/common/interp_forth.c Thu Oct 24 03:01:40 2019 (r353983)
@@ -39,9 +39,9 @@ INTERP_DEFINE("4th");
/* #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
/*
@@ -128,7 +128,7 @@ bf_command(FICL_VM *vm)
vmUpdateTib(vm, tail + len);
}
}
- DEBUG("cmd '%s'", line);
+ DPRINTF("cmd '%s'", line);
command_errmsg = command_errbuf;
command_errbuf[0] = 0;
@@ -310,7 +310,7 @@ bf_run(const char *line)
*/
result = ficlExec(bf_vm, __DECONST(char *, line));
- DEBUG("ficlExec '%s' = %d", line, result);
+ DPRINTF("ficlExec '%s' = %d", line, result);
switch (result) {
case VM_OUTOFTEXT:
case VM_ABORTQ:
Modified: stable/12/stand/common/module.c
==============================================================================
--- stable/12/stand/common/module.c Thu Oct 24 02:53:07 2019 (r353982)
+++ stable/12/stand/common/module.c Thu Oct 24 03:01:40 2019 (r353983)
@@ -499,7 +499,14 @@ file_loadraw(const char *fname, char *type, int insert
/* Looks OK so far; create & populate control structure */
fp = file_alloc();
- fp->f_name = strdup(name);
+ if (fp == NULL) {
+ snprintf(command_errbuf, sizeof (command_errbuf),
+ "no memory to load %s", name);
+ free(name);
+ close(fd);
+ return (NULL);
+ }
+ fp->f_name = name;
fp->f_type = strdup(type);
fp->f_args = NULL;
fp->f_metadata = NULL;
@@ -507,6 +514,13 @@ file_loadraw(const char *fname, char *type, int insert
fp->f_addr = loadaddr;
fp->f_size = laddr - loadaddr;
+ if (fp->f_type == NULL) {
+ snprintf(command_errbuf, sizeof (command_errbuf),
+ "no memory to load %s", name);
+ free(name);
+ close(fd);
+ return (NULL);
+ }
/* recognise space consumption */
loadaddr = laddr;
@@ -552,6 +566,7 @@ mod_load(char *modname, struct mod_depend *verinfo, in
return (ENOENT);
}
err = mod_loadkld(filename, argc, argv);
+ free(filename);
return (err);
}
@@ -607,7 +622,7 @@ mod_loadkld(const char *kldname, int argc, char *argv[
snprintf(command_errbuf, sizeof(command_errbuf),
"don't know how to load module '%s'", filename);
}
- if (err && fp)
+ if (err)
file_discard(fp);
free(filename);
return (err);
Modified: stable/12/stand/common/part.c
==============================================================================
--- stable/12/stand/common/part.c Thu Oct 24 02:53:07 2019 (r353982)
+++ stable/12/stand/common/part.c Thu Oct 24 03:01:40 2019 (r353983)
@@ -44,9 +44,9 @@ __FBSDID("$FreeBSD$");
#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
@@ -155,34 +155,34 @@ gpt_checkhdr(struct gpt_hdr *hdr, uint64_t lba_self, u
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: %d", sz);
+ DPRINTF("invalid GPT header size: %d", sz);
return (NULL);
}
crc = le32toh(hdr->hdr_crc_self);
hdr->hdr_crc_self = 0;
if (crc32(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 %d", hdr->hdr_revision);
+ DPRINTF("unsupported GPT revision %d", 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);
@@ -190,7 +190,7 @@ gpt_checkhdr(struct gpt_hdr *hdr, uint64_t lba_self, u
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);
@@ -214,7 +214,7 @@ gpt_checktbl(const struct gpt_hdr *hdr, uint8_t *tbl,
/* Check CRC only when buffer size is enough for table. */
if (hdr->hdr_crc_table !=
crc32(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);
}
}
@@ -310,7 +310,7 @@ ptable_gptread(struct ptable *table, void *dev, diskre
table->type = PTABLE_NONE;
goto out;
}
- DEBUG("GPT detected");
+ DPRINTF("GPT detected");
size = MIN(hdr.hdr_entries * hdr.hdr_entsz,
MAXTBLSZ * table->sectorsize);
@@ -346,7 +346,7 @@ ptable_gptread(struct ptable *table, void *dev, diskre
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);
@@ -402,7 +402,7 @@ ptable_ebrread(struct ptable *table, void *dev, diskre
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)
@@ -430,7 +430,7 @@ ptable_ebrread(struct ptable *table, void *dev, diskre
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);
@@ -470,14 +470,14 @@ ptable_bsdread(struct ptable *table, void *dev, diskre
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;
@@ -487,15 +487,15 @@ ptable_bsdread(struct ptable *table, void *dev, diskre
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++) {
@@ -513,7 +513,7 @@ ptable_bsdread(struct ptable *table, void *dev, diskre
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:
@@ -556,7 +556,7 @@ ptable_vtoc8read(struct ptable *table, void *dev, disk
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;
@@ -566,20 +566,20 @@ ptable_vtoc8read(struct ptable *table, void *dev, disk
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 ||
@@ -595,7 +595,7 @@ ptable_vtoc8read(struct ptable *table, void *dev, disk
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:
@@ -619,7 +619,7 @@ ptable_iso9660read(struct ptable *table, void *dev, di
return (table);
if (dread(dev, buf, 1, cdb2devb(16)) != 0) {
- DEBUG("read failed");
+ DPRINTF("read failed");
ptable_close(table);
table = NULL;
goto out;
@@ -663,7 +663,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect
return (NULL);
/* First, read the MBR. */
if (dread(dev, buf, 1, DOSBBSECTOR) != 0) {
- DEBUG("read failed");
+ DPRINTF("read failed");
goto out;
}
@@ -703,7 +703,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect
/* 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;
@@ -715,13 +715,13 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect
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)
@@ -731,9 +731,9 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect
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
@@ -744,7 +744,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect
#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)
@@ -770,7 +770,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect
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);
Modified: stable/12/stand/efi/libefi/efi_console.c
==============================================================================
--- stable/12/stand/efi/libefi/efi_console.c Thu Oct 24 02:53:07 2019 (r353982)
+++ stable/12/stand/efi/libefi/efi_console.c Thu Oct 24 03:01:40 2019 (r353983)
@@ -135,11 +135,13 @@ efi_cons_rawputchar(int c)
UINTN x, y;
conout->QueryMode(conout, conout->Mode->Mode, &x, &y);
- if (c == '\t')
- /* XXX lame tab expansion */
- for (i = 0; i < 8; i++)
+ if (c == '\t') {
+ int n;
+
+ n = 8 - ((conout->Mode->CursorColumn + 8) % 8);
+ for (i = 0; i < n; i++)
efi_cons_rawputchar(' ');
- else {
+ } else {
#ifndef TERM_EMU
if (c == '\n')
efi_cons_efiputchar('\r');
Modified: stable/12/stand/i386/libi386/biosdisk.c
==============================================================================
--- stable/12/stand/i386/libi386/biosdisk.c Thu Oct 24 02:53:07 2019 (r353982)
+++ stable/12/stand/i386/libi386/biosdisk.c Thu Oct 24 03:01:40 2019 (r353983)
@@ -65,9 +65,9 @@ __FBSDID("$FreeBSD$");
#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 {
@@ -218,12 +218,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);
}
@@ -620,7 +620,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);
@@ -919,7 +919,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, s
return (EIO);
}
- DEBUG("open_disk %p", dev);
+ DPRINTF("open_disk %p", dev);
offset = dblk * BIOSDISK_SECSIZE;
dblk = offset / bd->bd_sectorsize;
@@ -932,7 +932,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, s
* 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);
}
@@ -972,7 +972,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, s
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);
@@ -997,7 +997,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, s
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;
@@ -1010,7 +1010,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, s
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
@@ -1259,7 +1259,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);
@@ -1312,6 +1312,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);
}
Modified: stable/12/stand/i386/libi386/vidconsole.c
==============================================================================
--- stable/12/stand/i386/libi386/vidconsole.c Thu Oct 24 02:53:07 2019 (r353982)
+++ stable/12/stand/i386/libi386/vidconsole.c Thu Oct 24 03:01:40 2019 (r353983)
@@ -49,6 +49,8 @@ static int vidc_ischar(void);
static int vidc_started;
+void get_pos(int *x, int *y);
+
#ifdef TERM_EMU
#define MAXARGS 8
#define DEFAULT_FGCOLOR 7
@@ -57,7 +59,6 @@ static int vidc_started;
void end_term(void);
void bail_out(int c);
void vidc_term_emu(int c);
-void get_pos(int *x, int *y);
void curs_move(int *_x, int *_y, int x, int y);
void write_char(int c, int fg, int bg);
void scroll_up(int rows, int fg, int bg);
@@ -136,11 +137,18 @@ vidc_rawputchar(int c)
{
int i;
- if (c == '\t')
- /* lame tab expansion */
- for (i = 0; i < 8; i++)
+ if (c == '\t') {
+ int n;
+#ifndef TERM_EMU
+ int curx, cury;
+
+ get_pos(&curx, %cury);
+#endif
+
+ n = 8 - ((curx + 8) % 8);
+ for (i = 0; i < n; i++)
vidc_rawputchar(' ');
- else {
+ } else {
#ifndef TERM_EMU
vidc_biosputchar(c);
#else
@@ -188,8 +196,6 @@ vidc_rawputchar(int c)
}
}
-#ifdef TERM_EMU
-
/* Get cursor position on the screen. Result is in edx. Sets
* curx and cury appropriately.
*/
@@ -205,6 +211,8 @@ get_pos(int *x, int *y)
*x = v86.edx & 0x00ff;
*y = (v86.edx & 0xff00) >> 8;
}
+
+#ifdef TERM_EMU
/* Move cursor to x rows and y cols (0-based). */
void
Modified: stable/12/stand/powerpc/Makefile
==============================================================================
--- stable/12/stand/powerpc/Makefile Thu Oct 24 02:53:07 2019 (r353982)
+++ stable/12/stand/powerpc/Makefile Thu Oct 24 03:01:40 2019 (r353983)
@@ -6,7 +6,7 @@ NO_OBJ=t
SUBDIR.yes= boot1.chrp ofw uboot
-.if "${TARGET_ARCH}" == "powerpc64"
+.if "${MACHINE_ARCH}" == "powerpc64"
SUBDIR.${MK_FDT}+= kboot
.endif
Modified: stable/12/stand/userboot/userboot/elf64_freebsd.c
==============================================================================
--- stable/12/stand/userboot/userboot/elf64_freebsd.c Thu Oct 24 02:53:07 2019 (r353982)
+++ stable/12/stand/userboot/userboot/elf64_freebsd.c Thu Oct 24 03:01:40 2019 (r353983)
@@ -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();
More information about the svn-src-all
mailing list