stdio: add vsnprintf and change printf to kprintf
This commit is contained in:
parent
05c528f64c
commit
0395b65ad8
21 changed files with 102 additions and 186 deletions
26
dev/ahci.c
26
dev/ahci.c
|
|
@ -25,7 +25,7 @@ static paddr_t ahci_pbase = 0;
|
|||
|
||||
static void ahci_irq_handler()
|
||||
{
|
||||
printf(LOG_ERROR "AHCI INTERRUPT\n");
|
||||
kprintf(LOG_ERROR "AHCI INTERRUPT\n");
|
||||
}
|
||||
|
||||
static int ahci_port_type(hbaport_t *port)
|
||||
|
|
@ -116,13 +116,13 @@ static void ahci_probe_ports(struct pci_device *dev, hbamem_t *abar)
|
|||
|
||||
ahci_rebase(&abar->ports[i], i);
|
||||
sata_device_count++;
|
||||
printf(LOG_INFO "SATA drive found at port %d\n", i);
|
||||
kprintf(LOG_INFO "SATA drive found at port %d\n", i);
|
||||
} else if (type == AHCI_DEV_SATAPI) {
|
||||
printf(LOG_INFO "SATAPI drive found at port %d\n", i);
|
||||
kprintf(LOG_INFO "SATAPI drive found at port %d\n", i);
|
||||
} else if (type == AHCI_DEV_SEMB) {
|
||||
printf(LOG_INFO "SEMB drive found at port %d\n", i);
|
||||
kprintf(LOG_INFO "SEMB drive found at port %d\n", i);
|
||||
} else if (type == AHCI_DEV_PM) {
|
||||
printf(LOG_INFO "PM drive found at port %d\n", i);
|
||||
kprintf(LOG_INFO "PM drive found at port %d\n", i);
|
||||
}
|
||||
}
|
||||
pi >>= 1;
|
||||
|
|
@ -195,7 +195,7 @@ bool ahci_access_sectors(struct sata_device *dev, paddr_t lba, uint16_t count, p
|
|||
}
|
||||
|
||||
if (spin == 1000000) {
|
||||
printf(LOG_ERROR "AHCI: Port is hung\n");
|
||||
kprintf(LOG_ERROR "AHCI: Port is hung\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -207,20 +207,20 @@ bool ahci_access_sectors(struct sata_device *dev, paddr_t lba, uint16_t count, p
|
|||
if ((port->ci & (1 << slot)) == 0)
|
||||
break;
|
||||
if (port->is & HBA_PORT_IS_TFES) {
|
||||
printf(LOG_ERROR "AHCI: Read disk error\n");
|
||||
kprintf(LOG_ERROR "AHCI: Read disk error\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* check again */
|
||||
if (port->is & HBA_PORT_IS_TFES) {
|
||||
printf(LOG_ERROR "AHCI: Read disk error\n");
|
||||
kprintf(LOG_ERROR "AHCI: Read disk error\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* disk read success */
|
||||
#ifdef KDEBUG
|
||||
printf(LOG_DEBUG "Read %d sectors from disk\n", ocount);
|
||||
kprintf(LOG_DEBUG "Read %d sectors from disk\n", ocount);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
|
@ -268,13 +268,13 @@ void ahci_init()
|
|||
struct pci_device *dev = pci_find_device(0x01, 0x06);
|
||||
/* check interrupt number */
|
||||
if (dev == NULL) {
|
||||
printf(LOG_WARN "No SATA controllers found\n");
|
||||
kprintf(LOG_WARN "No SATA controllers found\n");
|
||||
return;
|
||||
}
|
||||
abar = (hbamem_t *)((uintptr_t)dev->bar5 | hhdm_start);
|
||||
|
||||
if (!(abar->ghc & (1 << 31))) {
|
||||
printf(LOG_WARN "AHCI controller not enabled\n");
|
||||
kprintf(LOG_WARN "AHCI controller not enabled\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -294,7 +294,7 @@ void ahci_init()
|
|||
kmap(ahci_pbase, ahci_pbase | hhdm_start, ahci_zone_size, attrs.val);
|
||||
|
||||
if (sata_device_count == 0) {
|
||||
printf(LOG_WARN "No SATA devices found\n");
|
||||
kprintf(LOG_WARN "No SATA devices found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -306,5 +306,5 @@ void ahci_init()
|
|||
pci_config_write_long(dev->bus, dev->slot, dev->func, 0x3C, tmp);
|
||||
irq_map(irq, ahci_irq_handler);
|
||||
|
||||
printf(LOG_SUCCESS "AHCI controller ready\n");
|
||||
kprintf(LOG_SUCCESS "AHCI controller ready\n");
|
||||
}
|
||||
|
|
|
|||
24
dev/apic.c
24
dev/apic.c
|
|
@ -69,7 +69,7 @@ int madt_parse_next_entry(int offset)
|
|||
int type = madt[offset];
|
||||
int len = madt[offset + 1];
|
||||
|
||||
printf(LOG_INFO "MADT Entry %d: %s\n", n_madt_entries, madt_entry_types[type]);
|
||||
kprintf(LOG_INFO "MADT Entry %d: %s\n", n_madt_entries, madt_entry_types[type]);
|
||||
|
||||
/* Can't declare variables inside switch statement */
|
||||
struct madt_ioapic *m_ioapic = (struct madt_ioapic *)madt;
|
||||
|
|
@ -78,11 +78,11 @@ int madt_parse_next_entry(int offset)
|
|||
switch (type) {
|
||||
case MADT_LAPIC:
|
||||
lapic_id = m_lapic->apic_id;
|
||||
printf(LOG_INFO "LAPIC ID: %xh\n", m_lapic->apic_id);
|
||||
kprintf(LOG_INFO "LAPIC ID: %xh\n", m_lapic->apic_id);
|
||||
break;
|
||||
case MADT_IOAPIC:
|
||||
ioapic_addr = m_ioapic->ioapic_addr;
|
||||
printf(LOG_INFO "IOAPIC address: %xh\n", m_ioapic->ioapic_addr);
|
||||
kprintf(LOG_INFO "IOAPIC address: %xh\n", m_ioapic->ioapic_addr);
|
||||
break;
|
||||
case MADT_IOAPIC_OVRD:
|
||||
break;
|
||||
|
|
@ -95,7 +95,7 @@ int madt_parse_next_entry(int offset)
|
|||
case MADT_X2_LAPIC:
|
||||
break;
|
||||
default:
|
||||
printf(LOG_WARN "Unrecognized MADT entry #%d, type=%d\n", n_madt_entries, type);
|
||||
kprintf(LOG_WARN "Unrecognized MADT entry #%d, type=%d\n", n_madt_entries, type);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -114,33 +114,33 @@ void apic_eoi()
|
|||
void apic_init()
|
||||
{
|
||||
if (__madt == NULL) {
|
||||
printf(LOG_WARN "Failed to locate MADT\n");
|
||||
kprintf(LOG_WARN "Failed to locate MADT\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int offset = 0x2C;
|
||||
int length = __madt->h.length;
|
||||
printf(LOG_INFO "MADT Length: %x\n", length);
|
||||
kprintf(LOG_INFO "MADT Length: %x\n", length);
|
||||
|
||||
while ((offset = madt_parse_next_entry(offset)))
|
||||
;
|
||||
|
||||
lapic_addr = __madt->lapic_addr;
|
||||
|
||||
printf(LOG_INFO "IOAPIC ADDR: %X\n", ioapic_addr);
|
||||
printf(LOG_INFO "LAPIC ADDR : %X\n", lapic_addr);
|
||||
kprintf(LOG_INFO "IOAPIC ADDR: %X\n", ioapic_addr);
|
||||
kprintf(LOG_INFO "LAPIC ADDR : %X\n", lapic_addr);
|
||||
|
||||
uint32_t r = ioapic_read(ioapic_addr, 0);
|
||||
r |= 0x04000000;
|
||||
|
||||
ioapic_write(ioapic_addr, 0, r);
|
||||
printf(LOG_WARN "IOAPIC ID:%x\n", r);
|
||||
kprintf(LOG_WARN "IOAPIC ID:%x\n", r);
|
||||
|
||||
printf(LOG_WARN "LAPIC_ID:%xh\n", lapic_id);
|
||||
kprintf(LOG_WARN "LAPIC_ID:%xh\n", lapic_id);
|
||||
ioapic_redirect_insert(4, 0x21, 0, 0);
|
||||
/* Set spurious interrupt vector to 0xFF and enable the LAPIC */
|
||||
lapic_id = lapic_write(lapic_addr, 0xF0, 0x1FF);
|
||||
printf(LOG_WARN "%x\n", lapic_id);
|
||||
kprintf(LOG_WARN "%x\n", lapic_id);
|
||||
|
||||
printf(LOG_SUCCESS "APIC initialized\n");
|
||||
kprintf(LOG_SUCCESS "APIC initialized\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ void console_init()
|
|||
{
|
||||
memset(console.line, 0, 512);
|
||||
console.resizemode = 0;
|
||||
printf(LOG_SUCCESS "Console ready\n");
|
||||
kprintf(LOG_SUCCESS "Console ready\n");
|
||||
}
|
||||
|
||||
bool console_ready()
|
||||
|
|
@ -37,18 +37,18 @@ void console_resize()
|
|||
memset(console.resize_cols, 0, 8);
|
||||
console.l_resize_rows = 0;
|
||||
console.l_resize_cols = 0;
|
||||
printf("\e[s"); /* save cursor position */
|
||||
kprintf("\e[s"); /* save cursor position */
|
||||
|
||||
printf("\e[999;999H"); /* move cursor FAR away */
|
||||
printf("\e[6n"); /* cursor position request */
|
||||
printf("\e[u"); /* restore cursor position */
|
||||
kprintf("\e[999;999H"); /* move cursor FAR away */
|
||||
kprintf("\e[6n"); /* cursor position request */
|
||||
kprintf("\e[u"); /* restore cursor position */
|
||||
memset(console.line, 0, 512);
|
||||
}
|
||||
|
||||
void console_input(char c)
|
||||
{
|
||||
if (!console.resizemode) {
|
||||
printf("%c", c);
|
||||
kprintf("%c", c);
|
||||
} else {
|
||||
if (c == 'R') {
|
||||
/* detect end of escape sequence */
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ void pci_init()
|
|||
struct pci_device *dev = &pci_devices[i];
|
||||
const char fmt[] = LOG_DEBUG "PCI device BUS[%d:%d] CLASS[%d:%d] vendor_id=%xh device_id=%xh, header_type=%d\n";
|
||||
|
||||
printf(fmt, dev->bus, dev->slot, dev->class, dev->subclass, dev->vendor_id, dev->device_id, dev->header_type);
|
||||
kprintf(fmt, dev->bus, dev->slot, dev->class, dev->subclass, dev->vendor_id, dev->device_id, dev->header_type);
|
||||
}
|
||||
#endif /* KDEBUG */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ void pic_eoi(uint8_t irq)
|
|||
|
||||
void exception(int vector, int error)
|
||||
{
|
||||
printf(LOG_WARN "EXCEPTION: %x, error code: %d\n", vector, error);
|
||||
kprintf(LOG_WARN "EXCEPTION: %x, error code: %d\n", vector, error);
|
||||
}
|
||||
|
||||
void pic_init()
|
||||
|
|
@ -63,5 +63,5 @@ void pic_init()
|
|||
outb(PIC2_DATA, mask2);
|
||||
|
||||
pic_eoi(15);
|
||||
printf(LOG_SUCCESS "8259 PIC initialized\n");
|
||||
kprintf(LOG_SUCCESS "8259 PIC initialized\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,13 +20,13 @@ int serial_init()
|
|||
|
||||
outb(COM1 | 0, 0xAE); /* Enable loopback mode */
|
||||
if (inb(COM1 | 0) != 0xAE) { /* Loopback test */
|
||||
printf(LOG_WARN "Serial COM1 loopback test failed\n");
|
||||
kprintf(LOG_WARN "Serial COM1 loopback test failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
outb(COM1 | 1, 0x01); /* Enable interrupts */
|
||||
outb(COM1 | 4, 0x0F); /* Enter normal operation */
|
||||
printf(LOG_SUCCESS "Serial COM1 initialized\n");
|
||||
kprintf(LOG_SUCCESS "Serial COM1 initialized\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue