add print like attribute and fix broken printf

This commit is contained in:
quackerd 2024-10-31 11:04:05 -04:00
parent 1eed961317
commit ae5541ce16
26 changed files with 65 additions and 65 deletions

View File

@ -123,7 +123,7 @@ Debug_Backtrace(int argc, const char *argv[])
kprintf("%-16s %-16s\n", "IP Pointer", "Base Pointer");
while (3) {
kprintf("%016llx %016llx\n", rip, rbp);
kprintf("%016lx %016lx\n", rip, rbp);
ptr = (uint64_t *)rbp;
if (rbp == 0ULL || rip == 0ULL) {
break;

View File

@ -1577,7 +1577,7 @@ db_disasm(uintptr_t loc, UNUSED bool altfmt)
case Ilq:
len = db_lengths[rex & REX_W ? QUAD : LONG];
get_value_inc(imm64, loc, len, FALSE);
kprintf("$%#lr", imm64);
kprintf("$%lu", imm64);
break;
case O:

View File

@ -245,7 +245,7 @@ gic_discover(void)
gic.gic_dist = (void*)DEVPA2VA(dist_base);
gic.gic_rdist = (void*)DEVPA2VA(redist_base);
kprintf("GIC v3 dist base = 0x%llx, redist base = 0x%llx.\n", gic.gic_dist, gic.gic_rdist);
kprintf("GIC v3 dist base = 0x%p, redist base = 0x%p.\n", gic.gic_dist, gic.gic_rdist);
while((gic.gic_rdist[index].lpis.GICR_TYPER & (1<<4)) == 0) // Keep incrementing until GICR_TYPER.Last reports no more RDs in block
{
@ -668,7 +668,7 @@ gic_redist_init(void)
return ret;
}
cpustate->gic_redist_id = rd;
kprintf("GIC: CPU %d, MPID 0x%lx, Redist ID 0x%lx.\n", cpustate->id, cpustate->mpid, cpustate->gic_redist_id);
kprintf("GIC: CPU %d, MPID 0x%u, Redist ID 0x%u.\n", cpustate->id, cpustate->mpid, cpustate->gic_redist_id);
// Mark this core as being active
gic_wakeup_redist(rd);

View File

@ -124,7 +124,7 @@ MachineBoot_AddMem()
len = initRamEnd - start;
start = initRamEnd;
}
kprintf("Initializing physical memory region: base = 0x%llx, len = 0x%llx ... ", start, len);
kprintf("Initializing physical memory region: base = 0x%lx, len = 0x%lx ... ", start, len);
PAlloc_AddRegion(start + MEM_DIRECTMAP_BASE, len);
kprintf("Done!\n");
}

View File

@ -35,7 +35,7 @@ PTimer_Tick(UNUSED void * arg)
KTimer_Process();
kprintf("Hardware timer tick, epoch = %llu, tsc = %llu, CVAL = %llu.\n", KTime_GetEpoch(), Time_GetTSC(), SYSREG_GET(CNTP_CVAL_EL0));
kprintf("Hardware timer tick, epoch = %lu, tsc = %lu, CVAL = %lu.\n", KTime_GetEpoch(), Time_GetTSC(), SYSREG_GET(CNTP_CVAL_EL0));
}
void
@ -59,13 +59,13 @@ PTimer_Init()
SYSREG_SET(CNTP_CTL_EL0, cntp_ctl_el0);
KTime_SetTime(KTIMER_EPOCH, tsc, tsc_freq);
kprintf("Hardware timer: epoch = %llu, tsc = %llu, tsc freq = %llu.\n", KTIMER_EPOCH, tsc, tsc_freq);
kprintf("Hardware timer: epoch = %llu, tsc = %lu, tsc freq = %lu.\n", KTIMER_EPOCH, tsc, tsc_freq);
}
static void
Debug_ReadTSC(UNUSED int argc, UNUSED const char *argv[])
{
kprintf("RDTSC: %lld\n", Time_GetTSC());
kprintf("RDTSC: %lu\n", Time_GetTSC());
}
REGISTER_DBGCMD(readtsc, "Print current timestamp", Debug_ReadTSC);

View File

@ -103,9 +103,9 @@ void
trap_entry(TrapFrame * tf)
{
if (tf->type == T_TYPE_EXC) {
Panic("Unexpected exception: Type = 0x%llx, IntID = 0x%llx, ESR = 0x%llx, FAR = 0x%llx, ELR = 0x%llx, SPSR = 0x%llx.\n", tf->type, tf->intid, tf->esr, tf->far, tf->elr, tf->spsr);
Panic("Unexpected exception: Type = 0x%lx, IntID = 0x%lx, ESR = 0x%lx, FAR = 0x%lx, ELR = 0x%lx, SPSR = 0x%lx.\n", tf->type, tf->intid, tf->esr, tf->far, tf->elr, tf->spsr);
} else {
kprintf("IRQ: Type = 0x%llx, IntID = 0x%llx, ESR = 0x%llx, FAR = 0x%llx, ELR = 0x%llx, SPSR = 0x%llx.\n", tf->type, tf->intid, tf->esr, tf->far, tf->elr, tf->spsr);
kprintf("IRQ: Type = 0x%lx, IntID = 0x%lx, ESR = 0x%lx, FAR = 0x%lx, ELR = 0x%lx, SPSR = 0x%lx.\n", tf->type, tf->intid, tf->esr, tf->far, tf->elr, tf->spsr);
// irq
IRQ_Handler(tf->intid);
}
@ -119,7 +119,7 @@ Debug_Traps(UNUSED int argc, UNUSED const char *argv[])
kprintf("Trap Interrupts Trap Interrupts\n");
for (i = 0; i < T_IRQ_MAX / 2; i++)
{
kprintf("%-4d %-12d %-4d %-12d\n",
kprintf("%-4d %-12lu %-4d %-12lu\n",
i, intStats[i],
T_IRQ_MAX / 2 + i, intStats[T_IRQ_MAX / 2 + i]);
}

View File

@ -236,8 +236,8 @@ AHCI_DumpPort(AHCI *ahci, int port)
volatile AHCIPort *p = ahci->port[port];
kprintf("Port %d\n", port);
kprintf("CLBA: 0x%016llx\n", p->clba);
kprintf("FB: 0x%016llx\n", p->fb);
kprintf("CLBA: 0x%016lx\n", p->clba);
kprintf("FB: 0x%016lx\n", p->fb);
kprintf("IS: 0x%08x\n", p->is);
kprintf("IE: 0x%08x\n", p->ie);
kprintf("CMD: 0x%08x\n", p->cmd);

View File

@ -157,5 +157,5 @@ void
Serial_Init(void)
{
uart_init(&g_uart0);
kprintf("Initialized PL011 UART, base = 0x%llx.\n", g_uart0.base);
kprintf("Initialized PL011 UART, base = 0x%lx.\n", g_uart0.base);
}

View File

@ -417,7 +417,7 @@ Debug_PCIDump(int argc, const char *argv[])
{
uint32_t barReg = PCI_OFFSET_BARFIRST + 4 * bar;
kprintf("BAR%d: %016llx\n", bar, PCICfgRead32(bus, device, func, barReg));
kprintf("BAR%d: %016x\n", bar, PCICfgRead32(bus, device, func, barReg));
}
}

View File

@ -90,7 +90,7 @@ O2FS_Mount(Disk *disk)
}
DLOG(o2fs, "File system mounted\n");
DLOG(o2fs, "Root @ 0x%llx\n", sb->root.offset);
DLOG(o2fs, "Root @ 0x%lx\n", sb->root.offset);
fs->fsptr = entry;
fs->fsval = sb->root.offset;
@ -279,7 +279,7 @@ O2FSGrowVNode(VNode *vn, uint64_t filesz)
}
}
DLOG(o2fs, "Growing: %d\n", filesz);
DLOG(o2fs, "Growing: %ld\n", filesz);
bn->size = filesz;
BufCache_Write(vnEntry);
@ -377,7 +377,7 @@ O2FS_GetRoot(VFS *fs, VNode **dn)
void
O2FSDumpDirEntry(BDirEntry *entry)
{
VLOG(o2fs, "%16s %08llx %08llx\n", entry->name, entry->objId.offset, entry->size);
VLOG(o2fs, "%16s %08lx %08lx\n", entry->name, entry->objId.offset, entry->size);
}
/**
@ -403,7 +403,7 @@ O2FS_Lookup(VNode *dn, VNode **fn, const char *name)
uint64_t blocks = (dirBN->size + sb->blockSize - 1) / sb->blockSize;
uint64_t b;
DLOG(o2fs, "Lookup %lld %d\n", dirBN->size, blocks);
DLOG(o2fs, "Lookup %lu %lu\n", dirBN->size, blocks);
for (b = 0; b < blocks; b++) {
// Read block
@ -464,7 +464,7 @@ O2FS_Stat(VNode *fn, struct stat *statinfo)
BufCacheEntry *fileEntry = (BufCacheEntry *)fn->fsptr;
BNode *fileBN = fileEntry->buffer;
DLOG(o2fs, "O2FS %p %d\n", fileBN, fileBN->size);
DLOG(o2fs, "O2FS %p %lu\n", fileBN, fileBN->size);
statinfo->st_ino = fileEntry->diskOffset;
statinfo->st_size = fileBN->size;
@ -498,7 +498,7 @@ O2FS_Read(VNode *fn, void *buf, uint64_t off, uint64_t len)
uint64_t blocks = (fileBN->size + sb->blockSize - 1) / sb->blockSize;
uint64_t readBytes = 0;
DLOG(o2fs, "Read %lld %d\n", fileBN->size, blocks);
DLOG(o2fs, "Read %lu %lu\n", fileBN->size, blocks);
if (off > fileBN->size) {
return 0;
@ -524,7 +524,7 @@ O2FS_Read(VNode *fn, void *buf, uint64_t off, uint64_t len)
if (status < 0)
return status;
DLOG(o2fs, "READ %lx %lx %lld\n", buf, entry->buffer, bLen);
DLOG(o2fs, "READ %p %p %lu\n", buf, entry->buffer, bLen);
memcpy(buf, entry->buffer + bOff, bLen);
BufCache_Release(entry);
@ -564,7 +564,7 @@ O2FS_Write(VNode *fn, void *buf, uint64_t off, uint64_t len)
uint64_t blocks = (fileBN->size + sb->blockSize - 1) / sb->blockSize;
uint64_t readBytes = 0;
DLOG(o2fs, "Write %lld %d\n", fileBN->size, blocks);
DLOG(o2fs, "Write %lu %lu\n", fileBN->size, blocks);
// XXX: Check permissions
@ -590,7 +590,7 @@ O2FS_Write(VNode *fn, void *buf, uint64_t off, uint64_t len)
if (status < 0)
return status;
DLOG(o2fs, "WRITE %lx %lx %lld\n", buf, entry->buffer, bLen);
DLOG(o2fs, "WRITE %p %p %lu\n", buf, entry->buffer, bLen);
memcpy(entry->buffer + bOff, buf, bLen);
BufCache_Write(entry);
BufCache_Release(entry);

View File

@ -284,9 +284,9 @@ BufCache_Write(BufCacheEntry *entry)
static void
Debug_BufCache(UNUSED int argc, UNUSED const char *argv[])
{
kprintf("Hits: %lld\n", cacheHit);
kprintf("Misses: %lld\n", cacheMiss);
kprintf("Allocations: %lld\n", cacheAlloc);
kprintf("Hits: %ld\n", cacheHit);
kprintf("Misses: %ld\n", cacheMiss);
kprintf("Allocations: %ld\n", cacheAlloc);
}
REGISTER_DBGCMD(diskcache, "Display disk cache statistics", Debug_BufCache);

View File

@ -117,7 +117,7 @@ Debug_GetValue(uintptr_t addr, int size, bool isSigned)
void
Debug_PrintSymbol(uintptr_t off, UNUSED int strategy)
{
kprintf("0x%llx", off);
kprintf("0x%lx", off);
}
uint64_t
@ -159,7 +159,7 @@ Debug_SymbolToInt(const char *s)
if (*s >= '0' || *s <= '9')
return Debug_StrToInt(s);
kprintf("Unknown symbol '%s'\n");
kprintf("Unknown symbol '%s'\n", s);
return 0;
}
@ -215,7 +215,7 @@ Debug_Dump(int argc, const char *argv[])
off = Debug_SymbolToInt(argv[1]);
len = Debug_SymbolToInt(argv[2]);
kprintf("Dump 0x%llx 0x%llx\n", off, len);
kprintf("Dump 0x%lx 0x%lx\n", off, len);
Debug_PrintHex((const char *)off, len, 0, len);
}
@ -236,7 +236,7 @@ Debug_Disasm(int argc, const char *argv[])
off = Debug_SymbolToInt(argv[1]);
if (argc == 3)
len = Debug_SymbolToInt(argv[2]);
kprintf("Disassembly 0x%llx:\n", off);
kprintf("Disassembly 0x%lx:\n", off);
for (; len > 0; len--)
{

View File

@ -64,7 +64,7 @@ Debug_Disks(UNUSED int argc, UNUSED const char *argv[])
Disk *d;
LIST_FOREACH(d, &diskList, entries) {
kprintf("disk%lld.%lld: %lld Sectors\n",
kprintf("disk%lu.%lu: %lu Sectors\n",
d->ctrlNo, d->diskNo, d->sectorCount);
}
}
@ -95,7 +95,7 @@ Debug_DumpDisk(int argc, const char *argv[])
sga.entries[0].offset = sector;
sga.entries[0].length = 512;
kprintf("Reading Sector %lld from disk%lld.%lld\n", sector, ctrlNo, diskNo);
kprintf("Reading Sector %lu from disk%lu.%lu\n", sector, ctrlNo, diskNo);
Disk_Read(d, &buf, &sga, NULL, NULL);
Debug_PrintHex((const char *)&buf, 512, 0, 512);

View File

@ -150,14 +150,14 @@ Loader_Load(Thread *thr, VNode *vn, void *buf, UNUSED uint64_t len)
if (phdr[i].p_type == PT_LOAD) {
uint64_t va = phdr[i].p_vaddr;
uint64_t memsz = phdr[i].p_memsz;
Log(loader, "%08llx %016llx %08llx %08llx\n", phdr[i].p_offset,
Log(loader, "%08lx %016lx %08lx %08lx\n", phdr[i].p_offset,
phdr[i].p_vaddr, phdr[i].p_filesz, phdr[i].p_memsz);
// Make sure it is page aligned
va = va & ~(uint64_t)PGMASK;
memsz += phdr[i].p_vaddr - va;
Log(loader, "AllocMap %016llx %08llx\n", va, memsz);
Log(loader, "AllocMap %016lx %08lx\n", va, memsz);
if (!PMap_AllocMap(as, va, memsz, PROT_ALL)) {
// XXX: Cleanup!
ASSERT(false);

View File

@ -48,7 +48,7 @@ Debug_NICs(UNUSED int argc, UNUSED const char *argv[])
NIC *n;
LIST_FOREACH(n, &nicList, entries) {
kprintf("nic%lld: %02x:%02x:%02x:%02x:%02x:%02x\n", n->nicNo,
kprintf("nic%ld: %02x:%02x:%02x:%02x:%02x:%02x\n", n->nicNo,
n->mac[0], n->mac[1], n->mac[2], n->mac[3], n->mac[4], n->mac[5]);
}
}

View File

@ -277,9 +277,9 @@ PAlloc_Release(void *pg)
static void
Debug_PAllocStats(int argc, const char *argv[])
{
kprintf("Total Pages: %llu\n", totalPages);
kprintf("Allocated Pages: %llu\n", totalPages - freePages);
kprintf("Free Pages: %llu\n", freePages);
kprintf("Total Pages: %lu\n", totalPages);
kprintf("Allocated Pages: %lu\n", totalPages - freePages);
kprintf("Free Pages: %lu\n", freePages);
}
REGISTER_DBGCMD(pallocstats, "Page allocator statistics", Debug_PAllocStats);

View File

@ -177,8 +177,8 @@ again:
printnum(func, handle, unum, 8, width, padc);
break;
case 'p':
unum = (unsigned long)va_arg(ap, void *);
printnum(func, handle, unum, 8, width, padc);
unum = (uintptr_t)va_arg(ap, void *);
printnum(func, handle, unum, 16, width, padc);
break;
case 'x':
unum = getuint(ap, lflag);

View File

@ -277,12 +277,12 @@ Process_Dump(Process *proc)
};
kprintf("title %s\n", proc->title);
kprintf("pid %llu\n", proc->pid);
kprintf("pid %lu\n", proc->pid);
kprintf("state %s\n", stateStrings[proc->procState]);
kprintf("space %016llx\n", proc->space);
kprintf("threads %llu\n", proc->threads);
kprintf("refCount %d\n", proc->refCount);
kprintf("nextFD %llu\n", proc->nextFD);
kprintf("space %016lx\n", (uintptr_t)proc->space);
kprintf("threads %lu\n", proc->threads);
kprintf("refCount %lu\n", proc->refCount);
kprintf("nextFD %lu\n", proc->nextFD);
}
static void
@ -298,7 +298,7 @@ Debug_Processes(int argc, const char *argv[])
TAILQ_FOREACH(proc, &processList, processList)
{
kprintf("Process: %d(%016llx)\n", proc->pid, proc);
kprintf("Process: %lu(%016lx)\n", proc->pid, (uintptr_t)proc);
Process_Dump(proc);
}

View File

@ -111,7 +111,7 @@ Debug_Semaphores(int argc, const char *argv[])
Thread *thr;
kprintf("%-36s %8d\n", sema->name, sema->count);
TAILQ_FOREACH(thr, &sema->waiters, semaQueue) {
kprintf("waiting: %d:%d\n", thr->proc->pid, thr->tid);
kprintf("waiting: %lu:%lu\n", thr->proc->pid, thr->tid);
}
}

View File

@ -34,7 +34,7 @@ SGArray_Dump(SGArray *sga)
kprintf("--- SGArray Begin ---\n");
for (i = 0; i < sga->len; i++)
{
kprintf("%d: %016llx %016llx\n", i, sga->entries[i].offset,
kprintf("%d: %016lx %016lx\n", i, sga->entries[i].offset,
sga->entries[i].length);
}
kprintf("--- SGArray End ---\n");

View File

@ -151,7 +151,7 @@ Debug_Slabs(int argc, const char *argv[])
kprintf("%-36s %-10s %-10s %-10s\n", "Slab Name", "Alloc", "Free", "Total");
LIST_FOREACH(slab, &slabList, slabList) {
kprintf("%-36s %-10lld %-10lld %-10lld\n", slab->name,
kprintf("%-36s %-10ld %-10ld %-10ld\n", slab->name,
slab->objs - slab->freeObjs, slab->freeObjs, slab->objs);
}
}

View File

@ -142,7 +142,7 @@ Debug_Spinlocks(int argc, const char *argv[])
kprintf("%-36s Locked CPU Count WaitTime LockTime\n", "Lock Name");
LIST_FOREACH(lock, &lockList, lockList)
{
kprintf("%-36s %6llu %3llu %8llu %12llu %12llu\n", lock->name,
kprintf("%-36s %6lu %3lu %8lu %12lu %12lu\n", lock->name,
lock->lock, lock->cpu, lock->count,
lock->waitTime, lock->lockTime);
}

View File

@ -161,7 +161,7 @@ Syscall_Spawn(uint64_t user_path, uint64_t user_argv)
proc = Process_Create(cur->proc, path);
thr = Thread_Create(proc);
Thread_Release(cur);
Log(syscall, "SPAWN %lx\n", thr);
Log(syscall, "SPAWN %p\n", thr);
Handle *handle = Console_OpenHandle();
Handle_Add(proc, handle);

View File

@ -326,15 +326,15 @@ Thread_Dump(Thread *thr)
};
// Thread_DumpArch(thr)
kprintf("space %016llx\n", thr->space);
kprintf("kstack %016llx\n", thr->kstack);
kprintf("tid %llu\n", thr->tid);
kprintf("refCount %d\n", thr->refCount);
kprintf("space %016lx\n", (uintptr_t)thr->space);
kprintf("kstack %016lx\n", thr->kstack);
kprintf("tid %lu\n", thr->tid);
kprintf("refCount %lu\n", thr->refCount);
kprintf("state %s\n", states[thr->schedState]);
kprintf("ctxswtch %llu\n", thr->ctxSwitches);
kprintf("utime %llu\n", thr->userTime);
kprintf("ktime %llu\n", thr->kernTime);
kprintf("wtime %llu\n", thr->waitTime);
kprintf("ctxswtch %lu\n", thr->ctxSwitches);
kprintf("utime %lu\n", thr->userTime);
kprintf("ktime %lu\n", thr->kernTime);
kprintf("wtime %lu\n", thr->waitTime);
if (thr->proc) {
Process_Dump(thr->proc);
}
@ -350,18 +350,18 @@ Debug_Threads(int argc, const char *argv[])
for (int i = 0; i < MAX_CPUS; i++) {
thr = curProc[i];
if (thr) {
kprintf("Running Thread CPU %d: %d(%016llx) %d\n", i, thr->tid, thr, thr->ctxSwitches);
kprintf("Running Thread CPU %d: %lu(%016lx) %lu\n", i, thr->tid, (uintptr_t)thr, thr->ctxSwitches);
Thread_Dump(thr);
}
}
TAILQ_FOREACH(thr, &runnableQueue, schedQueue)
{
kprintf("Runnable Thread: %d(%016llx) %d\n", thr->tid, thr, thr->ctxSwitches);
kprintf("Runnable Thread: %lu(%016lx) %lu\n", thr->tid, (uintptr_t)thr, thr->ctxSwitches);
Thread_Dump(thr);
}
TAILQ_FOREACH(thr, &waitQueue, schedQueue)
{
kprintf("Waiting Thread: %d(%016llx) %d\n", thr->tid, thr, thr->ctxSwitches);
kprintf("Waiting Thread: %lu(%016lx) %lu\n", thr->tid, (uintptr_t)thr, thr->ctxSwitches);
Thread_Dump(thr);
}

View File

@ -105,7 +105,7 @@ VFS_Lookup(const char *path)
// Release oldNode
if (*end == '\0') {
Log(vfs, "%s %lx\n", path, curNode);
Log(vfs, "%s %p\n", path, curNode);
return curNode;
}

View File

@ -126,7 +126,7 @@ Debug_XMemStats(int argc, const char *argv[])
for (r = 0; r < MAX_XMEM_REGIONS; r++)
{
if (regions[r].inUse) {
kprintf("Region %2d: %016llx %016llx\n", r,
kprintf("Region %2d: %016lx %016lx\n", r,
regions[r].base, regions[r].length);
}
}