no more kprintf - kernel uses libsys printf now, only kputc is special

to the kernel.
This commit is contained in:
Ben Gras
2010-03-03 15:45:01 +00:00
parent 18924ea563
commit e6cb76a2e2
34 changed files with 213 additions and 224 deletions
+10 -10
View File
@@ -108,7 +108,7 @@ PUBLIC void apic_calibrate_clocks(void)
irq_hook_t calib_clk;
BOOT_VERBOSE(kprintf("Calibrating clock\n"));
BOOT_VERBOSE(printf("Calibrating clock\n"));
/*
* Set Initial count register to the highest value so it does not
* underflow during the testing period
@@ -156,10 +156,10 @@ PUBLIC void apic_calibrate_clocks(void)
tsc_delta = sub64(tsc1, tsc0);
lapic_bus_freq[cpuid] = system_hz * lapic_delta / (PROBE_TICKS - 1);
BOOT_VERBOSE(kprintf("APIC bus freq %lu MHz\n",
BOOT_VERBOSE(printf("APIC bus freq %lu MHz\n",
lapic_bus_freq[cpuid] / 1000000));
cpu_freq = div64u(tsc_delta, PROBE_TICKS - 1) * system_hz;
BOOT_VERBOSE(kprintf("CPU %d freq %lu MHz\n", cpuid,
BOOT_VERBOSE(printf("CPU %d freq %lu MHz\n", cpuid,
cpu_freq / 1000000));
cpu_set_freq(cpuid, cpu_freq);
@@ -291,7 +291,7 @@ PRIVATE int lapic_enable_in_msr(void)
addr = (msr.lo >> 12) | ((msr.hi & 0xf) << 20);
if (phys2vir(addr) != (lapic_addr >> 12)) {
if (msr.hi & 0xf) {
kprintf("ERROR : APIC address needs more then 32 bits\n");
printf("ERROR : APIC address needs more then 32 bits\n");
return 0;
}
lapic_addr = phys2vir(msr.lo & ~((1 << 12) - 1));
@@ -313,7 +313,7 @@ PUBLIC int lapic_enable(void)
cpu_has_tsc = _cpufeature(_CPUF_I386_TSC);
if (!cpu_has_tsc) {
kprintf("CPU lacks timestamp counter, "
printf("CPU lacks timestamp counter, "
"cannot calibrate LAPIC timer\n");
return 0;
}
@@ -374,14 +374,14 @@ PUBLIC int lapic_enable(void)
*((u32_t *)lapic_eoi_addr) = 0;
apic_calibrate_clocks();
BOOT_VERBOSE(kprintf("APIC timer calibrated\n"));
BOOT_VERBOSE(printf("APIC timer calibrated\n"));
return 1;
}
PRIVATE void apic_spurios_intr(void)
{
kprintf("WARNING spurious interrupt\n");
printf("WARNING spurious interrupt\n");
for(;;);
}
@@ -444,7 +444,7 @@ PUBLIC void apic_idt_init(int reset)
#ifdef CONFIG_APIC_DEBUG
if (cpu_is_bsp(cpuid))
kprintf("APIC debugging is enabled\n");
printf("APIC debugging is enabled\n");
lapic_set_dummy_handlers();
#endif
@@ -459,10 +459,10 @@ PUBLIC void apic_idt_init(int reset)
/* configure the timer interupt handler */
if (cpu_is_bsp(cpuid)) {
local_timer_intr_handler = (vir_bytes) lapic_bsp_timer_int_handler;
BOOT_VERBOSE(kprintf("Initiating BSP timer handler\n"));
BOOT_VERBOSE(printf("Initiating BSP timer handler\n"));
} else {
local_timer_intr_handler = (vir_bytes) lapic_ap_timer_int_handler;
BOOT_VERBOSE(kprintf("Initiating AP timer handler\n"));
BOOT_VERBOSE(printf("Initiating AP timer handler\n"));
}
/* register the timer interrupt handler for this CPU */
+1 -1
View File
@@ -181,7 +181,7 @@ lapic_intr_dummy_handler_msg:
#define lapic_intr_dummy_handler(vect) \
pushl $vect; \
push $lapic_intr_dummy_handler_msg; \
call kprintf; \
call printf; \
1: jmp 1b; /* never return */
#define LAPIC_INTR_DUMMY_HANDLER(vect) \
+1 -1
View File
@@ -81,6 +81,6 @@ struct proc *p;
kprintf("arch_do_vmctl: strange param %d\n", m_ptr->SVMCTL_PARAM);
printf("arch_do_vmctl: strange param %d\n", m_ptr->SVMCTL_PARAM);
return EINVAL;
}
+2 -2
View File
@@ -85,7 +85,7 @@ PUBLIC int arch_init_local_timer(unsigned freq)
lapic_set_timer_periodic(freq);
} else
{
BOOT_VERBOSE(kprintf("Initiating legacy i8253 timer\n"));
BOOT_VERBOSE(printf("Initiating legacy i8253 timer\n"));
#else
{
#endif
@@ -112,7 +112,7 @@ PUBLIC int arch_register_local_timer_handler(irq_handler_t handler)
#ifdef CONFIG_APIC
if (lapic_addr) {
/* Using APIC, it is configured in apic_idt_init() */
BOOT_VERBOSE(kprintf("Using LAPIC timer as tick source\n"));
BOOT_VERBOSE(printf("Using LAPIC timer as tick source\n"));
} else
#endif
{
+4 -4
View File
@@ -43,7 +43,7 @@ PUBLIC int do_sdevio(struct proc * caller, message *m_ptr)
if (first)
{
first= 0;
kprintf("do_sdevio: for %d, req %d\n",
printf("do_sdevio: for %d, req %d\n",
m_ptr->m_source, m_ptr->DIO_REQUEST);
}
}
@@ -86,7 +86,7 @@ PUBLIC int do_sdevio(struct proc * caller, message *m_ptr)
} else {
if(proc_nr != _ENDPOINT_P(caller->p_endpoint))
{
kprintf("do_sdevio: unsafe sdevio by %d in %d denied\n",
printf("do_sdevio: unsafe sdevio by %d in %d denied\n",
caller->p_endpoint, proc_nr_e);
return EPERM;
}
@@ -120,7 +120,7 @@ PUBLIC int do_sdevio(struct proc * caller, message *m_ptr)
}
if (i >= nr_io_range)
{
kprintf(
printf(
"do_sdevio: I/O port check failed for proc %d, port 0x%x\n",
m_ptr->m_source, port);
retval = EPERM;
@@ -130,7 +130,7 @@ PUBLIC int do_sdevio(struct proc * caller, message *m_ptr)
if (port & (size-1))
{
kprintf("do_devio: unaligned port 0x%x (size %d)\n", port, size);
printf("do_devio: unaligned port 0x%x (size %d)\n", port, size);
retval = EPERM;
goto return_error;
}
+16 -16
View File
@@ -62,14 +62,14 @@ void pagefault( struct proc *pr,
/* Page fault we can't / don't want to
* handle.
*/
kprintf("pagefault for process %d ('%s'), pc = 0x%x, addr = 0x%x, flags = 0x%x, is_nested %d\n",
printf("pagefault for process %d ('%s'), pc = 0x%x, addr = 0x%x, flags = 0x%x, is_nested %d\n",
pr->p_endpoint, pr->p_name, pr->p_reg.pc,
pagefaultcr2, frame->errcode, is_nested);
proc_stacktrace(pr);
if(pr->p_endpoint != SYSTEM) {
proc_stacktrace(proc_addr(SYSTEM));
}
kprintf("pc of pagefault: 0x%lx\n", frame->eip);
printf("pc of pagefault: 0x%lx\n", frame->eip);
minix_panic("page fault in system process", pr->p_endpoint);
return;
@@ -138,7 +138,7 @@ PUBLIC void exception_handler(int is_nested, struct exception_frame * frame)
ep = &ex_data[frame->vector];
if (frame->vector == 2) { /* spurious NMI on some machines */
kprintf("got spurious NMI\n");
printf("got spurious NMI\n");
return;
}
@@ -182,7 +182,7 @@ PUBLIC void exception_handler(int is_nested, struct exception_frame * frame)
#if 0
{
kprintf(
printf(
"vec_nr= %d, trap_errno= 0x%lx, eip= 0x%lx, cs= 0x%x, eflags= 0x%lx\n",
frame->vector, (unsigned long)frame->errcode,
(unsigned long)frame->eip, frame->cs,
@@ -202,17 +202,17 @@ PUBLIC void exception_handler(int is_nested, struct exception_frame * frame)
/* Exception in system code. This is not supposed to happen. */
if (ep->msg == NIL_PTR || machine.processor < ep->minprocessor)
kprintf("\nIntel-reserved exception %d\n", frame->vector);
printf("\nIntel-reserved exception %d\n", frame->vector);
else
kprintf("\n%s\n", ep->msg);
kprintf("is_nested = %d ", is_nested);
printf("\n%s\n", ep->msg);
printf("is_nested = %d ", is_nested);
kprintf("vec_nr= %d, trap_errno= 0x%x, eip= 0x%x, cs= 0x%x, eflags= 0x%x trap_esp 0x%08x\n",
printf("vec_nr= %d, trap_errno= 0x%x, eip= 0x%x, cs= 0x%x, eflags= 0x%x trap_esp 0x%08x\n",
frame->vector, frame->errcode, frame->eip, frame->cs, frame->eflags, frame);
/* TODO should we enable this only when compiled for some debug mode? */
if (saved_proc) {
kprintf("scheduled was: process %d (%s), ", proc_nr(saved_proc), saved_proc->p_name);
kprintf("pc = %u:0x%x\n", (unsigned) saved_proc->p_reg.cs,
printf("scheduled was: process %d (%s), ", proc_nr(saved_proc), saved_proc->p_name);
printf("pc = %u:0x%x\n", (unsigned) saved_proc->p_reg.cs,
(unsigned) saved_proc->p_reg.pc);
proc_stacktrace(saved_proc);
@@ -236,7 +236,7 @@ PUBLIC void proc_stacktrace(struct proc *whichproc)
iskernel = iskernelp(whichproc);
kprintf("%-8.8s %6d 0x%lx ",
printf("%-8.8s %6d 0x%lx ",
whichproc->p_name, whichproc->p_endpoint, whichproc->p_reg.pc);
while(v_bp) {
@@ -246,19 +246,19 @@ PUBLIC void proc_stacktrace(struct proc *whichproc)
data_copy(pr->p_endpoint, pv, KERNEL, (vir_bytes) (v), n))
if(PRCOPY(whichproc, v_bp, &v_hbp, sizeof(v_hbp)) != OK) {
kprintf("(v_bp 0x%lx ?)", v_bp);
printf("(v_bp 0x%lx ?)", v_bp);
break;
}
if(PRCOPY(whichproc, v_bp + sizeof(v_pc), &v_pc, sizeof(v_pc)) != OK) {
kprintf("(v_pc 0x%lx ?)", v_bp + sizeof(v_pc));
printf("(v_pc 0x%lx ?)", v_bp + sizeof(v_pc));
break;
}
kprintf("0x%lx ", (unsigned long) v_pc);
printf("0x%lx ", (unsigned long) v_pc);
if(v_hbp != 0 && v_hbp <= v_bp) {
kprintf("(hbp %lx ?)", v_hbp);
printf("(hbp %lx ?)", v_hbp);
break;
}
v_bp = v_hbp;
}
kprintf("\n");
printf("\n");
}
+19 -19
View File
@@ -405,11 +405,11 @@ vir_bytes bytes; /* # of bytes to be copied */
}
if(!(linear = umap_local(rp, seg, vir_addr, bytes))) {
kprintf("SYSTEM:umap_virtual: umap_local failed\n");
printf("SYSTEM:umap_virtual: umap_local failed\n");
phys = 0;
} else {
if(vm_lookup(rp, linear, &phys, NULL) != OK) {
kprintf("SYSTEM:umap_virtual: vm_lookup of %s: seg 0x%lx: 0x%lx failed\n", rp->p_name, seg, vir_addr);
printf("SYSTEM:umap_virtual: vm_lookup of %s: seg 0x%lx: 0x%lx failed\n", rp->p_name, seg, vir_addr);
phys = 0;
}
if(phys == 0)
@@ -418,7 +418,7 @@ vir_bytes bytes; /* # of bytes to be copied */
if(phys == 0) {
kprintf("SYSTEM:umap_virtual: lookup failed\n");
printf("SYSTEM:umap_virtual: lookup failed\n");
return 0;
}
@@ -426,7 +426,7 @@ vir_bytes bytes; /* # of bytes to be copied */
* so that the umap makes sense.
*/
if(bytes > 0 && !vm_contiguous(rp, linear, bytes)) {
kprintf("umap_virtual: %s: %d at 0x%lx (vir 0x%lx) not contiguous\n",
printf("umap_virtual: %s: %d at 0x%lx (vir 0x%lx) not contiguous\n",
rp->p_name, bytes, linear, vir_addr);
return 0;
}
@@ -526,17 +526,17 @@ PUBLIC int vm_contiguous(struct proc *targetproc, u32_t vir_buf, size_t bytes)
u32_t phys;
if((r=vm_lookup(targetproc, vir_buf, &phys, NULL)) != OK) {
kprintf("vm_contiguous: vm_lookup failed, %d\n", r);
kprintf("kernel stack: ");
printf("vm_contiguous: vm_lookup failed, %d\n", r);
printf("kernel stack: ");
util_stacktrace();
return 0;
}
if(!first) {
if(prev_phys+I386_PAGE_SIZE != phys) {
kprintf("vm_contiguous: no (0x%lx, 0x%lx)\n",
printf("vm_contiguous: no (0x%lx, 0x%lx)\n",
prev_phys, phys);
kprintf("kernel stack: ");
printf("kernel stack: ");
util_stacktrace();
return 0;
}
@@ -657,13 +657,13 @@ PRIVATE void vm_pt_print(u32_t *pagetable, u32_t v)
if(!(pte_v & I386_VM_PRESENT))
continue;
pfa = I386_VM_PFA(pte_v);
kprintf("%4d:%08lx:%08lx %2s ",
printf("%4d:%08lx:%08lx %2s ",
pte, v + I386_PAGE_SIZE*pte, pfa,
(pte_v & I386_VM_WRITE) ? "rw":"RO");
col++;
if(col == 3) { kprintf("\n"); col = 0; }
if(col == 3) { printf("\n"); col = 0; }
}
if(col > 0) kprintf("\n");
if(col > 0) printf("\n");
return;
}
@@ -683,14 +683,14 @@ PRIVATE void vm_print(u32_t *root)
if(!(pde_v & I386_VM_PRESENT))
continue;
if(pde_v & I386_VM_BIGPAGE) {
kprintf("%4d: 0x%lx, flags %s\n",
printf("%4d: 0x%lx, flags %s\n",
pde, I386_VM_PFA(pde_v), flagstr(pde_v, 1));
} else {
pte_a = (u32_t *) I386_VM_PFA(pde_v);
kprintf("%4d: pt %08lx %s\n",
printf("%4d: pt %08lx %s\n",
pde, pte_a, flagstr(pde_v, 1));
vm_pt_print(pte_a, pde * I386_VM_PT_ENTRIES * I386_PAGE_SIZE);
kprintf("\n");
printf("\n");
}
}
@@ -794,7 +794,7 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */
phys_addr[i] = umap_virtual(p, seg_index,
vir_addr[i]->offset, bytes);
if(phys_addr[i] == 0) {
kprintf("virtual_copy: map 0x%x failed for %s seg %d, "
printf("virtual_copy: map 0x%x failed for %s seg %d, "
"offset %lx, len %d, i %d\n",
type, p->p_name, seg_index, vir_addr[i]->offset,
bytes, i);
@@ -816,13 +816,13 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */
phys_addr[i] = vir_addr[i]->offset;
break;
default:
kprintf("virtual_copy: strange type 0x%x\n", type);
printf("virtual_copy: strange type 0x%x\n", type);
NOREC_RETURN(virtualcopy, EINVAL);
}
/* Check if mapping succeeded. */
if (phys_addr[i] <= 0 && vir_addr[i]->segment != PHYS_SEG) {
kprintf("virtual_copy EFAULT\n");
printf("virtual_copy EFAULT\n");
NOREC_RETURN(virtualcopy, EFAULT);
}
}
@@ -884,11 +884,11 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */
/* can't copy to/from process with PT without VM */
#define NOPT(p) (!(p) || !HASPT(p))
if(!NOPT(procs[_SRC_])) {
kprintf("ignoring page table src: %s / %d at 0x%lx\n",
printf("ignoring page table src: %s / %d at 0x%lx\n",
procs[_SRC_]->p_name, procs[_SRC_]->p_endpoint, procs[_SRC_]->p_seg.p_cr3);
}
if(!NOPT(procs[_DST_])) {
kprintf("ignoring page table dst: %s / %d at 0x%lx\n",
printf("ignoring page table dst: %s / %d at 0x%lx\n",
procs[_DST_]->p_name, procs[_DST_]->p_endpoint,
procs[_DST_]->p_seg.p_cr3);
}
+21 -21
View File
@@ -342,28 +342,28 @@ PUBLIC void printseg(char *banner, int iscs, struct proc *pr, u32_t selector)
u32_t base, limit, index, dpl;
struct segdesc_s *desc;
if(banner) { kprintf("%s", banner); }
if(banner) { printf("%s", banner); }
index = selector >> 3;
kprintf("RPL %d, ind %d of ",
printf("RPL %d, ind %d of ",
(selector & RPL_MASK), index);
if(selector & TI) {
kprintf("LDT");
printf("LDT");
if(index >= LDT_SIZE) {
kprintf("invalid index in ldt\n");
printf("invalid index in ldt\n");
return;
}
if(!pr) {
kprintf("local selector but unknown process\n");
printf("local selector but unknown process\n");
return;
}
desc = &pr->p_seg.p_ldt[index];
} else {
kprintf("GDT");
printf("GDT");
if(index >= GDT_SIZE) {
kprintf("invalid index in gdt\n");
printf("invalid index in gdt\n");
return;
}
desc = &gdt[index];
@@ -380,14 +380,14 @@ PUBLIC void printseg(char *banner, int iscs, struct proc *pr, u32_t selector)
((u32_t) desc->base_middle << BASE_MIDDLE_SHIFT) |
((u32_t) desc->base_high << BASE_HIGH_SHIFT);
kprintf(" -> base 0x%08lx size 0x%08lx ", base, limit+1);
printf(" -> base 0x%08lx size 0x%08lx ", base, limit+1);
if(iscs) {
if(!(desc->granularity & BIG))
kprintf("16bit ");
printf("16bit ");
} else {
if(!(desc->granularity & BIG))
kprintf("not big ");
printf("not big ");
}
if(desc->granularity & 0x20) { /* reserved */
@@ -395,28 +395,28 @@ PUBLIC void printseg(char *banner, int iscs, struct proc *pr, u32_t selector)
}
if(!(desc->access & PRESENT))
kprintf("notpresent ");
printf("notpresent ");
if(!(desc->access & SEGMENT))
kprintf("system ");
printf("system ");
if(desc->access & EXECUTABLE) {
kprintf(" exec ");
if(desc->access & CONFORMING) kprintf("conforming ");
if(!(desc->access & READABLE)) kprintf("non-readable ");
printf(" exec ");
if(desc->access & CONFORMING) printf("conforming ");
if(!(desc->access & READABLE)) printf("non-readable ");
} else {
kprintf("nonexec ");
if(desc->access & EXPAND_DOWN) kprintf("non-expand-down ");
if(!(desc->access & WRITEABLE)) kprintf("non-writable ");
printf("nonexec ");
if(desc->access & EXPAND_DOWN) printf("non-expand-down ");
if(!(desc->access & WRITEABLE)) printf("non-writable ");
}
if(!(desc->access & ACCESSED)) {
kprintf("nonacc ");
printf("nonacc ");
}
dpl = ((u32_t) desc->access & DPL) >> DPL_SHIFT;
kprintf("DPL %d\n", dpl);
printf("DPL %d\n", dpl);
return;
}
@@ -431,7 +431,7 @@ PUBLIC int prot_set_kern_seg_limit(vir_bytes limit)
int incr_clicks;
if(limit <= kinfo.data_base) {
kprintf("prot_set_kern_seg_limit: limit bogus\n");
printf("prot_set_kern_seg_limit: limit bogus\n");
return EINVAL;
}
+11 -11
View File
@@ -199,10 +199,10 @@ PUBLIC void arch_init(void)
#if defined(CONFIG_APIC) && !defined(CONFIG_SMP)
if (config_no_apic) {
BOOT_VERBOSE(kprintf("APIC disabled, using legacy PIC\n"));
BOOT_VERBOSE(printf("APIC disabled, using legacy PIC\n"));
}
else if (!apic_single_cpu_init()) {
BOOT_VERBOSE(kprintf("APIC not present, using legacy PIC\n"));
BOOT_VERBOSE(printf("APIC not present, using legacy PIC\n"));
}
#endif
@@ -266,7 +266,7 @@ PRIVATE void ser_dump_segs(void)
{
if (isemptyp(pp))
continue;
kprintf("%d: %s ep %d\n", proc_nr(pp), pp->p_name, pp->p_endpoint);
printf("%d: %s ep %d\n", proc_nr(pp), pp->p_name, pp->p_endpoint);
printseg("cs: ", 1, pp, pp->p_reg.cs);
printseg("ds: ", 0, pp, pp->p_reg.ds);
if(pp->p_reg.ss != pp->p_reg.ds) {
@@ -319,38 +319,38 @@ PRIVATE void printslot(struct proc *pp, int level)
#define COL { int i; for(i = 0; i < level; i++) printf("> "); }
if(level >= NR_PROCS) {
kprintf("loop??\n");
printf("loop??\n");
return;
}
COL
kprintf("%d: %s %d prio %d/%d time %d/%d cycles 0x%x%08x cr3 0x%lx rts %s misc %s",
printf("%d: %s %d prio %d/%d time %d/%d cycles 0x%x%08x cr3 0x%lx rts %s misc %s",
proc_nr(pp), pp->p_name, pp->p_endpoint,
pp->p_priority, pp->p_max_priority, pp->p_user_time,
pp->p_sys_time, pp->p_cycles.hi, pp->p_cycles.lo, pp->p_seg.p_cr3,
rtsflagstr(pp->p_rts_flags), miscflagstr(pp->p_misc_flags));
if((dep = P_BLOCKEDON(pp)) != NONE) {
kprintf(" blocked on: ");
printf(" blocked on: ");
if(dep == ANY) {
kprintf(" ANY\n");
printf(" ANY\n");
} else {
int procno;
if(!isokendpt(dep, &procno)) {
kprintf(" ??? %d\n", dep);
printf(" ??? %d\n", dep);
} else {
depproc = proc_addr(procno);
if(isemptyp(depproc)) {
kprintf(" empty slot %d???\n", procno);
printf(" empty slot %d???\n", procno);
depproc = NULL;
} else {
kprintf(" %s\n", depproc->p_name);
printf(" %s\n", depproc->p_name);
}
}
}
} else {
kprintf("\n");
printf("\n");
}
COL
+3 -3
View File
@@ -88,7 +88,7 @@ int arch_watchdog_init(void)
void arch_watchdog_lockup(struct nmi_frame * frame)
{
kprintf("KERNEL LOCK UP\n"
printf("KERNEL LOCK UP\n"
"eax 0x%08x\n"
"ecx 0x%08x\n"
"edx 0x%08x\n"
@@ -125,11 +125,11 @@ void i386_watchdog_start(void)
{
if (watchdog_enabled) {
if (arch_watchdog_init()) {
kprintf("WARNING watchdog initialization "
printf("WARNING watchdog initialization "
"failed! Disabled\n");
watchdog_enabled = 0;
}
else
BOOT_VERBOSE(kprintf("Watchdog enabled\n"););
BOOT_VERBOSE(printf("Watchdog enabled\n"););
}
}