summaryrefslogtreecommitdiffstats
path: root/src/sys/init/init_main.C
blob: dd83ea131edd88d7c137cb05cfbf2807166c7d1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <kernel/console.H>  // TODO : Remove this.

#include <kernel/syscalls.H>
#include <sys/syscall.h>

#include <sys/task.h>
#include <sys/sync.h>
#include <sys/msg.h>
#include <sys/mmio.h>

mutex_t global_mutex = MUTEX_INITIALIZER;

/*
void init_child(void* unused)
{
    mutex_lock(&global_mutex);
    printk("Crun: %d on %d\n", task_gettid(), task_getcpuid());
    mutex_unlock(&global_mutex);
    for (volatile int i = 0 ; i < 100000; i++);
    task_end();
}
*/

void vfs_main(void*);

void init_main(void* unused)
{
    printk("Starting init!\n");
    
    printk("Bringing up VFS..."); 
    task_create(&vfs_main, NULL);
    
    // TODO... add a barrier to ensure VFS is fully up.
    while (NULL == _syscall0(Systemcalls::MSGQ_RESOLVE_ROOT))
	task_yield(); 


/* 
    uint64_t* mmio_addr = (uint64_t*) mmio_map((void*)0x800000000, 1);
    printk("MMIO Access %lx\n", *mmio_addr);

    msg_q_t msgq = msg_q_create();
    msg_q_register(msgq, "/msg/init");

    msg_t* msg = msg_allocate();
    msg->type = 1; msg->data[0] = 0xDEADBEEF12345678;
    msg_send(msgq, msg);
    msg = msg_wait(msgq);

    printk("Got Message: %lx\n", msg->data[0]);

    while(1)
    {
	mutex_lock(&global_mutex);
	int t = task_create(&init_child, NULL);
	printk("Create child %d\n", t);
	for (volatile int i = 0 ; i < 1000000; i++);
	mutex_unlock(&global_mutex);
    }
*/

    task_exec("libexample.so", NULL);

    task_exec("libcxxtest.so", NULL);
    
    while(1)
	task_yield();
}
OpenPOWER on IntegriCloud