[AIX 진단 서브시스템 8] 진단 커널 확장 (1) PDIAGEX 개요와 libpdiag.a 함수

핵심 정리

  • PDIAGEX(Portable Diagnostic Kernel Extension)는 장치 드라이버에 진단 코드를 넣지 않고도 사용자 수준 응용 프로그램이 장치 레지스터 읽기·쓰기, DMA, 인터럽트 처리를 할 수 있게 하는 커널 확장입니다. 진단 컨트롤러가 DA 실행 전에 적재합니다(PDiagRes·PDiagTask의 KernExt 필드).
  • 장치를 시험하려면 DIAGNOSE 상태(CuDv state=4)로 만들어야 합니다. DEFINED에서 cfgdiag 메서드로만 들어가고 ucfgdiag로만 DEFINED로 돌아오며, AVAILABLE과 DIAGNOSE 사이 직접 전환은 없습니다. 라이브러리 함수 pdiag_diagnose_state·pdiag_restore_state가 장치와 자식을 옮겨 줍니다.
  • pdiag_ 함수는 /usr/lib/libpdiag.a, pdiag_dd_ 함수는 커널 확장 /usr/lib/drivers/pdiagex에 있으며, 응용 프로그램은 pdiagex.exp를 import 파일로 링크합니다. SLIH는 /usr/lpp/diagnostics/slih(DIAGX_SLIH_DIR)에 둡니다.
  • pdiag_open(장치, dds, 인터럽트처리기, &handle)이 자원 핸들을 만들고 DMA 채널과 인터럽트 처리기를 준비하며, pdiag_close(handle)가 모두 해제합니다. 반환값은 DGX_OK와 DGX_*_FAIL 코드입니다.
  • pdiag_cs_get_attr로 ODM에서 장치 속성(bus_id, int_level 등)을 얻고 pdiag_cs_free_attr로 해제하며, pdiag_pcicfg_read/write로 PCI 구성 레지스터를 8·16·32비트로 읽고 씁니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (내용이 같음)
원문 Understanding the Diagnostic Subsystem for AIX — 5.3판 3장(7687쪽), 6.1판 6474쪽
파일 /usr/lib/libpdiag.a, /usr/lib/drivers/pdiagex, /usr/lib/methods/cfgdiag, /usr/lib/methods/ucfgdiag, /usr/lpp/diagnostics/slih
헤더 sys/pdiag_def.h, sys/pdiagex_dds.h, sys/cfgdb.h, cf.h

진단 커널 확장(PDIAGEX)과 장치 구성 서비스의 쓰임과 프로그래밍 인터페이스를 설명합니다.

pdiag_ 호출은 /usr/lib/libpdiag.a에, pdiag_dd_ 호출은 커널 확장 /usr/lib/drivers/pdiagex에 들어 있습니다.

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

영어 원문

Diagnostic kernel extension

This section describes the use of and programming interfaces to the Diagnostic Kernel Extension (PDIAGEX) and device configuration services.

The pdiag_ calls are contained in /usr/lib/libpdiag.a. The pdiag_dd_ calls are contained in /usr/lib/drivers/pdiagex kernel extension.

The following topics are discussed in detail:

개요

이식 가능한 진단 커널 확장(Portable Diagnostic Kernel Extension, PDIAGEX)은 장치 드라이버에 특별한 진단 코드를 넣지 않고도 사용자 수준 응용 프로그램이 장치를 시험할 수 있게 설계되었습니다. PDIAGEX는 응용 프로그램을 부르기 전에 진단 컨트롤러가 커널에 적재하고 바인드합니다.

PDIAGEX는 장치 레지스터 읽기·쓰기, DMA(Direct Memory Access) 수행, 인터럽트 처리를 위한 시스템 호출을 제공합니다.

PDIAGEX로 장치를 시험하려면, 장치 메서드를 불러 장치를 DEFINED나 AVAILABLE 상태에서 DIAGNOSE 상태로 옮겨 시스템의 나머지가 장치를 쓸 수 없게 합니다. 장치가 DIAGNOSE 상태가 되면 PDIAGEX로 시험할 수 있습니다. 이는 libpdiag.a의 pdiag_diagnose_state 호출로 합니다.

PDIAGEX를 쓰는 응용 프로그램은 pdiagex.exp 파일을 import 파일로 지정해 링크해야 합니다.

영어 원문

Overview

The Portable Diagnostic Kernel Extension (PDIAGEX) is designed to allow a user-level application to exercise or test a device without requiring specialized diagnostic code to be added to the device driver. PDIAGEX is loaded and bound into the kernel by the Diagnostic Controller before the application is invoked.

The PDIAGEX provides system calls for reading and writing device registers, performing Direct Memory Access (DMA), and handling interrupts.

To use PDIAGEX for exercising a device, make the device unavailable to the rest of the system by invoking device methods to move the device from the DEFINED or AVAILABLE state to the DIAGNOSE state. Once the device is in the DIAGNOSE state, the device may be exercised using PDIAGEX. This is accomplished by using the libpdiag.a call pdiag_diagnose_state.

Applications using PDIAGEX must be linked with the pdiagex.exp file specified as an import file.

장치 구성

PDIAGEX를 쓰려면 진단과 일반 장치 드라이버가 어댑터에 접근하는 것을 직렬화(serialization)해 제한해야 합니다. 직렬화는 장치 구성 소프트웨어가 제공합니다.

DIAGNOSE라는 장치 상태가 정의되어 있으며, 장치의 CuDv 객체에서 state=4로 나타냅니다. /usr/include/sys/cfgdb.h 파일에 다음 define 문이 더해졌습니다.

text
#define DIAGNOSE  4

이 상태는 DEFINED 상태에서만, /usr/lib/methods/cfgdiag 메서드를 실행해서만 들어갈 수 있습니다. DIAGNOSE 상태에서 DEFINED 상태로는 /usr/lib/methods/ucfgdiag 메서드를 실행해서만 돌아갈 수 있습니다. AVAILABLE과 DIAGNOSE 상태 사이의 전환은 허용되지 않습니다. 이렇게 해서 DIAGNOSE 상태를 지원하는 장치에 대한 접근을 직렬화합니다. AVAILABLE 상태에서는 장치의 일반 장치 드라이버가 적재되어 동작하고, DIAGNOSE 상태에서는 PDIAGEX(또는 별도의 진단 장치 드라이버)가 적재되어 장치를 제어합니다.

/usr/lib/methods/cfgdiag 메서드는 장치의 부모가 올바른 상태인지 확인합니다. 장치가 Micro Channel 어댑터면 어댑터가 슬롯에 있는지 확인합니다. 그다음 busresolve를 실행해 버스 자원이 제대로 할당되었는지 확인합니다.

장치와 그 자식을 시험에 알맞은 상태로 옮기는 진단 라이브러리 루틴 두 개가 있습니다. pdiag_diagnose_state와 pdiag_restore_state입니다.

영어 원문

Device configuration

Using PDIAGEX requires that serialization be used to limit access to the adapters by the diagnostics and the normal device drivers. Serialization is provided by the device configuration software.

A device state, DIAGNOSE, is defined. The state is identified by state=4 in the CuDv object for the device. A define statement:

text
#define DIAGNOSE  4

has been added to the /usr/include/sys/cfgdb.h file.

This state can be entered only from the DEFINED state and only by running the /usr/lib/methods/cfgdiag method. From the DIAGNOSE state, a device can be changed back to the DEFINED state only by running the /usr/lib/methods/ucfgdiag method. Transitions between the AVAILABLE and DIAGNOSE states are not allowed. This provides a mechanism for serializing access to the devices that support this DIAGNOSE state. While in the AVAILABLE state, a device's normal device driver is loaded and operational, but while it is in the DIAGNOSE state, the PDIAGEX (or separate diagnostic device driver) is loaded and has control of the device.

The /usr/lib/methods/cfgdiag method checks that the parent of the device is in the correct state. If the device is a Micro Channel adapter, it verifies that the adapter is in the slot. Busresolve then runs to ensure that bus resources are allocated properly.

Two diagnostic library routines have been created to move the device and its children to their appropriate states for testing. The routines are pdiag_diagnose_state and pdiag_restore_state.

PDIAGEX 적재

진단 컨트롤러는 진단 응용 프로그램을 실행하기 전에 필요한 커널 확장의 적재와 해제를 조율합니다.

PDiagRes와 PDiagTask 객체 클래스의 KernExt 필드로 장치에 커널 확장이 필요하다고 컨트롤러에 알립니다. 응용 프로그램에 필요한 커널 확장을 쉼표(,)로 구분한 목록이며, 각 커널 확장은 응용 프로그램을 부르기 전에 적재됩니다.

영어 원문

Loading PDIAGEX

The Diagnostic Controller coordinates the loading and unloading of the kernel extensions required before executing the Diagnostic Application.

The KernExt field in the PDiagRes and PDiagTask object class is used to tell the Controller that the device requires a kernel extension. This is a ',' comma-separated list of required kernel extensions for the application. Each kernel extension is loaded before the application is invoked.

2차 인터럽트 처리기

모든 2차 인터럽트 처리기(SLIH)는 /usr/lpp/diagnostics/slih 디렉터리에 둬야 합니다.

이 디렉터리는 환경 변수 DIAGX_SLIH_DIR로 정의됩니다. 코드 이름(code name)은 절대 쓰지 말고, 해당되면 구성 요소 이름을 씁니다.

영어 원문

Second level interrupt handlers

All second-level interrupt handlers should reside in the directory /usr/lpp/diagnostics/slih.

This directory is defined by environment variable DIAGX_SLIH_DIR. Avoid code names at all times. Use the component name if applicable.

libpdiag.a의 프로그래밍 인터페이스

이식 가능한 진단 라이브러리의 응용 프로그래밍 인터페이스입니다.

  • pdiag_diagnose_state
  • pdiag_diagnose_multifunc_state
  • pdiag_restore_state
  • pdiag_restore_multifunc_state
  • pdiag_cs_open
  • pdiag_cs_close
  • pdiag_cs_get_attr
  • pdiag_cs_free_attr
  • pdiag_open
  • pdiag_close
  • pdiag_pcicfg_read
  • pdiag_pcicfg_write
  • pdiag_set_eeh_option
  • pdiag_shared_slot
  • pdiag_read_slot_reset
  • pdiag_set_slot_reset
영어 원문

Programming interfaces for libpdiag.a

This section provides information on application programming interfaces to the Portable Diagnostic library.

  • pdiag_diagnose_state

  • pdiag_diagnose_multifunc_state

  • pdiag_restore_state

  • pdiag_restore_multifunc_state

  • pdiag_cs_open

  • pdiag_cs_close

  • pdiag_cs_get_attr

  • pdiag_cs_free_attr

  • pdiag_open

  • pdiag_close

  • pdiag_pcicfg_read

  • pdiag_pcicfg_write

  • pdiag_set_eeh_option

  • pdiag_shared_slot

  • pdiag_read_slot_reset

  • pdiag_set_slot_reset

pdiag_diagnose_state

목적

시험할 장치를 시험에 알맞은 상태로 만듭니다.

구문

text
#include <sys/pdiag_def.h>
int32  pdiag_diagnose_state ( char * device_instance )

설명

pdiag_diagnose_state 서브루틴은 장치(와 필요하면 그 자식)의 구성을 해제해 장치를 DIAGNOSE 상태로 만듭니다. 바뀐 모든 장치의 원래 상태를 저장합니다. 바뀐 장치를 원래 상태로 되돌리려면 pdiag_restore_state를 씁니다.

이 함수는 플랫폼 구현에 따라 다릅니다. 주 목적은 대상 장치가 진단에 알맞은 상태인지, 시험 동안 EEH(Enhanced Error Handling) 옵션이 켜져 있는지 확인하는 것입니다. 장치가 이미 진단 상태이거나 운영 체제가 이 목적으로 허용하는 상태면 성공 상태 값 0을 돌려줘야 합니다. 오류가 나면 0이 아닌 값을 돌려줘야 합니다.

전역 변수 diag_cfg_errno에는 장치에 대해 부른 메서드의 반환값이 들어갑니다.

매개변수

매개변수 설명
device_instance 시험할 장치 이름

반환값

값 뜻
0 성공
-1 소프트웨어 오류
1 장치 메서드가 오류를 돌려줌. diag_cfg_errno 변수에 장치 메서드의 오류 코드가 들어 있습니다(/usr/include/cf.h 참고). E_FINDCHILD와 E_NEWCHILD 값은 실패가 아닙니다.
-2 EEH 하드웨어 오류

관련 참조

pdiag_diagnose_multifunc_state, pdiag_restore_state, pdiag_restore_multifunc_state

영어 원문

pdiag_diagnose_state

Purpose

Puts the device under test into the correct state for testing.

Syntax

text
#include <sys/pdiag_def.h>
int32  pdiag_diagnose_state ( char * device_instance )

Description

The pdiag_diagnose_state subroutine unconfigures the device, and its children if necessary, to set the device into the DIAGNOSE state. Original states of all devices changed will be saved. Use pdiag_restore_state to put the changed devices back to their original states.

This function is platform-implementation specific. Its main purpose is to make sure that the target device is in the correct state for diagnostic purposes and that the Enhanced Error Handling (EEH) option is enabled during the test. If the device is already in a diagnostic state, or any state allowed by the operating system for this purpose, then this function should return a successful status value of zero. If an error occurs, then this function should return a non-zero value.

The global variable diag_cfg_errno will be set to the return value of the method invoked for the device.

Parameters

  • device_instance — Name of the device under test.

Return Value

The pdiag_diagnose_state subroutine returns one of the following values:

  • 0 — Successful return.
  • -1 — Software error.
  • 1 — Error returned from device method. The diag_cfg_errno variable contains the error code from the device method. Refer to the/usr/include/cf.h file. The E_FINDCHILD and E_NEWCHILD values are not failures.
  • -2 — EEH hardware error.

Related reference

“pdiag_diagnose_multifunc_state” “pdiag_restore_state” on page 67 “pdiag_restore_multifunc_state” on page 68

pdiag_diagnose_multifunc_state

목적

단일 기능 장치, 브리지 없는 다중 기능 장치, 브리지 장치를 시험에 알맞은 상태로 만듭니다.

구문

text
#include <sys/pdiag_def.h>
int32 pdiag_diagnose_multifunc_state (char *device_instance, int eeh_activate)

설명

pdiag_diagnose_multifunc_state 서브루틴은 장치(와 필요하면 그 자식)의 구성을 해제해 장치를 DIAGNOSE 상태로 만듭니다. 바뀐 모든 장치의 원래 상태를 저장합니다. 원래 상태로 되돌리려면 pdiag_restore_multifunc_state를 씁니다.

이 함수는 플랫폼 구현에 따라 다릅니다. 주 목적은 대상 장치가 진단에 알맞은 상태인지, 시험 동안 EEH 옵션이 켜져 있는지 확인하는 것입니다. 장치가 이미 진단 상태이거나 운영 체제가 이 목적으로 허용하는 상태면 성공 상태를 돌려줘야 하며, 오류가 나면 0이 아닌 값을 돌려줘야 합니다.

전역 변수 diag_cfg_errno에는 장치에 대해 부른 메서드의 반환값이 들어갑니다.

매개변수

매개변수 설명
device_instance 시험할 장치 이름
eeh_activate 0 EEH 옵션을 켜지 않음, 1 브리지 어댑터의 EEH 옵션을 켬, 2 브리지 없는 다중 기능 어댑터의 EEH 옵션을 켬, 3 단일 기능 어댑터의 EEH 옵션을 켬

반환값

값 뜻
0 성공
-1 소프트웨어 오류
1 장치 메서드가 오류를 돌려줌. diag_cfg_errno 변수에 장치 메서드의 오류 코드가 들어 있습니다(/usr/include/cf.h 참고). E_FINDCHILD와 E_NEWCHILD 값은 실패가 아닙니다.
-2 하드웨어 오류

관련 참조

pdiag_diagnose_state, pdiag_restore_state, pdiag_restore_multifunc_state

영어 원문

pdiag_diagnose_multifunc_state

Purpose

Puts a single function device, a multifunction non-bridged device, and a bridged device under test, into the correct state for testing.

Syntax

text
#include <sys/pdiag_def.h>
int32 pdiag_diagnose_multifunc_state (char *device_instance, int eeh_activate)

Description

The pdiag_diagnose_multifunc_state subroutine unconfigures the device, and its children if necessary, to set the device into the DIAGNOSE state. The original states of all changed devices will be saved. Use pdiag_restore_multifunc_state to put the changed devices back to their original states.

This function is platform-implementation specific. Its main purpose is to make sure that the target device is in the correct state for diagnostic purposes, and that the Enhanced Error Handling (EEH) option is enabled during test. If the device is already in a diagnostic state, or any state allowed by the operating system for this purpose, this function should return successful status. If an error occurs, this function should return a non-zero.

The global variable, diag_cfg_errno, will be set to the return value of the method invoked for the device.

Parameters

  • device_instance — Name of device under test.
  • eeh_activate — 0 Do not enable the EEH option 1 Enable the EEH option for bridged adapters 2 Enable the EEH option for multifunction non-bridged adapters 3 Enable the EEH option for single function adapters

Return Value

The pdiag_diagnose_multifunc_state subroutine function returns one of the following values:

  • 0 — Successful return
  • -1 — Software error
  • 1 — Error returned from device method. The diag_cfg_errno variable contains the error code from the device method. Refer to the/usr/include/cf.h file. The E_FINDCHILD and E_NEWCHILD values are not failures.
  • -2 — Hardware error

Related reference

“pdiag_diagnose_state” on page 65 “pdiag_restore_state” “pdiag_restore_multifunc_state” on page 68

pdiag_restore_state

목적

자원과 자식을 시험 전의 처음 상태로 되돌립니다.

구문

text
#include    <sys/pdiag_def.h>
int32  pdiag_restore_state ( char * device_instance )

설명

pdiag_restore_state 서브루틴은 장치(와 필요하면 그 자식)를 pdiag_diagnose_state 루틴을 부르기 전의 원래 상태로 되돌립니다.

이 함수는 플랫폼 구현에 따라 다릅니다. 주 목적은 대상 장치가 진단을 하기 전의 원래 상태로 돌아갔는지, EEH 옵션이 꺼졌는지 확인하는 것입니다. 장치가 이미 올바른 상태면 성공 상태 값 0을 돌려줘야 하며, 오류가 나면 0이 아닌 값을 돌려줘야 합니다.

전역 변수 diag_cfg_errno에는 장치에 대해 부른 메서드의 반환값이 들어갑니다.

매개변수

매개변수 설명
device_instance 시험할 장치 이름

반환값

값 뜻
0 성공
-1 소프트웨어 오류
1 장치 메서드가 오류를 돌려줌. diag_cfg_errno 변수에 장치 메서드의 오류 코드가 들어 있습니다(/usr/include/cf.h 참고). E_FINDCHILD와 E_NEWCHILD 값은 실패가 아닙니다.
-2 EEH 하드웨어 오류

관련 참조

pdiag_diagnose_multifunc_state, pdiag_diagnose_state, pdiag_restore_multifunc_state

영어 원문

pdiag_restore_state

Purpose

Restores resource and children to their initial state before testing.

Syntax

text
#include    <sys/pdiag_def.h>
int32  pdiag_restore_state ( char * device_instance )

Description

The pdiag_restore_state subroutine puts the device, and its children if necessary, back to the original state before the pdiag_diagnose_state routine was called.

This function is platform-implementation specific. Its main purpose is to make sure that the target device is back in its original state prior to performing diagnostics on the device, and that the Enhanced Error Handling (EEH) option is disabled. If the device is already in the correct state, then this function should return a successful status value of zero. If an error occurs, then this function should return a non-zero value.

The diag_cfg_errno global variable will be set to the return value of the method invoked for the device.

Parameters

  • device_instance — Name of the device under test.

Return Value

The pdiag_restore_state subroutine returns one of the following values:

  • 0 — Successful return.
  • -1 — Software error.
  • 1 — Error returned from device method. The diag_cfg_errno variable contains the error code from the device method. Refer to the/usr/include/cf.h file. The E_FINDCHILD and E_NEWCHILD values are not failures.
  • -2 — EEH hardware error.

Related reference

“pdiag_diagnose_multifunc_state” on page 66 “pdiag_diagnose_state” on page 65 “pdiag_restore_multifunc_state”

pdiag_restore_multifunc_state

목적

장치와 그 자식을 시험 전의 처음 상태로 되돌립니다.

구문

text
#include <sys/pdiag_def.h>
int32 pdiag_restore_multifunc_state (char *device_instance, int eeh_activate)

설명

pdiag_restore_multifunc_state 서브루틴은 장치(와 필요하면 그 자식)를 pdiag_diagnose_multifunc_state 루틴을 부르기 전의 원래 상태로 되돌립니다.

이 함수는 플랫폼 구현에 따라 다릅니다. 주 목적은 대상 장치가 진단 기능을 수행하기 전의 원래 상태로 돌아갔는지, EEH 옵션이 처음 상태로 돌아갔는지 확인하는 것입니다. 장치가 이미 올바른 상태면 성공 상태를 돌려줘야 하며, 오류가 나면 0이 아닌 값을 돌려줘야 합니다.

전역 변수 diag_cfg_errno에는 장치에 대해 부른 메서드의 반환값이 들어갑니다.

매개변수

매개변수 설명
device_instance 시험할 장치 이름
eeh_activate 0 EEH 옵션을 끄지 않음, 1 EEH 옵션을 끔

반환값

값 뜻
0 성공
-1 소프트웨어 오류
1 장치 메서드가 오류를 돌려줌. diag_cfg_errno 변수에 장치 메서드의 오류 코드가 들어 있습니다(/usr/include/cf.h 참고). E_FINDCHILD와 E_NEWCHILD 값은 실패가 아닙니다.
-2 하드웨어 오류

관련 참조

pdiag_diagnose_multifunc_state, pdiag_diagnose_state, pdiag_restore_state

영어 원문

pdiag_restore_multifunc_state

Purpose

Restores a device and its children to their initial state before testing.

Syntax

text
#include <sys/pdiag_def.h>
int32 pdiag_restore_multifunc_state (char *device_instance, int eeh_activate)

Description

The pdiag_restore_multifunc_state subroutine puts the device, and its children if necessary, back to the original state before the pdiag_diagnose_multifunc_state routine was called.

This function is platform-implementation specific. Its main purpose is to make sure that the target device is back in its original state before diagnostic functions were performed on the device and the Enhanced Error handling (EEH) option is returned to the state originally encountered. If the device is already in the correct state, this function should return a successful status. If an error occurs, this function should return a non-zero.

The diag_cfg_errno global variable will be set to the return value of the method invoked for the device.

Parameters

  • device_instance — Name of device under test.
  • eeh_activate — 0 Do not disable the EEH option 1 Disable the EEH option

Return Value

The pdiag_restore_multifunc_state function returns one of the following values:

  • 0 — Successful return
  • -1 — Software error
  • 1 — Error returned from device method. The diag_cfg_errno variable contains the error code from the device method. Refer to the/usr/include/cf.h file. The E_FINDCHILD and E_NEWCHILD values are not failures.
  • -2 — Hardware error

Related reference

“pdiag_diagnose_multifunc_state” on page 66 “pdiag_diagnose_state” on page 65 “pdiag_restore_state” on page 67

pdiag_cs_open

목적

장치 정보를 얻는 데 쓰는 구성 서비스, 곧 ODM(Object Data Manager)을 열고 초기화합니다.

구문

text
int32 pdiag_cs_open ( )

설명

pdiag_cs_open 서브루틴은 ODM에 odm_initialize 호출을 냅니다.

매개변수

매개변수 설명
(없음) 매개변수를 받지 않습니다.

반환값

늘 0을 돌려줍니다.

영어 원문

pdiag_cs_open

Purpose

Opens and initializes the configuration services, which are used to obtain device information. This is the Object Data Manager (ODM).

Syntax

text
int32 pdiag_cs_open ( )

Description

The pdiag_cs_open subroutine issues an odm_initialize call to the Object Data Manager.

Parameters

Takes no parameters.

Return Value

A value of 0 is always returned.

pdiag_cs_close

목적

장치 정보를 얻는 데 쓰는 구성 서비스, 곧 ODM을 닫습니다.

구문

text
int32 pdiag_cs_close ( )

설명

pdiag_cs_close 서브루틴은 ODM에 odm_terminate 호출을 냅니다.

매개변수

매개변수 설명
(없음) 매개변수를 받지 않습니다.

반환값

늘 0을 돌려줍니다.

영어 원문

pdiag_cs_close

Purpose

Closes the configuration services, which are used to obtain device information. This is the Object Data Manager (ODM).

Syntax

text
int32 pdiag_cs_close ( )

Description

The pdiag_cs_close subroutine issues an odm_terminate call to the Object Data Manager.

Parameters

Takes no parameters.

Return Value

A value of 0 is always returned.

pdiag_cs_get_attr

목적

자원의 속성 정보를 돌려줍니다.

구문

text
int32 pdiag_cs_get_attr ( char * device_instance , char * attribute,
                char ** cvalue , char * type )

설명

pdiag_cs_get_attr 서브루틴은 구성 데이터베이스를 찾아 장치의 속성 값을 얻습니다. 값과 형을 호출 응용 프로그램에 돌려줍니다.

매개변수

매개변수 설명
device_instance 시험할 장치 이름
attribute 가져올 속성을 나타내는 문자열. 지원하는 장치 속성 이름: alias, alt_addr, attn_mac, beacon_mac, bus_addr_start, bus_id, bus_intr_lvl, bus_io_addr, bus_io_length, bus_mem_addr, bus_mem_start, bus_type, dma1_start, dma2_start, dma3_start, dma4_start, dma_bus_mem, dma_channel, dma_lvl, gd_frequency, int_level, intr_priority, rcv_que_size, ring_speed, use_alt_addr, vram_start, xmt_que_size
cvalue 데이터 버퍼의 포인터. 이 함수가 속성 데이터를 담으려고 할당한 버퍼의 주소로 설정합니다.
type 돌려준 데이터 형을 나타내도록 이 함수가 설정하는 문자. s 문자열, i long 정수

반환값

성공하면 0을 돌려줍니다.

영어 원문

pdiag_cs_get_attr

Purpose

Returns resource attribute information.

Syntax

text
int32 pdiag_cs_get_attr ( char * device_instance , char * attribute,
                char ** cvalue , char * type )

Description

The pdiag_cs_get_attr subroutine searches the data configuration database to obtain the value of the attribute for the device. The value and type is returned to the calling application.

Parameters

  • device_instance — Name of the device under test.
  • attribute — Character string describing attribute to be retrieved. Supported device attribute names: alias alt_addr attn_mac beacon_mac bus_addr_start bus_id bus_intr_lvl bus_io_addr bus_io_length bus_mem_addr bus_mem_start bus_type dma1_start dma2_start dma3_start dma4_start dma_bus_mem dma_channel dma_lvl gd_frequency int_level intr_priority rcv_que_size ring_speed use_alt_addr vram_start xmt_que_size
  • cvalue — Pointer to data buffer, set by this function to address of buffer allocated to hold the attribute data.
  • type — Character set by this function to indicate the returned data type. Supported data types are: s String i Long integer

Return Value

A value of 0 is returned if successful.

pdiag_cs_free_attr

목적

pdiag_cs_get_attr 요청이 할당한 버퍼를 해제합니다.

구문

text
int32 pdiag_cs_free_attr ( char * cvalue )

설명

pdiag_cs_free_attr 서브루틴은 앞선 pdiag_cs_get_attr 호출이 할당한 버퍼를 해제합니다.

매개변수

매개변수 설명
cvalue 이전에 할당한 데이터 버퍼의 포인터

반환값

성공하면 0을 돌려줍니다.

영어 원문

pdiag_cs_free_attr

Purpose

Frees a buffer allocated by a pdiag_cs_get_attr request.

Syntax

text
int32 pdiag_cs_free_attr ( char * cvalue )

Description

The pdiag_cs_free_attr subroutine frees the buffer allocated by a previous pdiag_cs_get_attr call.

Parameters

  • cvalue — Pointer to previously allocated data buffer.

Return Value

A value of 0 is returned if successful.

pdiag_open

목적

시험할 자원을 준비합니다.

구문

text
#include <sys/pdiagex_dds.h>
#include <sys/pdiag_def.h>
int32 pdiag_open( device_instance, dds_ptr, int_handler, handle )
pdiag_addr_t         device_instance ;
pdiagex_dds_t       *dds_ptr ;
pdiag_addr_t         int_handler;
pdiag_info_handle_t *handle ;

설명

pdiag_open() 함수는 이 자원의 핸들을 위한 메모리를 할당합니다. pdiagex_dds_t 구조체에는 시험할 자원의 정보가 들어 있으며, 테스트 단위 코드는 pdiag_open을 부르기 전에 이 구조체의 데이터를 초기화해야 합니다. 돌려받는 pdiag_info_handle_t 구조체가 이 자원에 대해 만든 핸들입니다. 테스트 단위는 이 구조체의 내부를 알 필요는 없지만, 이후 함수 호출에 쓰도록 포인터를 보관해야 합니다. DMA 채널은 d_init 커널 서비스를 불러 초기화한 다음 전송을 위해 마스크를 풉니다. 곧 pdiag_dd_dma_setup()을 따로 하지 않아도 됩니다. Micro Channel 버스 유형이면 모든 버퍼를 쓸 수 있다고 표시하는 DMA TCW 관리 표도 초기화합니다.

사용자 인터럽트 처리기 루틴이 있으면 처리기를 고정(pin)하고, i_init 커널 서비스로 초기화하고, 인터럽트 데이터용 메모리를 할당합니다.

자원을 동시에 할당·해제하지 못하도록 이 루틴과 pdiag_close()는 실행하는 동안 같은 잠금을 공유합니다. 앞선 호출이 잠금을 가진 동안 이 루틴이나 pdiag_close()를 부르면, 호출한 프로세스는 루틴을 쓸 수 있을 때까지 잠듭니다.

참고: 경우에 따라 dds 구조체의 멤버가 필요 없을 수 있습니다. 예를 들어 dds->bus_type이 BUS_60X면 dds 멤버 bus_io_addr, bus_io_length, dma_bus_addr, dma_bus_length, dma_lvl, dma_flags, dma_chan_id는 쓰지 않으며 PDIAGEX가 무시합니다.

실행 환경

pdiag_open() 함수는 프로세스 환경에서만 부를 수 있습니다.

매개변수

매개변수 설명
device_instance 열 장치 이름 문자열의 포인터
dds_ptr dds가 설명하는 자원의 속성으로 이미 초기화된 pdiagex_dds_t 구조체를 가리킵니다("데이터 사전" 참고).
int_handler 적재할 인터럽트 처리기 이름 문자열의 포인터
handle 돌려받는 진단 자원 핸들의 포인터

반환값

pdiag_open 함수는 다음 값 가운데 하나를 돌려줍니다.

값 뜻
DGX_OK 성공. errno는 설정하지 않습니다.
DGX_BOUND_FAIL 입력 매개변수가 범위를 벗어남(dds.dma_bus_len이 PAGESIZE의 배수가 아니거나 0, Micro Channel 버스만). errno는 설정하지 않습니다.
DGX_BADVAL_FAIL 입력 매개변수(dds.bus_type)가 올바르지 않음. errno는 설정하지 않습니다.
DGX_INVALID_HANDLE 지정한 핸들 포인터가 올바르지 않음. errno는 suword()의 반환 코드
DGX_COPYDDS_FAIL dds 정보를 복사할 수 없음. errno는 copyin()/copyout()의 반환 코드
DGX_DINIT_FAIL DMA 채널을 초기화할 수 없음. errno는 d_init()의 반환 코드
DGX_IINIT_FAIL 사용자 인터럽트 처리기를 초기화할 수 없음. errno는 i_init()의 반환 코드
DGX_KMOD_FAIL 커널 공간에서 사용자 인터럽트 처리기를 찾을 수 없음. errno는 kmod_entrypt()의 반환 코드
DGX_PINCODE_FAIL 사용자 인터럽트 처리기나 인터럽트 환경의 PDIAGEX 함수를 고정할 수 없음. errno는 pincode()의 반환 코드
DGX_PINU_FAIL 지정한 사용자 버퍼를 고정할 수 없음. errno는 pinu()의 반환 코드
DGX_XMALLOC_FAIL 자원을 할당할 수 없음. errno는 xmalloc()의 반환 코드
DGX_XMATTACH_FAIL 사용자 버퍼를 물리 주소에 붙일 수 없음. errno는 xmattach()의 반환 코드

관련 참조

pdiag_close

영어 원문

pdiag_open

Purpose

Prepares a resource for testing.

Syntax

text
#include <sys/pdiagex_dds.h>
#include <sys/pdiag_def.h>
int32 pdiag_open( device_instance, dds_ptr, int_handler, handle )
pdiag_addr_t         device_instance ;
pdiagex_dds_t       *dds_ptr ;
pdiag_addr_t         int_handler;
pdiag_info_handle_t *handle ;

Description

The pdiag_open() function allocates memory for a handle for this particular resource. The pdiagex_dds_t structure contains information about the resource to be tested. The Test Unit code must initialize the data in this structure before calling pdiag_open. The returned pdiag_info_handle_t structure is the handle created for the resource. The Test Unit does not need to know any of the internal details of this structure, but must retain the pointer for use in subsequent function calls. The DMA channel is initialized by calling the d_init kernel service and then the DMA channel is unmasked for transfer; that is, you are not required to do a pdiag_dd_dma_setup(). For Micro Channel bus_types, it also initializes a DMA TCW management table to indicate that all buffers are available.

If a user interrupt-handler routine exists, it pins the handler, initializes this handler (using the i_init kernel service), and allocates memory for interrupt data.

Both this routine and pdiag_close() share a common lock while executing to prevent simultaneous resource allocation/deallocation. If a call is made to this routine or pdiag_close() while the lock is being held by a previous call, the calling process will sleep until the routine is available.

Note: In some instances, the members of the dds structure may not be necessary. For example, if dds->bus_type is equal to BUS_60X, the dds members, bus_io_addr, bus_io_length, dma_bus_addr, dma_bus_length, dma_lvl, dma_flags, and dma_chan_id are not used and are ignored by PDIAGEX. See Programming interfaces for libpdiag.a.

Execution Environment

The pdiag_open() function can be called from the process environment only.

Parameters

  • device_instance — Pointer to the string name of the specific device to open.
  • dds_ptr — Points to a pdiagex_dds_t structure which should already be initialized with attributes for the particular resource described by the dds (see " Data Dictionary").
  • int_handler — Pointer to the string name of the interrupt handler to be loaded.
  • handle — Returned pointer to diagnostic resource handle.

Return Value

The pdiag_open function returns one of the following values:

  • DGX_OK — The operation was successful. The errno is not set.
  • DGX_BOUND_FAIL — An input parameter is out of bounds (dds.dma_bus_len is not a multiple of PAGESIZE or zero) (Micro Channel bus type only). The errno is not set.
  • DGX_BADVAL_FAIL — An input parameter (dds.bus_type) is not valid. The errno is not set.
  • DGX_INVALID_HANDLE — Specified handle pointer is not valid. The errno is set to the suword() return code.
  • DGX_COPYDDS_FAIL — Application could not copy the dds information. The errno is set to the copyin()/copyout() return code.
  • DGX_DINIT_FAIL — Application could not initialize the DMA channel. The errno is set to the d_init() return code.
  • DGX_IINIT_FAIL — Application could not initialize the user's interrupt handler. The errno is set to the i_init() return code.
  • DGX_KMOD_FAIL — Application could not locate the user's interrupt handler in kernel space. The errno is set to the kmod_entrypt() return code.
  • DGX_PINCODE_FAIL — Application could not pin the user's interrupt handler or the interrupt environment PDIAGEX functions. The errno is set to the pincode() return code.
  • DGX_PINU_FAIL — Application could not pin the specified user buffer. The errno is set to the pinu() return code.
  • DGX_XMALLOC_FAIL — Application could not allocate resources. The errno is set to the xmalloc() return code.
  • DGX_XMATTACH_FAIL — Application could not attach user buffer to the physical address. The errno is set to the xmattach() return code.

Related reference

“pdiag_close”

pdiag_close

목적

PDIAGEX 커널 확장의 자원을 해제합니다.

구문

text
#include <sys/pdiagex_dds.h>
#include <sy/pdiag_def.h>
int pdiag_close( handle )
pdiag_info_handle_t  handle ;

설명

pdiag_close() 함수는 DMA와 인터럽트 채널이 초기화되었으면 해제합니다. DMA 채널도 마스크하므로 pdiag_dd_dma_complete()를 따로 하지 않아도 됩니다. 할당하거나, 고정하거나, 교차 메모리로 붙인 메모리는 모두 알맞게 떼고, 고정을 풀고, 해제합니다.

사용자 인터럽트 처리기 루틴을 마지막으로 쓰는 것이면 커널 메모리에서 내립니다.

자원을 동시에 할당·해제하지 못하도록 이 루틴과 pdiag_open()은 실행하는 동안 같은 잠금을 공유합니다. 앞선 호출이 잠금을 가진 동안 부르면 호출한 프로세스는 루틴을 쓸 수 있을 때까지 잠듭니다.

참고: 이 루틴을 부르기 전에 모든 pdiag_dd_dma_setup() 호출에 짝이 되는 pdiag_dd_dma_complete() 호출이 있어야 합니다. 끝나지 않은 DMA 작업이 있으면 이 루틴이 실패합니다.

실행 환경

pdiag_close() 함수는 프로세스 환경에서만 부를 수 있습니다.

매개변수

매개변수 설명
handle pdiag_open()이 돌려준 pdiag_info_handle_t 구조체의 포인터

반환값

값 뜻
DGX_OK 성공. errno는 설정하지 않습니다.
DGX_INVALID_HANDLE 지정한 핸들이 이미 닫혔거나 pdiag_open 호출로 만든 것이 아님. errno는 설정하지 않습니다.
DGX_OUTSTANDINGDMA_FAIL 끝나지 않은 DMA 작업 때문에 닫을 수 없음. errno는 설정하지 않습니다.

관련 참조

pdiag_open

영어 원문

pdiag_close

Purpose

Frees up PDIAGEX Kernel Extension resources.

Syntax

text
#include <sys/pdiagex_dds.h>
#include <sy/pdiag_def.h>
int pdiag_close( handle )
pdiag_info_handle_t  handle ;

Description

The pdiag_close() function frees the DMA and interrupt channels, if they were initialized. This function also masks the DMA channel; that is, you are not required to do a pdiag_dd_dma_complete(). Any memory that was allocated, pinned, or cross-memory attached is detached, unpinned, and freed appropriately.

If this is the last use of the user's interrupt-handler routine, it is unloaded from kernel memory.

Both this routine and pdiag_open() share a common lock while executing to prevent simultaneous resource allocation and deallocation. If a call is made to this routine or pdiag_open() while the lock is being held by a previous call, the calling process will sleep until the routine is available.

Note: All pdiag_dd_dma_setup() ) calls should be matched with a pdiag_dd_dma_complete() call prior to calling this routine. Any outstanding DMA operations results in the failure of this routine.

Execution Environment

The pdiag_close() function can be called from the process environment only.

Parameters

  • handle — Pointer to pdiag_info_handle_t structure which is returned from pdiag_open().

Return Value

The pdiag_close function returns one of the following values:

  • DGX_OK — The operation was successful. The errno is not set.
  • DGX_INVALID_HANDLE — Specified handle has been closed or was not generated by the (pdiag_open) call. The errno is not set.
  • DGX_OUTSTANDINGDMA_FAIL — An outstanding DMA operation is preventing closure. The errno is not set.

Related reference

“pdiag_open” on page 71

pdiag_pcicfg_read

목적

PCI 구성 레지스터를 읽습니다.

구문

text
#include <sys/pdiagex_dds.h>
#include <sys/pdiag_def.h>
int32 pdiag_pcicfg_read( device_instance, reg_offset, datasize, data )
pdiag_addr_t         device_instance ;
ulong                reg_offset ;
int                  datasize ;
uchar                *data ;

설명

pdiag_pcicfg_read() 함수는 이 자원의 PCI 구성 레지스터를 8, 16, 32비트로 읽습니다. reg_offset 매개변수에는 장치의 PCI 구성 표 안 레지스터 오프셋이 들어 있으며, 호출 응용 프로그램은 부르기 전에 올바른 오프셋을 줘야 합니다. 돌려받는 데이터는 PCI 레지스터 구성 표에서 읽은 8, 16, 32비트 값입니다. 필요한 바이트 순서 바꾸기는 모두 이 함수 안에서 하므로, 호출 응용 프로그램은 데이터의 바이트 위치를 바꾸면 안 됩니다.

실행 환경

pdiag_pcicfg_read() 함수는 프로세스 환경에서만 부를 수 있습니다.

매개변수

매개변수 설명
device_instance 읽을 장치 이름 문자열의 포인터
reg_offset 읽을 PCI 구성 표 레지스터의 오프셋
datasize 데이터 크기. 8비트는 IOCHAR8, 16비트는 IOSHORT16, 32비트는 IOLONG32
data PCI 구성 표에서 읽은 데이터를 받을 곳의 포인터. 읽는 값의 크기는 datasize 매개변수로 지정한 크기입니다.

반환값

값 뜻
0 성공
-1 소프트웨어 오류

관련 참조

pdiag_pcicfg_write

영어 원문

pdiag_pcicfg_read

Purpose

Reads a PCI Configuration register.

Syntax

text
#include <sys/pdiagex_dds.h>
#include <sys/pdiag_def.h>
int32 pdiag_pcicfg_read( device_instance, reg_offset, datasize, data )
pdiag_addr_t         device_instance ;
ulong                reg_offset ;
int                  datasize ;
uchar                *data ;

Description

The pdiag_pcicfg_read() function reads 8, 16, or 32 bits of a PCI Configuration register for this particular resource. The reg_offset parameter contains the register offset into the device's PCI configuration table. The calling application must provide a valid register offset before calling pdiag_pcicfg_read. The returned data is the 8, 16, or 32 bit value read from the PCI register configuration table. All the byte swapping required is performed internally by this function; the calling application must not alter the byte positioning of the data.

Execution Environment

The pdiag_pcicfg_read() function can be called from the process environment only.

Parameters

  • device_instance — Pointer to the string name of the specific device to read.
  • reg_offset — Contains the offset within the PCI configuration table register to be read.
  • datasize — The data size will be specified as follows:
  • 8 bits — IOCHAR8
  • 16 bits — IOSHORT16
  • 32 bits — IOLONG32
  • data Pointer to the data to be read within the PCI Configuration Table. Note: The value read is the specified size on the datasize parameter.

Return Value

The pdiag_pcicfg_read function returns one of the following values:

  • 0 — Successful return
  • -1 — Software error

Related reference

“pdiag_pcicfg_write”

pdiag_pcicfg_write

목적

PCI 구성 레지스터에 씁니다.

구문

text
#include <sys/pdiagex_dds.h>
#include <sys/pdiag_def.h>
int32 pdiag_pcicfg_write( device_instance, reg_offset, datasize, data )
pdiag_addr_t         device_instance ;
ulong                reg_offset ;
int                  datasize ;
uchar                data ;

설명

pdiag_pcicfg_write() 함수는 이 자원의 PCI 구성 레지스터에 8, 16, 32비트를 씁니다. reg_offset 매개변수에는 장치의 PCI 구성 표 안 레지스터 오프셋이 들어 있으며, 테스트 단위 코드는 부를 때 올바른 오프셋을 줘야 합니다. 데이터 값은 datasize 매개변수로 지정한 크기에 따라 PCI 레지스터 구성 표에 쓸 8, 16, 32비트 값입니다. 필요한 바이트 순서 바꾸기는 모두 이 함수 안에서 하므로, 호출 응용 프로그램은 데이터의 바이트 위치를 바꾸면 안 됩니다.

실행 환경

pdiag_pcicfg_write() 함수는 프로세스 환경에서만 부를 수 있습니다.

매개변수

매개변수 설명
device_instance 쓸 장치 이름 문자열의 포인터
reg_offset 쓸 PCI 구성 표 레지스터의 오프셋
datasize 데이터 크기. 8비트는 IOCHAR8, 16비트는 IOSHORT16, 32비트는 IOLONG32
data 특정 PCI 레지스터에 쓸 값. 값의 크기는 datasize 매개변수로 지정해야 하며 IOCHAR8, IOSHORT16, IOLONG32 가운데 하나여야 합니다.

반환값

값 뜻
0 성공
-1 소프트웨어 오류

관련 참조

pdiag_pcicfg_read

영어 원문

pdiag_pcicfg_write

Purpose

Writes to a PCI Configuration register.

Syntax

text
#include <sys/pdiagex_dds.h>
#include <sys/pdiag_def.h>
int32 pdiag_pcicfg_write( device_instance, reg_offset, datasize, data )
pdiag_addr_t         device_instance ;
ulong                reg_offset ;
int                  datasize ;
uchar                data ;

Description

The pdiag_pcicfg_write() function writes 8, 16, or 32 bits to a PCI Configuration register for this particular resource. The reg_offset parameter contains the register offset into the device's PCI configuration table. The Test Unit code must provide a valid register offset when calling pdiag_pcicfg_write. The data

value is the 8, 16, or 32 bit value to be written to the PCI register configuration table depending on the data size specified in the datasize parameter. All the byte swapping required is performed internally by this function; the calling application must not alter the byte positioning of the data.

Execution Environment

The pdiag_pcicfg_write() function can be called from the process environment only.

Parameters

  • device_instance — Pointer to the string name of the specific device to write.
  • reg_offset — Contains the offset within the PCI configuration table register to be written.
  • datasize — The data size will be specified as follows:
  • 8 bits — IOCHAR8
  • 16 bits — IOSHORT16
  • 32 bits — IOLONG32
  • data Contains the value to be written to a specific PCI register. Note: The size of the value must be specified in the datasize parameter and must be IOCHAR8,

IOSHORT16, or IOLONG32.

Return Value

The pdiag_pcicfg_write function returns one of the following values:

  • 0 — Successful return
  • -1 — Software error

Related reference

“pdiag_pcicfg_read” on page 73

자주 쓰는 형태

bash
odmget -q "name=ent1" CuDv | grep status     # 4면 DIAGNOSE 상태
ls /usr/lpp/diagnostics/slih                  # 진단 SLIH
odmget PDiagRes | grep -B3 KernExt            # 커널 확장이 필요한 DA