1
0
aedrix-kernel/kernel/start_kernel.c
Aaron Lindsay 8cb4100463 init: Initialize serial subsystem before init_earlyinitcalls()
Otherwise, the serial sybsystem isn't initialized before the serial
drivers attempt to register themselves.
2012-10-06 14:53:00 -04:00

109 lines
2.8 KiB
C

/*
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>
#ifdef CONFIG_VEXPRESS_A9
#include <drivers/pl111.h>
#endif
#ifdef CONFIG_RPI
#include <drivers/bcm2835_videocore.h>
#endif
struct fb myfb;
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");
}
void video_init(void) {
#ifdef CONFIG_VEXPRESS_A9
pl111_init(&myfb, 16);
#endif
#ifdef CONFIG_RPI
bcm2835_videocore_init(&myfb, 16);
#endif
}
void serial_console_init() {
struct serial_dev *sdev = serial_first_device();
if (sdev)
print_init(sdev->putc);
}
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;
declare_memory_region(lower, upper);
} while (!atags_next_mem_region(&atags));
init_initcalls();
video_init();
console_init(&myfb);
print_console_logo();
return 0;
}