summaryrefslogtreecommitdiffstats
path: root/sbe/image/base_main.C
blob: 97a9633bf23379977469bcfe3eb9e392e8c10618 (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
//-----------------------------------------------------------------------------
// *! (C) Copyright International Business Machines Corp. 2014
// *! All Rights Reserved -- Property of IBM
// *! *** IBM Confidential ***
//-----------------------------------------------------------------------------

/// \file base_main.c
/// \brief base program that creates and starts a thread
///
/// This file is a placeholder code in order to compile. I will be replaced in future by the code placed into the .text section.

extern "C" {
#include "pk.h"
#include "pk_trace.h"
#include "base_ppe_main.h"
}
#define KERNEL_STACK_SIZE   256
#define MAIN_THREAD_STACK_SIZE  256

uint8_t     G_kernel_stack[KERNEL_STACK_SIZE];
uint8_t     G_main_thread_stack[MAIN_THREAD_STACK_SIZE];
PkThread    G_main_thread;

// A simple thread that just increments a local variable and sleeps
void main_thread(void* arg)
{

    while(1)
    {

        pk_sleep(PK_SECONDS(1));

    }
}


// The main function is called by the boot code (after initializing some
// registers)
int main(int argc, char **argv)
{
    // initializes kernel data (stack, threads, timebase, timers, etc.)
    pk_initialize((PkAddress)G_kernel_stack,
                  KERNEL_STACK_SIZE,
                  0,
                  500000000);


    //Initialize the thread control block for G_main_thread
    pk_thread_create(&G_main_thread,
                      (PkThreadRoutine)main_thread,
                      (void*)NULL,
                      (PkAddress)G_main_thread_stack,
                      (size_t)MAIN_THREAD_STACK_SIZE,
                      (PkThreadPriority)1);



    //Make G_main_thread runnable
    pk_thread_resume(&G_main_thread);

    // Start running the highest priority thread.
    // This function never returns
    pk_start_threads();
    
    return 0;
}
OpenPOWER on IntegriCloud