NeXTSTEPDRIVERKIT:Chapter2 4

From 흡혈양파의 번역工房
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Interfacing with the Driver

드라이버와의 인터페이싱(Interfacing with the Driver)

Drivers export a set of methods that the kernel or programs can use to communicate with the driver. These exported or interface methods communicate requests to the I/O thread.
드라이버는 커널 또는 프로그램이 드라이버와 통신하는데 사용할 수 있는 일련의 메소드를 내보냅니다(export). 이렇게 내보내진(exported) 또는 인터페이스 메서드는 I/O 스레드에 요청을 전달합니다.


You don't need to be concerned about the interface to your driver in most cases. The kernel will find your driver and use its exported methods automatically—you don't have to do anything. Most display, network, SCSI controller, and sound drivers are integrated into the system this way.
대부분의 경우 드라이버와의 인터페이스에 대해 걱정할 필요는 없습니다. 커널은 드라이버를 찾아서 내보낸 메소드(exported method)를 자동으로 사용하게 되기 때문에 아무 것도 할 필요가 없습니다. 대부분의 디스플레이, 네트워크, SCSI 컨트롤러 및 사운드 드라이버는 이러한 방식으로 시스템에 통합되어 있습니다.


For some drivers, such as SCSI peripherals, you may need to provide an interface that user-level programs or other drivers can access. This interface program then invokes the driver's exported methods.
SCSI 주변 장치와 같은 일부 드라이버의 경우에는, 사용자 수준 프로그램이나 다른 드라이버가 액세스 할 수있는 인터페이스를 제공해야 할 수도 있습니다. 이 인터페이스 프로그램은 드라이버의 내보내는 메소드(exported methods)를 호출합니다.


The ideal interface between user-level programs and drivers would be Objective C messages. Currently, this direct interface isn't possible for these reasons:
사용자 수준 프로그램과 드라이버 사이의 이상적인 인터페이스는 Objective C 메시지입니다. 하지만 현재 이러한 직접적인 인터페이스는 다음의 이유로 사용할 수 없습니다.

  • User-level drivers aren't supported.
    사용자 수준 드라이버는 지원되지 않습니다.
  • The Distributed Objects system (which enables Objective C messages to be sent between objects in separate tasks) doesn't work in the kernel.
    분산 객체 시스템(Objective C 메시지를 객체간에 별도의 작업으로 전송할 수 있게 함)은 커널에서 작동하지 않습니다.


You can make your driver's user level to kernel level API more object-oriented by providing user-level classes that cover your driver's interface. For example, Sound Kit objects such as NXSoundOut hide the sound driver's private Mach message interface.
드라이버의 인터페이스를 다루는 사용자 수준의 클래스를 제공하면, 커널 레벨 API에 대한 드라이버의 사용자 수준을 보다 객체 지향적으로 만들 수 있습니다. 예를 들어, NXSoundOut 과 같은 Sound Kit 객체는 사운드 드라이버의 개인 Mach 메시지 인터페이스를 감추고 있습니다.


This section discusses ways you can communicate with the driver if you need to.
이 절에서는 필요한 경우 드라이버와 통신할 수있는 방법에 대해 설명합니다.


진입 지점(Entry Points)

If you need to provide an interface, you may want to provide a set of entry points for common driver requests, such as read, write, and so on. Your driver may have UNIX-style or Mach message-based entry points.
인터페이스를 제공해야하는 경우에 읽기, 쓰기 등과 같은 일반적인 드라이버 요청에 대한 진입 저점 세트를 제공 할 수 있습니다. 드라이버에 UNIX 스타일 또는 Mach 메시지 기반 진입 지점이 있을 수 있습니다.


UNIX-style 진입 지점

You can add a set of UNIX-style entry point functions, such as open(2) and read(2), to the cdevsw table for character drivers by invoking the IODevice class method addToCdevswFromDescription:open:close:read:write:ioctl:stop:reset:select:m map:getc:putc:. A similar method adds entry points to the bdevsw table for block drivers. These methods search for free locations in these tables. The entry point functions added can then communicate with your driver by sending it Objective C messages or Mach messages. See Chapter 2, "Using Mach Messages" in NEXTSTEP Operating System Software.
IODevice 클래스 메소드인 addToCdevswFromDescription:open:close:read:write:ioctl:stop:reset:select:m map:getc:putc: 를 호출해서 open(2) 및 read(2) 와 같은 UNIX 스타일 진입 지점 함수 세트를, 문자 드라이버(character drivers)의 cdevsw 테이블에 추가 할 수 있습니다. 비슷한 방법으로 블록 드라이버(block drivers)에 대한 bdevsw 테이블에 진입 지점을 추가할 수도 있습니다. 이 메소드는 대상 테이블에서 사용 가능한 위치를 검색합니다. 추가된 엔트리 포인트 함수는 Objective C 메시지, 또는 Mach 메시지를 보내서 드라이버와 통신할 수 있습니다. NEXTSTEP Operating System Software 의 2 장, "Using Mach Messages" 을 참조하시기 바랍니다.


Note: Mach messages are not the same kind of messages as Objective C messages sent to objects. See the references on the Mach operating system and Objective C language in the "Suggested Reading" section of the Appendix.
Note: Mach 메시지는 Objective C 메시지가 객체에 전송 된 것같은 종류의 메시지가 아닙니다. 부록의 "Suggested Reading" 섹션에서 Mach 운영 체제 및 Objective C 언어에 대한 참조를 참조하십시오.


Your driver can retrieve or set the driver's character major device number with characterMajor or setCharacterMajor. Similarly, blockMajor or setBlockMajor retrieves or sets the driver's block major device number.
드라이버는 characterMajor 또는 setCharacterMajor 로 드라이버의 문자 주요 장치 번호(character major device number)를 검색하거나 설정할 수 있습니다. 마찬가지로 blockMajor 또는 setBlockMajor 는 드라이버의 블록 주요 장치 번호를 가져 오거나 설정합니다.


UNIX entry points are documented in books about UNIX device drivers. See "Suggested Reading" in the Appendix for more information about UNIX device drivers.
UNIX 엔트리 포인트는 UNIX 장치 드라이버에 대한 책에서 설명합니다. UNIX 장치 드라이버에 대한 자세한 내용은 부록의 "Suggested Reading" 을 참조하시기 바랍니다.[1]


Mach 메시지를 통한 진입 지점(Entry Points via Mach Messages)

You can develop a message-based driver interface based on Mach messages. You can create a loadable kernel server and communicate with it using Mach messages. Use the Mach Interface Generator (MiG) to create this message interface. (MiG generates remote procedure calls that handle the Mach messaging for you.) The loadable kernel server can then send Objective C or Mach messages to the driver, just as UNIX entry point routines can do.
Mach 메시지를 기반으로, 메시지 기반 드라이버 인터페이스를 개발할 수 있습니다. 로드 가능한 커널 서버를 생성하고 Mach 메시지를 사용해서 커널 서버와 통신 할 수 있습니다. Mach Interface Generator (MiG)를 사용하여이 메시지 인터페이스를 생성하십시오. (MiG는 당신을 위해 Mach 메시지를 처리하는 원격 프로시저 호출을 생성합니다.) 로드 가능한 커널 서버는 UNIX 진입 지점 루틴이 할 수 있는 것처럼, Objective C 또는 Mach 메시지를 드라이버에 보낼 수 있습니다.


For more information, refer to NEXTSTEP Operating System Software, Chapter 2, "Using Mach Messages" and Part 2, "Writing Loadable Kernel Servers."
자세한 내용은 NEXTSTEP Operating System Software, 2 장, "Using Mach Messages" 및 2 부, "Writing Loadable Kernel Servers"을 참조하십시오.


기타 통신 방법(Other Communication Methods)

You can provide other ways to interface with your driver besides entry points.
진입 지점점 외에도 운전자와 인터페이스 할 수있는 다른 방법을 제공 할 수 있습니다.


Using IODeviceMaster

An IODeviceMaster object can get the object number of a device driver using one of the lookUp... methods such as lookUpByDeviceName:objectNumber:deviceKind:. Then it can get or set parameters via methods such as getCharValues:forParameter:objectNumber:count: or setCharValues:forParameter:objectNumber:count:. Manipulating parameters enables applications to control the driver. It also allows telling preloaded programs which major device numbers are used.
IODeviceMaster 객체는 lookUpByDeviceName:objectNumber:deviceKind: 와 같은 lookUp... 메서드 중 하나를 사용해서 장치 드라이버의 객체 번호를 가져올 수 있습니다. 그 다음에 getCharValues:forParameter:objectNumber:count: 또는 setCharValues:forParameter:objectNumber:count: 같은 메소드를 통해 매개 변수를 가져(get) 오거나 설정(set)할 수 있습니다. 매개변수를 조작(Manipulating parameters)하면 응용 프로그램이 드라이버를 제어할 수 있습니다. 또한 주요 장치 번호가 사용되는 사전에 로드 된 프로그램을 알릴(telling) 수 있습니다.


You can also send driver-specific commands and send and receive small amounts of data. Since IODeviceMaster's buffers are small, the performance overhead would be prohibitive to handle large amounts of data. Although any process can use IODeviceMaster to get information from a driver, IODeviceMaster allows only the superuser to send information to a driver. This mechanism replaces the UNIX ioctl() interface.
드라이버 관련 명령을 보내고 소량의 데이터를 송수신할 수도 있습니다. IODeviceMaster 의 버퍼가 작기 때문에 대용량 데이터를 처리하는 경우라면 성능에 대한 오버 헤드를 피할수 없습니다. 모든 프로세스는 IODeviceMaster 를 사용하여 드라이버에서 정보를 얻을 수는 있지만 IODeviceMaster 는 오직 수퍼 유저만 이 정보를 드라이버로 보낼 수 있습니다. 이 메커니즘은 UNIX 의 ioctl() 인터페이스를 대체합니다.


IODevice 메소드 사용하기

If the amount of data you need to transfer to and from your driver is relatively small, you can use the getIntValues/setIntValues or the getCharValues/setCharValues methods in IODevice to communicate with user-level applications. Using those methods is easier than using Mach messages.
드라이버끼리 주고받는 데이터 양이 상대적으로 적다면, IODevice 의 getIntValues​/setIntValues ​​메서드 또는 getCharValues​/setCharValues ​​메서드를 사용해서 사용자 수준 응용 프로그램과 통신할 수 있습니다. 이러한 방법을 사용하는 것은 Mach 메시지를 사용하는 것보다 쉽습니다.


Notes