Custom wince Shell

Source: Internet
Author: User

 

ARM-based Windows CE kernel startup Analysis 1

1. startup. S2

2. kernelstart2

2.1 arminit () 3

2.1.1 oalintrinit3

2.1.2 oaltimerinit4

2.1.2.1 variable tick scheduler4

2.2 kernelinit () 4

2.3 firstschedule5


1. startup. s

Kernel entry point: startup. s, the kernel starts from here. because the kernel is loaded by the bootloader, during kernel running, the bootloader has completed the basic hardware initialization (disabling watchdog, PLL settings, and so on), startup. s tasks are relatively simple, but the g_oaladdresstable array address in oemaddrtab_cfg.inc is used as a parameter and passed to kernelstart. This array is used to describe and map physical addresses to virtual addresses.

(. + 8) is the pipeline processing. kernelstart () is located in

Private/winceos/coreos/nk/kernel/ARM/armtrap. s

2. kernelstart

The mdram. c file in the local directory of arminit.

Kernelinit () is located in private/winceos/coreos/nk/kernel/kwin32.c.

Firstschedule () is located in a label of armtrap. S.

Focus on arminit () and kernelinit (). initialize the target board first, and then initialize the kernel. firstschdule () to start scheduling the first program.

2.1 arminit ()

Let's take a look at several key actions of arminit () as follows:

Kernelrelocate () is a relocation. kernelfindmemory () is used to find available system memory, which is divided into two parts: application memory and object store. both functions are implemented by Ms. the function we need to add is a function whose name starts with OEM.

Oeminitdebugserial () initializes a debugging port. Generally, we use a serial port as the debugging port. This function must be implemented by ourselves in platform/smdk2440a/src/kernel/oal/debug. c defines this function. for example, you can set serial port 0 as the debugging port, and initialize string port 0 in this function.

Oeminit () is a very important function,

Oalcacheglobalsinit () is implemented in platform/common/src/ARM/common/Cache/init. S. This part of code is provided in the form of pqoal.

Oalintrinit () initialization interrupted.

Oaltimerinit () initializes the timer timer4 as a system clock (tick ),

Configgpio () initializes the gpio port and sets related registers.

Initdisplay () initializes the LCD. Sometimes, we want to display a waiting image or a logo during oal startup and kernel loading. To achieve this, we need to initialize the LCD first.

Oalkitlstart () is ready to start kitl.

In addition, some basic information will be printed at arminit through the debugging port, and "Windows CE kernel for arm..." will be printed at the beginning ...." Print information such as the intermediate Processor type. Print "arminit done." at the end ."

2.1.1 oalintrinit

Call oalintrmapinit () to initialize two arrays g_oalsysintr2irq and g_oalirq2sysintr. These two arrays represent the ing between IRQ and sysintr with logical interruptions.

Then initialize the interrupt register,

Finally, leave an interface to the OEM: bspintrinit (). If the OEM needs to initialize some interruptions at this stage, define this function and implement it.

2.1.2 oaltimerinit

This function is important. We all know that all wince systems require a timer to provide a heartbeat,


G_oaltimer contains various system clock-related variables.

Curridlehigh, curridlelow, these two 32-bit DWORD variables are combined to implement a 64-bit counter, reflecting the time when the system is in idle mode. It is generally updated in the oemidle () function. The user program can obtain this value by calling the getidletime () function.

Initialize kernel function pointer: pqueryperformancefrequency, pqueryperformancecounter. Use these two functions to implement high-precision timers. The prototypes of these two functions have also been implemented by pqoal.

Initialize timer4 as the system clock. timer4 is a 16-bit timer. This function sets timer4 as the auto-reprinting mode.

2.1.2.1 variable tick Scheduler

Variable system clock cycle, which is a new performance added in wince5.0.

During each timer interruption, the kernel analyzes all threads and determines which thread to switch to for running. if all threads are waiting, the system enters the idle state. in this status, any interruption will wake up the system to start scheduling again. generally, the system is in the idle state most of the time, and the kernel will call oemidle () to enter the idle state. We already know that this state will be awakened by any interruption. in previous versions, system interruptions (timer4 interruptions) were generated every millisecond to check whether the system needs to be rescheduled. in order to save power, do not want to interrupt so frequently. therefore, in wince5.0, poemupdaterescheduletime () is called before oemidle () is called (). use this function to reset the time when the system clock was interrupted.

2.2 kernelinit ()

Let's look at the kernelinit () function.

But focus more on kernelinit ().

2.3 firstschedule

Located in a label of armtrap. S. Start the first thread scheduling. The entire kernel starts to run.

 

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.