Android LK Interpretation

Source: Internet
Author: User

Before read LK but are scattered, also remember, this time a good record, as their own essays to see

What did I do, I'll write about it:

1. Initialize the board structure according to the hardware information of the board
2. Initialize all kinds of clocks
3. Initialization interrupt (How many interrupts are supported)
4. Initialize UART (set clock, configure corresponding GPIO, set various states)
5. Initialization of Heap
6. Initializing threads
7. Establish Idle Threads

8.panel initialization is still a little light.

Initialization preparation for the 9.shell environment

The first function of LK

void Kmain (void) {//Get us to some sort of thread context thread_init_early ();


	Early Arch Stuff Arch_early_init ();


	Do any super early platform initialization platform_early_init ();


	Do any super early target initialization target_early_init ();
	dprintf (INFO, "Welcome to lk\n\n");


	Bs_set_timestamp (Bs_bl_start);
	Deal with the Any static constructors dprintf (spew, "calling constructors\n");


	Call_constructors ();
	Bring up the kernel heap dprintf (spew, "initializing heap\n");


	Heap_init ();


	__stack_chk_guard_setup ();
	Initialize the threading system dprintf (Spew, "initializing threads\n");


	Thread_init ();
	Initialize the DPC system dprintf (Spew, "initializing dpc\n");


	Dpc_init ();
	Initialize kernel timers dprintf (spew, "initializing timers\n");


Timer_init (); #if (! Enable_nandwrite)//Create a thread to complete system initialization dprintf (spew, "creating bootstrap completion, thre
	Ad\n "); Thread_resume (Thread_create ("BootstrAp2 ", &bootstrap2, NULL, Default_priority, default_stack_size));


	Enable interrupts exit_critical_section ();
Become the Idle thread Thread_become_idle ();
#else Bootstrap_nandwrite (); #endif}


The next one to see

Let's see the first one.

void thread_init_early (void)
{
	int i;

	/* Initialize the Run queues * * for
	(i=0 i < num_priorities; i++)
		list_initialize (&run_queue[i));       static struct List_node run_queue[num_priorities];

/*static inline void list_initialize (struct list_node *list)
{
	List->prev = List->next = list;
} * * *

	Initialize the thread list
	/list_initialize (&thread_list);    static struct List_node thread_list;


	/* Create a thread to cover the current running state */
	thread_t *t = &bootstrap_thread;     Static thread_t Bootstrap_thread;
	Init_thread_struct (T, "Bootstrap");


	/* Half construct this thread, since we ' re already running
	/t->priority = highest_priority;
	T->state = thread_running;
	T->saved_critical_section_count = 1;
	List_add_head (&thread_list, &t->thread_list_node);
	Current_thread = t;
}
Look again.

static void Init_thread_struct (thread_t *t, const char *name)
{
	memset (t, 0, sizeof (thread_t));
	T->magic = thread_magic;
	strlcpy (t->name, name, sizeof (T->name));   Put <span style= "font-family:arial, Helvetica, Sans-serif;" >bootstrap assignment to Thread name</span>

}






Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.