init: Move all init into init.c from start_kernel.c
This commit is contained in:
parent
5f59e07432
commit
c90edb451d
@ -18,6 +18,8 @@
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <framebuffer.h>
|
||||
|
||||
#ifndef CONSOLE_H
|
||||
#define CONSOLE_H
|
||||
|
||||
|
@ -18,9 +18,6 @@
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
void init_earlyinitcalls();
|
||||
void init_initcalls();
|
||||
|
||||
struct initcall_func {
|
||||
void (*fptr)();
|
||||
};
|
||||
|
100
kernel/init.c
100
kernel/init.c
@ -18,8 +18,18 @@
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <types.h>
|
||||
#include <atags.h>
|
||||
#include <console.h>
|
||||
#include <framebuffer.h>
|
||||
#include <kmalloc.h>
|
||||
#include <print.h>
|
||||
#include <mm.h>
|
||||
#include <mmu.h>
|
||||
#include <types.h>
|
||||
|
||||
#include <drivers/fb.h>
|
||||
#include <drivers/serial.h>
|
||||
|
||||
|
||||
extern uint32 early_initcalls_start, early_initcalls_end;
|
||||
extern uint32 initcalls_start, initcalls_end;
|
||||
@ -35,3 +45,91 @@ void init_initcalls() {
|
||||
for (initcall = (void (**)()) &initcalls_start; initcall < (void (**)())&initcalls_end; initcall++)
|
||||
(*initcall)();
|
||||
}
|
||||
struct fb console_fb;
|
||||
|
||||
void print_console_logo() {
|
||||
print(" _ _ _\n");
|
||||
print(" / \\ ___ __| |_ __(_)_ __\n");
|
||||
print(" / _ \\ / _ \\/ _` | '__| \\ \\/ /\n");
|
||||
print(" / ___ \\ __/ (_| | | | |> <\n");
|
||||
print(" /_/ \\_\\___|\\__,_|_| |_/_/\\_\\\n\n");
|
||||
print(" Copyright (C) 2012 - Aaron Lindsay\n\n\n");
|
||||
}
|
||||
|
||||
void video_console_init(void) {
|
||||
struct fb_dev *fbdev = fb_first_device();
|
||||
int ret;
|
||||
|
||||
if (!fbdev) {
|
||||
print("Error: No framebuffer-capable device registered.");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = fbdev->init(&console_fb, 16);
|
||||
if (ret) {
|
||||
print("Error: Failed to initialize framebuffer device.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((console_init(&console_fb)))
|
||||
return;
|
||||
|
||||
print_register_func(&console_putc);
|
||||
print_console_logo();
|
||||
|
||||
print("Initialized video console on %s.\n", fbdev->name);
|
||||
}
|
||||
|
||||
void serial_console_init() {
|
||||
struct serial_dev *sdev = serial_first_device();
|
||||
|
||||
if (!sdev)
|
||||
return;
|
||||
|
||||
print_register_func_early(sdev->putc);
|
||||
print("Initialized serial console on %s\n", sdev->name);
|
||||
}
|
||||
|
||||
//Forward declarations of non-initcall initializations that are only needed
|
||||
//once, and only here
|
||||
void serial_init();
|
||||
void kmalloc_init();
|
||||
|
||||
int main(void) {
|
||||
char *lower, *upper;
|
||||
struct atag *atags;
|
||||
|
||||
//setup MMU
|
||||
mmu_reinit();
|
||||
|
||||
/* Initialize the serial subsystem before
|
||||
* init_earlyinitcalls(), because console drivers get
|
||||
* initialized here so as to have an output console as
|
||||
* early as possible, and we don't want those
|
||||
* initializations to fail. */
|
||||
serial_init();
|
||||
init_earlyinitcalls();
|
||||
serial_console_init();
|
||||
|
||||
//setup memory subsystems
|
||||
mm_init();
|
||||
kmalloc_init();
|
||||
|
||||
if (atags_first_mem_region(&atags)) {
|
||||
print("Error: atags must contain at least one memory region\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
do {
|
||||
lower = (char *)atags->data.mem.start;
|
||||
upper = lower + atags->data.mem.size - 1;
|
||||
print("atags: physical memory at %x-%x\n", lower, upper);
|
||||
declare_memory_region(lower, upper);
|
||||
} while (!atags_next_mem_region(&atags));
|
||||
|
||||
init_initcalls();
|
||||
|
||||
video_console_init();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -13,8 +13,7 @@ OBJS_$(d) := $(d)/atags.o \
|
||||
$(d)/math.o \
|
||||
$(d)/mm.o \
|
||||
$(d)/mmu.o \
|
||||
$(d)/print.o \
|
||||
$(d)/start_kernel.o
|
||||
$(d)/print.o
|
||||
|
||||
KOBJS += $(OBJS_$(d))
|
||||
|
||||
|
@ -1,118 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2012, Aaron Lindsay <aaron@aclindsay.com>
|
||||
|
||||
This file is part of Aedrix.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <atags.h>
|
||||
#include <init.h>
|
||||
#include <kmalloc.h>
|
||||
#include <mmu.h>
|
||||
#include <mm.h>
|
||||
#include <print.h>
|
||||
#include <framebuffer.h>
|
||||
#include <console.h>
|
||||
|
||||
#include <drivers/serial.h>
|
||||
#include <drivers/fb.h>
|
||||
|
||||
struct fb console_fb;
|
||||
|
||||
void print_console_logo() {
|
||||
print_func(&console_putc, " _ _ _\n");
|
||||
print_func(&console_putc, " / \\ ___ __| |_ __(_)_ __\n");
|
||||
print_func(&console_putc, " / _ \\ / _ \\/ _` | '__| \\ \\/ /\n");
|
||||
print_func(&console_putc, " / ___ \\ __/ (_| | | | |> <\n");
|
||||
print_func(&console_putc, " /_/ \\_\\___|\\__,_|_| |_/_/\\_\\\n\n");
|
||||
print_func(&console_putc, " Copyright (C) 2012 - Aaron Lindsay\n\n\n");
|
||||
}
|
||||
|
||||
void video_console_init(void) {
|
||||
struct fb_dev *fbdev = fb_first_device();
|
||||
int ret;
|
||||
|
||||
if (!fbdev) {
|
||||
print("Error: No framebuffer-capable device registered.");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = fbdev->init(&console_fb, 16);
|
||||
if (ret) {
|
||||
print("Error: Failed to initialize framebuffer device.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((console_init(&console_fb)))
|
||||
return;
|
||||
|
||||
print_register_func(&console_putc);
|
||||
print_console_logo();
|
||||
|
||||
print_func(&console_putc, "Successfully initialized video console on %s.\n", fbdev->name);
|
||||
}
|
||||
|
||||
void serial_console_init() {
|
||||
struct serial_dev *sdev = serial_first_device();
|
||||
|
||||
if (!sdev)
|
||||
return;
|
||||
|
||||
print_register_func_early(sdev->putc);
|
||||
print("Successfully initialized serial console on %s\n", sdev->name);
|
||||
}
|
||||
|
||||
void serial_init();
|
||||
void kmalloc_init();
|
||||
|
||||
int main(void) {
|
||||
char *lower, *upper;
|
||||
struct atag *atags;
|
||||
|
||||
//setup MMU
|
||||
mmu_reinit();
|
||||
|
||||
/* Initialize the serial subsystem before
|
||||
* init_earlyinitcalls(), because console drivers get
|
||||
* initialized here so as to have an output console as
|
||||
* early as possible, and we don't want those
|
||||
* initializations to fail. */
|
||||
serial_init();
|
||||
init_earlyinitcalls();
|
||||
serial_console_init();
|
||||
|
||||
//setup memory
|
||||
mm_init();
|
||||
kmalloc_init();
|
||||
|
||||
if (atags_first_mem_region(&atags)) {
|
||||
print("Error: atags must contain at least one memory region\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
do {
|
||||
lower = (char *)atags->data.mem.start;
|
||||
upper = lower + atags->data.mem.size - 1;
|
||||
print("atags: physical memory at %x-%x\n", lower, upper);
|
||||
declare_memory_region(lower, upper);
|
||||
} while (!atags_next_mem_region(&atags));
|
||||
|
||||
init_initcalls();
|
||||
|
||||
video_console_init();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user