[AIX 진단 서브시스템 6] 응용 프로그램 테스트 단위(TU)와 exectu()

핵심 정리

  • 테스트 단위(TU)는 진단 응용 프로그램(DA)이 장치를 시험하려고 부르는 ANSI C 코드 모음입니다. TU 하나는 레지스터 읽기/쓰기 같은 시험 기능 하나이며, 사용자 인터페이스 코드를 넣지 않습니다. 권장 순서로 실행하면 하드웨어 기능의 95% 이상을 시험해야 합니다.
  • TU 번호는 161439(0x10xEFFF). 1번 TU_OPEN은 지속 데이터 버퍼를 잡고(TU_INFO_HANDLE), 속성을 읽고(pdiag_cs_get_attr), 시험 가능 상태로 만들고(pdiag_diagnose_state), 장치를 엽니다(pdiag_open). 0xEFFF번 TU_CLOSE는 그 반대입니다.
  • 호출은 exectu(resource_name, TU_TYPE *, TU_INFO_HANDLE *, TU_RETURN_TYPE *)이며, 결과는 major_rc(0 = 정상, FRU 격리용)와 minor_rc(더 세밀한 위치)로 돌려줍니다.
  • 다중 스레드에서 같은 TU 코드가 동시에 돌 수 있으므로 정적 변수를 쓰지 않고(재진입), 지속 데이터는 TU_INFO_HANDLE이 가리키는 버퍼에 둡니다. 장치 접근은 interface.c의 dd_open, dd_read, dd_write, dd_dma 등으로 감싸 이식성을 지킵니다.
  • 인터럽트 처리기는 TU 라이브러리와 따로 모듈로 만들어 pdiag_open에서 적재하며, interrupt_flag 비트와 TU의 flag_mask를 AND해 0이 아니면 pdiag_dd_watch_for_interrupt가 돌아옵니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (내용이 같음)
원문 Understanding the Diagnostic Subsystem for AIX — 5.3판 3장(5772쪽), 6.1판 4559쪽
헤더 /usr/include/diag/tucb.h, {DEVICE}_err_detail.h, {DEVICE}_input_params.h
관련 함수 exectu(), pdiag_open, pdiag_close, pdiag_dd_read, pdiag_dd_write, pdiag_dd_watch_for_interrupt, pdiag_cs_get_attr

응용 프로그램 테스트 단위(Application Test Unit, TU)는 진단 응용 프로그램이 장치를 시험하는 데 씁니다. 보통 크기가 크거나 기능 구성 때문에 TU는 장치 드라이버 안에 넣기보다 응용 프로그램으로 만드는 것이 알맞습니다.

이 절은 TU 코드의 요구 사항을 정의하고, 여러 대상 환경용 코드를 만들어야 하는 TU 개발자에게 지침을 줍니다. TU 코드는 ANSI C로, 일반적으로 인정되는 좋은 프로그래밍 관행에 따라 만들어야 합니다. 예를 들면 다음과 같습니다.

  • 모듈화
  • 읽기 쉬움
  • 스스로 문서가 되는 코드
  • 유지 보수성
  • 재진입(re-entrant) 가능

어셈블러 수준 코드는 되도록 쓰지 않아야 합니다. 다만 시험 기능의 효과에 성능이 결정적인 경우에는 필요할 수 있습니다. 그런 코드는 이식 가능하다고 보지 않으며 대상 플랫폼마다 다시 써야 합니다.

다음 주제를 자세히 다룹니다.

영어 원문

Application test units

Application Test Units (TU) are used by the Diagnostic Applications to test a device. Typically, due to either their large size or their functional composition, TUs are more appropriately written as applications as opposed to being included within device drivers.

The Application Test Units section defines requirements for Application Test Unit code and provides guidance for TU Developers who need to develop code for multiple target environments. The TU code should be developed in ANSI C language and according to generally accepted good programming practices, including, but not limited to:

  • Modularity

  • Readability

  • Self Documenting

  • Maintainability

  • Re-entrant Capability

The use of assembler-level code is strongly discouraged, but may be necessary in certain cases where performance is critical to the effectiveness of the test function. Such code would not be considered portable and would have to be rewritten for the target platform.

The following topics are discussed in detail:

테스트 단위의 정의

테스트 단위 방법론의 바탕은 테스트 단위라고 하는 기본적이고 모듈화된 구성 단위입니다. 테스트 단위는 시험 대상 시스템이나 하위 시스템에 대해 수행하는 작업 하나입니다.

대부분 레지스터 읽기/쓰기 시험 같은 개별 기능 시험입니다. 테스트 단위에는 다음 기본 가정이 있습니다.

  • 테스트 단위 하나에서는 모듈화된 시험 기능 하나만 수행합니다.
  • 테스트 단위에는 번호가 있으며, 호출하는 응용 프로그램이 실행할 테스트 단위 번호를 지정합니다.
  • 테스트 단위에는 환경에 따른 코드를 넣지 않습니다. 특히 사용자 인터페이스 호출이 그렇습니다. 또 읽기·쓰기 같은 장치 접근 방법은 범용 함수 호출로 하며, 그 함수는 다른 소스 파일에 정의해 필요하면 대상 환경의 요구에 맞게 코딩합니다.
  • 테스트 단위는 소스 파일에 알맞게 묶습니다. 그래서 대상 환경의 요구에 맞게 실행 라이브러리를 골라 빌드할 수 있습니다.
  • 같은 테스트 단위가 어떤 제어 변수(예: 속도나 모드 설정)에 따라 하드웨어를 다른 방식으로 시험할 수 있으면, 그 테스트 단위는 번호가 서로 다른 여러 "논리" 테스트 단위를 나타낼 수 있습니다. 테스트 단위가 불리면 요청받은 번호를 해석해 제어 변수를 알맞게 설정합니다.
영어 원문

Test unit definition

Fundamental to the Test Unit methodology is a basic, modular building block that is referred to as a Test Unit. A test unit is a single operation performed on the system or subsystem under test.

Most often this is an individual function test, such as a register read/write test. Several basic assumptions are made for the test units:

  • Only one modular test function is performed in each individual test unit.

  • Test units are numbered, and the calling application specifies the number of the test unit it wishes to execute.

  • No environmental specific code is allowed in a test unit. This specifically includes user interface calls. Also, device-access methods such as reads or writes are done with generic function calls, which can then be defined in a different source file and coded, if necessary, to meet the specific requirements of the target environments.

  • Test units are grouped appropriately in source files. This allows custom building of executable libraries to meet the requirements of the target environments.

  • In cases where the same test unit may be used to test hardware in different ways based on some control variables (for example, speed or mode settings), that test unit may be used to represent several "logical" test units, each with a different test unit number. When the test unit is called, it would interpret the test unit number requested and set the control variables appropriately.

하드웨어 기능 범위

테스트 단위 패키지는 문서에 적힌 권장 순서로 TU를 실행하면 하드웨어 기능의 95% 이상을 시험하도록 설계하고 구현해야 합니다.

영어 원문

Hardware functional coverage

The Test Unit package should be designed and implemented such that if the TUs are run in the recommended order as documented, then a minimum coverage of 95% of the hardware function is achieved.

테스트 단위 번호

테스트 단위 번호는 TU 개발자가 정한 논리적인 순서를 따라야 합니다. 0은 TU 번호로 쓰지 않습니다.

TU 번호의 허용 범위는 161439(16진수 1EFFF)입니다. tucb 머리 구조체의 TU 멤버가 32비트 정수로 정의되어 있어도 이 범위를 지켜야 합니다. 지정한 대로 실행할 때 TU를 번호 순서대로 실행할 수 있도록 번호 체계를 만드는 것이 좋습니다. 알맞은 곳에 나중의 TU를 끼워 넣을 수 있도록 번호 사이를 띄우는 것도 방법입니다.

영어 원문

Test unit numbering

Test Units should be numbered according to some logical sequence, which is determined by the TU Developer. Zero should not be used as a TU number.

The allowable range for TU numbers is 1 through 61439 (1 through EFFF hex). This numbering requirement must be respected even though the TU member of the tucb header structure is defined as a 32 bit integer. It is desirable that a numbering scheme be developed by the TU Developer allowing TUs to be executed in sequential numerical order when executing them as designated. This might include spacing the TUs so that future TUs can be inserted into the number sequence, where appropriate.

테스트 단위 코드의 장치 열기와 닫기

테스트 단위로 장치를 시험하기 전에, "TU와 인터럽트 처리기의 프로그래밍 인터페이스" 절에 정의한 인터페이스로 장치를 열어야 합니다.

시험이 끝나면 장치를 닫고 원래 상태로 되돌려야 합니다. 시험을 위한 장치 열기와 닫기에는 장치의 테스트 단위 라이브러리를 설계할 때 고려해야 할 문제가 있습니다.

  • 열기와 닫기에서 오류가 날 수 있으며, 호출 응용 프로그램이 다룰 수 있는 형식, 곧 테스트 단위 결과로 돌려줘야 합니다.
  • 호출 응용 프로그램은 보통 장치의 테스트 단위를 전부 또는 대부분 실행하므로, 테스트 단위를 부를 때마다 장치를 열고 닫으면 성능 부담이 너무 큽니다.
  • 조건에 따라 테스트 단위를 다른 조합과 순서로 실행할 수 있으므로, 호출 응용 프로그램은 다른 시험 기능과 따로 장치 열기·닫기 함수를 부를 수 있어야 합니다.

테스트 단위 규칙

위 문제를 다루는 표준 방법으로, 장치 라이브러리 안의 테스트 단위는 다음 규칙을 따라야 합니다.

  1. TU_OPEN이라고 하는 테스트 단위 1번이 있어야 합니다. 자료 구조를 초기화하고, 장치를 진단에 알맞은 상태로 만들고, 시험을 위해 장치를 엽니다. 다른 시험 기능은 하지 않습니다. 오류는 진단 결과로 돌려줍니다. 이 테스트 단위의 숫자 식별자로 정의값 TU_OPEN을 씁니다. 구체적으로 TU_OPEN은 다음을 합니다.
    • TU_INFO_HANDLE 매개변수가 NULL인지 보고, 지속 데이터를 담을 메모리 버퍼를 할당해 TU_INFO_HANDLE에 그 주소를 넣습니다("지속 데이터와 TU_INFO_HANDLE" 참고).
    • 구성 서비스(pdiag_cs_get_attr)를 불러 필요한 장치 속성 정보를 읽고, pdiag_open 호출의 매개변수로 넘기는 pdiagex_dds_t 구조체에 알맞은 정보를 넣습니다.
    • pdiag_diagnose_state를 불러 장치를 시험 가능한 상태로 만듭니다.
    • pdiag_open을 불러 시험을 위해 장치를 열고, 인터럽트 처리기가 있으면 적재합니다.
    • 위 기능이 모두 오류 없이 끝나면 주 반환 코드로 "0"을 돌려줍니다.
  2. TU_CLOSE라고 하는 테스트 단위 61439번(16진수 0xEFFF)이 있어야 합니다. 장치를 닫고 진단을 부르기 전의 원래 상태로 되돌립니다. 숫자 식별자로 정의값 TU_CLOSE를 씁니다. 구체적으로 TU_CLOSE는 다음을 합니다.
    • pdiag_close를 불러 장치를 닫고 인터럽트 처리기를 내립니다.
    • pdiag_restore_state를 불러 장치를 TU_OPEN 전의 상태로 되돌립니다.
    • TU_OPEN이 할당한 메모리 버퍼를 해제합니다. 해제할 버퍼는 대부분 TU_INFO_HANDLE 안의 포인터가 가리키는 "보조" 지속 데이터 버퍼입니다.
    • 위 기능이 모두 오류 없이 끝나면 주 반환 코드로 "0"을 돌려줍니다.
    • 올바른 진단 순서는 테스트 단위 TU_OPEN을 부르고, TU_OPEN이나 TU_CLOSE가 아닌 테스트 단위를 원하는 만큼 부르고, 마지막에 TU_CLOSE를 부르는 것입니다.
영어 원문

Test unit code device open and close

Before a device can be tested by one of the test units, it must be opened for access through the interfaces defined in the Programming Interfaces for TUs and Interrupt Handlers section.

Also, when testing is complete, the device must be closed and restored to its original state. The opening and closing of the device for testing presents some problems that must be accounted for in the design of the Test Unit library for the device:

  • Errors may occur on the open and close operation, and these must be presented back to the calling applications in a form those applications know how to handle; that is, test unit results.

  • Since the calling application will typically run through all or most of the Test Units for a given device, the performance penalty of opening and closing the device for each call to a Test Unit is prohibitive.

  • Under different conditions, test units may be run in different combinations and sequences, so the calling application must be able to call the functions which do device open and close independent of the other test functions.

Test Unit Conventions

To provide a standard solution for handling the above problems, the following conventions for Test Units within a specific device library are required.

  1. There must be a Test Unit number 1, referred to as TU_OPEN, which includes functions to initialize data structures, place the device in the correct state for diagnostics, and open the device for testing. It does not perform any other test functions. Any error conditions are returned as diagnostic results. The define value TU_OPEN should be used as the numerical identifier for this Test Unit. Specifically, TU_OPEN performs the following: a. Sees that the TU_INFO_HANDLE parameter is set to NULL, allocates a memory buffer to hold persistent data, and assigns TU_INFO_HANDLE to that address. For more information, see "Persistent Data and the TU_INFO_HANDLE". b. Reads needed device attribute information by making calls to the configuration services (pdiag_cs_get_attr), and places appropriate information into the pdiagex_dds_t structure that is passed as a parameter on the pdiag_open call. c. Calls pdiag_diagnose_state to place the device into a testable state. d. Calls pdiag_open to open the device for testing, and loads the interrupt handler, if one exists. e. Assuming all the above functions are performed without error, returns a value of "0" as the major return code.

  2. There must be a Test Unit number 61439 (0xEFFF hex), referred to as TU_CLOSE, which closes the device and restores the device to the original state it was in prior to diagnostics being invoked. The define value TU_CLOSE should be used as the numerical identifier for this test unit. Specifically, TU_CLOSE performs the following: a. Calls pdiag_close to close the device, and unloads the interrupt handler. b. Calls pdiag_restore_state to return the device to the state it was in prior to TU_OPEN. c. Frees any memory buffers that were allocated by TU_OPEN. For the most part, the buffers that need to be freed are "secondary" persistent data buffers, pointed to by pointers in TU_INFO_HANDLE. d. Assuming all the above functions are performed without error, returns a value of "0" as the major return code. e. A valid diagnostic sequence consists of a call to Test Unit TU_OPEN, some arbitrary number of calls to Test Units other than TU_OPEN or TU_CLOSE, and then a final call to Test Unit TU_CLOSE.

이식성

오늘날의 시스템은 보통 하드웨어 플랫폼 하나에서 여러 운영 체제를 지원합니다. 이런 시스템은 대개 같은 하드웨어 기능을 공유하므로, 진단은 어느 운영 환경에서든 동작하는 하드웨어 고장 분석을 지원하도록 만들어야 합니다. 그래서 모든 TU 패키지는 이식성을 염두에 두고 설계해야 합니다.

운영 환경의 차이 말고도 실행 환경마다 다른 종류의 사용자 인터페이스가 필요합니다. 예를 들어 현장용 시스템 진단은 설계 검증 시험에서 쓰는 하드웨어 시험기(exerciser)와 다른 인터페이스를 쓸 수 있습니다.

TU 패키지가 사용자와 아무것도 주고받지 않게(화면 출력, 키보드 입력 없음) 하면 문제의 3분의 1은 풀립니다. 그러면 TU는 모두 한 인터페이스로 불리고, TU 패키지를 바꾸지 않고도 여러 종류의 사용자 인터페이스를 만들 수 있습니다.

또 다른 3분의 1은 운영 환경에서 장치에 어떻게 접근하느냐의 문제입니다. 운영 환경마다 장치 드라이버가 다르므로(예: UNIX 드라이버, DOS/WIN 드라이버, 펌웨어 기반, 범용 I/O), 기능 시험이 어떤 드라이버·환경으로 접근하는지 알아야 하는 부담을 떼어 낼 방법이 필요합니다. 그래서 기능 시험 대신 장치에 접근하는 표준 장치 접근 루틴이 필요합니다. 기능 시험에 보통 필요한 장치 접근은 다음과 같습니다.

  • 장치 열기
  • 읽기
  • 쓰기
  • 인터럽트 설정과 처리
  • DMA(Direct Memory Access) 설정과 정리
  • 장치 닫기

이 루틴의 인터페이스는 설계상 아래의 장치 접근 방법(곧 실행 환경)과 무관해야 하며, 운영 환경이 달라도 바뀌면 안 됩니다. 루틴의 내부는 운영 환경마다 달라지며, 알맞은 시스템·드라이버 호출로 기능 시험 대신 장치 접근 요청을 수행합니다.

영어 원문

Portability

With today's systems, multiple operating systems are typically supported on a single hardware platform. Since these systems usually share the same hardware features, diagnostics need to be written to support hardware failure analysis that works within any of these operating environments. For this reason, all TU packages must be designed with portability in mind.

Besides the operating environment differences, there is also the need for different types of user interfaces for the different execution environments. For instance, system diagnostics for the field may use a different interface than the hardware exerciser used in the design verification test.

By ensuring that the TU package performs no interaction with the user (output to screen and input from keyboard), one third of the problem will have been solved. Then all the invocations of the TUs will be made through one interface, and different types of user interfaces can be developed with no need to change the TU package.

Another third of the problem concerns how the device gets accessed through the operating environment. Since different operating environments have different device drivers (for example, UNIX drivers, DOS/WIN drivers, Firmware based, or generic I/O, there must be a way to isolate the functional test from the burden of knowing what driver/environment is being used for access. Therefore, standard device-access routines are needed to perform the device accesses on the functional test's behalf. The device accesses typically needed for functional tests are:

  • Device Open

  • Read

  • Write

  • Interrupt Setup and Handling

  • Direct Memory Access (DMA) Setup and Cleanup

  • Device Close

The interface of these routines must be independent of the underlying device-access method (that is, execution environment) by design, and must not change across operating environments. The internals of these routines will change per operating environment, using the appropriate system/driver calls to accomplish the device-access requests on the functional tests' behalf.

서비스 중 TU와 서비스 밖 TU

이 문서의 아키텍처는 주로 "서비스 밖(out-of-service)" 테스트 단위, 곧 시험하는 동안 운영 체제가 장치를 다른 용도로 쓸 수 없는 테스트 단위를 만들기 위한 것입니다. 그러나 고가용성 시스템에서는 장치가 "서비스 중(in-service)"일 때 쓸 수 있는 테스트 단위가 있으면 좋을 때가 많습니다. 특히 DASD 매체, RAID, 메모리·캐시 어레이, 다중 포트 어댑터처럼 일부만 고장 날 수 있는 장치가 그렇습니다. 서비스 밖 테스트 단위가 서비스 중단이 감지되지 않을 만큼 아주 짧게만 장치를 차지해 서비스 중 진단과 비슷한 일을 할 수도 있습니다.

같은 하드웨어 구성 요소에서 다른 작업과 정말 동시에 실행하도록 설계한 테스트 단위는 대개 운영 체제가 설치한 "일반" 기능 장치 드라이버를 거쳐 시험해야 합니다. 장치 드라이버 모델은 운영 체제마다 다르기 쉬우므로, 그 인터페이스에 맞춰 만든 테스트 단위는 다른 운영 체제로 쉽게 옮기지 못할 수 있습니다. 그러나 아래 "테스트 단위 코드의 권장 구조"처럼 테스트 단위 라이브러리를 잘 구성하면 바꿔야 할 함수를 소스 파일 하나로 모을 수 있습니다.

영어 원문

In-service versus out-of-service test units

The architecture described in this document is primarily for the creation of "out-of-service" Test Units, meaning that the device being tested is not available for any other use by the operating system while it is under test. In high-availability systems, however, it is often desirable to have Test Units which can be used while the device is "in-service." This may be especially true for devices which can have partial failures; for example, DASD media, RAID, memory/cache arrays, and multi-port adapters. A variation of In-Service diagnostics can sometimes be done with an Out-of-Service Test Unit that takes over the device for such a short period of time that no service outage is detected.

Test units designed to be run truly concurrently with other operations on the same hardware component will, in general, have to perform their testing through the "normal" functional device driver installed by the operating system. Because the device driver model tends to be unique to each operating system, the Test Unit written to that interface may not be easily portable to other operating systems. However, proper structuring of the Test Unit library, as discussed below in "Recommended General Structure of Test Unit Code," will help isolate into a single source file those functions which must be modified.

테스트 단위 코드의 권장 구조

이 문서에서 정한 TU 환경은 여러 운영 환경에서 TU 소스 코드를 그대로 옮길 수 있게 하려는 것입니다.

이식성을 지키려면 TU는 이 문서에서 정한 장치·시스템 인터페이스만 써야 합니다. 그러나 경험상 외부 함수를 떼어 내 추상화해, 이식 문제가 생기면 소스 파일 하나에서 고칠 수 있게 하는 것이 좋은 프로그래밍 관행입니다. 그래서 TU 개발자는 그런 분리와 추상화를 위한 특별한 소스 파일을 TU 라이브러리에 넣을 것을 강하게 권합니다. 아래는 TU 개발의 일관성을 높이도록 그 소스 파일의 권장 구현을 설명한 것입니다. 일관성은 테스트 단위 코드를 오래 유지 보수하는 데 매우 중요합니다.

TU 라이브러리에는 실제 TU 함수가 쓸 수 있는 추상화된 장치 함수 묶음을 제공하는 C 소스 파일 interface.c가 있어야 합니다. interface.c에 구현해야 할 함수는 다음과 같습니다.

함수 설명
dd_open 시험할 장치를 준비하고 필요한 장치 속성을 얻습니다.
dd_close 시험 뒤 정리합니다.
dd_read 읽기 작업을 합니다.
dd_write 쓰기 작업을 합니다.
dd_dma DMA 작업을 위해 사용자 버퍼를 초기화하고, 고정(pin)하고, 교차 메모리(cross-memory)로 붙입니다.
dd_dma_enable DMA 작업을 켜거나 끕니다.
dd_dma_cleanup DMA 작업에 할당한 자원을 해제합니다.
dd_interrupt 인터럽트 상태를 처리합니다.

원문 그림에서 보듯 이 함수들은 "TU와 인터럽트 처리기의 프로그래밍 인터페이스"에 설명한 서비스 하나 이상에 대응해야 합니다.

그림은 또 TU 라이브러리에 exectu() 인터페이스를 구현하는 C 소스 파일이 있어야 한다는 것을 보여 줍니다. 이 파일은 TU 라이브러리의 프로그램 진입점을 제공하고, 지정한 TU 번호를 알맞은 내부 함수로 해석해 그 함수를 부릅니다.

영어 원문

Recommended general structure of test unit code

The TU environment specified in this document is designed to provide source code portability of TUs across multiple operating environments.

TUs should only use the device and system interfaces specified in this document to ensure portability. However, experience has shown that it is good programming practice to isolate and abstract external functions so that any problems in porting can be corrected within a single source code file. For this reason, it is strongly recommended that TU developers include a special source file in their TU library for the purpose of providing that isolation and abstraction. The following describes a recommended implementation of that source file, given to help promote consistency in TU development. The consistency is very important for long-term maintenance of the Test Unit code.

TU libraries should include a C source file called interface.c, which provides a set of abstracted device functions that can be used by the actual TU functions. The following is a list of functions that should be implemented within the interface.c.

  • dd_open — Prepares a device for testing and obtains needed device attributes.
  • dd_close — Cleans up after testing.
  • dd_read — Performs a read operation.
  • dd_write — Performs a write operation.
  • dd_dma — Initializes, pins, and cross-memory attaches the user buffer for a DMA operation.
  • dd_dma_enable — Enables/Disables a DMA operation.
  • dd_dma_cleanup — Deallocates any resources previously allocated for a DMA operation.
  • dd_interrupt — Processes interrupt conditions.

As illustrated below, these functions should provide mappings to one or more of the services described in "Programming Interfaces for TUs and Interrupt Handlers" .

The figure also illustrates how TU libraries should include a C source file that implements the exectu() interface, which provides the program entry point for the TU library, decodes the specified TU number to the correct internal function, and calls that function.

다중 작업 환경을 위한 설계

테스트 단위는 재진입 규칙을 염두에 두고 설계해야 합니다. 같은 테스트 단위 묶음을 같은 장치에 동시에 실행할 가능성은 낮지만, 같은 종류의 장치(또는 같은 TU 코드로 시험하는 장치)가 시스템에 여럿 있을 수 있습니다.

시스템 시험기나 특정 하위 시스템의 부하 시험의 일부로 테스트 단위를 동시에 실행하려 할 수 있으므로, 같은 TU 코드가 한 프로세스의 여러 스레드에서 실행될 수 있습니다. 이때 정적 변수를 쓰면 TU 코드의 여러 실행 인스턴스 사이에 데이터 충돌이 날 수 있습니다.

영어 원문

Designing for multitasking environments

Test units should be designed with rules of re-entrance in mind. Although it is unlikely that a given set of Test Units could be run simultaneously against the same device, it is possible that more than one of the same type of device (or devices which are tested by the same TU code) exists in the system.

Since it may be desirable to run the Test Units concurrently as part of a system exerciser or a stress test for a specific subsystem, it is possible that the same TU code may be run in different threads under the same process. The use of static variables in this case could lead to data conflicts between the multiple instances of TU code execution.

지속 데이터와 TU_INFO_HANDLE

테스트 단위를 다중 스레드로 동시에 실행할 수 있어야 하므로 TU 함수는 재진입 가능하게 만들어야 하며, 정적으로 정의한 변수나 구조체는 쓸 수 없습니다.

참고: 정적 상수 값은 문제가 되지 않습니다.

문제를 예로 들면, 두 실행 스레드가 같은 종류의 두 장치 인스턴스에 같은 TU를 동시에 실행한다고 합시다. 정적 변수에 저장한 값이 두 스레드에서 모두 바뀌어 프로그램이 실패하기 쉽습니다. 그러므로 모든 변수와 구조체는 지역(스택) 변수로 정의하거나 할당한 메모리에 만들어야 합니다. 정적 변수가 없으면 TU를 한 번 실행한 뒤 다음 실행까지 데이터를 남겨 두기 어렵습니다.

exectu() 인터페이스의 TU_INFO_HANDLE 포인터는 특정 테스트 단위를 여러 번 부르는 동안 유지되는 데이터 버퍼의 포인터를 TU 작성자에게 주려는 것입니다. TU 라이브러리를 처음 부를 때 TU_INFO_HANDLE 포인터는 NULL입니다. 첫 TU인 TU_OPEN이 버퍼를 할당하고 TU_INFO_HANDLE 포인터를 설정해야 합니다. 그러면 TU 작성자가 남겨 두려는 데이터(예: 장치 속성 정보)를 그 버퍼에 넣을 수 있고, 버퍼의 포인터는 이후 TU 라이브러리를 부를 때마다 다시 넘어옵니다.

TU가 호출 응용 프로그램에 제어를 돌려준 뒤에도 데이터 버퍼는 할당된 채 남으므로, 중간에 끝내야 할 때나 마지막 TU(TU_CLOSE)를 부른 뒤에는 호출 응용 프로그램이 버퍼를 해제할 책임이 있습니다.

지속 데이터 버퍼에 둘 데이터는 다음과 같습니다.

  • 여러 장치 속성이 들어 있고 pdiag_open 호출의 매개변수로 쓰는 pdiagex_dds_t 구조체
  • pdiag_open 호출이 돌려주며 다른 모든 장치 작업 함수의 입력 매개변수로 쓰는 PDIAG_INFO_HANDLE
  • 장치 상태(DIAGNOSE 또는 NORMAL)의 표시
  • pdiag_cs_get_attr 함수로 구성 서비스에서 얻은 다른 장치 속성 정보(TU를 부를 때마다 다시 요청하는 부담을 피하려고)
  • TU 작성자가 한 호출에서 다음 호출까지 남겨 두고 싶은 그 밖의 정보
영어 원문

Persistent data and the TU_INFO_HANDLE

Because of the requirement to allow multi-threaded, simultaneous execution of Test Units, the TU functions must be written to be re-entrant, implying that statically defined variables or structure are not allowed.

Note: Static constant values are not a problem.

To illustrate the problem, imagine two threads of execution calling the same TU to run simultaneously against two device instances of the same type. Values stored in static variables would get changed in both threads of execution, probably leading to a program failure. Therefore, all variables and structures must be either defined locally as stack variables, or created using allocated memory. Without static variables, it is difficult to retain any data around from one execution of a TU to the next.

The intent of the TU_INFO_HANDLE pointer in the exectu()interface is to provide the TU writer with a pointer to a data buffer that will persist across multiple execution calls to specific Test Units. On the first call to a TU library, the TU_INFO_HANDLE pointer will be set to NULL. The first TU, TU_OPEN, must allocate the buffer and set the TU_INFO_HANDLE pointer. Data that the TU writer wants to have persist (for example, device attribute information) can then be placed within that buffer, and the pointer to the buffer will be passed back on each subsequent call to the TU library.

Because the data buffer remains allocated after the TU returns control to the calling application, it is the responsibility of the calling application to free the buffer any time that a premature termination is required, or after it calls the last TU (TU_CLOSE).

Data that should be kept in the persistent data buffer includes:

  • The pdiagex_dds_t structure which contains several device attributes and is used as a parameter to the pdiag_open call.

  • The PDIAG_INFO_HANDLE returned from the pdiag_open call, which is used as an input parameter to all the other device operation functions.

  • An indicator of the state of the device (DIAGNOSE or NORMAL)

  • Other device-attribute information obtained from Configuration Services using the pdiag_cs_get_attr function (to avoid the overhead of rerequesting it for each TU call).

  • Any other information the TU writer would like to have persist from one call to the next.

테스트 단위 호출 인터페이스

테스트 단위를 실행하려고, 테스트 단위 코드와 관리 응용 프로그램 사이의 인터페이스로 exectu()라는 C 함수를 정의했습니다.

이 인터페이스는 다음을 위해 정의했습니다.

  • 기능 시험에 쓰는 구조체와 프로토콜의 복잡함을 감춥니다.
  • 테스트 단위 코드를 부를 수 있는 여러 관리 응용 프로그램에 같은 인터페이스를 줍니다.

"exectu()의 정의" 절을 봅니다.

영어 원문

Test unit call interface

To execute test units, a C language function with the name exectu( ) has been defined to provide the interface between the test unit code and the managing application.

The definition of this interface has been developed to:

  • Hide the complexity of the structures and protocols used in performing functional tests

  • Provide a uniform interface for all the different management applications that may invoke the test unit code.

See the section "Definition of EXECTU".

(6.1) TU_TYPE 입력 구조체의 정의

exectu() 인터페이스는 테스트 단위 제어 블록(TUCB, Test Unit Control Block) 구조체의 정의에 의존합니다. TUCB는 TU_TYPE이라는 C 데이터 형으로 정의되며 diag/tucb.h 헤더 파일에 있습니다. 이 헤더 파일은 고치지 말고 그대로, 이 구조체를 쓰는 소스 파일마다 포함해야 합니다.

여러 관리 응용 프로그램이 테스트 단위 기능을 쓸 수 있도록 이 TUCB 구조체는 정의에서 벗어나면 안 됩니다. 새 데이터 형이나 구조체를 더할 수 없습니다. 각 테스트 단위는 제공하는 기능 안에서 자급자족해야 합니다. 데이터 형 OUTPUT_DATA와 INPUT_DATA는 diag/tucb.h 파일에 void로 선언되어 있습니다. 이 구조체를 쓰려면 매개변수를 다시 정의하는 헤더 파일 두 개가 필요합니다.

  • {DEVICE}_err_detail.h 파일: 장치별 오류 로그 상세 출력 데이터(OUTPUT_DATA)를 정의합니다.
  • {DEVICE}_input_params.h 파일: 테스트 단위의 장치별 입력 매개변수 데이터(INPUT_DATA)를 정의합니다.

두 헤더 파일은 (쓴다면) diag/tucb.h 파일보다 먼저 포함해야 합니다.

TU_TYPE 구조체는 다음과 같습니다.

text
typedef struct tucb_t {
           char  *resource_name;
           TU_INPUT_TYPE parms;
} TU_TYPE;

resource_name은 테스트 단위를 실행할 (운영 체제가 정의한) 하드웨어나 물리 장치 이름의 문자열입니다. TU_INPUT_TYPE은 TU_TYPE의 하위 구조체이며, 다음 입력 매개변수가 들어 있습니다.

text
typedef struct tucb_in_t {
            ulong tu;
            ulong loop;
            OUTPUT_DATA *data_log;
            ulong data_log_length;
            INPUT_DATA *tu_data;
            ulong tu_data_length;
            FILE *msg_file;
} TU_INPUT_TYPE;

구조체 멤버의 정의는 "exectu()의 정의"를 봅니다.

참고: 대부분의 응용 프로그램에는 TU 번호와 반복 횟수만 필요합니다. 그러나 이 인터페이스는 특별한 시험 환경을 위해 테스트 단위에 특별한 매개변수를 넘기고 자세한 데이터를 돌려받는 열린 방법을 제공합니다.

이런 데이터를 쓰려면 호출 응용 프로그램이 테스트 단위 설계를 구체적으로 알아야 하므로, 시스템 관리 응용 프로그램에 필요한 범용 진단 처리는 할 수 없습니다. 그러나 이 설계로 진단 설계를 자세히 아는 원격 진단 응용 프로그램이 범용 진단 지식만 가진 로컬 에이전트 함수를 거쳐 동작할 수 있습니다. 로컬 에이전트는 요청받은 크기의 버퍼를 할당하고 테스트 단위와 원격 진단 응용 프로그램 사이에 데이터를 넘기기만 하면 됩니다.

영어 원문

Definition of the TU_TYPE input structure

The exectu( ) interface is dependent on the definition of a Test Unit Control Block (TUCB) structure. The TUCB is defined as a C language data type called TU_TYPE, and is located in the diag/tucb.h header file. This header file must be used without modification and included in each source file using the structure.

To make the test unit functions available to a wide range of managing applications, this TUCB structure must not deviate from the defined structure. No new data types or structures may be added. Each test unit should be self-sufficient in the function provided. The data types OUTPUT_DATA and INPUT_DATA are declared as 'void' in the diag/tucb.h file. If these structures are to be used, two header files are required to redefine these parameters:

  • The {DEVICE}_err_detail.h File file should be used to define device specific error log detail output data (OUTPUT_DATA).

  • The {DEVICE}_input_params.h File file should be used to define device specific input parameter data for a test unit (INPUT_DATA).

Both header files (if used) should be included before the diag/tucb.h file.

The TU_TYPE structure is specified as follows:

text
typedef struct tucb_t {
           char  *resource_name;
           TU_INPUT_TYPE parms;
} TU_TYPE;

The resource_name is a string containing the name of the hardware or physical device (as defined by the operating system) on which to run the test unit. TU_INPUT_TYPE is a substructure of TU_TYPE, and contains several input parameters, as specified in the following:

text
typedef struct tucb_in_t {
            ulong tu;
            ulong loop;
            OUTPUT_DATA *data_log;
            ulong data_log_length;
            INPUT_DATA *tu_data;
            ulong tu_data_length;
            FILE *msg_file;
} TU_INPUT_TYPE;

See "Definition of EXECTU()" for structure member definitions.

Note: For most applications, the TU number and loop count are the only parameters required. However, this interface allows for an open way of passing special parameters into the Test Units and receiving detailed data back out, to allow for specialized testing environments.

Using such data requires specific knowledge about the Test Unit design in the calling application, and does not allow for generic diagnostic handling, as would be required from a system management application. However, this design would allow a remote diagnostic application, which could have detailed diagnostic design knowledge, to work through a local agent function which only has generic diagnostic knowledge. The local agent would only have to allocate buffers of the requested size, and pass data between the Test Units and the remote diagnostic application.

(6.1) TU_RETURN_TYPE 출력 구조체의 정의

exectu() 인터페이스는 반환값으로 unsigned long major_rc 반환 코드를 기대합니다. 이 반환값을 확장해 TUCB 반환 구조체를 exectu() 함수 호출의 셋째 인수로 넘깁니다(실제 정의에서는 넷째 인수 tu_rc). TUCB 반환 구조체는 TU_RETURN_TYPE이라는 C 데이터 형이며 diag/tucb.h 헤더 파일에 정의되어 있습니다.

이 헤더 파일은 고치지 말고 그대로, 이 구조체를 쓰는 소스 파일마다 포함해야 합니다.

text
typedef struct tucb_out_t {
            ulong                 major_rc;
            ulong                 minor_rc;
            ulong                 actual_loop;
            ulong                 data_log_length;
            ulong                 severity;
} TU_RETURN_TYPE;

구조체 멤버의 정의는 "exectu()의 정의"를 봅니다.

영어 원문

Definition of the TU_RETURN_TYPE output structure

The exectu( ) interface expects, as a return value, a unsigned long major_rc return code value. As an extension of this return value, a Test Unit Control Block (TUCB) return structure is included as a third argument to the exectu() function call. The TUCB return structure is defined as a C language data type called TU_RETURN_TYPE, and is defined in the diag/tucb.h header file.

This header file must be used without modification and included in each source file where the structure is used.

text
typedef struct tucb_out_t {
            ulong                 major_rc;
            ulong                 minor_rc;
            ulong                 actual_loop;
            ulong                 data_log_length;
            ulong                 severity;
} TU_RETURN_TYPE;

See Definition of EXECTU() for structure member definitions.

반환 코드

major_rc

exectu() 함수의 major_rc 반환값은 실행한 TU의 성공·실패를 나타내야 합니다. 시험이 모두 성공하면 0을, 아니면 특정 값에 해당하는 0이 아닌 값을 돌려줘야 합니다. 관리 응용 프로그램은 major_rc로 진단 절차의 흐름을 정하고, 바꿔야 할 알맞은 카드 수준 FRU를 찾습니다. 모든 관리 응용 프로그램의 고장 격리 요구를 만족하려면 반환 코드를 될 수 있는 대로 세밀하게 설계해 고장 격리를 최대로 해야 합니다. 대부분 FRU 하나로 격리하려는 것입니다.

참고: major_rc 반환 코드를 정의할 때 다음을 지킵니다.

  • 반환 코드에 메모리 오프셋 정보를 넣지 않습니다.
  • 실패한 비트 같은 자세한 정보는 반환 코드로 돌려주지 않고 OUTPUT_DATA 오류 로그를 씁니다.

minor_rc

minor_rc 반환값은 더 구체적인 오류 표시를 돌려주는 데 쓰며, 보통 FRU 안에서 모듈이나 I/O 선까지 고장을 격리하는 데 도움을 줍니다. 이 정보는 하드웨어 초기 구동(bring-up)과 디버그, 제조에서 특정 하드웨어 결함을 가리키는 데 쓰려는 것입니다. OUTPUT_DATA 오류 로그와 함께 쓰면 TU 작성자는 필요한 수준까지 고장을 격리할 정보를 돌려줄 수 있어야 합니다. 그러나 대부분의 관리 응용 프로그램은 major_rc 반환값에만 관심이 있습니다.

영어 원문

Return codes

Use the topic to view the list of return codes.

major_rc

The major_rc return value from the exectu() function should indicate the success or failure of the TU which was executed. If all testing is successful, it should return a value of zero (0), otherwise a non-zero value should be returned corresponding to a specific value. A managing application uses the major_rc return code to determine the flow of the diagnostic procedure, and to look up the appropriate card level Field Replaceable Unit (FRU) or FRUs to be replaced. To satisfy the failure-isolation requirements of all managing applications, the return codes should be designed to be as granular as possible to provide maximum fault isolation. For most purposes, this means attempting to isolate to a single FRU.

Note: When defining major_rc return codes, keep the following in mind:

  • Never return memory offset information in the return code.

  • Do not return any detailed information, such as failing bits, through the return code. Instead, use the OUTPUT_DATA error log.

minor_rc

The minor_rc return value is used to pass back a more specific error indication, and would typically be provided as an aid for fault isolation within a FRU, perhaps down to modules or I/O lines. This information is intended for use in bring-up and debug, and in manufacturing, to point to a specific hardware defect. Used in conjunction with the OUTPUT_DATA error log, the TU writer should be able to pass back enough information to isolate to a failure to whatever level is needed. However, most management applications will only be interested in the major_rc return value.

인터럽트 처리기 호출 인터페이스

장치의 진단 인터럽트 처리기 함수는 테스트 단위 라이브러리와 따로 실행 모듈로 묶어야 합니다. 이 모듈은 TU_OPEN이 pdiag_open 함수를 부를 때 운영 체제에 적재되고 진단 시스템 서비스에 등록됩니다.

서비스가 인터럽트를 받으면 이 "2차" 인터럽트 처리기들에 차례로 제어를 넘깁니다. 각 인터럽트 처리기는 자기 어댑터의 상태를 읽어 인터럽트의 원천인지 봅니다. 테스트 단위가 pdiag_dd_watch_for_interrupt 서비스를 불러 인터럽트를 기다리고 있으면 sleep_flag가 1이 되며, 이는 인터럽트 처리기가 처리를 마치면 pdiag_dd_interrupt_notify를 해야 한다는 뜻입니다.

인터럽트 처리기는 장치 메서드로 장치를 읽고 쓸 수 있습니다. 보통 장치의 레지스터를 읽어 인터럽트에 관한 정보를 더 얻고, (필요하면) 레지스터를 써서 인터럽트 상태를 지웁니다. data_area 버퍼로 TU에 돌려줄 데이터의 내용과, TU가 인터럽트를 기다리기는 하는지는 TU와 인터럽트 처리기 설계자가 정합니다. 그 결정은 특정 장치의 동작과 시험 방법에 달려 있습니다.

구문

인터럽트 처리기의 함수 원형은 다음과 같습니다.

text
int device_interrupt (
        PDIAG_INFO_HANDLE * handle ,
        pdiag_addr_t data_area ,
        int32 *interrupt_flag ,
        uint32 sleep_flag ,
        uint32 *sleep_word )

매개변수

매개변수 설명
handle 장치 작업에 쓰는 핸들의 포인터
data_area 인터럽트 처리가 끝난 뒤 테스트 단위가 살펴볼 정보를 인터럽트 처리기가 저장하는 버퍼 영역
interrupt_flag 어떤 인터럽트가 일어났는지 나타내는 비트 필드
sleep_flag 기다리는 테스트 단위에 알려야 하는지 나타내는 불(boolean) 값
sleep_word 테스트 단위가 기다리는 세마포어. pdiag_dd_interrupt_notify 서비스의 매개변수로 씁니다.

관련 개념

SLIH 변환에 필요한 변경: 64비트 커널로 이식하는 모든 SLIH에 적용해야 할 변경입니다("테스트 단위 64비트 이식" 글 참고).

영어 원문

Interrupt handler call interface

The diagnostic interrupt handler function for a device must be packaged in an executable module separate from the Test Unit library. This module is loaded into the operating system and registered with the diagnostic system services when the TU_OPEN calls the pdiag_open function.

When the services receive an interrupt, control is passed to these "second-level" interrupt handlers in sequential order. Each interrupt handler reads the status of its respective adapter to see if it was the source of the interrupt. If the Test Unit is waiting for the interrupt by calling the pdiag_dd_watch_for_interrupt service, the sleep_flag will be set to 1, indicating that the interrupt handler should do a pdiag_dd_interrupt_notify when it has completed.

Interrupt handlers can use the device methods to read and write operations on the device. Typically, they will read registers on the device to obtain more information about the interrupt, and write registers (if necessary) to clear the interrupt condition. The content of any data passed back to the TU through the data_area buffer, and whether the TUs even wait for interrupts, is a decision left to the designer of the TUs and interrupt handler. That decision depends upon the operation of the specific device and how it is being tested.

Syntax

The function entry prototype for an interrupt handler is as follows:

text
int device_interrupt (
        PDIAG_INFO_HANDLE * handle ,
        pdiag_addr_t data_area ,
        int32 *interrupt_flag ,
        uint32 sleep_flag ,
        uint32 *sleep_word )

Parameters

  • handle — Pointer to a handle for use in device operations
  • data_area — Buffer area where the interrupt handler can store information that the Test Unit can review after interrupt processing is complete.
  • interrupt_flag — Bit field indicating which interrupt occurred
  • sleep_flag — Boolean value to indicate whether the waiting Test Unit should be notified
  • sleep_word — Semaphore that the Test Unit is waiting for, used as a parameter to the pdiag_dd_interrupt_notify service

Related concepts

SLIH conversion required changes The following required changes must be applied to all SLIHs being ported to 64-bit kernel.

테스트 단위에서 인터럽트 처리하기

테스트 단위의 일반적인 흐름은 장치 주소 공간을 읽고 써서 장치 작업을 설정한 다음, 작업이 끝났거나 주의가 필요하다는 장치 인터럽트를 기다리는 것입니다. 인터럽트 처리는 장치마다 다르고 시험 과정의 일부이므로, 테스트 단위 라이브러리에 더해 인터럽트 처리기 함수를 제공해야 합니다.

테스트 단위 1(TU_OPEN)이 시험을 위해 장치를 열 때, (필요하면) pdiag_open 시스템 서비스의 매개변수로 인터럽트 처리기 모듈 이름을 넘겨 인터럽트 처리기를 적재할 수 있습니다. pdiag_open 입력의 일부로 데이터 버퍼 주소도 넘기므로, 장치 메서드는 어느 인터럽트 처리기를 쓸지, 인터럽트 처리기의 데이터를 어디로 돌려줄지 압니다.

인터럽트 처리기 함수의 목적은 인터럽트 표시를 받고, 장치에서 정보를 모으고, 장치의 인터럽트 상태를 지우고, 기다리는 테스트 단위에 인터럽트가 일어났다고 알리는 것입니다. 인터럽트 상태가 남아 있는 한 인터럽트 처리기가 계속 불리므로 인터럽트 상태를 지우는 것이 매우 중요합니다. 이 함수는 특정 장치 I/O 인터럽트를 처리하려고 불리므로, 장치에서 모은 정보는 장치 동작을 진단하는 데 유용합니다. 인터럽트 처리기는 이 정보를 (장치를 열 때 정한) 데이터 버퍼 영역에 넣으며, 기다리는 테스트 단위가 분석에 씁니다.

인터럽트 처리의 기본 흐름은 원문의 "Interrupt Processing in Test Units" 그림과 같으며, 순서는 다음과 같습니다.

  1. 테스트 단위 1(TU_OPEN)에 대한 exectu() 호출이 pdiag_open을 불러 시험을 위해 장치를 엽니다. pdiag_open에 넘기는 입력에는 인터럽트 처리기 모듈 이름과 메모리에 할당한 데이터 버퍼 영역의 주소가 들어 있습니다.
  2. 테스트 단위가 시작되어 장치에 어떤 작업을 하고, pdiag_dd_watch_for_interrupt를 불러 장치 인터럽트 형태의 응답(인터럽트가 없으면 시간 초과)을 기다립니다.
  3. 장치 메서드 층이 운영 체제에서 인터럽트 표시를 받습니다.
  4. 장치 메서드가 등록된 인터럽트 처리기로 제어를 넘깁니다.
  5. 인터럽트 처리기 함수가 장치에서 데이터를 모아 데이터 버퍼 영역에 넣고, 인터럽트를 지우고, 테스트 단위를 WAIT 상태에서 풀어 줍니다.
  6. 인터럽트 처리기가 끝나고 호출자(장치 메서드)로 돌아갑니다.
  7. 테스트 단위가 인터럽트 처리기가 돌려준 데이터를 처리하며 실행을 계속합니다.
  8. 시험이 끝나면 테스트 단위 0xEFFF(TU_CLOSE)를 불러, pdiag_close로 장치를 닫고 인터럽트 처리기를 내립니다.

테스트 단위를 실행하는 동안 장치 설정과 인터럽트 기다리기는 필요한 만큼 되풀이할 수 있습니다. 인터럽트 처리기 등록은 시험을 위해 장치를 열 때 한 번만 하면 됩니다. 다만 (필요하면) 장치를 닫았다가 다른 인터럽트 처리기 모듈 이름으로 다시 열어 다른 인터럽트 처리기를 쓸 수 있습니다.

영어 원문

Interrupt handling in test units

A typical sequence of events in the functional flow of a Test Unit is to set up a device operation through reads and writes to the device address space, and then wait to receive an interrupt from the device to indicate that an operation has completed or needs attention. Since interrupt handling is device-specific and part of the test process, an interrupt handler function must be provided in addition to the Test Unit library.

When a device is opened for testing by Test Unit 1 (TU_OPEN), an interrupt handler may be loaded (if one is needed) by passing an interrupt handler module name as one of the parameters on the pdiag_open system service. A data buffer address is also passed as part of the input to the pdiag_open function, so the device methods know which interrupt handler to use, as well as where to pass back data from the interrupt handler.

The purpose of the interrupt handler function is to receive the interrupt indication, possibly gather some information from the device, clear the interrupt condition on the device, and notify a waiting Test Unit that the interrupt has occurred. Clearing of the interrupt condition is critical, because the interrupt handler will be called continuously as long as the interrupt condition exists. Since this function is called to handle a specific device I/O interrupt, the information it gathers from the device is useful in diagnosing the device behavior. The interrupt handler puts this information into the data buffer area (defined at device-open time), where the waiting Test Unit can access it for analysis.

The basic flow of interrupt processing is shown in the "Interrupt Processing in Test Units" illustration. The flow of events is as follows:

Test Units

Common Service Layer Interrupt Handler

Test Unit Library

data buffer exectu

Interrupt Processing in Test Units

  1. An exectu() call is made to Test Unit 1 (TU_OPEN), which calls pdiag_open to open the device for testing. Included in the input information passed to pdiag_open is the name of the interrupt handler module and the address of a memory-allocated data buffer area.

  2. A Test Unit is started, which performs some operations on the device, and then calls pdiag_dd_watch_for_interrupt to wait for a response in the form of a device interrupt (or a time-out if no interrupt occurs).

  3. The device-methods layer receives an interrupt indication from the operating system.

  4. The device-methods pass control to the registered interrupt handler.

  5. The interrupt handler function gathers data from the device and places it in the data buffer area, clears the interrupt, and releases the Test Unit from its WAIT state.

  6. The interrupt handler completes and returns to the caller (the device methods).

  7. The Test Unit continues execution by processing the data returned from the interrupt handler.

  8. When testing is completed, a call is made to Test Unit 0xEFFF (TU_CLOSE), which calls pdiag_close to close the device and unload the interrupt handler.

The cycle of device setup and wait for interrupt can be repeated as often as necessary during the execution of the Test Units. Registration of the interrupt handler only needs to be done once, at the time when the device is opened for testing. However, different interrupt handlers could be used (if necessary) by closing the device, then reopening the device with a different interrupt handler module-name parameter.

인터럽트 플래그 비트 마스크 쓰기

인터럽트 처리 루틴의 interrupt_flag 매개변수와 pdiag_dd_watch_for_interrupt 시스템 서비스의 flag_mask 매개변수로, 테스트 단위와 인터럽트 처리기가 일어난 인터럽트의 종류와 테스트 단위가 알고 싶은 인터럽트 종류를 주고받습니다.

이 워드의 비트 필드는 장치와 장치가 낼 수 있는 인터럽트 종류의 수에 따라 TU 개발자가 원하는 대로 정할 수 있습니다. 다만 이 매개변수의 쓰임을 이해하는 것이 중요합니다.

인터럽트 처리기가 인터럽트 상태 때문에 불리면 자기 장치를 살펴 어떤 종류의 인터럽트가 일어났는지 봐야 합니다. 인터럽트 상태가 없으면 돌아가기 전에 interrupt_flag를 0으로 설정합니다. 인터럽트 상태가 있으면 돌아가기 전에 interrupt_flag의 알맞은 비트를 1로 설정합니다.

TU는 pdiag_dd_watch_for_interrupt 서비스를 불러 인터럽트 상태를 기다리며, 이 함수의 매개변수 하나가 flag_mask 워드입니다. 이는 인터럽트 처리기와 같은 비트 정의를 쓰는 비트 마스크로, TU가 지켜볼 인터럽트 종류를 나타냅니다. 인터럽트 종류마다 비트 하나를 두고 해당 비트를 1로 설정합니다. pdiag_dd_watch_for_interrupt는 알맞은 인터럽트를 감지하거나(곧 flag_mask와 interrupt_flag를 AND한 결과가 0이 아니거나) 시간 한도에 이를 때까지 돌아오지 않습니다.

참고: 테스트 단위 작성자가 인터럽트 종류를 둘 이상 지켜보면서 어느 인터럽트가 일어났는지도 알아야 한다면, 인터럽트 처리기가 그 정보를 돌려줄 수 있도록 data_area 버퍼에 구조체 요소를 정의해야 합니다.

예

text
#define Int_A 80000000       /* Common defines used by both the TU and */
#define Int_B 40000000       /* interrupt handler                     */
#define Int_C 20000000

TU가 다음과 같이 pdiag_dd_watch_for_interrupt를 부른다고 합시다.

text
flag_mask = Int_A | Int_B

경우 1

  1. 인터럽트를 받습니다.
  2. 인터럽트 처리기가 다음을 설정합니다.
text
interrupt_flag = Int_C
  1. pdiag_dd_watch_for_interrupt는 시간 초과가 날 때까지 돌아오지 않습니다.

경우 2

  1. 인터럽트를 받습니다.
  2. 인터럽트 처리기가 장치를 읽어 인터럽트 A를 보고 다음을 설정합니다.
text
interrupt_flag = Int_A
  1. pdiag_dd_watch_for_interrupt가 돌아옵니다.

경우 3

  1. 인터럽트를 받습니다.
  2. 인터럽트 처리기가 장치를 읽어 인터럽트 B와 C를 모두 보고 다음을 설정합니다.
text
interrupt_flag = Int_B | Int_C
  1. pdiag_dd_watch_for_interrupt가 돌아옵니다.
영어 원문

Using the interrupt flag bit mask

The interrupt_flag parameter to the interrupt handling routine and the flag_mask parameter on the pdiag_dd_watch_for_interrupt system service are used by the Test Unit and interrupt handler to communicate the type of interrupt that occurred, and which types of interrupts the Test Unit wants to know about.

The bit fields within these words can be defined in whatever way the TU developer wants to assign them, based on the device involved and how many different interrupt types it can surface. However, it is important to understand how these parameters should be used.

When an interrupt handler is called as the result of an interrupt condition, it should examine its device to see which type of interrupt, if any, occurred on that device. If it detects no interrupt condition, the interrupt_flag should be set to 0 before it returns. If it does detect an interrupt condition, then it should set an appropriate bit equal to 1 in the interrupt_flag before it returns.

A TU waits for an interrupt condition to occur by calling the pdiag_dd_watch_for_interrupt service, and one of the parameters to that function is a flag_mask word. This is defined as a bit mask, using the same bit definitions as in the interrupt handler, to indicate the interrupt types for which the TU wants to watch. It does this by setting one or more bit values equal to 1, where each bit represents an interrupt type. The pdiag_dd_watch_for_interrupt will not return until either an appropriate interrupt is detected (essentially determined by a non-zero result when "and"ing the flag_mask and the interrupt_flag 0 values), or until the time limit is reached.

Note: If the Test Unit writer wants to watch for more than one interrupt type, but also needs to know which specific interrupt occurred, the writer should define a structure element in the data_area buffer where the interrupt handler can pass back that information.

Example

text
#define Int_A 80000000       /* Common defines used by both the TU and */
#define Int_B 40000000       /* interrupt handler                     */
#define Int_C 20000000

Assume TU calls pdiag_dd_watch_for_interrupt with:

text
flag_mask = Int_A | Int_B

Case 1

  1. Interrupt received 2.
text
interrupt_flag = Int_C
  1. pdiag_dd_watch_for_interrupt does not return until timeout occurs.

Case 2

  1. Interrupt received

  2. Interrupt handler reads device, sees interrupt A, sets:

text
interrupt_flag = Int_A
  1. pdiag_dd_watch_for_interrupt returns

Case 3

  1. Interrupt received

  2. Interrupt handler reads device, sees both interrupt B and C, sets:

text
interrupt_flag = Int_B | Int_C
  1. pdiag_dd_watch_for_interrupt returns

TU와 인터럽트 처리기의 프로그래밍 인터페이스

시스템 인터페이스 호출과 헤더 파일 사용은 X/Open Portability Guide Issue 4 표준을 따라야 합니다. 그러면 같은 표준을 따르는 다른 플랫폼으로 옮길 수 있습니다.

TU 개발자가 쓸 수 있는 표준 서비스는 다음과 같습니다. 이 서비스만 쓰면 이 진단 기반 구조를 지원하는 다른 플랫폼으로 TU를 옮길 수 있습니다. 함수, 입력 매개변수, 함수 원형은 "진단 커널 확장 인터페이스"를 봅니다.

함수 설명 쓸 수 있는 곳
pdiag_open 시험을 위해 장치를 엽니다. TU
pdiag_close 시험 뒤 장치를 놓아 줍니다. TU
pdiag_dd_read 장치 읽기 작업을 합니다. TU, 32비트 인터럽트
pdiag_dd_write 장치 쓰기 작업을 합니다. TU, 32비트 인터럽트
pdiag_dd_dma_setup DMA 작업을 위해 사용자 버퍼를 초기화하고, 고정하고, 교차 메모리로 붙입니다. TU
pdiag_dd_dma_enable DMA 작업을 켜거나 끕니다. TU
pdiag_dd_dma_complete DMA 사용자 버퍼의 고정을 풀고 교차 메모리 서술자를 뗍니다. TU
pdiag_dd_watch_for_interrupt 장치 인터럽트가 일어나거나 지정한 시간 초과에 이를 때까지 기다립니다. TU
pdiag_dd_interrupt_notify 기다리는 테스트 단위에 인터럽트를 받았다고 알립니다. 32비트 인터럽트
pdiag_diagnose_state 시험할 장치를 시험 가능한 상태로 만듭니다. TU
pdiag_restore_state 시험할 장치를 시험 전의 원래 상태로 되돌립니다. TU
pdiag_cs_open 구성 데이터 서비스를 열거나 초기화합니다. TU
pdiag_cs_close 구성 데이터 서비스를 닫거나 끝냅니다. TU
pdiag_cs_get_attr 장치 속성 값을 얻습니다. TU
pdiag_cs_free_attr pdiag_cs_get_attr가 할당한 저장 공간을 해제합니다. TU
findmcode 적재할 특정 마이크로코드 파일을 찾습니다. TU
pdiag_dd_read_64 장치 읽기 작업을 합니다. 64비트 인터럽트
pdiag_dd_write_64 장치 쓰기 작업을 합니다. 64비트 인터럽트
영어 원문

Programming interfaces for TUs and interrupt handlers

System interface calls and use of header files should conform to the X/Open Portability Guide Issue 4 standards. This ensures portability to other platforms meeting the same standards.

The following table lists the standard set of services available to TU developers. Using only these services provides portability of TUs to other platforms where this diagnostic infrastructure is supported. See "Diagnostic Kernel Extension Interfaces" for more information on these functions, their input parameters, and the function prototypes.

Function Name Description Usable by:
pdiag_open Opens a device for testing TU
pdiag_close Frees up a device after testing TU
pdiag_dd_read Performs a read operation to a device TU, 32-bit Interrupt
pdiag_dd_write Performs a write operation to a device TU, 32-bit Interrupt
pdiag_dd_dma_setup Initializes, pins, and cross-memory attaches user buffer for a dma operation TU
pdiag_dd_dma_enable Enables/disables a dma operation TU
pdiag_dd_dma_complete Unpins the dma user buffer and detaches the cross-memory descriptor TU
pdiag_dd_watch_for_interrupt Waits for device interrupt to occur, or until a specified timeout is reached TU
pdiag_dd_interrupt_notify Notifies waiting test unit that an interrupt has been received 32-bit Interrupt
pdiag_diagnose_state Places device under test into a testable state TU
pdiag_restore_state Places device under test into original state before testing TU
pdiag_cs_open Open/Initialize configuration data services TU
pdiag_cs_close Close/Terminate configuration data services TU
pdiag_cs_get_attr Obtain device attribute value TU
pdiag_cs_free_attr Free storage that was allocated by pdiag_cs_get_attr TU
findmcode Locate specific microcode file for loading TU
pdiag_dd_read_64 Performs a read operation to a device 64-bit Interrupt
pdiag_dd_write_64 Performs a write operation to a device 64-bit Interrupt

구성 서비스의 장치 속성

pdiag_cs_* 함수(위 표 참고)가 제공하는 구성 데이터 서비스는 TU 개발자가 시험할 장치의 정보를 얻는 인터페이스입니다. 아래 표는 장치에서 얻을 수 있는 표준 속성입니다. 다만 일부는 특정 장치 종류에만 있으므로 모든 장치가 모든 속성을 지원하지는 않습니다.

보통 TU 개발자는 테스트 단위 TU_OPEN(시험을 위해 장치를 여는 테스트 단위)을 부를 때 이 서비스로 필요한 속성 정보를 모아, 이후 테스트 단위를 부를 때 참고하도록 저장해 둡니다. 그러면 테스트 단위 묶음을 실행하는 동안 구성 서비스를 여러 번 부르는 성능 부담을 피할 수 있습니다.

속성 설명
bus_id 어댑터 I/O 버스 ID 값
bus_intr_lvl 버스 인터럽트 수준
bus_io_length 버스 I/O 영역의 기준 주소(원문 그대로)
bus_mem_addr 공유 버스 메모리 영역의 기준 주소
bus_mem_length 공유 버스 메모리 영역의 길이
bus_type 버스 종류(예: Microchannel, PCI, 60X)
connwhere CuDv에 저장된 connwhere 위치
dms_bus_flags DMA 작업의 버스 플래그(PCI/ISA만)
dma_bus_length DMA용 버스 메모리 영역의 길이(바이트, MCA만)
dma_bus_mem DMA에 쓰는 버스 메모리의 주소(MCA만)
dma_chan_id 장치의 DMA 채널 ID
dma_flags DMA 동작을 나타내는 플래그(MCA만)
dma_lvl DMA 버스 중재 수준(MCA만)
intr_flags 인터럽트 플래그
intr_priority 인터럽트 우선순위
maxmaster 동시 DMA 마스터 호출의 최대 수
parent_name 부모 장치 이름
slot_num 어댑터의 슬롯 번호(MCA는 실제 슬롯 번호, PCI는 장치 번호)
영어 원문

Configuration services device attributes

The configuration data services provided by the pdiag_cs_* functions (described in the previous table) define the interface by which the TU developer may obtain information about the device under test. The table below lists the standard attributes which may be available for a given device; however, not all attributes are supported for all devices, since some are specific to particular device types.

Normally, the TU developer should use this service to gather the required attribute information during the call to Test Unit TU_OPEN (the Test Unit which opens the device for testing), and save this device information for reference during subsequent Test Unit calls. This avoids the performance overhead of calling the configuration services many times during the execution of a set of Test Units.

  • bus_id — Adapter I/O bus ID value
  • bus_intr_lvl — Bus interrupt level
  • bus_io_length — Base address of bus I/O area
  • bus_mem_addr — Base address of Shared Bus Memory area
  • bus_mem_length — Length of Shared Bus Memory area
  • bus_type — Type of bus (for example, Microchannel, PCI, 60X)
  • connwhere — Connwhere location as stored in CuDv
  • dms_bus_flags — Bus flags for DMA operation (PCI/ISA only)
  • dma_bus_length — Length of bus memory DMA area in bytes (MCA only)
  • dma_bus_mem — Address of bus memory used for DMA (MCA only)
  • dma_chan_id — DMA channel ID of device
  • dma_flags — Flags to indicate DMA actions (MCA only)
  • dma_lvl — DMA bus arbitration level (MCA only)
  • intr_flags — Interrupt flags
  • intr_priority — Interrupt priority
  • maxmaster — Maximum number of concurrent DMA master calls
  • parent_name — Parent device name
  • slot_num — Slot number of adapter (for MCA, actual slot number, for PCI, device number)

메시지 처리

일반적으로 제품용으로 내놓는 TU 코드에는 printf()나 fprintf() 호출을 넣지 않아야 합니다. 디버그 메시지, 실행 진행 메시지 등도 마찬가지입니다. 그러나 이런 관행이 초기 코드 개발 때 흔하고 유용하며, 나중에 무엇인가 고장 났을 때도 필요할 수 있다는 것을 압니다.

그래서 두 요구를 모두 만족하도록 메시지를 조건부로 컴파일해 코드에 넣거나 뺄 수 있게 해야 합니다. 호출 응용 프로그램이 메시지를 stdout을 포함한 아무 파일로나 돌릴 수 있도록 fprintf() 호출만 씁니다. 그리고 메시지를 조건부로 컴파일하려면 다음 규칙을 따릅니다.

포함 파일 하나에 표준 조건 플래그 TU_DEBUG_MSG로 다음 PRINT 매크로를 조건부로 정의합니다.

text
#ifdef TU_DEBUG_MSG
#define PRINT( args ) fprintf args
#else
#define PRINT( args )
#endif

다음으로 TUCB 구조체 정의의 "msg_file" 포인터로 메시지를 보낼 곳을 정합니다.

그리고 코드에서 메시지를 내야 할 곳마다 PRINT 매크로를 씁니다. 호출 응용 프로그램이 "msg_file" 매개변수를 stdout으로 설정하면 메시지가 터미널이나 모니터로 갑니다. 파일로 보내려면 호출 응용 프로그램이 fopen() 함수로 파일을 열고 "msg_file"을 그 호출이 돌려준 포인터로 설정합니다.

예를 들어 "Hello, World number 1"이라는 메시지를 출력하고 싶고, tucb_ptr가 응용 프로그램이 넘긴 TU_TYPE 구조체의 포인터이고, w_num이 값이 1인 변수라면, TU 코드의 알맞은 곳에 다음과 같은 줄을 넣을 수 있습니다.

text
PRINT((tucb_ptr->parms.msg_file, "Hello, World number %d",w_num));

참고: 가변 길이 인수 목록을 PRINT 매크로를 거쳐 fprintf() 함수로 넘기려면 괄호를 두 겹으로 써야 합니다.

영어 원문

Message handling

In general, there should be no printf() or fprintf() calls imbedded in TU code which is delivered for production use. This includes debug messages, execution-progress messages, and so on. However, it is

understood that such practices are common and useful during the initial code development, and sometimes desirable at a later time when something breaks.

Therefore, to satisfy both requirements, the messages should be allowed to be conditionally compiled in and out of the code. To allow the calling application to redirect the messages to any file, including stdout, only the fprintf() call should be used. Then, to conditionally compile the messages, the following convention should be followed:

In one of the include files, define the following PRINT macros conditionally with the standard conditional flag TU_DEBUG_MSG.

text
#ifdef TU_DEBUG_MSG
#define PRINT( args ) fprintf args
#else
#define PRINT( args )
#endif

Next, use the "msg_file" pointer in the TUCB structure definition which determines where messages will be sent.

Then, at any place in the code where a message should be output, use the PRINT macro. The calling application would then set the "msg_file" parameter to stdout in order to have messages directed to a terminal or monitor. Alternatively, to have messages directed to a file, the calling application would use the fopen() function to open a file and set "msg_file" to the pointer returned from this call.

For example, you want to print the message "Hello, World number 1", and tucb_ptr is a pointer to the TU_TYPE structure passed by the application, and w_num is a variable with a value of 1. You could then insert, at an appropriate place in the TU code, a line like the following:

text
PRINT((tucb_ptr->parms.msg_file, "Hello, World number %d",w_num));

Note: The double parentheses are required to pass variable-length argument lists through the PRINT macro to the fprintf() function.

시그널 처리

일반적으로 시그널 처리는 진단 응용 프로그램(DA)의 책임입니다.

종료 시그널을 잡으면 시그널 처리기는 장치를 제대로 정리하고 자원을 놓아 주도록 exectu() 인터페이스로 TU_CLOSE를 시작해야 합니다. TU_CLOSE는 TU_OPEN이 이미 성공적으로 불렸을 때만 시작해야 합니다.

영어 원문

Signal handling

In general, signal handling is the responsibility of the diagnostic application (DA).

When a signal to terminate is caught, the signal handler must start TU_CLOSE through the exectu( ) interface, so that a proper cleanup of the device is performed and a release of resources occurs. TU_CLOSE should be started only if TU_OPEN has already been called successfully.

exectu()의 정의

진단 응용 프로그램(DA)에 묶인 테스트 단위(TU)를 실행합니다.

구문

text
#include   <diag/tucb.h>
ulong
exectu ( TU_TYPE *tucb_ptr, TU_INFO_HANDLE *tu_handle, TU_RETURN_TYPE *tu_rc )

설명

exectu 서브루틴은 테스트 단위 제어 블록이 가리키는 TU를 실행합니다. 테스트 단위는 보통 적재 가능한 라이브러리로 빌드해 묶습니다. 테스트 단위가 시험할 장치는 장치 인스턴스를 나타내는 문자열 지정자로 가리킵니다.

매개변수

매개변수 설명
tucb_ptr 테스트 단위 제어 블록의 포인터. diag/tucb.h 파일에 정의된 TU_TYPE(char *resource_name과 TU_INPUT_TYPE parms)이며, TU_INPUT_TYPE에는 아래 멤버가 있습니다.
tu 실행할 테스트 단위 번호
loop 오류가 나지 않는 한 테스트 단위를 실행할 횟수
data_log 오류 상세 로그나 출력 데이터 로그. 장치마다 다르며 {device}_output_data.h 파일에 정의됩니다. 빈 구조체 배열을 가리켜야 하며, 테스트 단위가 출력이나 오류 상세 데이터로 채웁니다. 쓰려면 호출 응용 프로그램이 초기화해야 합니다.
data_log_length data_log 구조체의 크기. tucb 데이터를 원격 관리 응용 프로그램에 넘길 때 씁니다. 호출 응용 프로그램이 채울 자료 구조의 크기에 기록할 레코드 수를 곱해 초기화합니다. 테스트 단위는 이 수를 쓸 OUTPUT_DATA 구조체의 크기로 나눠 레코드 수를 계산합니다. 0이면 data_log에 아무것도 기록하지 않습니다.
tu_data 테스트 단위에 입력 데이터를 더 넘기는 입력 매개변수. 특별한 경우에만 써야 하며, 제조나 하드웨어 시험기 같은 특별한 응용 프로그램을 위한 것입니다.
tu_data_length tu_data 구조체의 크기. tucb 데이터를 원격 관리 응용 프로그램에 넘길 때 씁니다. 호출 응용 프로그램이 채울 자료 구조의 크기에 레코드 수를 곱해 초기화하고, 테스트 단위는 이 수를 INPUT_DATA 구조체 크기로 나눠 데이터 레코드 수를 계산합니다.
msg_file 메시지를 보낼 파일 포인터("메시지 처리" 참고)
tu_handle 테스트 단위 라이브러리를 이어서 부르는 동안 TU가 유지해야 할 데이터 블록의 포인터. 지속 데이터의 내용과 배치는 TU 작성자가 정하지만 꼭 둬야 할 자료 구조가 있습니다("지속 데이터와 TU_INFO_HANDLE" 참고). 포인터 변수는 진단 응용 프로그램이 정의하지만 TU_OPEN이 자기가 할당한 메모리 버퍼를 가리키도록 설정합니다. diag/tucb.h 파일에 정의되어 있습니다.
tu_rc 테스트 단위 제어 블록 반환 코드 구조체의 포인터. diag/tucb.h 파일에 정의된 TU_RETURN_TYPE이며, major_rc(주 반환 코드, FRU 격리용), minor_rc(부 반환 코드, 더 세밀한 고장 격리용), actual_loop(테스트 단위가 실제로 실행된 횟수), data_log_length(기록된 데이터 로그 레코드의 전체 수), severity(진단 실패의 심각도) 멤버가 있습니다.

원문의 두 구조체 정의는 다음과 같습니다.

c
typedef struct tucb_t {
    char *resource_name;
    TU_INPUT_TYPE parms;
} TU_TYPE;

typedef struct tucb_in_t {
    ulong tu;
    ulong loop;
    OUTPUT_DATA *data_log;
    ulong data_log_length;
    INPUT_DATA *tu_data;
    ulong tu_data_length;
    FILE *msg_file;
} TU_INPUT_TYPE;

typedef struct tucb_out_t {
    ulong major_rc;
    ulong minor_rc;
    ulong actual_loop;
    ulong data_log_length;
    ulong severity;
} TU_RETURN_TYPE;

반환값

major_rc 반환 코드는 테스트 단위의 출력으로 정의되며, TU_RETURN_TYPE 구조체에 든 값과 같습니다.

실패 없이 성공적으로 끝나면 major_rc 필드에 0을 돌려줘야 합니다.

영어 원문

Definition of exectu()

Executes test unit (TU) bound into a Diagnostic Application (DA).

Syntax

text
#include   <diag/tucb.h>
ulong
exectu ( TU_TYPE *tucb_ptr, TU_INFO_HANDLE *tu_handle, TU_RETURN_TYPE *tu_rc )

Description

The exectu subroutine runs an TU referenced by the test unit control block. The test units are normally built and packaged as a loadable library. The device to be tested by the test unit is referenced by a character-string designator indicating the device instance.

Parameters

  • tucb_ptr — Pointer to the test-unit control block. This structure is defined in diag/tucb.h file. typedef struct tucb_t { char *resource_name; TU_INPUT_TYPE parms; } TU_TYPE; where TU_INPUT_TYPE is as follows: typedef struct tucb_in_t { ulong tu; ulong loop; OUTPUT_DATA *data_log; ulong data_log_length; INPUT_DATA *tu_data; ulong tu_data_length; FILE *msg_file; } TU_INPUT_TYPE;
  • tu — Test-unit number of the test unit to run.
  • loop — Indicates the number of times the test unit should be run provided that an error does not occur.
  • data_log — Error details log and or output data log. This log is device specific and is defined by the {device}_output_data.h file. It should point to an empty array of structures and then filled in with output or error detail data by the test unit(s). This parameter should be initialized by the calling application if intended to be used.
  • data_log_length — Size of the data_log structure. This field is used when passing the tucb data to a remote managing application. This number is initialized by the calling application by calculating the size of the data structure to be filled in and multiplying it by the number of records to be logged. The test unit calculates the number of records by dividing this number by the size of the intended OUTPUT_DATA structure to be used. A data_log_length value of zero results in no data being logged to the data_log.
  • tu_data — Input parameter to be used to pass extra input data to the test units. This parameter must only be used as special case scenarios. It is intended for special applications such as manufacturing or hardware exercisers.
  • tu_data_length — Size of the tu_data structure. This field is used when passing the tucb data to a remote managing application. This number is initialized by the calling application by calculating the size of the data structure to be filled in and multiplying it by the number of records to be logged. The test unit calculates the number of data records by dividing this number by the size of the intended INPUT_DATA structure to be used.
  • tu_handle — Pointer to a block of data that the TUs need to have persist between subsequent calls to the TU library. Content and layout of the persistent data is a decision left to the TU writer, but there are certain data structures which should be kept here, as described in the next section. Pointer variable is defined in the diagnostic application, but it is set by TU_OPEN to point to a memory buffer allocated by the TU_OPEN code. This structure is defined in diag/tucb.h file.
  • tu_rc — Pointer to the test-unit control block return code structure. This structure is defined in diag/tucb.h file. typedef struct tucb_out_t { ulong major_rc; ulong minor_rc; ulong actual_loop; ulong data_log_length; ulong severity; } TU_RETURN_TYPE; major_rc Major return code. Used for FRU isolation. minor_rc Minor return code. Used for more granular detailed fault isolation. actual_loop Indicates the number of times the test unit ran. data_log_length Returns the total number of data log records that have been recorded. severity Indicates the severity of a diagnostic failure.

Return Value

The major_rc return code is defined as the output from a test unit. This is the same value contained in the TU_RETURN_TYPE structure.

Upon successful completion with no failure, a value of 0 should be returned in the major_rc field.

I/O 장치의 PCI 구성 공간

PCI 장치의 표준 PCI 구성 헤더(Configuration Header)에는 쓸 수 있는 필드가 몇 개 있습니다.

  • 명령 레지스터(Command Register)
  • 지연 타이머(Latency Timer)
  • 캐시 라인 크기(Cache Line Size)
  • 기준 주소 레지스터(BAR)
  • 확장 ROM 기준 주소
  • 인터럽트 라인

이 가운데 일부는 펌웨어가 쓰며 장치 드라이버가 절대 바꾸면 안 됩니다. PCI 구성 헤더 레지스터를 프로그래밍할 때는 다음 PCI 구성 헤더 프로그래밍 표를 따라야 합니다.

레지스터/비트 펌웨어 동작(부팅 또는 ibm,configure-connector 호출) 소프트웨어(장치 드라이버) 동작
Command/Fast Back-to-Back Enable PCI 핫 플러그가 되는 플랫폼에서는 0을 씁니다. 핫 플러그가 안 되는 플랫폼에서는 같은 PCI 버스의 모든 I/O 장치가 Fast Back-to-Back 전송을 할 수 있으면 1을 쓸 수 있습니다. 값을 보존합니다.
Command/SERR# enable 1을 씁니다.
Command/Wait cycle control 0을 씁니다(1로 고정되어 있을 수 있어 0을 쓴 뒤에도 읽으면 1일 수 있음).
Command/Parity Error Response 1을 씁니다.
Command/VGA Palette snoop 0을 씁니다.
Command/Memory Write and Invalidate Enable 0(리셋 값)을 씁니다.
Command/Special Cycles
Command/Bus Master 부트 장치가 아니면 0(리셋 값)을 씁니다. 첫 DMA 작업 전에 1을 써야 하고, 장치 드라이버 구성을 해제하기 전에 0을 써야 합니다.
Command/Memory Space 부트 장치가 아니면 0(리셋 값)을 씁니다. 부트 장치면 BAR와 확장 ROM 기준 주소를 설정할 때까지 1을 쓰지 않습니다. 그 I/O 장치가 해당 주소 공간을 쓸 때만 1을 씁니다. I/O 장치의 메모리 공간에 대한 첫 작업(있으면) 전에 1을 써야 하고, 장치 드라이버 구성을 해제하기 전에 0을 써야 합니다.
Command/IO Space I/O 장치의 I/O 공간에 대한 첫 작업(있으면) 전에 1을 써야 하고, 장치 드라이버 구성을 해제하기 전에 0을 써야 합니다.
Built-in Self Test (BIST) 0을 씁니다. BIST가 구현되어 있으면 1을 써서 BIST를 시작할 수 있습니다.
Latency Timer 시스템별 값으로 초기화합니다. 값을 보존합니다.
Cache Line Size
Base Address Registers 요청한 크기와 쓸 수 있는 주소 공간에 따라 초기화합니다. ODM의 M.n과 O.n 사용자 정의 속성에 따라 씁니다.
Expansion ROM Base Address ODM의 M.n과 O.n 사용자 정의 속성에 따라 씁니다. 소프트웨어가 확장 ROM을 쓰지 않으면 Command/Memory Space를 켜기 전에 LSB에 0을 씁니다.
Interrupt Line 무시합니다. 무시합니다. 정보는 ODM에서 얻습니다.
영어 원문

PCI configuration space for I/O devices

There are several writable fields in the standard PCI Configuration Header for PCI devices.

They are:

  • Command Register

  • Latency Timer

  • Cache Line Size

  • Base Address Registers

  • Expanded ROM Base Address

  • Interrupt Line

Some of these are written by the firmware and should never be changed by the device driver. The PCI Configuration Header Programming Table must be followed when programming the PCI Configuration Header registers.

Register/Bit Name Firmware Action (Boot or ibm, configure-connector call) Software (Device Driver) Action Command/Fast Back-to-Back Enable Write to a value of 0 on platforms capable of PCI Hot Plug. May be written to a value of 1 on non-Hot-Plug capable platforms if all I/O devices on the same PCI bus are capable of Fast Back-to-Back transfers. Preserve value

Command/SERR# enable Write a value of 1 Command/Wait cycle control Write to a value of 0 (may be hardwired to a 1, so may be a 1 when read even after being written to a 0) Command/Parity Error Response Write a value of 1 Command/VGA Palette snoop Write a value of 0 Command/Memory Write and Invalidate Enable Write to 0 (reset value)

Command/Special Cycles Command/Bus Master Write to 0 (reset value) unless boot device. Must write to a 1 before the first DMA operation. Must write to a 0 before unconfiguring device driver. Command/Memory Space Write a value of 0 (reset value) unless boot device, in which case does not write a value of 1 until BARs and Expansion ROM Base Address are set. Only written to a 1 if that specific address space is used for that I/O device. Must write to a 1 before the first operation (if any) to the I/O devices memory space. Must write to a 0 before unconfiguring device driver. Command/IO Space Must write to a 1 before the first operation (if any) to the I/O devices I/O space. Must write to a 0 before unconfiguring device driver. Build-in Self Test (BIST) Write a value of 0 If BIST is implemented, can write to a 1 to initiate BIST Latency Timer Initialize to a system-specific value Preserve value Cache Line Size

Register/Bit Name Firmware Action (Boot or ibm, configure-connector call) Software (Device Driver) Action Base Address Registers Initialize based on size requested and address space available Writes based on the ODM M.n and O.n customized attributes Expansion ROM Base Address Writes based on the ODM M.n and O.n customized attributes. Write LSB to a 0 before enabling the Command/Memory Space if Expansion ROM not used by software. Interrupt Line Ignore Ignore - get information from ODM

자주 쓰는 형태

c
/* TU 호출 순서(DA 쪽) */
TU_TYPE tucb; TU_RETURN_TYPE rc; void *h = NULL;
tucb.resource_name = "ent0";
tucb.parms.tu = TU_OPEN;  tucb.parms.loop = 1;  exectu(..., &tucb, &h, &rc);
tucb.parms.tu = 0x10;                            exectu(..., &tucb, &h, &rc);  /* 시험 TU */
tucb.parms.tu = TU_CLOSE;                        exectu(..., &tucb, &h, &rc);
if (rc.major_rc != 0) { /* FRU 보고(addfrub) */ }