[AIX 진단 서브시스템 9] 진단 커널 확장 (2) PDIAGEX 인터페이스와 자료 구조
https://archive.horanglab.com/posts/aix-diag-kex-2
핵심 정리
- 장치 접근:
pdiag_dd_read/pdiag_dd_write(TU와 32비트 SLIH), 64비트 커널 SLIH는pdiag_dd_read_64/pdiag_dd_write_64(intrlev는 늘INTRKMEM). memio로 I/O·메모리·POS 공간을, count와addr_incr_flag로 반복과 주소 증가를 정합니다. - DMA:
pdiag_dd_dma_setup→ (필요하면pdiag_dd_dma_enable로 FLUSH) →pdiag_dd_dma_complete. dds의 maxmaster가 1 이상이어야 합니다. (6.1) BUS_BID에서 4KB보다 큰 DMA는pdiag_dd_big_dma_setup/complete(최대 0x8000바이트). - 인터럽트: TU는
pdiag_dd_watch_for_interrupt(handle, flag_mask, timeout)로 기다리고, SLIH는flag_word를 갱신하고sleep_flag가 TRUE면pdiag_dd_interrupt_notify(sleep_word)로 깨웁니다. (6.1)pdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode는 하드웨어 시작과 기다리기를 잠금으로 묶어 인터럽트를 놓치지 않습니다. - EEH:
pdiag_read_slot_reset(리셋 상태·EEH 지원 조회),pdiag_set_eeh_option(EEH 켜기·끄기),pdiag_set_slot_reset(슬롯 리셋),pdiag_shared_slot(같은 슬롯의 장치 찾기). 모두 RTAS 호출을 씁니다. - 자료 구조:
pdiagex_dds_t(pdiag_open 전에 초기화),pdiagex_opflags_t,dma_struct,aioo_struct_t,diag_struc_t(핸들), (6.1)kick_io_t.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (6.1에서 big DMA와 kick_hdw safe mode 함수, kick_io_t가 더해짐) |
| 원문 | Understanding the Diagnostic Subsystem for AIX — 5.3판 3장(87104쪽), 6.1판 7599쪽 |
| 헤더 | sys/pdiagex_dds.h, sys/pdiagex_sys.h, sys/pdiag_def.h, sys/dma.h, sys/intr.h |
이식 가능한 진단 커널 확장 PDIAGEX의 응용 프로그래밍 인터페이스입니다.
테스트 단위 개발자는 코드를 여러 플랫폼에 최대한 옮길 수 있도록 이 인터페이스를 써야 합니다.
(6.1) pdiag_dd_big_dma_complete
pdiag_dd_big_dma_complete() 함수는 사용자 공간 DMA 버퍼의 매핑을 풀고, 고정을 풀고, 뗍니다.
목적
사용자 공간의 큰 DMA 버퍼를 정리합니다.
구문
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_big_dma_complete( handle, daddr, operation )
pdiag_info_handle_t handle ;
pdiag_addr_t daddr ;
uint32 operation ;
설명
주의
- 지금은 버스 유형이
BUS_BID일 때만 이 호출을 쓸 수 있습니다. - 이 함수의 operation 인수는
PDIAG_DMA_MASTER여야 합니다.
pdiag_dd_big_dma_complete()는 앞선 pdiag_dd_big_dma_setup() 호출로 매핑한 영역에 대한 I/O가 끝난 뒤 불러야 합니다. 지정한 주소의 매핑을 풀려고 D_UNMAP_LIST 매크로를 씁니다.
실행 환경
프로세스 환경에서만 부를 수 있습니다.
매개변수
| 매개변수 | 설명 |
|---|---|
handle |
pdiag_open()이 돌려준 pdiag_info_handle_t 구조체를 가리킵니다. |
daddr |
앞선 pdiag_dd_big_dma_setup() 루틴이 돌려준 버스 주소 |
operation |
수행할 작업 유형. 지금은 PDIAG_DMA_MASTER여야 합니다. |
반환값
| 값 | 뜻 |
|---|---|
DGX_OK |
성공. errno는 설정하지 않습니다. |
DGX_INVALID_HANDLE |
지정한 핸들이 이미 닫혔거나 pdiag_open() 호출로 만든 것이 아님. errno는 설정하지 않습니다. |
DGX_BADVAL_FAIL |
daddr 값이 올바르지 않음. errno는 설정하지 않습니다. |
DGX_UNPINU_FAIL |
지정한 사용자 버퍼의 고정을 풀 수 없음. errno는 unpinu()의 반환 코드 |
DGX_XMDETACH_FAIL |
사용자 공간을 물리 주소에서 뗄 수 없음. errno는 xmdetach()의 반환 코드 |
관련 참조
pdiag_dd_big_dma_setup
(6.1) pdiag_dd_big_dma_setup
pdiag_dd_big_dma_setup() 함수는 DMA 작업을 위해 큰 사용자 버퍼를 초기화하고, 고정하고, 교차 메모리로 붙입니다. 크기는 DIAG_MULTIPAGESIZE(지금은 0x8000)바이트까지입니다.
목적
DMA 작업을 위해 큰 사용자 버퍼를 준비합니다.
구문
#include <sys/pdiagex_dds.h>
#include <sys/dma.h>
int32 pdiag_dd_big_dma_setup(
handle, dma_flags, baddr, users_daddr, count, minxfer,operation )
pdiag_info_handle_t handle ;
int32 dma_flags ;
pdiag_addr_t baddr ;
pdiag_addr_t users_daddr ;
uint32 count ;
uint32 minxfer ;
uint32 operation ;
설명
주의
- Micro Channel이나 60X 버스 유형 어댑터에서는 지원하지 않습니다.
- 지금은 버스 유형이
BUS_BID일 때만 쓸 수 있습니다. - operation 인수는
PDIAG_DMA_MASTER여야 합니다.
버스 유형과 작업에 따라 다음을 합니다.
- 사용자 버퍼를 교차 메모리로 붙이고, 고정하고, 장치가 DMA로 접근하도록 매핑합니다. 지금은 0x1000바이트보다 큰 전송을
DIAG_MULTIPAGESIZE(0x8000바이트)까지 허용합니다. 결과 버스 주소는 연속된 공간으로 매핑됩니다. - 지정한 주소에
d_map_list커널 호출을 냅니다. DMA 공간은 사용자 대신 관리됩니다.
이 함수를 쓰려면 다음 요구 사항을 만족해야 합니다.
pdiag_open()으로 설정한 DDS 멤버 maxmaster가 동시에 쓸pdiag_dd_dma_setup()과pdiag_dd_big_dma_setup()의 최대 수(곧 어느 때든 짝이 되는 complete보다 더 불린 setup의 최대 수)로 설정되어 있어야 합니다.DGX_BOUND_FAIL오류 없이 통과하려면 maxmaster가 적어도 1이어야 합니다.pdiag_open()으로 설정한 DDS 멤버dma_flags에DMA_CONTIGUOUS플래그가 설정되어 있어야 합니다. 이 함수는 메모리 매핑 결과로 버스 주소 하나만 돌려주며,DMA_CONTIGUOUS는 불연속 버스 메모리 영역 목록이 아니라 주소 공간 하나만 돌려달라고 요청하는 플래그입니다.
실행 환경
프로세스 환경에서만 부를 수 있습니다.
매개변수
| 매개변수 | 설명 |
|---|---|
handle |
pdiag_open()이 돌려준 pdiag_info_handle_t 구조체를 가리킵니다. |
dma_flags |
어댑터에서 사용자 메모리로 전송하면 DMA_READ, 시스템에서 어댑터로 전송하면 0. 다른 DMA 플래그는 sys/dma.h 헤더 파일을 봅니다. |
baddr |
DMA 전송이 일어날 사용자의 읽기·쓰기 버퍼를 가리킵니다. |
users_daddr |
호출이 성공하면 baddr의 버스 메모리 주소로 채울 정수를 가리킵니다. |
count |
전송할 바이트 수 |
반환값
| 값 | 뜻 |
|---|---|
DGX_OK |
성공. errno는 설정하지 않습니다. |
DGX_INVALID_HANDLE |
지정한 핸들이 이미 닫혔거나 pdiag_open() 호출로 만든 것이 아님. errno는 설정하지 않습니다. |
DGX_BOUND_FAIL |
자원 밖에 DMA를 설정하려 했거나, count가 너무 크거나, 자원을 지금 쓸 수 없거나, maxmaster가 0. errno는 설정하지 않습니다. |
DGX_BADVAL_FAIL |
지정한 daddr를 갱신할 수 없음(DMA_CONTIGUOUS 플래그를 설정하지 않은 경우 등). errno는 suword()의 반환 코드 |
DGX_PINU_FAIL |
지정한 사용자 버퍼를 고정할 수 없음. errno는 pinu()의 반환 코드 |
DGX_XMATTACH_FAIL |
사용자 버퍼를 물리 주소에 붙일 수 없음. errno는 xmattach()의 반환 코드 |
DGX_XMALLOC_FAIL |
필요한 임시 메모리를 할당할 수 없음. errno는 설정하지 않습니다. |
DGX_FAIL |
사용자 메모리를 버스 메모리 공간에 매핑할 수 없음. errno는 d_map_list() 호출의 반환 코드 |
관련 참조
pdiag_dd_big_dma_complete
(6.1) pdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode
이 함수는 하드웨어의 여러 위치에 쓰고, 원하는 수의 인터럽트가 일어나거나 시간 초과가 날 때까지 잠듭니다. 기대한 인터럽트 가운데 하나라도 그 인터럽트의 시간 안에 일어나지 않으면 시간 초과가 됩니다.
하드웨어 작업을 시작하는 일을 스레드 안전하게 하며, 어댑터 SLIH가 내는 (최대 네 번의) pdiag_dd_interrupt_notify() 호출을 이 루틴이 놓치지 않도록 보장합니다. pdiagex 내부 잠금 장치가 인터럽트를 놓치지 않게 막으며, 이 루틴이 먼저 잠금을 놓을 때까지 사용자 SLIH는 불리지 않습니다.
예전 루틴인 pdiag_dd_watch_for_interrupt()는 하드웨어 시작 작업을 다루지 않습니다. 그래서 사용자 응용 프로그램이 예전 watch 함수를 부르기 전에 하드웨어 인터럽트가 이미 일어났을 수 있습니다.
목적
하드웨어 작업을 시작하고 기대한 인터럽트를 놓치지 않고 기다립니다.
구문
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode
( handle, kick_vec_parm_p,
num_kick_records, num_intrpts_expected, flag_found_p, timeout_sec );
pdiag_info_handle_t handle ;
kick_io_t*kick_vec_parm_p;
uint32 num_kick_records;
uint32 num_intrpts_expected;
uint32 *flag_found_p;
uint32 timeout_sec;
설명
이 함수는 다음 일을 합니다.
- 하드웨어를 시작하는 데 필요한 하드웨어 쓰기 작업 표(호출자가 준
kick_io_t구조체 배열)를 복사해 옵니다. 배열 요소마다 하드웨어 작업을 시작하려고 써야 할 위치를 설명합니다. 배열 크기는 제한이 없으며num_kick_records매개변수로 넘깁니다.kick_io_t구조체는pdiagex_dds.h헤더 파일에 있습니다. - pdiagex의
intr_lock잠금을 얻습니다. flag_word변수를 지웁니다.- 복사해 온 주소, 크기, 데이터 값을 써서 하드웨어를 시작합니다.
- 사용자가 기대하는 인터럽트(
num_intrpts_expected)마다e_sleep_thread()시스템 호출을 해 SLIH가 만드는pdiag_dd_interrupt_notify()를 처리합니다. pdiagexintr_lock잠금은e_sleep_thread()동안에만 놓입니다. 잠들 때마다의 시간 초과 값은timeout_sec으로 넘깁니다. 깨어날 때마다 SLIH가 만든flag_word값을 저장합니다. - pdiagex
intr_lock잠금을 놓습니다. - 잠들 때마다 저장한
flag_word값을flag_found_p가 가리키는 사용자의 uint32 배열(uint32[4])로 복사해 냅니다.
SLIH가 pdiag_dd_interrupt_notify()를 부르면 e_sleep_thread()가 더는 막히지 않습니다. 커널은 e_sleep_thread()가 intr_lock 잠금을 먼저 다시 얻도록 보장합니다. 그래서 이 루틴이 다른 e_sleep_thread()를 시작하거나 끝나면서 잠금을 놓을 때까지 SLIH는 다시 들어오지 않습니다. pdiagex와 커널 잠금 덕분에 이 루틴이 e_sleep_thread()를 할 때마다 사용자 SLIH는 한 번만 불립니다.
잠에서 깨어나 인터럽트 상태 정보를 얻으려면 이 루틴은 응용 프로그램 인터럽트 처리기와의 상호 작용에 크게 의존합니다. 상호 작용은 handle.flag_word, handle.sleep_word, handle.sleep_flag 변수로 합니다. handle.flag_word의 비트 형식은 사용자 응용 프로그램이 정하며 uint32 형이어야 합니다.
응용 프로그램의 인터럽트 처리기는 인터럽트를 받을 때마다 handle.flag_word를 갱신해야 합니다. 또 인터럽트를 받을 때마다 handle.sleep_flag를 확인해 이 루틴이 잠들어 있는지 보고, TRUE면 handle.sleep_word를 잠자기 워드로 pdiag_dd_interrupt_notify() 서비스를 불러 이 루틴을 깨워야 합니다.
실행 환경
프로세스 환경에서 부를 수 있습니다.
매개변수
| 매개변수 | 설명 |
|---|---|
handle |
pdiag_open()이 돌려준 pdiag_info_handle_t 구조체를 가리킵니다. |
kick_vec_param_p |
사용자 공간의 kick_io_t 레코드 배열의 포인터. 하드웨어 인터럽트를 일으킬 작업을 시작하는 데 필요한 하드웨어 쓰기를 설명합니다. kick_io_t는 /usr/include/sys/pdiagex_dds.h에 정의되어 있으며 주소, 데이터, 데이터 형, I/O 공간인지 메모리 매핑 공간인지를 나타내는 uint32 항목 넷이 있습니다. |
num_kick_records |
하드웨어를 시작하는 데 필요한 쓰기 작업 수. 호출 응용 프로그램의 kick_vec_param_p 주소에서 복사해 올 kick_io_t 레코드 수입니다. |
num_intrpts_expected |
SLIH에게서 기대하는 인터럽트 통지 수. 1~PDIAGEX_MAX_WATCH_INTRPTS 범위여야 합니다. |
flag_found_p |
uint32 형 요소 PDIAGEX_MAX_WATCH_INTRPTS개인 사용자 공간 배열의 포인터. 잠들 때마다 사용자 SLIH가 설정한 flag_word 값을 복사해 냅니다. |
timeout_sec |
시간 초과 전에 인터럽트 상태를 기다릴 초. num_intrpts_expected 하나하나에 적용되며 늘 0이 아니어야 합니다. |
반환값
| 값 | 뜻 |
|---|---|
| 0 | 성공 |
| 0x80000023 | e_sleep_thread가 시간 초과. 인터럽트가 일어났다면 SLIH가 pdiag_dd_interrupt_notify()를 부르지 않은 것입니다(원문은 x80000023). |
| 0x80000024 | 인터럽트 통지를 한 번 받았지만 두 번째에서 시간 초과 |
| 0x80000025 | 인터럽트 통지를 두 번 받았지만 세 번째에서 시간 초과 |
| 0x80000026 | 인터럽트 통지를 세 번 받았지만 네 번째에서 시간 초과 |
| 0xFFFFFFFF | 시간 초과가 아닌 다른 이유로 e_sleep_thread가 실패 |
| 0x80000000 | 지정한 핸들이 이미 닫혔거나 pdiag_open() 호출로 만든 것이 아님 |
| 0x80000027 | num_intrpts_expected가 범위를 벗어남. 1, 2, 3, 4 가운데 하나여야 합니다. |
| 0x80000028 | 어댑터 작업을 시작하는 하드웨어 쓰기가 실패 |
관련 참조
pdiag_dd_dma_enable
영어 원문
Programming Interfaces for PDIAGEX
This section provides information on application programming interfaces to the Portable Diagnostic Kernel Extension PDIAGEX.
Test unit developers should use these interfaces to ensure their code has maximum portability across platforms.
pdiag_dd_big_dma_complete
The pdiag_dd_big_dma_complete() function unmaps, unpins, and detaches the user space DMA buffer.
Syntax
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_big_dma_complete( handle, daddr, operation )
pdiag_info_handle_t handle ;
pdiag_addr_t daddr ;
uint32 operation ;
Description
Attention
At this time, you can only use this call if the bus type is
BUS_BID.The operation argument to this function must be
PDIAG_DMA_MASTER.
The pdiag_dd_big_dma_complete() must be called after I/O completion involving the area mapped by the prior pdiag_dd_big_dma_setup() function call.
This function utilizes the D_UNMAP_LIST macro to unmap the specified address.
Execution Environment
The pdiag_dd_big_dma_complete() function can only be called from the process environment.
Parameters
- handle — Points to
pdiag_info_handle_tstructure, which is returned frompdiag_open(). - daddr — The bus address that was returned by the previous
pdiag_dd_big_dma_setup()routine. - operation — Type of operation to perform. Note: At this time, this must be
PDIAG_DMA_MASTER.
Return Value
The pdiag_dd_dma_complete 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 thepdiag_open()call. The errno is not set.DGX_BADVAL_FAIL— The daddr value is not valid. The errno is not set.DGX_UNPINU_FAIL— Application could not unpin the specified user buffer. The errno is set to the unpinu() return code.DGX_XMDETACH_FAIL— Application could not detach user space from the physical address. The errno is set to the xmdetach() return code.
Related reference
“pdiag_dd_big_dma_setup” The pdiag_dd_big_dma_setup() function initializes, pins, and cross-memory attaches a large user buffer for a DMA operation. The size can be up to DIAG_MULTIPAGESIZE (currently, this is 0x8000) bytes.
pdiag_dd_big_dma_setup
The pdiag_dd_big_dma_setup() function initializes, pins, and cross-memory attaches a large user buffer for a DMA operation. The size can be up to DIAG_MULTIPAGESIZE (currently, this is 0x8000) bytes.
Syntax
#include <sys/pdiagex_dds.h>
#include <sys/dma.h>
int32 pdiag_dd_big_dma_setup(
handle, dma_flags, baddr, users_daddr, count, minxfer,operation )
pdiag_info_handle_t handle ;
int32 dma_flags ;
pdiag_addr_t baddr ;
pdiag_addr_t users_daddr ;
uint32 count ;
uint32 minxfer ;
uint32 operation ;
Description
Attention
This function is not supported for Micro Channel or 60X bus type adapters.
At this time, you can only use this call if the bus type is
BUS_BID.The operation argument to this function must be
PDIAG_DMA_MASTER.
The following is performed by the pdiag_dd_big_dma_setup function depending on the bus type and operation:
The
pdiag_dd_big_dma_setup()function cross-memory attaches, pins, and maps the user buffer for DMA access by the device. The function currently allows for a transfer sizes greater than 0x1000 bytes, up toDIAG_MULTIPAGESIZE(which is 0x8000 bytes). The resulting bus addresses are mapped as a contiguous space.This function issues the
d_map_listkernel call for the specified address. The DMA space is managed for the user.
The following are requirements that must be met in order to use the pdiag_dd_big_dma_setup() function:
The device-dependant structure (DDS) member maxmaster, which was previously set with
pdiag_open(), must have been set to the maximum number of concurrentpdiag_dd_dma_setup()sandpdiag_dd_big_dma_setup()sto be used (that is, the maximum number ofpdiag_dd_dma_setup()sandpdiag_dd_big_dma_setup()scalled above the number of associatedpdiag_dd_dma_complete()sandpdiag_dd_big_dma_complete()sat any given time). maxmaster must be set to at least 1 (one) for this call to pass without aDGX_BOUND_FAILerror.The
DMA_CONTIGUOUSflag must have been set on the DDS memberdma_flags, which was previously set withpdiag_open(), This function returns only a single bus address as a result of the memory mapping operation. TheDMA_CONTIGUOUSflag is used to request that the mapping returns only a single address space, rather than a list of discontiguous bus memory regions.
Execution Environment
The diag_dd_big_dma_setup() function can be called from the process environment only.
Parameters
- handle — Points to
pdiag_info_handle_tstructure, which is returned frompdiag_open(). dma_flags— Use theDMA_READflag for transferring data from the adapter to user memory. Use 0 (zero) for transferring data from the system to the adapter. For more information on other DMA flags, see the sys/dma.h header file.- baddr — Points to the user's read or write buffer where the DMA transfer should take place.
users_daddr— Points to an integer to be filled with the bus memory address of baddr upon successful completion of this call.- count — Number of bytes to be transferred.
Return Value
The pdiag_dd_big_dma_setup 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 thepdiag_open()call. The errno is not set.DGX_BOUND_FAIL— The application tried to set up a DMA outside its resources, the count is too large, the resources are currently unavailable, or maxmaster is set to zero. The errno is not set.DGX_BADVAL_FAIL— PDIAGEX was unable to update the specified daddr. This might be because theDMA_CONTIGUOUSflag was not set as described above, or other causes. The errno is set to thesuword() return code.DGX_PINU_FAIL— The application could not pin the specified user buffer. The errno is set to thepinu() return code.DGX_XMATTACH_FAIL— The application could not attach user buffer to the physical address. The errno is set to thexmattach() return code.DGX_XMALLOC_FAIL— The function could not allocate necessary temporary memory. The errno is not set.DGX_FAIL— The user memory could not be mapped to bus memory space. The errno is set to the return code from thed_map_list()call.
Related reference
“pdiag_dd_big_dma_complete” on page 75 The pdiag_dd_big_dma_complete() function unmaps, unpins, and detaches the user space DMA buffer.
pdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode
The pdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode() function writes any number of locations in the hardware and sleeps until a desired number of interrupts occur or a timeout occurs. The timeout occurs if any of the expected interrupts does not occur within the timeout time for that interrupt.
The pdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode() function provides a thread-safe way to kick off a hardware operation and guarantees that all (up to four) expected pdiag_dd_interrupt_notify() service calls by the adapter SLIH are not missed by this routine. A pdiagex internal locking mechanism prevents interrupts from being missed. The user SLIH will not be called until this routine first releases the lock.
The pdiag_dd_watch_for_interrupt() legacy routine does not handle the hardware kick-off operation. With the legacy function, the hardware interrupt may have already occurred before the user application calls the legacy watch function.
Syntax
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode
( handle, kick_vec_parm_p,
num_kick_records, num_intrpts_expected, flag_found_p, timeout_sec );
pdiag_info_handle_t handle ;
kick_io_t*kick_vec_parm_p;
uint32 num_kick_records;
uint32 num_intrpts_expected;
uint32 *flag_found_p;
uint32 timeout_sec;
Description
The pdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode() function performs the following operations:
Copies in the caller-provided table of hardware write operations required to kick off the hardware. This table is an array of
kick_io_tstructures. Each element in the array describes a hardware location that must be written to start the hardware operation. The calling application can pass an array of any size to this routine. Thekick_io_tstructure is described in thepdiagex_dds.hheader file. The size of the array is passed in using the parameternum_kick_records.Acquires the pdiagex
intr_locklock.Clears the
flag_wordvariable.Kicks off the hardware by writing the addresses, size, and data value or values that were just copied in.
For each of the interrupts that the user expects (passed in using the
num_intrpts_expectedparameter), this function does ane_sleep_thread()system call to process eachpdiag_dd_interrupt_notify()function that the SLIH generates. The pdiagexintr_locklock is released only during thee_sleep_thread()system call. A timeout value for each sleep is passed in using thetimeout_secparameter. Theflag_wordvariable that the SLIH created is saved for each time the routine is awakened.Releases the pdiagex
intr_locklock.The values of
flag_wordvariable saved after each sleep are copied out to the user's array of type uint32 variables pointed to by theflag_found_pparameter to this routine. The array should be of type uint32[4].
If the SLIH calls pdiag_dd_interrupt_notify() function, then the e_sleep_thread() system call no longer blocks. Once the SLIH calls pdiag_dd_interrupt_notify() function, the kernel guarantees that the e_sleep_thread() system call will be first to reacquire the intr_lock lock. This means that the SLIH will not be reentered until this routine releases the lock, either starting another e_sleep_thread(), or at exit of this routine. The pdiagex and kernel locks only permit the user SLIH to be called once each time this routine does this e_sleep_thread() system call.
To be awakened from the sleep state and get interrupt condition information, this routine is highly dependent on the interaction of the application's interrupt handler. This interaction is maintained by using the handle.flag_word, handle.sleep_word, and handle.sleep_flag variables. The handle.flag_word bit format is determined by the user's application. It must be of type uint32.
The application's interrupt handler should update the handle.flag_word each time it receives an interrupt. The application's interrupt handler should also test the handle.sleep_flag each time it receives an interrupt to determine if the pdiag_dd_watch_for_interrupt() routine is sleeping. If handle.sleep_flag is TRUE, the application's interrupt handler should wake the pdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode() routine using the pdiag_dd_interrupt_notify() service with handle.sleep_word as the sleep word.
Execution Environment
The pdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode() function can be called from the process environment.
Parameters
- handle — Points to
pdiag_info_handle_tstructure, which is returned frompdiag_open(). kick_vec_param_p— Pointer to a user space array ofkick_io_trecords. These records are used to describe the hardware write or writes required to initiate an operation that should result in an interrupt caused by the hardware. Thekick_io_tis defined in the/usr/include/sys/pdiagex_dds.hheader file. It has four uint32 entries that specify the address, data, data type, and whether the register is in I/O space or memory-mapped space.num_kick_records— The number of write operations needed to kick off the hardware. This value specifies the number ofkick_io_trecords that need to be copied from the calling application at thekick_vec_param_puser address.num_intrpts_expected— Specifies the number of interrupt notifications that are expected from the SLIH. This must be in the range of 1 toPDIAGEX_MAX_WATCH_INTRPTSinterrupts.flag_found_p— Pointer to a user space array ofPDIAGEX_MAX_WATCH_INTRPTSelements of uint32 type. The routine copies out the values of theflag_wordas set by the user's SLIH, after each sleep.timeout_sec— Number of seconds to wait for the interrupt condition before timing out. This value is for each of thenum_intrpts_expected. This must always be a non-zero value.
Return Value
The pdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode() function returns one of the following values:
- 0 — The operation was successful.
- x80000023 — The
e_sleep_threadtimed out. If any interrupts occurred, the SLIH did not callpdiag_dd_interrupt_notify(). - 0x80000024 — One interrupt notification was received, but the
e_sleep_threadtimed out the second time. If another interrupt occurred, the SLIH did not callpdiag_dd_interrupt_notify(). - 0x80000025 — Two interrupt notifications were received, but the
e_sleep_threadtimed out the third time. If another interrupt occurred, the SLIH did not callpdiag_dd_interrupt_notify(). - 0x80000026 — Three interrupt notifications were received, but the
e_sleep_threadtimed out the fourth time. If another interrupt occurred, the SLIH did not callpdiag_dd_interrupt_notify(). - 0xFFFFFFFF — The
e_sleep_threadfailed for reason other than a timeout. - 0x80000000 — Specified handle has been closed or was not generated by the
pdiag_open()call. - 0x80000027 —
num_intrpts_expectedwas out of range. It must be 1, 2, 3, or 4. - 0x80000028 — The hardware write to kick off the adapter operation failed.
Related reference
“pdiag_dd_dma_enable” on page 89
pdiag_dd_watch_for_interrupt
목적
원하는 인터럽트 상태가 일어나거나, 정한 시간 안에 일어나지 않아 시간 초과가 날 때까지 잠듭니다.
구문
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_watch_for_interrupt( handle, flag_mask, timeout_sec )
pdiag_info_handle_t handle ;
uint32 flag_mask ;
uint32 timeout_sec;
설명
pdiag_dd_watch_for_interrupt()는 원하는 인터럽트 상태가 일어나거나 timeout_sec초가 지날 때까지 잠듭니다. 루틴을 부르기 전에 인터럽트 상태가 이미 일어났으면 잠들지 않고 바로 돌아옵니다. 잠에서 깨어나 인터럽트 상태 정보를 얻으려면 이 루틴은 응용 프로그램 인터럽트 처리기와의 상호 작용에 크게 의존합니다. 상호 작용은 handle.flag_word, handle.sleep_word, handle.sleep_flag로 합니다.
응용 프로그램의 인터럽트 처리기는 인터럽트를 받을 때마다 handle.flag_word를 갱신해야 합니다. handle.flag_word와 flag_mask의 형식은 응용 프로그램이 정합니다. 인터럽트 처리기는 인터럽트를 받을 때마다 handle.sleep_flag를 확인해 이 루틴이 잠들어 있는지 보고, TRUE면 handle.sleep_word를 잠자기 워드로 pdiag_dd_interrupt_notify() 서비스를 불러 이 루틴을 깨워야 합니다.
실행 환경
프로세스 환경에서 부를 수 있습니다.
매개변수
| 매개변수 | 설명 |
|---|---|
handle |
pdiag_open()이 돌려준 pdiag_info_handle_t 구조체를 가리킵니다. |
flag_mask |
32비트 플래그 마스크. handle.flag_word와 비트 AND했을 때 handle.flag_word가 원하는 인터럽트 상태를 나타낼 때만 0이 아닌 결과가 나옵니다. |
timeout_sec |
시간 초과 전에 인터럽트 상태를 지켜볼 초. 0이면 시간 초과가 없어 멈춤(hang)이 생길 수 있습니다. |
반환값
| 값 | 뜻 |
|---|---|
DGX_OK |
성공. errno는 설정하지 않습니다. |
DGX_FAIL |
timeout_sec초가 지나기 전에 인터럽트 상태가 일어나지 않음 |
DGX_INVALID_HANDLE |
지정한 핸들이 이미 닫혔거나 pdiag_open() 호출로 만든 것이 아님. errno는 설정하지 않습니다. |
영어 원문
pdiag_dd_watch_for_interrupt
Purpose
The pdiag_dd_watch_for_interrupt() function sleeps until a desired interrupt condition occurs, or a time-out occurs if the interrupt does not occur within the specified time.
Syntax
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_watch_for_interrupt( handle, flag_mask, timeout_sec )
pdiag_info_handle_t handle ;
uint32 flag_mask ;
uint32 timeout_sec;
Description
pdiag_dd_watch_for_interrupt() sleeps until a desired interrupt condition occurs or timeout_sec seconds pass. If the interrupt condition occurs before the routine is called, the function simply returns, without sleeping. To be awakened from the sleep state and get interrupt condition information, this routine is highly dependent on the interaction of the application's interrupt handler. This interaction is maintained by using the handle.flag_word, handle.sleep_word, and handle.sleep_flag.
The application's interrupt handler should update the handle.flag_word each time it receives an interrupt. The handle.flag_word and flag_mask format is determined by the application. The application's interrupt handler should also test the handle.sleep_flag each time it receives an interrupt to determine if the pdiag_dd_watch_for_interrupt() routine is sleeping. If handle.sleep_flag is TRUE, the application's interrupt handler should wake the pdiag_dd_watch_for_interrupt() routine using the pdiag_dd_interrupt_notify() service with handle.sleep_word as the sleep word.
Execution Environment
The pdiag_dd_watch_for_interrupt() function can be called from the process environment.
Parameters
- handle — Points to
pdiag_info_handle_tstructure which is returned frompdiag_open(). flag_mask— 32-bit flag mask which, when bitwise ANDed with thehandle.flag_word, produces a nonzero result only when thehandle.flag_wordidentifies the desired interrupt condition.timeout_sec— Number of seconds to watch for the interrupt condition before timing out. (A value of zero will never time-out; possible hang condition).
Return Value
The pdiag_dd_watch_for_interrupt function returns one of the following values:
DGX_OK— The operation was successful. The errno is not set.DGX_FAIL— The interrupt condition did not occur beforetimeout_secseconds passed.DGX_INVALID_HANDLE— Specified handle has been closed or was not generated by thepdiag_open()call. The errno is not set.
pdiag_dd_interrupt_notify
목적
TU 라이브러리의 인터럽트 처리 함수만 쓸 수 있으며, 기다리고 있는 pdiag_dd_watch_for_interrupt 호출에 인터럽트가 처리되었다고 알립니다.
구문
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_interrupt_notify( sleep_word )
uint32 sleep_word ;
설명
pdiag_dd_interrupt_notify()는 앞서 기다리고 있는 pdiag_dd_watch_for_interrupt 호출에 기대한 인터럽트를 받아 처리했다고 알립니다. TU 라이브러리에 든 2차 인터럽트 처리기 코드만 씁니다.
실행 환경
인터럽트 환경에서만 부를 수 있습니다.
매개변수
| 매개변수 | 설명 |
|---|---|
sleep_word |
TU가 기다리는 세마포어 핸들. 인터럽트 처리기의 매개변수로 넘어옵니다. |
반환값
| 값 | 뜻 |
|---|---|
DGX_OK |
성공. errno는 설정하지 않습니다. |
영어 원문
pdiag_dd_interrupt_notify
Purpose
The pdiag_dd_interrupt_notify() function can only be used by the interrupt handling function of the TU library. This function notifies a pending pdiag_dd_watch_for_interrupt call that an interrupt has been processed.
Syntax
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_interrupt_notify( sleep_word )
uint32 sleep_word ;
Description
pdiag_dd_interrupt_notify() is used to notify a previously pending call to pdiag_dd_watch_for_interrupt that an expected interrupt has been received and processed. This call is only used by the second-level interrupt-handler code provided in the TU library.
Execution Environment
The pdiag_dd_interrupt_notify() function can only be called from the interrupt environment.
Parameters
sleep_word— Semaphore handle that TU is waiting on, passed in as a parameter to the interrupt handler.
Return Value
The pdiag_dd_interrupt_notify function returns one of the following values:
DGX_OK— The operation was successful. The errno is not set.
pdiag_dd_write, pdiag_dd_write_64
참고: pdiag_dd_write_64는 64비트 커널에서만 씁니다.
목적
자원에 쓰기 작업을 합니다.
구문
32비트 커널의 구문:
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_write( handle, type, offset, data, flags )
pdiag_info_handle_t handle ;
uint32 type ;
uint32 offset ;
pdiag_addr_t data ;
pdiagex_opflags_t *flags ;
64비트 커널의 구문:
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_write_64( handle, type, offset, data, flags )
pdiag_info_handle_t handle ;
uint32 type ;
uint32 offset ;
pdiag_addr_t data ;
pdiagex_opflags_t *flags ;
설명
pdiag_dd_write()와 pdiag_dd_write_64() 함수는 지정한 데이터를 지정한 오프셋 주소에 씁니다. 사용자가 times 변수를 켜면 이 함수의 시간 정보도 돌려줍니다. 각 쓰기는 memio 작업과 count 매개변수에 따라 다릅니다.
| memio | count가 1일 때 |
|---|---|
PDIAG_IO_OP |
지정한 버스 I/O 오프셋 주소에 데이터를 씁니다. |
PDIAG_MEM_OP |
지정한 메모리 오프셋 주소에 데이터를 씁니다. |
PDIAG_POS_OP |
지정한 POS 오프셋 주소에 데이터를 씁니다. |
count가 1보다 크면 오프셋 주소에 지정한 횟수만큼 쓸 수 있습니다. 한 위치(오프셋 주소)에 count번 쓰거나, 오프셋 주소부터 연속된 count개 위치에 쓸 수 있습니다. 어느 경우든 쓸 데이터는 지정한 버퍼 주소부터 데이터 버퍼의 연속된 위치에서 가져옵니다.
참고: 쓸 때는 쓰기 데이터 버퍼가 적어도 count × type 크기여야 하고(버퍼 주소를 늘리지 않는 경우는 예외), 수행할 쓰기마다 올바른 데이터로 채워져 있어야 합니다. 그렇지 않으면 의미 없는 데이터가 지정한 영역에 쓰여 시험에 문제가 생길 수 있습니다.
실행 환경
pdiag_dd_write()는 프로세스나 인터럽트 환경에서, pdiag_dd_write_64()는 인터럽트 환경에서만 부를 수 있습니다.
매개변수
| 매개변수 | 설명 |
|---|---|
handle |
pdiag_open()이 돌려준 pdiag_info_handle_t 구조체를 가리킵니다. |
type |
지정한 주소에 쓰는 데이터 길이. IOCHAR8 바이트, IOSHORT16 워드, IOLONG32 long |
offset |
작업 종류에 따른 오프셋. PDIAG_IO_OP 기준 I/O 주소에서의 오프셋, PDIAG_MEM_OP 기준 메모리 주소에서의 오프셋, PDIAG_POS_OP 기준 POS 주소에서의 오프셋 |
data |
지정한 주소에 쓸 정보 블록의 포인터. 크기는 IOCHAR8이면 count(데이터를 늘리지 않으면 1), IOSHORT16이면 count×2(늘리지 않으면 2), IOLONG32이면 count×4(늘리지 않으면 4)입니다. |
flags |
flags 구조체의 멤버: memio(작업 종류: PDIAG_IO_OP I/O, PDIAG_MEM_OP 메모리, PDIAG_POS_OP I/O 구성 공간), count(접근 횟수: I/O·메모리는 작업 횟수, POS는 1로 설정), addr_incr_flag(count번 접근할 때 데이터 버퍼 주소와 오프셋 주소를 늘릴지: PDIAG_SING_LOC_ACC 둘 다 늘리지 않음, PDIAG_SING_LOC_BUF 데이터 주소는 늘리지 않고 오프셋 주소만 type만큼 늘림, PDIAG_SING_LOC_HW 데이터 주소만 type만큼 늘리고 오프셋 주소는 늘리지 않음, PDIAG_MULT_LOC_ACC 둘 다 type만큼 늘림), intrlev(호출 환경: PROCLEV 프로세스 수준, INTRKMEM 인터럽트 수준이고 데이터 버퍼가 커널 메모리에 있음. 32비트 함수는 둘 다 되지만 _64 함수는 늘 INTRKMEM) |
times |
시간 정보를 돌려줄 timestruc_t 구조체의 포인터. NULL이면 시간 정보를 돌려주지 않습니다. |
반환값
| 값 | 뜻 |
|---|---|
DGX_OK |
성공. errno는 설정하지 않습니다. |
DGX_INVALID_HANDLE |
지정한 핸들이 이미 닫혔거나 pdiag_open() 호출로 만든 것이 아님. errno는 설정하지 않습니다. |
DGX_BOUND_FAIL |
offset이 I/O 주소 범위의 너비보다 큼. errno는 설정하지 않습니다. |
DGX_BADVAL_FAIL |
type 필드가 올바르지 않음(IOCHAR8, IOSHORT16, IOLONG32가 아님). errno는 설정하지 않습니다. |
DGX_FAIL |
I/O 쓰기 접근 중 오류. errno는 BUS_PUT(L/S/C)X 매크로의 반환 코드 |
DGX_COPY_FAIL |
사용자 데이터 버퍼를 커널 메모리로(에서) 복사할 수 없음. errno는 xmemin/out이나 copyin/out의 반환 코드 |
관련 참조
pdiag_dd_read, pdiag_dd_read_64. 관련 개념: SLIH 변환에 필요한 변경(테스트 단위 64비트 이식 글)
영어 원문
pdiag_dd_write, pdiag_dd_write_64
Note: pdiag_dd_write_64 is only used in 64-bit kernel.
Purpose
The pdiag_dd_write() and the pdiag_dd_write_64() functions perform write operations on a resource.
Syntax for 32-Bit Kernel
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_write( handle, type, offset, data, flags )
pdiag_info_handle_t handle ;
uint32 type ;
uint32 offset ;
pdiag_addr_t data ;
pdiagex_opflags_t *flags ;
Syntax for 64-Bit Kernel
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_write_64( handle, type, offset, data, flags )
pdiag_info_handle_t handle ;
uint32 type ;
uint32 offset ;
pdiag_addr_t data ;
pdiagex_opflags_t *flags ;
Description
The pdiag_dd_write() and the pdiag_dd_write_64() functions write the specified data to the specified offset address. If the user enables the times variable, timing information for this function is also returned. Each write performed is dependent on the memio operation and count parameters.
PDIAG_IO_OP— If count is1, data is written to the specified bus I/O offset address.PDIAG_MEM_OP— If count is1, data is written to the specified memory offset address.PDIAG_POS_OP— If count is1, data is written to the specified POS offset address.
A specified number of write accesses to the offset address may be performed if count is greater than 1. The user may choose to write the data to one location (the offset address) count times, or write the data to count consecutive locations, starting at the offset address. In either case, the data to be written is supplied by consecutive locations of the data buffer starting at the specified buffer address.
Note: When writing data, it is imperative that the write data buffer is at least the size of count * type (unless the write data buffer address is not being incremented) and filled with valid data for each write operation to be performed. If this is not done, meaningless data is written to the designated area. This may cause problems with your testing.
Execution Environment
The pdiag_dd_write() function can be called from the process or the interrupt environment. The pdiag_dd_write_64() function can only be called from the interrupt environment.
Parameters
- handle — Points to
pdiag_info_handle_tstructure which is returned frompdiag_open(). - type — Defines the data length (byte, word or long) read from the address specified when type is IOCHAR8, IOSHORT16, and IOLONG32 respectively.
- offset — Offset value that is dependent on the type of operation being performed. It can be one of the following values:
PDIAG_IO_OPOffset from base I/O address.PDIAG_MEM_OPOffset from base memory address.PDIAG_POS_OPoffset from base POS address. - data — Pointer to a block of information to be written to the specified address. This block will be of size: count for type IOCHAR8 (1 if not incrementing data) OR count
*2for type IOSHORT16 (2 if not incrementing data) OR count*4for type IOLONG32 (4 if not incrementing data). - flags — The flags structure contains the following members:
- memio — Indication of the type of read operation to perform.
PDIAG_IO_OPFor I/O write operations.PDIAG_MEM_OPFor memory write operations.PDIAG_POS_OPFor I/O Configuration Space write operations. - count — Number of accesses to perform.
PDIAG_IO_OPNumber of write operations to be performed.PDIAG_MEM_OPNumber of times data is written.PDIAG_POS_OPCount should be set to 1. addr_incr_flag— Determines whether the data buffer address and the offset address get incremented on each of count accesses:PDIAG_SING_LOC_ACCSingle-location accesses: neither address is incremented.PDIAG_SING_LOC_BUFSingle-location access for buffer: the data address is never incremented. The address referred to by offset is incremented by type.PDIAG_SING_LOC_HWSingle-location access for hardware: the data address is incremented by type. The address referred to by offset is not incremented.PDIAG_MULT_LOC_ACCMultiple-location accesses: both addresses are incremented by type.- intrlev — Indicates which environment the calling routine is in: PROCLEV If calling from the process level. INTRKMEM If calling from the interrupt level and the data buffer is in kernel memory. Note: For the
pdiag_dd_writefunction, the intrlev parameter may be set to either PROCLEV or INTRKMEM. For thepdiag_dd_write_64function, the intrlev parameter must always be set to INTRKMEM. - times — Points to the
timestruc_tstructure which returns timing information. If times is a null pointer, no timing information will be returned back to the user.
Return Value
The pdiag_dd_write and the pdiag_dd_write_64 functions return 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 thepdiag_open()call. The errno is not set.DGX_BOUND_FAIL— offset given was larger than the width of the I/O address range. The errno is not set.DGX_BADVAL_FAIL— Type field was not valid (that is, not IOCHAR8, IOSHORT16, or IOLONG32). The errno is not set.DGX_FAIL— Error occurred during the I/O write access. The errno is set toBUS_PUT(L/S/C)Xmacro return code.DGX_COPY_FAIL— User data buffer could not be copied to or from kernel memory. The errno is set to the xmemin/out or copyin/out return code.
Related concepts
SLIH conversion required changes The following required changes must be applied to all SLIHs being ported to 64-bit kernel.
Related reference
“pdiag_dd_read, pdiag_dd_read_64”
pdiag_dd_read, pdiag_dd_read_64
참고: pdiag_dd_read_64는 64비트 커널에서만 씁니다.
목적
자원에서 읽기 작업을 합니다.
구문
32비트 커널의 구문:
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_read ( handle, type, offset, data, flags )
pdiag_info_handle_t handle ;
uint32 type ;
uint32 offset ;
pdiag_addr_t data ;
pdiagex_opflags_t *flags ;
64비트 커널의 구문:
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_read_64 ( handle, type, offset, data, flags )
pdiag_info_handle_t handle ;
uint32 type ;
uint32 offset ;
pdiag_addr_t data ;
pdiagex_opflags_t *flags ;
설명
pdiag_dd_read()와 pdiag_dd_read_64() 함수는 지정한 주소에서 데이터를 읽습니다. 사용자가 times 변수를 켜면 이 함수의 시간 정보도 돌려줍니다. 각 읽기는 memio 작업과 count 매개변수에 따라 다릅니다.
| memio | count가 1일 때 |
|---|---|
PDIAG_IO_OP |
지정한 버스 I/O 오프셋 주소에서 데이터를 읽습니다. |
PDIAG_MEM_OP |
지정한 메모리 오프셋 주소에서 데이터를 읽습니다. |
PDIAG_POS_OP |
지정한 POS 오프셋 주소에서 데이터를 읽습니다. |
count가 1보다 크면 오프셋 주소에서 지정한 횟수만큼 읽을 수 있습니다. 한 위치(오프셋 주소)에서 count번 읽거나, 오프셋 주소부터 연속된 count개 위치에서 읽을 수 있습니다. 어느 경우든 읽은 데이터는 지정한 버퍼 주소부터 데이터 버퍼에 저장됩니다.
참고: 읽을 때는 읽기 데이터 버퍼가 적어도 count × type 크기여야 합니다(버퍼 주소를 늘리지 않는 경우는 예외). 그렇지 않으면 읽기 버퍼 밖 영역에 의미 없는 데이터가 쓰여 시험에 문제가 생길 수 있습니다.
실행 환경
pdiag_dd_read()는 프로세스나 인터럽트 환경에서, pdiag_dd_read_64()는 인터럽트 환경에서만 부를 수 있습니다.
매개변수
| 매개변수 | 설명 |
|---|---|
handle |
pdiag_open()이 돌려준 pdiag_info_handle_t 구조체를 가리킵니다. |
type |
지정한 주소에서 읽는 데이터 길이. IOCHAR8 바이트, IOSHORT16 워드, IOLONG32 long |
offset |
작업 종류에 따른 오프셋. PDIAG_IO_OP 기준 I/O 주소에서의 오프셋, PDIAG_MEM_OP 기준 메모리 주소에서의 오프셋, PDIAG_POS_OP 기준 POS 주소에서의 오프셋 |
data |
지정한 주소에서 읽은 정보를 둘 주소. PDIAG_IO_OP와 PDIAG_MEM_OP는 읽은 값을 type 형식으로 data 주소에 둡니다. 데이터 버퍼가 type보다 작으면 버퍼 경계를 넘어 덮어쓰고, 크면 값이 버퍼의 위쪽 type 바이트에 놓입니다. PDIAG_POS_OP는 값이 1바이트를 차지하며, 버퍼가 1바이트보다 크면 버퍼의 위쪽 바이트에 놓입니다. |
flags |
flags 구조체의 멤버: memio(작업 종류: PDIAG_IO_OP I/O, PDIAG_MEM_OP 메모리, PDIAG_POS_OP I/O 구성 공간), count(접근 횟수: I/O·메모리는 작업 횟수, POS는 1로 설정), addr_incr_flag(count번 접근할 때 데이터 버퍼 주소와 오프셋 주소를 늘릴지: PDIAG_SING_LOC_ACC 둘 다 늘리지 않음, PDIAG_SING_LOC_BUF 데이터 주소는 늘리지 않고 오프셋 주소만 type만큼 늘림, PDIAG_SING_LOC_HW 데이터 주소만 type만큼 늘리고 오프셋 주소는 늘리지 않음, PDIAG_MULT_LOC_ACC 둘 다 type만큼 늘림), intrlev(호출 환경: PROCLEV 프로세스 수준, INTRKMEM 인터럽트 수준이고 데이터 버퍼가 커널 메모리에 있음. 32비트 함수는 둘 다 되지만 _64 함수는 늘 INTRKMEM) |
times |
시간 정보를 돌려줄 timestruc_t 구조체의 포인터. NULL이면 시간 정보를 돌려주지 않습니다. |
반환값
| 값 | 뜻 |
|---|---|
DGX_OK |
성공. errno는 설정하지 않습니다. |
DGX_INVALID_HANDLE |
지정한 핸들이 이미 닫혔거나 pdiag_open() 호출로 만든 것이 아님. errno는 설정하지 않습니다. |
DGX_BOUND_FAIL |
offset이 I/O 주소 범위의 너비보다 큼. errno는 설정하지 않습니다. |
DGX_BADVAL_FAIL |
type 필드가 올바르지 않음(IOCHAR, IOSHORT, IOLONG이 아님). errno는 설정하지 않습니다. |
DGX_FAIL |
I/O 읽기 접근 중 오류. errno는 BUS_GET(L/S/C)X 매크로의 반환 코드 |
DGX_COPY_FAIL |
사용자 데이터 버퍼를 커널 메모리로(에서) 복사할 수 없음. errno는 xmemin/out이나 copyin/out의 반환 코드 |
관련 참조
pdiag_dd_write, pdiag_dd_write_64. 관련 개념: SLIH 변환에 필요한 변경(테스트 단위 64비트 이식 글)
영어 원문
pdiag_dd_read, pdiag_dd_read_64
Note: pdiag_dd_read_64 is only used in the 64-bit kernel.
Purpose
The pdiag_dd_read() and the pdiag_dd_read_64() functions perform read operations on a resource.
Syntax for 32-Bit Kernel
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_read ( handle, type, offset, data, flags )
pdiag_info_handle_t handle ;
uint32 type ;
uint32 offset ;
pdiag_addr_t data ;
pdiagex_opflags_t *flags ;
Syntax for 64-Bit Kernel
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_read_64 ( handle, type, offset, data, flags )
pdiag_info_handle_t handle ;
uint32 type ;
uint32 offset ;
pdiag_addr_t data ;
pdiagex_opflags_t *flags ;
Description
The pdiag_dd_read() and the pdiag_dd_read_64() functions read the data from the specified address. If the user enables the times variable, timing information for this function is also returned. Each read performed is dependent on the memio operation and count parameters.
PDIAG_IO_OP— If count is 1, data is read from the specified bus I/O offset address.PDIAG_MEM_OP— If count is 1, data is read from the specified memory offset address.PDIAG_POS_OP— If count is 1, data is read from the specified POS offset address.
A specified number of read accesses from the offset address may be performed if count is greater than 1. The user may choose to read the data from one location (the offset address) count times, or read the data from count consecutive locations, starting at the offset address. In either case, the read data is stored in the data buffer starting at the specified buffer address.
Note: When reading data, it is imperative that the read data buffer is at least the size of count * type (unless the read data buffer address is not being incremented). If this is not done, meaningless data is written to an area outside the read buffer. This may cause problems with your testing.
Execution Environment
The pdiag_dd_read() function can be called from the process or the interrupt environment. The pdiag_dd_read_64() function can only be called from the interrupt environment.
Parameters
- handle — Points to
pdiag_info_handle_tstructure which is returned frompdiag_open(). - type — Defines the data length (byte, word or long) read from the address specified when type is IOCHAR8, IOSHORT16, and IOLONG32 respectively.
- offset — Offset value that is dependent on the type of operation being performed. It can be one of the following values:
PDIAG_IO_OPoffset from base I/O address.PDIAG_MEM_OPoffset from base memory address.PDIAG_POS_OPoffset from base POS address. - data — Address of the information read from the specified address. Note: For
PDIAG_IO_OPandPDIAG_MEM_OP: The value read from the specified offset will be placed at the specified data address in the form specified by type. If the data buffer is smaller than the specified type, the value will overwrite the bounds of your buffer. If the data buffer is larger than the specified type, the value will reside in the upper type bytes of the buffer. ForPDIAG_POS_OP: The value read from the specified offset will be placed at the specified data address and will occupy 1 byte. If the data buffer is larger than 1 byte, the value will reside in the upper byte of the buffer. - flags — The flags structure contains the following members:
- memio — Indication of the type of read operation to perform.
PDIAG_IO_OPFor I/O read operations.PDIAG_MEM_OPFor memory read operations..PDIAG_POS_OPFor I/O Configuration Space read operations. - count — Number of accesses to perform.
PDIAG_IO_OPNumber of read operations to be performed.PDIAG_MEM_OPNumber of times data is read.PDIAG_POS_OPCount should be set to 1. addr_incr_flag— Determines whether the data buffer address and the offset address get incremented on each of count accesses:PDIAG_SING_LOC_ACCSingle-location accesses: neither address is incremented.PDIAG_SING_LOC_BUFSingle-location access for buffer: the data address is never incremented. The address referred to by offset is incremented by type.PDIAG_SING_LOC_HWSingle-location access for hardware: the data address is incremented by type. The address referred to by offset is not incremented.PDIAG_MULT_LOC_ACCMultiple-location accesses: both addresses are incremented by type.- intrlev — Indicates which environment the calling routine is in: PROCLEV If calling from the process level INTRKMEM If calling from the interrupt level and the data buffer is in kernel memory. Note: For the
pdiag_dd_readfunction, the intrlev parameter may be set to either PROCLEV or INTRKMEM. For thepdiag_dd_read_64function, the intrlev parameter must always be set to INTRKMEM. - times — Points to the
timestruc_tstructure which returns timing information. If times is a null pointer, no timing information will be returned back to the user.
Return Value
The pdiag_dd_read and the pdiag_dd_read_64 functions return 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 thepdiag_open()call. The errno is not set.DGX_BOUND_FAIL— offset given was larger than the width of the I/O address range. The errno is not set.DGX_BADVAL_FAIL— Type field was not valid (that is, not IOCHAR, IOSHORT, or IOLONG). The errno is not set.DGX_FAIL— Error occurred during the I/O read access. The errno is set toBUS_GET(L/S/C)Xmacro return code.DGX_COPY_FAIL— User data buffer could not be copied to or from kernel memory. The errno is set to the xmemin/out or copyin/out return code.
Related concepts
SLIH conversion required changes The following required changes must be applied to all SLIHs being ported to 64-bit kernel.
Related reference
“pdiag_dd_write, pdiag_dd_write_64” on page 82
pdiag_dd_dma_setup
목적
DMA 작업을 위해 사용자 버퍼를 초기화하고, 고정하고, 교차 메모리로 붙입니다.
구문
#include <sys/pdiagex_dds.h>
#include <sys/dma.h>
int32 pdiag_dd_dma_setup
( handle, dma_flags, baddr, users_daddr, count, minxfer,operation )
pdiag_info_handle_t handle ;
int32 dma_flags ;
pdiag_addr_t baddr ;
pdiag_addr_t users_daddr ;
uint32 count ;
uint32 minxfer ;
uint32 operation ;
설명
버스 유형과 작업에 따라 다음을 합니다.
버스 유형이 BUS_MICRO_CHANNEL이나 BUS_60X이고 작업이 PDIAG_DMA_MASTER일 때
Micro Channel과 60X 버스 시스템의 DMA 마스터 기능은 사용자 버퍼를 count 길이만큼 고정하고 교차 메모리로 붙입니다. Micro Channel 버스 어댑터는 지정한 주소와 길이에 d_master 커널 호출을 냅니다. DMA 주소 공간은 대신 관리되며, DMA 버퍼 안 오프셋은 daddr 매개변수로 줍니다. 60X 버스 어댑터는 지정한 주소와 길이가 가리키는 페이지마다 xmemdma 커널 호출을 냅니다. 이 호출의 플래그는 XMEM_HIDE와 XMEM_ACC_CHK를 OR한 값입니다. DMA 주소 공간은 대신 관리되지 않으며, DMA 버퍼 안 오프셋은 daddr 매개변수로 줍니다.
참고: dds 멤버 maxmaster는 동시에 쓸 pdiag_dd_dma_setup()의 최대 수(곧 어느 때든 짝이 되는 pdiag_dd_dma_complete()보다 더 불린 setup의 최대 수)로 설정해야 합니다. DGX_BOUND_FAIL 오류 없이 통과하려면 maxmaster가 적어도 1이어야 합니다.
버스 유형이 BUS_BID이고 작업이 PDIAG_DMA_MASTER일 때
사용자 버퍼를 고정하고 교차 메모리로 붙입니다. 4KB, 곧 1페이지 전송만 허용하며 페이지 경계를 넘을 수 없습니다. 지금은 더 큰 전송을 허용하지 않습니다. 지정한 주소에 d_map_page 커널 호출을 냅니다. DMA 공간은 대신 관리되며, DMA 버퍼 안 오프셋은 users_daddr 매개변수로 줍니다.
버스 유형이 BUS_MICRO_CHANNEL이고 작업이 PDIAG_DMA_SLAVE일 때
Micro Channel의 슬레이브 작업에서는 지정한 길이에 d_slave 커널 호출을 냅니다. Micro Channel 슬레이브 DMA는 한 번에 하나만 할 수 있습니다.
참고: DGX_BOUND_FAIL 오류 없이 통과하려면 dds 멤버 maxmaster가 적어도 1이어야 합니다.
실행 환경
프로세스 환경에서만 부를 수 있습니다.
매개변수
| 매개변수 | 설명 |
|---|---|
handle |
pdiag_open()이 돌려준 pdiag_info_handle_t 구조체를 가리킵니다. |
dma_flags |
60X 버스 어댑터에서는 무시합니다. 아래는 Micro Channel 버스 어댑터에만 해당합니다. 어댑터에서 사용자 메모리로 전송하면 DMA_READ, 시스템에서 어댑터로 전송하면 0을 씁니다(다른 플래그는 sys/dma.h). pdiag_dd_dma_complete() 전에 데이터를 읽거나 고치려면 DMA_NOHIDE도 설정합니다. 명령 블록, 상태 블록, 공용 버퍼 풀처럼 통신용으로 오래 DMA 매핑을 두는 장치에 유용하며, 응용 프로그램이 읽고 쓸 때마다 complete를 부르고 다음 전송에 다시 setup할 필요가 없습니다. DMA_NOHIDE를 설정하고 complete 전에 읽으려면 pdiag_dd_dma_enable()로 flush한 뒤 읽고, 쓰려면 데이터를 고친 뒤 flush 작업으로 pdiag_dd_dma_enable()을 부릅니다. 사용자가 다루는 영역으로 어댑터가 데이터를 전송하지 않도록 해야 합니다. |
baddr |
DMA 전송이 일어날 사용자의 읽기·쓰기 버퍼를 가리킵니다. |
users_daddr |
호출이 성공하면 baddr의 물리 메모리 주소로 채울 정수를 가리킵니다. |
count |
전송할 바이트 수 |
minxfer |
장치가 다룰 최소 전송 길이(BUS_BID의 슬레이브 전송만) |
operation |
수행할 작업 유형: PDIAG_DMA_MASTER, PDIAG_DMA_SLAVE |
반환값
| 값 | 뜻 |
|---|---|
DGX_OK |
성공. errno는 설정하지 않습니다. |
DGX_INVALID_HANDLE |
지정한 핸들이 이미 닫혔거나 pdiag_open() 호출로 만든 것이 아님. errno는 설정하지 않습니다. |
DGX_BOUND_FAIL |
자원 밖에 DMA를 설정하려 했거나, 자원을 지금 쓸 수 없거나, dds 멤버 dma_bus_length(Micro Channel만)나 maxmaster가 0. errno는 설정하지 않습니다. |
DGX_BADVAL_FAIL |
지정한 daddr를 갱신할 수 없음. errno는 suword()의 반환 코드 |
DGX_PINU_FAIL |
지정한 사용자 버퍼를 고정할 수 없음. errno는 pinu()의 반환 코드 |
DGX_XMATTACH_FAIL |
사용자 버퍼를 물리 주소에 붙일 수 없음. errno는 xmattach()의 반환 코드 |
관련 참조
pdiag_dd_dma_complete, pdiag_dd_dma_enable
영어 원문
pdiag_dd_dma_setup
Purpose
The pdiag_dd_dma_setup() function initializes, pins, and cross-memory attaches the user buffer for a DMA operation.
Syntax
#include <sys/pdiagex_dds.h>
#include <sys/dma.h>
int32 pdiag_dd_dma_setup
( handle, dma_flags, baddr, users_daddr, count, minxfer,operation )
pdiag_info_handle_t handle ;
int32 dma_flags ;
pdiag_addr_t baddr ;
pdiag_addr_t users_daddr ;
uint32 count ;
uint32 minxfer ;
uint32 operation ;
Description
The following is performed by the pdiag_dd_dma_setup depending on the bus type and operation:
Where bus type = BUS_MICRO_CHANNEL or BUS_60X and operation is PDIAG_DMA_MASTER
- The DMA master function on Micro Channel and 60X bus systems pins and cross-memory attaches the user buffer for the length of count. For Micro Channel bus type adapters, the DMA master function issues the
d_masterkernel call for the specified address and length. The DMA address space is managed for you, and the offset into the DMA buffer is supplied in the daddr parameter. For 60X bus type adapters, the DMA master function issues the xmemdma kernel call for each page referred to by the specified address and length. The flags for this call will be (XMEM_HIDE|XMEM_ACC_CHK). The DMA address space is not managed for you, and the offset into the DMA buffer is supplied in the daddr parameter.
Note: The dds member, maxmaster, must be set to the maximum number of concurrent pdiag_dd_dma_setup()s to be used (that is, maximum number of pdiag_dd_dma_setup()s called above the number of associated pdiag_dd_dma_complete ()s at any given time). maxmaster must be set to at least 1 (one) for this call to pass without a DGX_BOUND_FAIL error.
Where bus type = BUS_BID and operation is PDIAG_DMA_MASTER
- The
pdiag_dd_dma_setup()function pins and cross-memory attaches the user buffer. The function allows for a transfer of 4k or 1 page. The transfer cannot cross a page boundary. Larger transfers are not allowed at this time. This function issues thed_map_pagekernel call for the specified address. The DMA space is managed for the user, and the offset into the DMA buffer is supplied in theusers_daddrparameter.
Where bus type = BUS_MICRO_CHANNEL and operation is PDIAG_DMA_SLAVE
- For slave operation on a Micro Channel, the
pdiag_dd_dma_setup()function issues thed_slavekernel call for the specified length. Only one Micro Channel slave DMA may occur at a time.
Note: The dds member, maxmaster, must be set to at least 1 (one) for this call to pass without a DGX_BOUND_FAIL error.
Execution Environment
The pdiag_dd_dma_setup() function can be called from the process environment only.
Parameters
- handle — Points to
pdiag_info_handle_tstructure which is returned frompdiag_open(). dma_flags— This flag is ignored for 60X bus type adapters. The following refers only to Micro Channel bus type adapters. Use theDMA_READflag for transferring data from the adapter to user memory. Use 0 (zero) for transferring data from the system to the adapter. See the header file sys/dma.h for more information on other DMA flags. If the user wants to read or modify data before callingpdiag_dd_dma_complete(), thenDMA_NOHIDEshould also be set. This may be useful for devices that set up long-term DMA mapping for purposes of communication (such as command blocks, status blocks, common buffer pools). Then thepdiag_dd_dma_complete()does not have to be called each time they want to let the application read/write, and thenpdiag_dd_dma_setup()again for the next DMA transfer. IfDMA_NOHIDEis set and the user wants to read data before callingpdiag_dd_dma_complete(), then call thepdiag_dd_dma_enable()routine to flush and read the data. IfDMA_NOHIDEis set and the user wants to write data before callingpdiag_dd_dma_complete(), then after the user modifies the data, call thepdiag_dd_dma_enable()routine with a flush operation. Make sure that the adapter will not be transferring data to the same area that the user is manipulating.- baddr — Points to user's read or write buffer where DMA transfer should take place.
users_daddr— Points to an integer to be filled with the physical memory address of baddr upon successful completion of this call.- count — Number of bytes to be transferred.
- minxfer — Minimum transfer length that the device will handle. (Slave transfer only on
BUS_BID). - operation — Type of operation to perform:
PDIAG_DMA_MASTERPDIAG_DMA_SLAVE
Return Value
The pdiag_dd_dma_setup 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 thepdiag_open()call. The errno is not set.DGX_BOUND_FAIL— Application tried to setup a DMA outside its resources, the resources are currently unavailable, or the dds memberdma_bus_length(Micro Channel only) or maxmaster is set to zero. The errno is not set.DGX_BADVAL_FAIL— PDIAGEX was unable to update the specified daddr. The errno is set to the suword() return code.DGX_PINU_FAIL— Application could not pin the specified user buffer. The errno is set to the pinu() 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_dd_dma_complete” “pdiag_dd_dma_enable” on page 89
pdiag_dd_dma_complete
목적
사용자 공간 DMA 버퍼의 고정을 풀고 뗍니다. 핸들의 dds.bus_type이 Micro Channel이면 d_complete() 커널 서비스도 부르며, 이 서비스는 감지된 IOCC 오류를 확인하고, IOCC 버퍼를 비우고(필요하면 숨김을 풀고), 정보가 바뀌었으면 페이지 표의 modified 비트를 설정합니다.
구문
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_dma_complete( handle, daddr, operation )
pdiag_info_handle_t handle ;
pdiag_addr_t daddr ;
uint32 operation ;
설명
버스 유형과 작업에 따라 다음을 합니다.
BUS_MICRO_CHANNEL,PDIAG_DMA_MASTER또는PDIAG_DMA_SLAVE: DMA 전송 뒤 정리합니다. 먼저 지정한 daddr로 해당pdiag_dd_dma_setup()호출에서 지정한 baddr, count,dma_flags를 찾습니다. 그다음 이 매개변수로d_complete커널 호출을 냅니다. DMA 전송에 쓴 사용자 주소 공간은 고정을 풀고, 떼고, 다른 DMA 전송에 쓸 수 있게 합니다.BUS_BID,PDIAG_DMA_MASTER: 앞선pdiag_dd_dma_setup()호출로 매핑한 영역에 대한 I/O가 끝난 뒤 불러야 합니다. 지정한 주소의 매핑을 풀려고D_UNMAP_PAGE매크로를 씁니다.BUS_BID,PDIAG_DMA_SLAVE: 앞선 setup으로 매핑한 영역에 대한 I/O가 끝난 뒤 불러야 합니다. 매핑을 풀려고D_UNMAP_SLAVE매크로를 씁니다.
실행 환경
BUS_MICRO_CHANNEL 시스템에서는 프로세스나 인터럽트 환경에서, BUS_BID 시스템에서는 프로세스 환경에서만 부를 수 있습니다.
매개변수
| 매개변수 | 설명 |
|---|---|
handle |
pdiag_open()이 돌려준 pdiag_info_handle_t 구조체를 가리킵니다. |
daddr |
사용자의 물리 DMA 주소 안 오프셋. pdiag_dd_dma_setup() 루틴이 돌려준 값입니다. DMA 슬레이브 complete에서는 0으로 설정합니다. |
operation |
수행할 작업 유형: PDIAG_DMA_MASTER, PDIAG_DMA_SLAVE |
반환값
| 값 | 뜻 |
|---|---|
DGX_OK |
성공. errno는 설정하지 않습니다. |
DGX_INVALID_HANDLE |
지정한 핸들이 이미 닫혔거나 pdiag_open() 호출로 만든 것이 아님. errno는 설정하지 않습니다. |
DGX_BADVAL_FAIL |
daddr 값이 올바르지 않음. errno는 설정하지 않습니다. |
DGX_DCOMPLETE_FAIL |
시스템 하드웨어가 감지한 DMA 오류를 받음. errno는 d_complete()의 반환 코드 |
DGX_UNPINU_FAIL |
지정한 사용자 버퍼의 고정을 풀 수 없음. errno는 unpinu()의 반환 코드 |
DGX_XMDETACH_FAIL |
사용자 공간을 물리 주소에서 뗄 수 없음. errno는 xmdetach()의 반환 코드 |
관련 참조
pdiag_dd_dma_setup, pdiag_dd_dma_enable
영어 원문
pdiag_dd_dma_complete
Purpose
The pdiag_dd_dma_complete() function unpins and detaches the user space DMA buffer. If the handle's dds.bus_type is set for the Micro Channel, this function also calls the d_complete() kernel service, which checks for detected IOCC errors, flushes the IOCC buffer (unhides it if necessary) and sets the page table 'modified' bit if the information was modified.
Syntax
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_dma_complete( handle, daddr, operation )
pdiag_info_handle_t handle ;
pdiag_addr_t daddr ;
uint32 operation ;
Description
The following is performed by the pdiag_dd_dma_complete depending on the bus type and operation:
Where bus type = BUS_MICRO_CHANNEL and operation is PDIAG_DMA_MASTER or PDIAG_DMA_SLAVE
The
pdiag_dd_dma_complete()function cleans up after the DMA transfer. First, the specified daddr is used to retrieve the baddr, count, anddma_flagsspecified in the correspondingpdiag_dd_dma_setup()calls.pdiag_dd_dma_complete()then issues thed_completekernel call using these parameters. The user address space used for the DMA transfer is then unpinned, detached, and made available for another DMA transfer. Where bus type =BUS_BIDand operation isPDIAG_DMA_MASTERThe
pdiag_dd_dma_complete()should be called after I/O completion involving the area mapped by the priorpdiag_dd_dma_setup()function call. This function utilizes theD_UNMAP_PAGEmacro to unmap the specified address. Where bus type =BUS_BIDand operation isPDIAG_DMA_SLAVEThe
pdiag_dd_dma_complete()should be called after I/O completion involving the area mapped by the priorpdiag_dd_dma_setup()function call. This function utilizes theD_UNMAP_SLAVEmacro to unmap the specified address.
Execution Environment
The pdiag_dd_dma_complete() function can be called from the process or the interrupt environment on a BUS_MICRO_CHANNEL system. The function can only be called from the process environment on a BUS_BID system.
Parameters
- handle — Points to
pdiag_info_handle_tstructure which is returned frompdiag_open(). - daddr — The offset into the user's physical DMA address. This is returned by
pdiag_dd_dma_setup() routine. For DMA slave completes, this should be set to 0. - operation — Type of operation to perform:
PDIAG_DMA_MASTERPDIAG_DMA_SLAVE
Return Value
The pdiag_dd_dma_complete 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 thepdiag_open()call. The errno is not set.DGX_BADVAL_FAIL— daddr value was not valid. The errno is not set.DGX_DCOMPLETE_FAIL— Application received a DMA error detected by the system hardware. The errno is set to thed_complete()return code.DGX_UNPINU_FAIL— Application could not unpin the specified user buffer. The errno is set to the unpinu() return code.DGX_XMDETACH_FAIL— Application could not detach user space from the physical address. The errno is set to the xmdetach() return code.
Related reference
“pdiag_dd_dma_setup” on page 86 “pdiag_dd_dma_enable”
pdiag_dd_dma_enable
목적
DMA 작업을 켜거나 끕니다. 실제 동작은 버스 유형과 요청한 작업에 따라 다릅니다.
구문
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_dma_enable( handle, daddr, operation )
pdiag_info_handle_t> handle ;
pdiag_addr_t daddr ;
uint32 operation ;
설명
BUS_MICRO_CHANNEL,PDIAG_DMA_FLUSH: 지정한 daddr로 해당pdiag_dd_dma_setup()호출에서 지정한 baddr와 count를 찾은 다음,d_cflush와d_bflush커널 루틴을 불러 각각 프로세서 캐시와 IOCC 버퍼를 비웁니다. DMA 주소 공간의 데이터를 바꾸려면 사용자 공간에서 데이터를 먼저 바꾸고PDIAG_DMA_FLUSH작업으로 이 함수를 부릅니다. DMA 주소 공간의 데이터를 읽으려면 먼저PDIAG_DMA_FLUSH로 이 함수를 부르고 사용자 공간의 데이터를 읽습니다. 이 작업은pdiag_dd_dma_setup()뒤에 DMA 영역을 보거나 바꿔야 할 때 쓰며, setup을dma_flags=DMA_NOHIDE로 불렀을 때만 동작합니다.pdiag_dd_dma_complete()전에 데이터를 읽으려 할 때만 필요합니다.BUS_MICRO_CHANNEL또는BUS_BID,PDIAG_DMA_DISABLE: 그 핸들의 DMA 채널을 끕니다.BUS_MICRO_CHANNEL또는BUS_BID,PDIAG_DMA_ENABLE: 그 핸들의 DMA 채널을 켭니다.
실행 환경
BUS_MICRO_CHANNEL 시스템에서는 프로세스나 인터럽트 환경에서, BUS_BID 시스템에서는 프로세스 환경에서만 부를 수 있습니다.
매개변수
| 매개변수 | 설명 |
|---|---|
handle |
pdiag_open()이 돌려준 pdiag_info_handle_t 구조체를 가리킵니다. |
daddr |
사용자의 물리 DMA 주소의 포인터. pdiag_dd_dma_setup() 루틴이 돌려준 값입니다. |
operation |
수행할 작업 유형: PDIAG_DMA_ENABLE, PDIAG_DMA_DISABLE, PDIAG_DMA_FLUSH |
반환값
| 값 | 뜻 |
|---|---|
DGX_OK |
성공. errno는 설정하지 않습니다. |
DGX_INVALID_HANDLE |
지정한 핸들이 이미 닫혔거나 pdiag_open() 호출로 만든 것이 아님. errno는 설정하지 않습니다. |
DGX_BADVAL_FAIL |
지정한 daddr가 올바르지 않음. errno는 설정하지 않습니다. |
DGX_FAIL |
프로세서와 I/O 컨트롤러(IOCC) 데이터 캐시 사이에 데이터를 전송할 수 없음. errno는 d_cflush나 d_bflush의 반환 코드 |
관련 참조
pdiag_dd_dma_complete, pdiag_dd_dma_setup, pdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode
영어 원문
pdiag_dd_dma_enable
Purpose
The pdiag_dd_dma_enable() function enables and disables a DMA operation. The actual function performed depends on the bus type and operation requested.
Syntax
#include <sys/pdiagex_dds.h>
int32 pdiag_dd_dma_enable( handle, daddr, operation )
pdiag_info_handle_t> handle ;
pdiag_addr_t daddr ;
uint32 operation ;
Description
Where bus type = BUS_MICRO_CHANNEL and operation is PDIAG_DMA_FLUSH
The
PDIAG_DMA_FLUSHoperation uses the specified daddr to retrieve the baddr and count specified in the correspondingpdiag_dd_dma_setup()call. Then thed_cflushandd_bflushkernel routines are called to do the processor cache and IOCC buffer flushes, respectively. If users need to change data in the DMA address space, they first change the data in their user space and then callpdiag_dd_dma_enable()with aPDIAG_DMA_FLUSHoperation. If they need to read data in the DMA address space, they first callpdiag_dd_dma_enable() with aPDIAG_DMA_FLUSHoperation, and then reads the data in the user space.The
PDIAG_DMA_FLUSHoperation flushes the processor cache and the IOCC buffer. This may be used if a user is required to look at or change the DMA area after apdiag_dd_dma_setup()routine. This routine works only ifpdiag_dd_dma_setup()is called withdma_flags=DMA_NOHIDE. This routine is required only if the user wants to read the data before doingpdiag_dd_dma_complete().
Where bus type = BUS_MICRO_CHANNEL or BUS_BID and operation is PDIAG_DMA_DISABLE
- The DMA channel for that handle is disabled.
Where bus type = BUS_MICRO_CHANNEL or BUS_BID and operation is PDIAG_DMA_ENABLE
- The DMA channel for that handle is enabled.
Execution Environment
The pdiag_dd_dma_enable() function can be called from the process or the interrupt environment on a BUS_MICRO_CHANNEL system. The function can only be called from the process environment on a BUS_BID system.
Parameters
- handle — Points to
pdiag_info_handle_tstructure which is returned frompdiag_open(). - daddr — Pointer to the user's physical DMA address. This is returned by
pdiag_dd_dma_setup()routine. - operation — Type of operation to perform:
PDIAG_DMA_ENABLEPDIAG_DMA_DISABLEPDIAG_DMA_FLUSH
Return Value
The pdiag_dd_dma_enable 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 thepdiag_open()call. The errno is not set.DGX_BADVAL_FAIL— Specified daddr is not valid. The errno is not set.DGX_FAIL— Application could not transfer data between the processor and the I/O controller (IOCC) data caches. The errno is set to thed_cflushord_bflushreturn code.
Related reference
“pdiag_dd_dma_complete” on page 88 “pdiag_dd_dma_setup” on page 86 “pdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode” on page 78 The pdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode() function writes any number of locations in the hardware and sleeps until a desired number of interrupts occur or a timeout occurs. The timeout occurs if any of the expected interrupts does not occur within the timeout time for that interrupt.
pdiag_shared_slot
목적
요청한 장치와 슬롯을 공유하는 모든 장치를 찾습니다.
구문
#include <sys/pdiag_def.h>
int32 pdiag_shared_slot (char *device_instance)
설명
pdiag_shared_slot 서브루틴은 장치의 형제를 찾은 다음 어느 형제가 같은 슬롯에 있는지 알아내려 합니다. 경우에 따라 실제보다 많은 장치가 슬롯을 공유한다고 돌려줄 수 있습니다. 목록 맨 앞에는 늘 그 장치 인스턴스를 두며, 슬롯을 공유하는 다른 장치가 없으면 장치 인스턴스의 포인터를 돌려줍니다.
참고: 이 서브루틴은 available 상태와 defined 상태의 어댑터를 모두 돌려줍니다. 어떤 어댑터가 시스템에서 빠졌는지 판단하는 것은 호출 응용 프로그램의 책임입니다.
매개변수
| 매개변수 | 설명 |
|---|---|
device_instance |
시험할 장치 이름 |
반환값
| 값 | 뜻 |
|---|---|
| 이중 연결 리스트 머리의 포인터 | 성공. device_instance가 목록 맨 앞에 있습니다. |
| NULL | 형제를 찾거나 ODM에서 데이터를 가져오다 오류가 남 |
관련 참조
pdiag_set_eeh_option, pdiag_read_slot_reset
영어 원문
pdiag_shared_slot
Purpose
Finds all devices that share a slot with the requested device.
Syntax
#include <sys/pdiag_def.h>
int32 pdiag_shared_slot (char *device_instance)
Description
The pdiag_shared_slot subroutine finds the siblings of a device and then attempts to determine which siblings are on the same slot. Under some circumstances this function may return more devices sharing a slot than physically exist. This function will always return the device instance at the front of the list, if there are no other devices sharing the slot, the function will return a pointer to the device instance.
Note: This subroutine function will return adapters that are in available and in defined state. It is the responsibility of the calling application to determine if any of the adapters have been removed from the system.
Parameters
device_instance— Name of device under test.
Return Value
The pdiag_shared_slot subroutine returns one of the following values:
- A pointer to the head of a doubly-linked
list Successful return. Note: The device_instance lies at the front of the list. NULL An error occurred while finding siblings or retrieving data from the ODM.
Related reference
“pdiag_set_eeh_option” on page 93 “pdiag_read_slot_reset” on page 92
pdiag_read_slot_reset
목적
I/O 어댑터로 가는 물리 리셋 신호의 상태와 EEH 슬롯의 능력을 조회합니다.
구문
#include <sys/pdiagex_dds.h>
#include <sys/pdiag_def.h>
int32 pdiag_read_slot_reset( char *device_instance, int32 operation_type )
설명
pdiag_read_slot_reset 서브루틴은 RTAS(Run-Time Abstraction Services) 호출을 내 I/O 어댑터로 가는 물리 리셋 신호의 상태와 EEH 슬롯의 능력을 조회합니다.
매개변수
| 매개변수 | 설명 |
|---|---|
device_instance |
시험할 장치 이름 |
operation_type |
수행할 기능. 0: 리셋 상태 조회(Query Reset State). 슬롯 리셋이 켜졌는지 꺼졌는지, I/O 어댑터가 멈춤(stopped) 상태인지 돌려줍니다. 1: 슬롯 능력 조회(Query Slot Capabilities). EEH를 지원하는지 돌려줍니다. |
반환값
리셋 상태 조회의 반환값:
| 값 | 뜻 |
|---|---|
| -2 | 소프트웨어 오류 |
| -1 | 하드웨어 오류 |
| 0 | 리셋이 꺼져 있고 I/O 어댑터가 EEH 멈춤 상태가 아님 |
| 1 | 리셋이 켜져 있고 I/O 어댑터가 EEH 멈춤 상태가 아님 |
| 2 | I/O 어댑터가 EEH 멈춤 상태이고, 리셋 신호는 꺼져 있으며, Load/Store 경로가 막혀 있음 |
| 3 | I/O 어댑터가 EEH 멈춤 상태이고, 리셋 신호는 꺼져 있으며, Load/Store 경로가 열려 있음 |
| 4 | I/O 어댑터를 영구적으로 쓸 수 없음 |
슬롯 능력 조회의 반환값:
| 값 | 뜻 |
|---|---|
| -2 | 소프트웨어 오류 |
| -1 | 하드웨어 오류 |
| 0 | EEH를 지원하지 않음 |
| 1 | EEH를 지원함 |
관련 참조
pdiag_set_slot_reset, pdiag_set_eeh_option, pdiag_shared_slot
영어 원문
pdiag_read_slot_reset
Purpose
Queries the state of the physical reset signal to the I/O Adapter and the Enhanced Error Handling (EEH) slot's capabilities.
Syntax
#include <sys/pdiagex_dds.h>
#include <sys/pdiag_def.h>
int32 pdiag_read_slot_reset( char *device_instance, int32 operation_type )
Description
The pdiag_read_slot_reset subroutine issues a Run-Time Abstraction service (RTAS) call to query the state of the physical reset signal to the I/O Adapter and the EEH slot's capability.
Parameters
device_instance— Name of the device under test.operation_type— Integer indicating the function to be performed. 0: Query Reset State This option returns the slot reset state, indicating if the slot reset is activated or deactivated, and if the I/O adapter is in stopped state or not. 1: Query Slot Capabilities This option returns the EEH I/O Adapter capabilities, indicating if EEH is supported or not.
Return Value
The pdiag_read_slot_reset subroutine returns one of the following values for the Query Reset State operation:
- -2 — Software error
- -1 — Hardware error
- 0 — Reset deactivated and I/O Adapter is not in the EEH stopped state.
- 1 — Reset activated and I/O Adapter is not in the EEH stopped state.
- 2 — I/O Adapter is in the EEH stopped state with the reset signal deactivated and the Load/Store Path is disabled.
- 3 — I/O Adapter is in the EEH stopped state with the reset signal deactivated and the Load/Store Path is enabled.
- 4 — I/O Adapter is permanently unavailable.
The pdiag_read_slot_reset subroutine returns one of the following values for the Query Slot Capabilities operation:
- -2 — Software error.
- -1 — Hardware error.
- 0 — EEH not supported.
- 1 — EEH supported.
Related reference
“pdiag_set_slot_reset” on page 93 “pdiag_set_eeh_option” on page 93
“pdiag_shared_slot” on page 91
pdiag_set_eeh_option
목적
EEH 옵션을 지원하는 시스템에서 I/O 어댑터의 EEH 옵션을 켜거나 끕니다.
구문
#include <sys/pdiagex_dds.h>
#include <sys/pdiag_def.h>
int32 pdiag_set_eeh_option( char *device_instance, int32 operation_type )
설명
pdiag_set_eeh_option 서브루틴은 RTAS 호출을 내 I/O 어댑터의 EEH 옵션을 켜거나 끕니다.
매개변수
| 매개변수 | 설명 |
|---|---|
device_instance |
시험할 장치 이름 |
operation_type |
수행할 기능. 0: EEH 옵션 끄기(고른 I/O 어댑터의 freeze 기능을 끔). 1: EEH 옵션 켜기(freeze 기능을 켬). EEH 기능을 지원하지 않으면 오류를 보고합니다. |
반환값
| 값 | 뜻 |
|---|---|
| -2 | 소프트웨어 오류 |
| -1 | 하드웨어 오류 |
| 0 | 성공 |
관련 참조
pdiag_read_slot_reset, pdiag_set_slot_reset, pdiag_shared_slot
영어 원문
pdiag_set_eeh_option
Purpose
Enables and disables the Enhanced Error Handling (EEH) option for an I/O Adapter, for systems supporting the EEH option.
Syntax
#include <sys/pdiagex_dds.h>
#include <sys/pdiag_def.h>
int32 pdiag_set_eeh_option( char *device_instance, int32 operation_type )
Description
The pdiag_set_eeh_option subroutine issues Run-Time Abstraction Services (RTAS) calls to enable and disable the EEH option for an I/O Adapter.
Parameters
device_instance— Name of the device under test.operation_type— Integer indicating the function to be performed. Supported operations: 0: Disable EEH option: This operation disables the EEH option for the selected I/O Adapter (freeze function is disabled). An error is reported if the EEH function is not supported. 1: Enable EEH option: This operation enables the EEH option for the selected I/O Adapter (freeze function enabled). An error is reported if the EEH function is not supported.
Return Value
The pdiag_set_eeh_option subroutine returns one of the following values:
- -2 — A software error occurred.
- -1 — A hardware error occurred.
- 0 — The operation was successful.
Related reference
“pdiag_read_slot_reset” on page 92 “pdiag_set_slot_reset” “pdiag_shared_slot” on page 91
pdiag_set_slot_reset
목적
EEH 옵션을 지원하는 시스템에서 I/O 어댑터로 가는 물리 리셋 신호를 켜고 끕니다.
구문
#include <sys/pdiagex_dds.h>
#include <sys/pdiag_def.h>
int32 pdiag_set_slot_reset( char *device_instance )
설명
pdiag_set_slot_reset 서브루틴은 RTAS 호출을 내 I/O 어댑터로 가는 슬롯별 물리 리셋 신호선을 켰다 꺼서 PCI 슬롯 하나를 리셋합니다. 필요한 시간 매개변수(예: PCI 버스의 리셋 신호를 최소 100밀리초 켜 두는 것)는 모두 이 서브루틴이 처리합니다.
매개변수
| 매개변수 | 설명 |
|---|---|
device_instance |
시험할 장치 이름 |
반환값
| 값 | 뜻 |
|---|---|
| -2 | 소프트웨어 오류 |
| -1 | 하드웨어 오류 |
| 0 | 성공 |
관련 참조
pdiag_read_slot_reset, pdiag_set_eeh_option
영어 원문
pdiag_set_slot_reset
Purpose
Activates and deactivates the physical reset signal to the I/O adapter for systems supporting the Enhanced Error Handling (EEH) option.
Syntax
#include <sys/pdiagex_dds.h>
#include <sys/pdiag_def.h>
int32 pdiag_set_slot_reset( char *device_instance )
Description
The pdiag_set_slot_reset subroutine resets a single PCI slot by activating and deactivating the slot specific physical reset signal line to the I/O adapter by issuing a Run-Time Abstraction Service (RTAS) call. All required timing parameters will be handled by this subroutine (such as the 100 millisecond minimum reset signal active time for PCI bus).
Parameters
device_instance— Name of the device under test.
Return Value
The pdiag_set_slot_reset subroutine returns one of the following values:
- -2 — A software error occurred.
- -1 — A hardware error occurred.
- 0 — The operation was successful.
Related reference
“pdiag_read_slot_reset” on page 92 “pdiag_set_eeh_option” on page 93
데이터 사전
진단 커널 확장 PDIAGEX가 쓰는 자료 구조와 커널 서비스입니다.
- PDIAGEX 자료 구조
- 커널 서비스
- 프로그램 I/O(PIO) 서비스
영어 원문
Data dictionary
This section provides information on the data structures and kernel services used by the Diagnostic Kernel Extension PDIAGEX.
PDIAGEX Data Structures
Kernel Services
Programmed I/O Services
PDIAGEX 자료 구조
PDIAGEX가 쓰는 자료 구조를 설명합니다.
영어 원문
PDIAGEX data structures
This section describes the data structures used by PDIAGEX.
pdiagex_dds_t
pdiagex_dds_t 구조체는 PDIAGEX의 장치 드라이버 구조(dds)를 정의합니다. pdiag_open()을 부르기 전에 자원의 속성으로 초기화해야 합니다. /usr/include/sys/pdiagex_dds.h에 정의되어 있으며 다음 필드가 있습니다.
/*----------------------------------------------------------------------*/
/* PDIAGEX_DDS_T
/* This structure MUST be filled in by the Calling Application (TU)
/* This structure is passed to pdiagex in the pdiag_open() routine
/*----------------------------------------------------------------------*/
typedef struct {
uint32 slot_num; /* slot number of adapter
/* BUS DATA */
uint32 bus_id; /* Identifies the I/O bus that the DMA
/* channel is to be allocated on.
uint32 bus_type; /* BUS_MICRO_CHANNEL, BUS_60X or BUS_BID
uint32 bus_io_addr; /* Base address of Bus I/O area
uint32 bus_io_length; /* Length (width) of Bus I/O area
uint32 bus_mem_addr; /* Base address of Shared Bus Memory area
uint32 bus_mem_length; /* Length (width) of Shared Bus Memory area
/* DMA /
/* Next three are for BUS_MICRO_CHANNEL devices only */
uint32 dma_bus_mem; /* Base address of Bus Memory DMA area
uint32 dma_bus_length; /* Length (multiple of PAGESIZE) of BUS
/* Memory DMA area in bytes.
uint32 dma_lvl; /* Bus arbitration level
uint32 maxmaster; /* maximum number of concurrent
/* dma_master calls
uint32 dma_flags; /* DMA flags as defined in sys/dma.h.
/* These flags describe what actions to
/* take ( master/slave, initialize the
/* channel, etc. Not used by 60X type devices)
/* dma_bus_flags is for BUS_BID devices only */
uint32 dma_bus_flags; /* Bus flags specific for DMA operation
uint32 dma_chan_id; /* For BUS_MICRO_CHANNEL
/* Dma channel ID is returned as a result
/* of the DMA initialization.
/* For BUS_BID
/* Dma channel ID is the assigned DMA
/* channel for the device.
/* For BUS_60X
/* Dma channel ID is not used
/* Interrupt Handler */
pdiag_addr_t data_ptr; /* Pointer for passing data to interrupt
uint32 d_count; /* Count of bytes of data for interrupt
uint32 bus_intr_lvl; /* Interrupt level
uint32 intr_priority; /* Interrupt priority
uint32 intr_flags; /* Interrupt flags as defined in intr.h
/* Attribute Expansion Area */
pdiag_addr_t attributes; /* Pointer to specific attributes
}pdiagex_dds_t;
영어 원문
pdiagex_dds_t
The pdiagex_dds_t structure defines the device driver structure (dds) for PDIAGEX. The pdiagex_dds_t structure must be initialized with attributes for the resource before calling pdiag_open(). The pdiagex_dds_t structure is defined in /usr/include/sys/pdiagex_dds.h and contains the following fields:
(46줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
pdiagex_opflags_t
pdiagex_opflags_t 구조체는 쓸 장치 작업을 정의합니다. /usr/include/sys/pdiagex_dds.h에 정의되어 있으며 다음과 같습니다.
/*----------------------------------------------------------------------*/
/* PDIAGEX_OPFLAGS_T
/* This structure MUST be filled in by the Calling Application (TU)
/* This structure is used for Read and Write Operations
/*----------------------------------------------------------------------*/
typedef struct {
uint32 memio; /* Type of Memory Operation
/*PDIAG_MEM_OP,PDIAG_IO_OP,PDIAG_POS_OP
uint32 count; /* Number of accesses to perform
uint32 addr_incr_flag; /* Flag that determines whether the data
/* buffer address and/or the offset
/* address gets incremented on each of
/* count accesses.
/* PDIAG_SING_LOC_ACC or
/* PDIAG_SING_LOC_HW or
/* PDIAG_SING_LOC_BUF or
/* PDIAG_MULT_LOC_ACC
uint32 intr_level; /* Indicates which environment the
/* calling application is in.
/* PROCLEV or INTRKMEM or INTRPMEM
struct timestruc_t *times; /* Address of times structure, NULL if
/* not used.
} pdiagex_opflags_t;
영어 원문
pdiagex_opflags_t
The pdiagex_opflags_t structure defines the device operations to be used. The pdiagex_opflags_t structure is defined in /usr/include/sys/pdiagex_dds.h and consists of the following:
(23줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
dma_struct
dma_struct 구조체는 PDIAGEX가 쓰는 DMA 구조를 정의합니다. /usr/include/sys/pdiagex_sys.h에 정의되어 있으며 다음 필드가 있습니다.
typedef struct dmast {
struct dmast *next;
int firsttcw;
/* first TCW used (micro channel only) */
int last_tcw;
/* last TCW used (micro channel only) */
int dma_flags;
/* see /usr/include/sys/dma.h */
uchar *baddr;
/* address of the host buffer to DMA to/from */
uchar *daddr;
/*Phys addr in DMAbus_mem, from
diag_dma_master()*/
uint count;
/* size of the DMA data in bytes */
struct xmem dp;
/* Cross Memory descriptor of baddr */
char pinned;
/* NonZero if DMA buffer was pinned */
char xmattached;
/* NonZero if DMA buffer was CrossMemAttached */
char in_use;
/* TRUE if this linked list member is valid */
} dma_info_t;
| 필드 | 설명 |
|---|---|
next |
'in_use' 목록의 다음 dma_info_t 구조체 포인터 |
firsttcw |
(Micro Channel 장치만) 진행 중인 DMA 마스터·슬레이브 작업이 쓰는 pdiagex_dds_t.dma_bus_mem의 첫 페이지 |
last_tcw |
(Micro Channel 장치만) 진행 중인 DMA 마스터·슬레이브 작업이 쓰는 pdiagex_dds_t.dma_bus_mem의 마지막 페이지 |
dma_flags |
<sys/dma.h>에 정의된 DMA 플래그. 마스터·슬레이브 전송, DMA 채널 초기화 등 할 동작을 나타냅니다. |
*baddr |
전송할 메모리 버퍼의 주소 |
*daddr |
DMA 마스터를 프로그래밍하는 데 쓰는 주소 |
count |
DMA 전송 크기(바이트) |
dp |
교차 메모리 서술자의 주소 |
pinned |
DMA 버퍼를 고정했으면 0이 아님 |
xmattached |
DMA 버퍼를 교차 메모리로 붙였으면 0이 아님 |
in_use |
DMA 버퍼가 전송에 올바른지 판단하는 플래그 |
영어 원문
dma_struct
The dma_struct structure defines the DMA structure used by PDIAGEX. The dma_struct structure is defined in /usr/include/sys/pdiagex_sys.h and contains the following fields:
(24줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
- next — Pointer to the next
dma_info_tstructure in an 'in_use' list. - firsttcw — (Micro Channel devices Only) first page of
pdiagex_dds_t.dma_bus_memused by an active DMA master/slave operation. last_tcw— (Micro Channel devices Only) last page ofpdiagex_dds_t.dma_bus_memused by an active DMA master/slave operation.dma_flags— DMA flags as defined in<sys/dma.h>. These flags describe what actions to take (such as, master/slave transfer, initialize the DMA channel, and so on).*baddr— Address of memory buffer for transfer.*daddr— Address used to program the DMA master.- count — Size (in bytes) of the DMA transfer.
- dp — Address of cross-memory descriptor.
- pinned — Nonzero if DMA buffer was pinned.
- xmattached — Nonzero if DMA buffer was cross-memory attached.
in_use— Flag for determining if DMA buffer is valid for transfer.
aioo_struct_t
AIOO_STRUCT_T 구조체는 핸들마다의 할당(Allocation), 초기화(Initialization), 진행 중인 작업(Outstanding Operation)을 정의합니다. 오류 복구 정리, 닫을 때 진행 중인 작업 정리, 응용 프로그램으로부터의 일반적인 보호를 위한 장치이며, 정리 작업에 공통 코드를 쓸 수도 있습니다.
/* Allocation/Initialization/OutstandingOperations Binary Flags Structure */
typedef struct {
uint AllocIntrptDataMem : 1;
uint AllocDmaAreaMem : 1;
uint CopyDDS : 1;
uint CopyIntrptEnt : 1;
uint PinIntrptFunct : 1;
uint PinUIntrptData : 1;
uint PinDiagExt : 1;
uint InitIntrptChan : 1;
uint InitDmaChan : 1;
uint XmatUIntrptData : 1;
} aioo_struct_t;
| 필드 | 설명 |
|---|---|
AllocIntrptDataMem |
인터럽트 데이터 영역을 할당했으면 0이 아님 |
AllocDmaAreaMem |
DMA 데이터 영역을 할당했으면 0이 아님 |
CopyDDS |
DDS 데이터를 핸들로 복사했으면 0이 아님 |
CopyIntrptEnt |
인터럽트 함수가 커널에 있었으면 0이 아님 |
PinIntrptFunct |
인터럽트 함수를 고정했으면 0이 아님 |
PinUIntrptData |
인터럽트 데이터 영역을 고정했으면 0이 아님 |
PinDiagExt |
PDIAGEX 확장을 고정했으면 0이 아님 |
InitIntrptChan |
인터럽트 채널을 초기화했으면 0이 아님 |
InitDmaChan |
DMA 채널을 초기화했으면 0이 아님 |
XmatUIntrptData |
인터럽트 데이터 영역을 교차 메모리로 붙였으면 0이 아님 |
영어 원문
aioo_struct_t
The AIOO_STRUCT_T structure defines the allocations, initializations, and outstanding operations for each handle. This provides a mechanism for error-recovery cleanup, cleanup of outstanding operations during a close, and general protection from the application. Common code may also be used for cleanup operations.
(13줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
- AllocIntrptDataMem — Nonzero if Interrupt data area allocated.
- AllocDmaAreaMem — Nonzero if DMA data area allocated.
- CopyDDS — Nonzero if DDS data was copied to handle.
- CopyIntrptEnt — Nonzero if Intrpt function was in Kernel.
- PinIntrptFunct — Nonzero if Intrpt function was pinned.
- PinUIntrptData — Nonzero if Intrpt data area was pinned.
- PinDiagExt — Nonzero if Pinned PDIAGEX Extension.
- InitIntrptChan — Nonzero if Intrpt channel was initialized.
- InitDmaChan — Nonzero if DMA channel was initialized.
- XmatUIntrptData — Nonzero if Intrpt data area was XMattached.
diag_struc_t
diag_struc_t 구조체는 pdiag_open() 호출이 핸들로 돌려주는 전체 자료 구조를 정의합니다. 다른 모든 PDIAGEX 함수 호출에 필요한 정보를 모두 담습니다.
typedef struct handl {
struct intr intr;
struct handl *next;
int (*intr_func)();
uchar *intr_data;>
struct xmem udata_dp;
diagex_dds_t dds;
struct timestruc_t itime;
struct timestruc_t ntime;
dma_info_t *dma_info;
aioo_struct_t aioo;
char *scratch_pad;
uint sleep_flag;
uint sleep_word;
uint flag_word;
struct watchdog wdt;
struct d_handle * dhandle;
dma_dio * dio_st;
uint timeout;
} diag_struc_t;
| 필드 | 설명 |
|---|---|
intr |
<sys/intr.h>에 정의된 인터럽트 처리기 구조체. diag_struc_t의 첫 매개변수여야 합니다. |
(*intr_func)() |
사용자 인터럽트 처리기의 포인터 |
*intr_data |
인터럽트 데이터의 포인터 |
udata_dp |
인터럽트 데이터의 교차 메모리 서술자 주소 |
dds |
PDIAGEX의 장치 드라이버 구조(dds) 정보를 담은 구조체(위의 pdiagex_dds_t 참고) |
itime |
인터럽트에 걸린 시간. 인터럽트 때 갱신합니다. |
ntime |
읽기·쓰기 작업에 걸린 시간. 읽기·쓰기 때 갱신합니다. |
*dma_info |
여러 DMA 작업을 가능하게 하는 dma_info_t 구조체의 포인터(위 참고) |
aioo |
할당, 초기화, 진행 중인 작업의 플래그 묶음 |
scratch_pad |
큰 전송을 위한 PIO 임시 영역 |
sleep_flag |
pdiag_dd_watch_for_interrupt()가 잠들어 응용 프로그램의 인터럽트 처리기가 pdiag_dd_interrupt_notify()를 부르기를 기다리면 TRUE로 설정합니다. 처음에는 FALSE이며, 깨어난 뒤 다시 FALSE가 됩니다. 응용 프로그램의 인터럽트 처리기는 이 값으로 pdiag_dd_watch_for_interrupt()를 깨울지 판단하며, 바꾸면 안 됩니다. |
sleep_word |
응용 프로그램의 인터럽트 처리기가 이 워드로 pdiag_dd_interrupt_notify()를 부를 때까지 pdiag_dd_watch_for_interrupt()가 이 워드에서 잠듭니다. 인터럽트 처리기가 바꾸면 안 됩니다. |
flag_word |
응용 프로그램이 정의하며, 응용 프로그램의 인터럽트 처리기가 특정 인터럽트 상태를 나타내도록 설정합니다. 응용 프로그램은 flag_mask를 지정해 pdiag_dd_watch_for_interrupt()를 부르며, 이 값과 비트 AND한 결과가 0이 아니고 함수가 깨어 있으면 돌아옵니다. |
wdt |
시간 초과 기능에 쓰는 워치독 타이머 |
dhandle |
pdiag_open() 함수에서 부르는 D_MAP_INIT 매크로가 돌려주는 구조체. rspc 유형 시스템에 DMA 작업을 낼 때 씁니다. |
dio_st |
DMA 작업에 쓰는 DIO 구조체의 포인터 |
timeout |
워치독 타이머가 만료되면 TRUE |
영어 원문
diag_struc_t
The diag_struc_t structure defines the complete data structure returned in the handle for the pdiag_open() call. This structure holds all the needed information for all the other PDIAGEX function calls.
(20줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
- intr — Interrupt handler structure as defined in
<sys/intr.h>. Needs to be first parameter indiag_struc_t. - (
*intr_func)() — Pointer to user's interrupt handler. *intr_data— Pointer to interrupt data.udata_dp— Address of cross-memory descriptor for interrupt data.- dds — Structure that contains the device driver structure (dds) information for PDIAGEX. See the
diagex_ddsstructure defined above. - itime — Time elapsed for interrupts. Updated at interrupts.
- ntime — Time elapsed for read or write operations. Updated at reads or writes.
*dma_info— Pointer todma_info_tstructure which allows multiple DMA operations. See thedma_info_tstructure defined above.- aioo — Set of flags for Allocations, Initializations, and Outstanding Operations.
scratch_pad— PIO scratch pad for large transfers.sleep_flag—pdiag_dd_watch_for_interrupt()sets this flag to TRUE if it is sleeping and waiting for the application's interrupt handler to callpdiag_dd_interrupt_notify(). This flag is initialized to FALSE and will be set to FALSE afterpdiag_dd_watch_for_interrupt()wakes up. >The application's interrupt handler should use this word to determine whether to 'wakeup'pdiag_dd_watch_for_interrupt(). This flag should not be modified by the application's interrupt handler.sleep_word—pdiag_dd_watch_for_interrupt()sleeps on this word until the application's interrupt handler callspdiag_dd_interrupt_notify()using this word. This word should not be modified by the application's interrupt handler.flag_word— This flag is defined by the application and should be set by the application's interrupt handler to specify certain interrupt conditions. The application may callpdiag_dd_watch_for_interrupt(), specifying aflag_maskwhich will be bitwise ANDed with thisflag_word. When this AND operation produces a nonzero result andpdiag_dd_watch_for_interrupt()is awake,pdiag_dd_watch_for_interrupt()will return.- wdt — This is the watchdog timer used by the timeout function.
- dhandle — Structure returned by
D_MAP_INITmacro which is called in thepdiag_open()function. This handle is used to issue DMA operations to rspc type systems. dio_st— Pointer to a DIO structure used in DMA operations.- timeout — True if watchdog timer expired.
(6.1) kick_io_t
kick_io_t는 하드웨어 시작(kick) I/O 작업 정보를 pdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode() 호출에 넘기는 데 씁니다.
typedef struct
{
uint32 kick_type; /* Size of the transfer.
* Use IOCHAR8, IOSHORT16, or IOLONG32.
*/
uint32 memio; /* Indicates IO or memory map space.
* Must be PDIAG_IO_OP or PDIAG_MEM_OP.
*/
uint32 offset; /* Offset in bytes from card base address.
*/
uint32 data; /* Right justified data to write.
* If IOCHAR8, then use 000000XX,
* if IOSHORT16, then use 0000XXXX,
* if IOLONG32, then use XXXXXXXX.
*/
} kick_io_t;
영어 원문
kick_io_t
kick_io_t is used to pass kick I/O operation information to
thepdiag_dd_kick_hdw_and_watch_for_interrupts_safe_mode() call.
(16줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
커널 서비스
PDIAGEX가 쓰는 커널 서비스입니다.
| 서비스 | 설명 |
|---|---|
copyin |
사용자 메모리와 커널 메모리 사이에 데이터를 복사합니다. |
copyout |
커널 메모리에서 사용자 메모리로 데이터를 복사합니다. |
curtime |
현재 시각을 timestruc_t 구조체로 읽습니다. |
d_bflush |
메모리 일관성이 없는 플랫폼에서 TCE 버스 주소 매개변수로 지정한 I/O 컨트롤러 캐시(IOCC)를 비웁니다. |
d_cflush |
메모리 일관성이 없는 플랫폼에서 프로세서 데이터 캐시를 비우고 IOCC 버퍼에 미리 가져온 데이터를 무효화합니다. |
e_sleep |
프로세스를 잠재웁니다. |
e_wakeup |
잠든 프로세스를 깨웁니다. |
i_clear |
인터럽트 처리기를 지웁니다. |
i_disable |
인터럽트 우선순위를 끕니다. |
i_enable |
인터럽트 우선순위를 켭니다. |
i_init |
인터럽트 처리기를 정의합니다. |
io_att |
현재 주소 공간에 I/O 접근용 영역을 고르고, 할당하고, 매핑합니다. |
io_det |
현재 주소 공간의 주어진 주소 영역의 매핑을 풀고 해제합니다. |
kmod_entrypt |
커널 모듈 진입점의 함수 포인터를 돌려줍니다. |
pincode |
객체 파일에 연결된 코드와 데이터를 고정합니다. |
pinu |
사용자나 시스템 메모리의 지정한 주소 범위를 고정합니다. |
unpincode |
객체 파일에 연결된 코드와 데이터의 고정을 풉니다. |
unpinu |
사용자나 시스템 메모리의 지정한 주소 범위의 고정을 풉니다. |
xmalloc |
메모리를 할당합니다. |
xmattach |
교차 메모리 작업을 위해 사용자 버퍼에 붙습니다. |
xmdetach |
교차 메모리 작업에 쓴 사용자 버퍼에서 뗍니다. |
xmemdma |
메모리 한 페이지를 DMA용으로 준비합니다(BUS_60X에서만). |
xmemin |
교차 메모리로 붙인 버퍼에서 커널 공간으로 데이터를 복사합니다. |
xmemout |
커널 공간에서 교차 메모리로 붙인 버퍼로 데이터를 복사합니다. |
xmfree |
할당한 메모리를 해제합니다. |
영어 원문
Kernel services
The following is a list of Kernel Services used by PDIAGEX.
- copyin — Copies data between user and kernel memory.
- copyout — Copies data from kernel to user memory.
- curtime — Read the current time into
timestruc_tstructure. d_bflush— Flushes the appropriate I/O controller cache (IOCC), identified by the TCE bus address parameter, on memory-inconsistent platforms.d_cflush— Flushes the processor data cache and invalidates any prefetched data that may be in the IOCC buffers on memory-inconsistent platforms.e_sleep— Causes process to sleep.e_wakeup— Wakes up sleeping process.i_clear— Removes an interrupt handler.i_disable— Disables interrupt priorities.i_enable— Enables interrupt priorities.i_init— Defines an interrupt handler.io_att— Selects, allocates, and maps a region in the current address space for I/O access.io_det— Unmaps and deallocates the region in the current address space at the given address.kmod_entrypt— Returns a function pointer to a kernel module's entry point.- pincode — Pins the code and data associated with an object file.
- pinu — Pins the specified address range in user or system memory.
- unpincode — Unpins the code and data associated with an object file.
- unpinu — Unpins the specified address range in user or system memory.
- xmalloc — Allocates memory.
- xmattach — Attaches to a user buffer for cross-memory operations.
- xmdetach — Detaches from a user buffer used for cross-memory operations.
- xmemdma — Prepares a page of memory for DMA (used with
BUS_60Xonly). - xmemin — Copies data to kernel space from a cross-memory attached buffer.
- xmemout — Copies data from kernel space to a cross-memory attached buffer.
- xmfree — Frees allocated memory.
프로그램 I/O 서비스
PDIAGEX가 쓰는 프로그램 I/O(PIO) 매크로입니다.
| 매크로 | 설명 |
|---|---|
BUS_GETCX |
지정한 버스 메모리, 버스 I/O, POS 주소에서 문자 값을 읽습니다(예외 처리 내장). |
BUS_GETLX |
지정한 주소에서 long 값을 읽습니다(예외 처리 내장). |
BUS_GETSX |
지정한 주소에서 short 값을 읽습니다(예외 처리 내장). |
BUS_PUTCX |
지정한 버스 메모리, 버스 I/O, POS 주소에 문자 값을 씁니다(예외 처리 내장). |
BUS_PUTLX |
지정한 주소에 long 값을 씁니다(예외 처리 내장). |
BUS_PUTSX |
지정한 주소에 short 값을 씁니다(예외 처리 내장). |
64비트 PDIAGEX가 쓰는 PIO 매크로는 다음과 같습니다.
| 매크로 | 설명 |
|---|---|
BUS_GETSTR |
지정한 버스 메모리에서 문자 값을 읽습니다. |
BUSIO_GETSTR |
지정한 버스 I/O에서 문자 값을 읽습니다. |
BUS_GETS |
지정한 버스 메모리에서 short 값을 읽습니다. |
BUSIO_GETS |
지정한 버스 I/O에서 short 값을 읽습니다. |
BUS_GETL |
지정한 버스 메모리에서 long(32비트) 값을 읽습니다. |
BUSIO_GETL |
지정한 버스 I/O에서 long(32비트) 값을 읽습니다. |
BUS_PUTSTR |
지정한 버스 메모리에 문자 값을 씁니다. |
BUSIO_PUTSTR |
지정한 버스 I/O에 문자 값을 씁니다. |
BUS_PUTS |
지정한 버스 메모리에 short 값을 씁니다. |
BUSIO_PUTS |
지정한 버스 I/O에 short 값을 씁니다. |
BUS_PUTL |
지정한 버스 메모리에 long(32비트) 값을 씁니다. |
BUSIO_PUTL |
지정한 버스 I/O에 long(32비트) 값을 씁니다. |
영어 원문
Programmed I/O services
The following is a list of Programmed I/O (PIO) macros used by PDIAGEX.
BUS_GETCX— Reads the specified character value from the supplied bus memory, bus I/O, or POS address with built-in exception catching.BUS_GETLX— Reads the specified long value from the supplied bus memory, bus I/O, or POS address with built-in exception catching.BUS_GETSX— Reads the specified short value from the supplied bus memory, bus I/O, or POS address with built-in exception catching.BUS_PUTCX— Writes the specified character value to the supplied bus memory, bus I/O, or POS address with built-in exception catching.BUS_PUTLX— Writes the specified long value to the supplied bus memory, bus I/O, or POS address with built-in exception catching.BUS_PUTSX— Writes the specified short value to the supplied bus memory, bus I/O, or POS address with built-in exception catching.
The following is a list of Programmed I/O (PIO) macros used by the 64 bit PDIAGEX.
BUS_GETSTR— Reads the specified character value from the supplied bus memory.BUSIO_GETSTR— Reads the specified character value from the supplied bus I/O.BUS_GETS— Reads the specified short value from the supplied bus memory.BUSIO_GETS— Reads the specified short value from the supplied bus I/O.BUS_GETL— Reads the specified long (32 bits) value from the supplied bus memory.BUSIO_GETL— Reads the specified long (32 bits) value from the supplied bus I/O.BUS_PUTSTR— Writes the specified character value to the supplied bus memory.BUSIO_PUTSTR— Writes the specified character value to the supplied bus I/O.BUS_PUTS— Writes the specified short value to the supplied bus memory.BUSIO_PUTS— Writes the specified short value to the supplied bus I/O.BUS_PUTL— Writes the specified long (32 bits) value to the supplied bus memory.BUSIO_PUTL— Writes the specified long (32 bits) value to the supplied bus I/O.
관련 글: 진단 커널 확장 (1), 응용 프로그램 테스트 단위, 진단 라이브러리 (1)