NeXTSTEPDRIVERKIT:Chapter3 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.
Network Devices

네트워크 장치

Two classes, IONetwork and IONetbufQueue, support all drivers that directly control networking hardware.
IONetwork 과 IONetbufQueue 의 두 클래스는 네트워킹 하드웨어를 직접 제어하는 ​​모든 드라이버를 지원합니다.


The Driver Kit contains special support for Ethernet and Token Ring drivers in two IODirectDevice subclasses--IOEthernet and IOTokenRing--from which you create a subclass to build your network driver. IOEthernet and IOTokenRing implement the hardware-independent code needed to control Ethernet and Token Ring cards.
Driver Kit 에는 두 개의 IODirectDevice 하위 클래스인 IOEthernet 및 IOTokenRing 의 이더넷 및 토큰링 드라이버에 대한 특별 지원이 포함되어 있습니다. 이 하위 클래스에서 네트워크 드라이버를 빌드할 수 있습니다. IOEthernet 및 IOTokenRing 은 이더넷 및 토큰링 카드를 제어하는​​데 필요한 하드웨어 독립적인 코드를 구현합니다.


Figure 3-1 shows the network device classes relative to their superclasses.
그림 3-1 은 상위 클래스와 관련된 네트워크 장치 클래스를 보여줍니다.


See the IOEthernet and IOTokenRing class descriptions for additional information on writing Ethernet and Token Ring drivers.
이더넷 및 토큰링 드라이버 작성에 대한 추가 정보는 IOEthernet 및 IOTokenRing 클래스 설명을 참조하십시오.


/NextDeveloper/Examples/DriverKit/SMC16 contains a network driver example.
/NextDeveloper/Examples/DriverKit/SMC16 에 네트워크 드라이버에 대한 예제가 있습니다.


Figure 3-3. Classes for Network Drivers


개발 요구사항(Development Requirements)

The following hardware is required or recommended for development and support efforts:
개발 및 지원 노력을 위해 다음 하드웨어가 필요하거나 권장됩니다.

  • Two workstations with NEXTSTEP User software (mandatory--these serve as debug master and slave)
    NEXTSTEP 사용자 소프트웨어가 있는 두 대의 워크 스테이션(필수 - 디버그 마스터 및 슬레이브 역할 수행)
  • NEXTSTEP Developer software on one of the workstations
    NEXTSTEP 워크스테이션중 한곳에 설치된 개발자 소프트웨어
  • For Ethernet drivers, two supported Ethernet adapters, one of which supports NEXTSTEP kernel debugging (contact NeXT to get a list of qualifying adapters)
    이더넷 드라이버의 경우, 지원되는 두 개의 이더넷 어댑터 중 하나가 NEXTSTEP 커널 디버깅을 지원.(NeXT에 연락하여 자격을 갖춘 어댑터 목록을 얻어야 합니다)
  • Target adapter hardware
    타겟 어댑터 하드웨어
  • Networking hardware (cables, tees, terminators, transceivers, and hub) to link the two workstations
    두개의 워크스테이션을 연결하는 네트워킹 하드웨어(케이블, 티(tee), 터미네이터, 송수신기 및 허브등).
  • Network analyzer (optional, but highly recommended)
    네트워크 분석기(옵션이지만 권장)


기본 작업(Basic Operations)

A network driver needs to support these operations:
네트워크 드라이버는 이러한 작업을 지원해야합니다:

  • Instantiating and initializing a driver object
    드라이버 객체 인스턴스화 및 초기화
  • Handling interrupts and timeouts
    인터럽트 및 타임아웃 처리
  • Cold initialization
    Cold 초기화
  • Warm initialization
    Warm 초기화
  • Transmitting
    전송중
  • Receiving
    수신중


드라이버 객체 인스턴스화 및 초기화

Override IODevice's probe: method. Your probe: method should find the hardware based upon a user-configured parameter such as an ID sequence or signature. This method must validate the device description passed to probe:, failing with a diagnostic message if any values are invalid. The probe: method should allocate an instance of IOEthernet or IOTokenRing, if necessary, and invoke initFromDeviceDescription: to initialize the instance. If it finds anything invalid in the hardware or device description, it shouldn't create a driver instance and should return NO.
IODevice 의 probe: 메소드를 덮어씁니다(Override). probe: 메서드는 ID 시퀀스(ID sequence) 또는 서명(signature)과 같은 사용자 설정 매개 변수(user-configured parameter)를 기반으로 하드웨어를 찾아야 합니다. 이 메소드는 probe: 로 전달된 디바이스 설명의 유효성을 검증해야 하며, 값이 유효하지 않은 경우 진단 메시지로 실패합니다. probe: 메소드는 필요한 경우 IOEthernet 또는 IOTokenRing 의 인스턴스를 할당하고 initFromDeviceDescription: 을 호출해서 인스턴스를 초기화해야 합니다. 하드웨어 또는 장치 설명에서 잘못된것이 있으면 드라이버 인스턴스를 생성해서는 안되며 NO 를 반환해야 합니다.


인터럽트 및 타임아웃 처리

Implement interruptOccurred and timeoutOccurred. The kernel invokes interruptOccurred from the I/O thread whenever the hardware interrupts and invokes timeoutOccurred when a timeout occurs.
interruptOccurredtimeoutOccurred 를 구현하십시오. 커널은 하드웨어가 인터럽트 할 때마다 I/O 스레드에서 interruptOccurred 를 호출하고 시간 초과가 발생하면 timeoutOccurred 를 호출합니다.


Cold 초기화(Cold Initialization)

Cold initialization should perform any one-time initialization actions, such as reading the hardware address from ROM or allocating system memory for DMA buffers.
Cold 초기화는 ROM 에서 하드웨어 주소를 읽거나 DMA 버퍼에 시스템 메모리를 할당하는것과 같은 일회성 초기화 작업을 수행해야합니다.


Warm 초기화(Warm Initialization)

Implement the resetAndEnable: method to prepare the hardware and software for network activity. This method should do the following:
resetAndEnable: 메소드를 구현해서 네트워크 활동을 위한 하드웨어 및 소프트웨어를 준비하십시오. 이 메서드에서는 다음을 수행할 수 있어야 합니다:

  • Disable interrupts
    인터럽트 비활성화
  • Clear pending timeouts
    타임아웃 보류 clear
  • Initialize hardware settings and software data structures
    하드웨어 설정 및 소프트웨어 데이터 구조 초기화
  • Cache physical addresses
    물리 주소 캐시
  • Enable running by invoking setRunning:
    setRunning: 을 호출해서 실행 허용
  • Reenable interrupts if the enable parameter is YES
    enable 매개 변수(parameter)가 YES 인 경우 인터럽트를 다시 활성화


전송중(Transmitting)

Depending on what your hardware supports, choose between using a single frame or a transmit queue.
하드웨어가 지원하는 기능에 따라 단일 프레임 또는 전송 대기열 중 하나를 선택하십시오.


To transmit a frame, implement the transmit: method to follow these steps:
프레임을 전송하려면 transmit: 메소드를 구현해서 다음 단계를 수행하십시오:

  1. Queue the frame if it can't be processed immediately.
    즉시 처리 할 수 없는 경우 프레임을 대기열에 둡니다.
  2. Perform a software loopback if necessary using performLoopback:.
    필요한 경우 performLoopback: 을 사용해서 소프트웨어 루프백을 수행하십시오.
  3. Transfer the frame to the hardware.
    프레임을 하드웨어로 전송하십시오.
  4. Free the frame's network buffer; you may need to do this in an interrupt handler.
    프레임의 네트워크 버퍼를 비우십시오. 인터럽트 처리기(interrupt handler)에서 이 작업을 수행해야 할 수 있습니다.
  5. Set a timeout.
    타임아웃 지정
  6. Handle the transmit interrupt or timeout.
    전송 인터럽트 또는 타임 아웃을 처리(Handle)하십시오.
  7. Increment statistics such as number of frames sent, number of timeouts, and so on by invoking methods such as incrementOutputPackets in IONetwork.

IONetwork 에서 incrementOutputPackets 와 같은 메소드를 호출해서 전송 된 프레임 수, 시간 초과 수 등과 같은 통계를 증가시킵니다.


Warning: Never attempt to retransmit at the driver level.
Warning: 드라이버 레벨에서 절대로 재전송을 시도하지 마십시오.


수신중(Receiving)

To receive a packet, follow these steps:
패킷을 받으려면 다음 단계를 수행하십시오:

  1. Handle the receive interrupt, which indicates that a packet has been received. Incoming frames must be in a network buffer. You can allocate network buffers with nb_alloc() or use nb_alloc_wrapper() to wrap already allocated memory as a network buffer. Note that these functions can't be called at the interrupt level.
    패킷이 수신되었음을 나타내는 수신 인터럽트를 처리합니다. 들어오는 프레임은 네트워크 버퍼에 있어야 합니다. 네트워크 버퍼를 nb_alloc() 으로 할당하거나 nb_alloc_wrapper() 를 사용해서 이미 할당된 메모리를 네트워크 버퍼로 래핑할 수 있습니다. 이러한 함수는 인터럽트 수준(interrupt level)에서 호출할 수 없습니다.
  2. Check that the network buffer size is correct. You can shrink it with nb_shrink_bot() if needed.
    네트워크 버퍼 크기가 올바른지 확인하십시오. 필요한 경우 nb_shrink_bot() 을 사용하여 축소할 수 있습니다.
  3. Filter unwanted packets with isUnwantedMulticastPacket: in IOEthernet if the hardware doesn't provide filtering based on individual multicast addresses.
    하드웨어가 개별 멀티 캐스트 주소(individual multicast addresses)를 기반으로 필터링을 제공하지 않는 경우라면, 원치 않는 패킷을 IOEthernet 에서 isUnwantedMulticastPacket: 으로 필터링 하십시오.
  4. Hand off the packet to the kernel by invoking handleInputPacket:extra: in IONetwork. This automatically invokes incrementInputPackets to increment that count.
    IONetwork 에서 handleInputPacket:extra: 를 호출해서 패킷을 커널에 전달하십시오. 그러면 자동으로 incrementInputPackets 이 호출되어 해당 개수가 증가합니다.
  5. Update statistics appropriately using methods such as incrementInputErrors in IONetwork.
    IONetwork 의 incrementInputErrors 와 같은 메소드를 사용해서 통계를 적절히 업데이트 하십시오.