임베디드/[ RTOS ]

[ RTOS ] 01. ThreadX의 Initialization

kim.svadoz 2021. 3. 29. 09:55
728x90
반응형

Understanding the initialization process is very important. The initial hardware environment is setup here. In addition, this is where the application is given its initial personality.

ThreadX attempts to utilize (whenever possible) the complete development tool’s initialization process. This makes it easier to upgrade to new versions of the development tools in the future.

초기화 프로세스를 이해하는 것은 매우 중요합니다. 초기 하드웨어 환경은 여기에서 설정됩니다. 또한 이것은 응용 프로그램에 초기 성격이 부여되는 곳입니다.

ThreadX는 가능한 한 전체 개발 도구의 초기화 프로세스를 활용하려고합니다. 따라서 향후 새로운 버전의 개발 도구로 쉽게 업그레이드 할 수 있습니다.

  • System Reset

All microprocessors have reset logic. When a reset occurs (either hardware or software), the address of the application’s entry point is retrieved from a specific memory location. After the entry point is retrieved, the processor transfers control to that location.

The application entry point is quite often written in the native assembly language and is usually supplied by the development tools (at least in template form). In some cases, a special version of the entry program is supplied with ThreadX.

모든 마이크로 프로세서에는 리셋 로직이 있습니다. 재설정 (하드웨어 또는 소프트웨어)이 발생하면 특정 메모리 위치에서 응용 프로그램의 진입 점 주소가 검색됩니다. 진입 점이 검색된 후 프로세서는 제어권을 해당 위치로 전송합니다.

응용 프로그램 진입 점은 기본 어셈블리 언어로 작성되는 경우가 많으며 일반적으로 개발 도구 (최소한 템플릿 형식)에서 제공합니다. 어떤 경우에는 특별한 버전의 진입 프로그램이 ThreadX와 함께 제공됩니다.

  • Development Tool Initialization

After the low-level initialization is complete, control transfers to the development tool’s high-level initialization. This is usually the place where initialized global and static C variables are setup. Remember that their initial values are retrieved from the constant area. Exact initialization processing is development tool specific.

하위 수준 초기화가 완료되면 제어가 개발 도구의 상위 수준 초기화로 이전됩니다. 일반적으로 초기화 된 전역 및 정적 C 변수가 설정되는 곳입니다. 초기 값은 상수 영역에서 검색됩니다. 정확한 초기화 처리는 개발 도구에 따라 다릅니다.

  • main

When the development tool initialization is complete, control transfers to the user-supplied main function. At this point, the application controls what happens next. For most applications, the main function simply calls tx_kernel_enter, which is the entry into ThreadX. However, applications can perform preliminary processing (usually for hardware initialization) prior to entering ThreadX.

The call to tx_kernel_enter does not return, so don’t place any processing after it!

개발 도구 초기화가 완료되면 제어가 사용자가 제공 한 주 기능으로 이전됩니다. 이 시점에서 애플리케이션은 다음에 발생하는 작업을 제어합니다. 대부분의 애플리케이션에서 main 함수는 단순히 ThreadX의 항목 인 tx_kernel_enter를 호출합니다. 그러나 응용 프로그램은 ThreadX에 들어가기 전에 예비 처리 (일반적으로 하드웨어 초기화 용)를 수행 할 수 있습니다.

tx_kernel_enter에 대한 호출이 반환되지 않으므로 이후에 처리를하지 마십시오!

  • tx_kernel_enter

The entry function coordinates initialization of various internal ThreadX data structures and then calls the application’s definition function tx_application_define.

When tx_application_define returns, control is transferred to the thread scheduling loop. This marks the end of initialization!

입력 함수는 다양한 내부 ThreadX 데이터 구조의 초기화를 조정 한 다음 응용 프로그램의 정의 함수 tx_application_define을 호출합니다.

tx_application_define이 반환되면 제어가 스레드 스케줄링 루프로 전송됩니다. 이것은 초기화의 끝을 표시합니다!

  • Application Definition Function

The tx_application_define function defines all of the initial application threads, queues, semaphores, mutexes, event flags, memory pools, and timers. It is also possible to create and delete system resources from threads during the normal operation of the application. However, all initial application resources are defined here.

The tx_application_define function has a single input parameter and it is certainly worth mentioning. The first-available RAM address is the sole input parameter to this function. It is typically used as a starting point for initial run-time memory allocations of thread stacks, queues, and memory pools.

After initialization is complete, only an executing thread can create and delete system resources— including other threads. Therefore, at least one thread must be created during initialization.

tx_application_define 함수는 모든 초기 애플리케이션 스레드, 큐, 세마포어, 뮤텍스, 이벤트 플래그, 메모리 풀 및 타이머를 정의합니다. 응용 프로그램이 정상적으로 작동하는 동안 스레드에서 시스템 리소스를 만들고 삭제할 수도 있습니다. 그러나 모든 초기 응용 프로그램 리소스가 여기에 정의됩니다.

tx_application_define 함수에는 단일 입력 매개 변수가 있으며 확실히 언급 할 가치가 있습니다. 처음 사용 가능한 RAM 주소는이 기능에 대한 유일한 입력 매개 변수입니다. 일반적으로 스레드 스택, 큐 및 메모리 풀의 초기 런타임 메모리 할당을위한 시작점으로 사용됩니다.

초기화가 완료된 후에는 실행중인 스레드 만 다른 스레드를 포함한 시스템 리소스를 만들고 삭제할 수 있습니다. 따라서 초기화 중에 하나 이상의 스레드를 만들어야합니다.

  • Interrupts

Interrupts are left disabled during the entire initialization process. If the application somehow enables interrupts, unpredictable behavior may occur. Figure 4 on page 51 shows the entire initialization process, from system reset through application-specific initialization.

인터럽트는 전체 초기화 프로세스 동안 비활성화 된 상태로 유지됩니다. 응용 프로그램이 어떻게 든 인터럽트를 활성화하면 예기치 않은 동작이 발생할 수 있습니다. 51 페이지의 그림 4는 시스템 재설정부터 애플리케이션 별 초기화까지 전체 초기화 프로세스를 보여줍니다.

image-20210210143048768

728x90
반응형