uKernel: convert kernel output to syslog()
This commit is contained in:
parent
f69bad2009
commit
c8e11f4560
|
@ -4,8 +4,8 @@
|
|||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
#include <kernel/drivers/bus.h>
|
||||
|
||||
|
@ -37,7 +37,7 @@ ukBus * bus_init(ukBus * parent, char const * name)
|
|||
strlen(drivers[i]->name)) == 0
|
||||
&& drivers[i]->init != NULL)
|
||||
{
|
||||
fprintf(stderr, "%s bus%s%s%s\n", name,
|
||||
syslog(LOG_KERN | LOG_NOTICE, "%s bus%s%s%s", name,
|
||||
(parent != NULL) ? " at " : "",
|
||||
(parent != NULL) ? parent->name : "",
|
||||
(parent != NULL) ? " bus" : "");
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
#include <kernel/drivers/clock.h>
|
||||
|
||||
|
@ -39,7 +39,7 @@ ukClock * clock_init(ukBus * bus, char const * name)
|
|||
strlen(drivers[i]->name)) == 0
|
||||
&& drivers[i]->init != NULL)
|
||||
{
|
||||
fprintf(stderr, "%s clock%s%s%s\n", name,
|
||||
syslog(LOG_KERN | LOG_NOTICE, "%s clock%s%s%s", name,
|
||||
(bus != NULL) ? " at " : "",
|
||||
(bus != NULL) ? bus->name : "",
|
||||
(bus != NULL) ? " bus" : "");
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
#include <kernel/drivers/clock.h>
|
||||
#include "cmos.h"
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
#include <kernel/drivers/console.h>
|
||||
|
||||
|
@ -43,7 +43,7 @@ ukConsole * console_init(ukBus * bus, char const * name)
|
|||
strlen(drivers[i]->name)) == 0
|
||||
&& drivers[i]->init != NULL)
|
||||
{
|
||||
fprintf(stderr, "%s console%s%s%s\n", name,
|
||||
syslog(LOG_KERN | LOG_NOTICE, "%s console%s%s%s", name,
|
||||
(bus != NULL) ? " at " : "",
|
||||
(bus != NULL) ? bus->name : "",
|
||||
(bus != NULL) ? " bus" : "");
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
#include <kernel/drivers/display.h>
|
||||
|
||||
|
@ -41,7 +41,7 @@ ukDisplay * display_init(ukBus * bus, char const * name)
|
|||
strlen(drivers[i]->name)) == 0
|
||||
&& drivers[i]->init != NULL)
|
||||
{
|
||||
fprintf(stderr, "%s display%s%s%s\n", name,
|
||||
syslog(LOG_KERN | LOG_NOTICE, "%s display%s%s%s", name,
|
||||
(bus != NULL) ? " at " : "",
|
||||
(bus != NULL) ? bus->name : "",
|
||||
(bus != NULL) ? " bus" : "");
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
#include <kernel/drivers/pic.h>
|
||||
|
||||
|
@ -39,7 +39,7 @@ ukPIC * pic_init(ukBus * bus, char const * name)
|
|||
strlen(drivers[i]->name)) == 0
|
||||
&& drivers[i]->init != NULL)
|
||||
{
|
||||
fprintf(stderr, "%s pic%s%s%s\n", name,
|
||||
syslog(LOG_KERN | LOG_NOTICE, "%s pic%s%s%s", name,
|
||||
(bus != NULL) ? " at " : "",
|
||||
(bus != NULL) ? bus->name : "",
|
||||
(bus != NULL) ? " bus" : "");
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
# include <stdio.h>
|
||||
# include <syslog.h>
|
||||
# include <kernel/drivers/bus.h>
|
||||
# include <kernel/drivers/clock.h>
|
||||
# include <kernel/drivers/console.h>
|
||||
|
@ -56,6 +56,9 @@ int multiboot(const ukMultibootInfo * mi)
|
|||
/* initialize the heap */
|
||||
multiboot_heap_reset(mi);
|
||||
|
||||
/* initialize logging */
|
||||
openlog("uKernel", LOG_ODELAY, LOG_KERN);
|
||||
|
||||
/* initialize the buses */
|
||||
ioportbus = bus_init(NULL, "ioport");
|
||||
vgabus = bus_init(ioportbus, "vga");
|
||||
|
@ -80,14 +83,14 @@ int multiboot(const ukMultibootInfo * mi)
|
|||
clock_init(cmosbus, "cmos");
|
||||
|
||||
/* report information on the boot process */
|
||||
puts("DeforaOS Multiboot");
|
||||
syslog(LOG_KERN | LOG_NOTICE, "%s", "DeforaOS Multiboot");
|
||||
if(mi->loader_name != NULL)
|
||||
printf("Loader: %s\n", mi->loader_name);
|
||||
syslog(LOG_KERN | LOG_INFO, "Loader: %s", mi->loader_name);
|
||||
if(mi->cmdline != NULL)
|
||||
printf("Command line: %s\n", mi->cmdline);
|
||||
printf("%u MB memory available\n",
|
||||
syslog(LOG_KERN | LOG_INFO, "Command line: %s", mi->cmdline);
|
||||
syslog(LOG_KERN | LOG_INFO, "%u MB memory available",
|
||||
(mi->mem_upper - mi->mem_lower) / 1024);
|
||||
printf("Booted from %#x\n", mi->boot_device_drive);
|
||||
syslog(LOG_KERN | LOG_INFO, "Booted from %#x", mi->boot_device_drive);
|
||||
|
||||
/* setup the GDT */
|
||||
#if defined(__amd64__)
|
||||
|
@ -96,16 +99,16 @@ int multiboot(const ukMultibootInfo * mi)
|
|||
if(_arch_setgdt(_gdt_4gb, sizeof(_gdt_4gb) / sizeof(*_gdt_4gb)) != 0)
|
||||
#endif
|
||||
{
|
||||
puts("Could not setup the GDT");
|
||||
syslog(LOG_KERN | LOG_EMERG, "%s", "Could not setup the GDT");
|
||||
return 4;
|
||||
}
|
||||
|
||||
/* load the modules */
|
||||
if(!(mi->flags & BOOT_MULTIBOOT_INFO_HAS_MODS))
|
||||
puts("No modules provided");
|
||||
syslog(LOG_KERN | LOG_INFO, "%s", "No modules provided");
|
||||
else
|
||||
{
|
||||
puts("Loading modules...");
|
||||
syslog(LOG_KERN | LOG_INFO, "%s", "Loading modules...");
|
||||
for(i = 0; i < mi->mods_count; i++)
|
||||
{
|
||||
mod = &mi->mods_addr[i];
|
||||
|
@ -116,7 +119,7 @@ int multiboot(const ukMultibootInfo * mi)
|
|||
/* setup the IDT */
|
||||
if(_arch_setidt(_idt, sizeof(_idt) / sizeof(*_idt)) != 0)
|
||||
{
|
||||
puts("Could not setup the IDT");
|
||||
syslog(LOG_KERN | LOG_EMERG, "%s", "Could not setup the IDT");
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,4 +13,4 @@ dist=Makefile,libc/src/chacha/chacha.c,libc/src/chacha/ecrypt-config.h,libc/src/
|
|||
#targets
|
||||
[libk]
|
||||
type=library
|
||||
sources=libc/src/ctype.c,libc/src/dirent.c,libc/src/errno.c,libc/src/fcntl.c,libc/src/pwd.c,libc/src/signal.c,libc/src/ssp/ssp.c,libc/src/ssp.c,libc/src/stdio.c,libc/src/stdlib.c,libc/src/string.c,libc/src/syscalls.S,libc/src/sys/ioctl.c,libc/src/sys/mman.c,libc/src/sys/stat.c,libc/src/sys/sysctl.c,libc/src/sys/time.c,libc/src/sys/wait.c,libc/src/termios.c,libc/src/time.c,libc/src/unistd.c,sys/mman.c,sys/time.c,unistd.c
|
||||
sources=libc/src/ctype.c,libc/src/dirent.c,libc/src/errno.c,libc/src/fcntl.c,libc/src/pwd.c,libc/src/signal.c,libc/src/ssp/ssp.c,libc/src/ssp.c,libc/src/stdio.c,libc/src/stdlib.c,libc/src/string.c,libc/src/syscalls.S,libc/src/sys/ioctl.c,libc/src/sys/mman.c,libc/src/sys/stat.c,libc/src/sys/sysctl.c,libc/src/syslog.c,libc/src/sys/time.c,libc/src/sys/wait.c,libc/src/termios.c,libc/src/time.c,libc/src/unistd.c,sys/mman.c,sys/time.c,unistd.c
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "lib/libc/src/sys/ioctl.c"
|
||||
#include "lib/libc/src/sys/stat.c"
|
||||
#include "lib/libc/src/sys/sysctl.c"
|
||||
#include "lib/libc/src/syslog.c"
|
||||
#include "lib/libc/src/sys/time.c"
|
||||
#include "lib/libc/src/sys/wait.c"
|
||||
#include "lib/libc/src/termios.c"
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
|
||||
/* public */
|
||||
|
@ -13,15 +16,23 @@
|
|||
int main(int argc, char * argv[])
|
||||
{
|
||||
int i;
|
||||
char buf[1024];
|
||||
size_t size = sizeof(buf) - 1;
|
||||
|
||||
puts("Failed to boot DeforaOS");
|
||||
printf("Command line:");
|
||||
syslog(LOG_KERN | LOG_EMERG, "Failed to boot DeforaOS");
|
||||
for(i = 0; i < argc; i++)
|
||||
printf(" \"%s\"", argv[i]);
|
||||
printf("\n");
|
||||
{
|
||||
strncat(buf, " ", 1);
|
||||
size -= MIN(size, 1);
|
||||
strncat(buf, argv[i], size);
|
||||
size -= MIN(size, strlen(argv[i]));
|
||||
}
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
syslog(LOG_KERN | LOG_INFO, "Command line: %s", buf);
|
||||
#ifdef DEBUG
|
||||
if(argv[i] != NULL)
|
||||
puts("uLoader: argv is not terminated properly");
|
||||
syslog(LOG_KERN | LOG_DEBUG, "%s",
|
||||
"uLoader: argv is not terminated properly");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
|
||||
#if defined(__i386__)
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <syslog.h>
|
||||
# include <kernel/drivers/bus.h>
|
||||
# include <kernel/drivers/console.h>
|
||||
# include <kernel/drivers/clock.h>
|
||||
|
@ -57,6 +57,9 @@ int multiboot(const ukMultibootInfo * mi)
|
|||
/* initialize the heap */
|
||||
multiboot_heap_reset(mi);
|
||||
|
||||
/* initialize logging */
|
||||
openlog("uLoader", LOG_ODELAY, LOG_KERN);
|
||||
|
||||
/* initialize the buses */
|
||||
ioportbus = bus_init(NULL, "ioport");
|
||||
vgabus = bus_init(ioportbus, "vga");
|
||||
|
@ -78,38 +81,38 @@ int multiboot(const ukMultibootInfo * mi)
|
|||
clock_init(cmosbus, clock);
|
||||
|
||||
/* report information on the boot process */
|
||||
puts("DeforaOS Multiboot");
|
||||
syslog(LOG_KERN | LOG_NOTICE, "%s", "DeforaOS Multiboot");
|
||||
if(mi->loader_name != NULL)
|
||||
printf("Loader: %s\n", mi->loader_name);
|
||||
syslog(LOG_KERN | LOG_INFO, "Loader: %s", mi->loader_name);
|
||||
if(mi->cmdline != NULL)
|
||||
printf("Command line: %s\n", mi->cmdline);
|
||||
printf("%u MB memory available\n",
|
||||
syslog(LOG_KERN | LOG_INFO, "Command line: %s", mi->cmdline);
|
||||
syslog(LOG_KERN | LOG_INFO, "%u MB memory available",
|
||||
(mi->mem_upper - mi->mem_lower) / 1024);
|
||||
printf("Booted from %#x\n", mi->boot_device_drive);
|
||||
syslog(LOG_KERN | LOG_INFO, "Booted from %#x", mi->boot_device_drive);
|
||||
|
||||
/* setup the GDT */
|
||||
if(_arch_setgdt(_gdt_4gb, sizeof(_gdt_4gb) / sizeof(*_gdt_4gb)) != 0)
|
||||
{
|
||||
puts("Could not setup the GDT");
|
||||
syslog(LOG_KERN | LOG_EMERG, "%s", "Could not setup the GDT");
|
||||
return 4;
|
||||
}
|
||||
|
||||
/* load the kernel */
|
||||
if(!(mi->flags & BOOT_MULTIBOOT_INFO_HAS_MODS))
|
||||
{
|
||||
puts("No modules provided");
|
||||
syslog(LOG_KERN | LOG_NOTICE, "%s", "No modules provided");
|
||||
return 6;
|
||||
}
|
||||
if(mi->mods_count == 0)
|
||||
{
|
||||
puts("No kernel provided");
|
||||
syslog(LOG_KERN | LOG_ERR, "%s", "No kernel provided");
|
||||
return 7;
|
||||
}
|
||||
mod = &mi->mods_addr[0];
|
||||
printf("Loading kernel: %s\n", mod->cmdline);
|
||||
syslog(LOG_KERN | LOG_NOTICE, "Loading kernel: %s", mod->cmdline);
|
||||
if(multiboot_load_module(mod, &elfclass, &entrypoint) != 0)
|
||||
{
|
||||
puts("Could not load the kernel");
|
||||
syslog(LOG_KERN | LOG_EMERG, "%s", "Could not load the kernel");
|
||||
return 8;
|
||||
}
|
||||
|
||||
|
@ -122,20 +125,25 @@ int multiboot(const ukMultibootInfo * mi)
|
|||
|
||||
/* hand control over to the kernel */
|
||||
#ifdef DEBUG
|
||||
printf("Jumping into the kernel at %#x (%u, %u, %#x)\n", entrypoint,
|
||||
mi->elfshdr_num, mi->elfshdr_size, mi->elfshdr_addr);
|
||||
syslog(LOG_KERN | LOG_DEBUG,
|
||||
"Jumping into the kernel at %#x (%u, %u, %#x)",
|
||||
entrypoint, mi->elfshdr_num, mi->elfshdr_size,
|
||||
mi->elfshdr_addr);
|
||||
#endif
|
||||
switch(elfclass)
|
||||
{
|
||||
case ELFCLASS32:
|
||||
puts("Detected 32-bit kernel");
|
||||
syslog(LOG_KERN | LOG_INFO, "%s",
|
||||
"Detected 32-bit kernel");
|
||||
return multiboot_boot_kernel32(&kmi, entrypoint);
|
||||
case ELFCLASS64:
|
||||
puts("Detected 64-bit kernel");
|
||||
syslog(LOG_KERN | LOG_INFO, "%s",
|
||||
"Detected 64-bit kernel");
|
||||
return multiboot_boot_kernel64(&kmi, entrypoint);
|
||||
}
|
||||
|
||||
puts("Unsupported ELF class for the kernel");
|
||||
syslog(LOG_KERN | LOG_EMERG, "%s",
|
||||
"Unsupported ELF class for the kernel");
|
||||
return 7;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user