2012-09-26 23:59:58 -04:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2012-09-25 22:44:19 -04:00
|
|
|
#include <atags.h>
|
2012-10-04 00:26:35 -04:00
|
|
|
#include <init.h>
|
2012-09-28 00:59:25 -04:00
|
|
|
#include <kmalloc.h>
|
2012-09-21 11:52:24 -04:00
|
|
|
#include <mmu.h>
|
2012-09-17 23:33:50 -04:00
|
|
|
#include <mm.h>
|
2012-09-07 23:56:32 -04:00
|
|
|
#include <print.h>
|
|
|
|
#include <framebuffer.h>
|
2012-09-09 01:58:38 -04:00
|
|
|
#include <console.h>
|
2012-09-07 23:56:32 -04:00
|
|
|
|
2012-10-04 00:26:35 -04:00
|
|
|
#include <drivers/serial.h>
|
|
|
|
|
2012-10-03 00:19:28 -04:00
|
|
|
#ifdef CONFIG_VEXPRESS_A9
|
2012-10-03 23:30:19 -04:00
|
|
|
#include <drivers/pl111.h>
|
2012-10-03 00:19:28 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_RPI
|
2012-10-03 23:30:19 -04:00
|
|
|
#include <drivers/bcm2835_videocore.h>
|
2012-10-03 00:19:28 -04:00
|
|
|
#endif
|
|
|
|
|
2012-09-07 23:56:32 -04:00
|
|
|
struct fb myfb;
|
|
|
|
|
2012-10-02 23:17:25 -04:00
|
|
|
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");
|
|
|
|
}
|
2012-09-17 23:33:50 -04:00
|
|
|
|
2012-10-02 23:17:25 -04:00
|
|
|
void video_init(void) {
|
2012-10-03 00:19:28 -04:00
|
|
|
#ifdef CONFIG_VEXPRESS_A9
|
|
|
|
pl111_init(&myfb, 16);
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_RPI
|
2012-10-02 23:17:25 -04:00
|
|
|
bcm2835_videocore_init(&myfb, 16);
|
2012-10-03 00:19:28 -04:00
|
|
|
#endif
|
2012-09-07 23:56:32 -04:00
|
|
|
}
|
2012-09-17 23:33:50 -04:00
|
|
|
|
2012-10-04 00:26:35 -04:00
|
|
|
void serial_console_init() {
|
|
|
|
struct serial_dev *sdev = serial_first_device();
|
2012-09-28 00:59:25 -04:00
|
|
|
|
2012-10-04 00:26:35 -04:00
|
|
|
if (sdev)
|
|
|
|
print_init(sdev->putc);
|
2012-09-28 00:59:25 -04:00
|
|
|
}
|
|
|
|
|
2012-10-06 14:53:00 -04:00
|
|
|
void serial_init();
|
2012-09-28 00:59:25 -04:00
|
|
|
void kmalloc_init();
|
2012-10-06 14:53:00 -04:00
|
|
|
|
2012-09-09 01:58:38 -04:00
|
|
|
int main(void) {
|
2012-09-25 22:44:19 -04:00
|
|
|
char *lower, *upper;
|
|
|
|
struct atag *atags;
|
2012-09-21 11:52:24 -04:00
|
|
|
|
|
|
|
//setup MMU
|
|
|
|
mmu_reinit();
|
|
|
|
|
2012-10-06 14:53:00 -04:00
|
|
|
/* 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();
|
2012-10-04 00:26:35 -04:00
|
|
|
init_earlyinitcalls();
|
|
|
|
serial_console_init();
|
2012-09-07 23:56:32 -04:00
|
|
|
|
2012-09-17 23:33:50 -04:00
|
|
|
//setup memory
|
|
|
|
mm_init();
|
2012-09-28 00:59:25 -04:00
|
|
|
kmalloc_init();
|
2012-09-25 22:44:19 -04:00
|
|
|
|
|
|
|
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));
|
2012-09-17 23:33:50 -04:00
|
|
|
|
2012-10-04 00:26:35 -04:00
|
|
|
init_initcalls();
|
2012-09-17 23:33:50 -04:00
|
|
|
|
2012-10-02 23:17:25 -04:00
|
|
|
video_init();
|
|
|
|
console_init(&myfb);
|
|
|
|
print_console_logo();
|
2012-09-07 23:56:32 -04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|