1
0

initcalls: Add initial implementation

Create simple serial subsystem which makes use of initcalls, and convert
existing serial drivers to its use.
This commit is contained in:
2012-10-04 00:26:35 -04:00
parent 3f624153e7
commit 9d86813d8c
14 changed files with 219 additions and 102 deletions

View File

@ -19,6 +19,7 @@
*/
#include <atags.h>
#include <init.h>
#include <kmalloc.h>
#include <mmu.h>
#include <mm.h>
@ -26,13 +27,13 @@
#include <framebuffer.h>
#include <console.h>
#include <drivers/serial.h>
#ifdef CONFIG_VEXPRESS_A9
#include <drivers/pl011.h>
#include <drivers/pl111.h>
#endif
#ifdef CONFIG_RPI
#include <drivers/pi_mini_uart.h>
#include <drivers/bcm2835_videocore.h>
#endif
@ -56,74 +57,11 @@ void video_init(void) {
#endif
}
void test_mm() {
struct page *p, *q;
void serial_console_init() {
struct serial_dev *sdev = serial_first_device();
print("\ntest_mm():\n");
p = mm_get_free_pages(0);
if (p)
print("%x, %x\n", p, p->address);
else
print("Error: failed to allocate memory for p\n");
q = mm_get_free_pages(4);
if (q)
print("%x, %x\n", q, q->address);
else
print("Error: failed to allocate memory for q\n");
mm_put_free_pages(p);
mm_put_free_pages(q);
q = mm_get_free_pages(1);
if (q)
print("%x, %x\n", q, q->address);
else
print("Error: failed to allocate memory for q\n");
p = mm_get_free_pages(0);
if (p)
print("%x, %x\n", p, p->address);
else
print("Error: failed to allocate memory for p\n");
mm_put_free_pages(p);
mm_put_free_pages(q);
}
void test_kmalloc() {
void *a, *b, *c, *d;
print("\ntest_kmalloc():\n");
a = kmalloc(4);
print("a: %x\n", a);
b = kmalloc(13);
print("b: %x\n", b);
c = kmalloc(4);
print("c: %x\n", c);
d = kmalloc(25);
print("d: %x\n", d);
kfree(c);
kfree(b);
kfree(a);
kfree(d);
a = kmalloc(13);
print("a: %x\n", a);
b = kmalloc(4);
print("b: %x\n", b);
c = kmalloc(25);
print("c: %x\n", c);
d = kmalloc(7);
print("d: %x\n", d);
}
void test_memory() {
test_mm();
test_kmalloc();
if (sdev)
print_init(sdev->putc);
}
void kmalloc_init();
@ -135,14 +73,9 @@ int main(void) {
//setup MMU
mmu_reinit();
//initialize the serial console
#ifdef CONFIG_VEXPRESS_A9
print_init(&pl011_putc);
#endif
#ifdef CONFIG_RPI
mini_uart_init();
print_init(&mini_uart_putc);
#endif
init_earlyinitcalls();
serial_console_init();
//setup memory
mm_init();
@ -159,7 +92,7 @@ int main(void) {
declare_memory_region(lower, upper);
} while (!atags_next_mem_region(&atags));
test_memory();
init_initcalls();
video_init();
console_init(&myfb);