⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cds.txt

📁 嵌入式系统设计与实例开发实验教材二源码 多线程应用程序设计 串行端口程序设计 AD接口实验 CAN总线通信实验 GPS通信实验 Linux内核移植与编译实验 IC卡读写实验 SD驱动使
💻 TXT
📖 第 1 页 / 共 3 页
字号:
available in the sense area dev_id->ii.sense. No device sensing by the devicedriver itself is required.typedef struct {   unsigned char res[32];       /* reserved   */   unsigned char data[32];      /* sense data */} sense_t;The device interrupt handler can use the following definitions to investigatethe primary unit check source coded in sense byte 0 :SNS0_CMD_REJECT         0x80SNS0_INTERVENTION_REQ   0x40SNS0_BUS_OUT_CHECK      0x20SNS0_EQUIPMENT_CHECK    0x10SNS0_DATA_CHECK         0x08SNS0_OVERRUN            0x04Depending on the device status, multiple of those values may be set together.Please refer to the device specific documentation for details.The devi_id->cstat field provides the (accumulated) subchannel status :SCHN_STAT_PCI            - program controlled interruptSCHN_STAT_INCORR_LEN     - incorrect lengthSCHN_STAT_PROG_CHECK     - program checkSCHN_STAT_PROT_CHECK     - protection checkSCHN_STAT_CHN_DATA_CHK   - channel data checkSCHN_STAT_CHN_CTRL_CHK   - channel control checkSCHN_STAT_INTF_CTRL_CHK  - interface control checkSCHN_STAT_CHAIN_CHECK    - chaining checkThe dev_id->dstat field provides the (accumulated) device status :DEV_STAT_ATTENTION   - attentionDEV_STAT_STAT_MOD    - status modifierDEV_STAT_CU_END      - control unit endDEV_STAT_BUSY        - busyDEV_STAT_CHN_END     - channel endDEV_STAT_DEV_END     - device endDEV_STAT_UNIT_CHECK  - unit checkDEV_STAT_UNIT_EXCEP  - unit exceptionPlease see the ESA/390 Principles of Operation manual for details on theindividual flag meanings.In rare error situations the device driver may require access to the originalhardware interrupt data beyond the scope of above mentioned infromation. Forthose situations the Linux/390 common device support provides the interruptresponse block (IRB) as part of the device status block in dev_id->ii.irb.Usage Notes :Prior to call do_IO() the device driver mustassure disabled state, i.e. the I/O mask value in the PSW must be disabled.This can be accomplished by calling __save_flags( flags). The current PSWflags are preserved and can be restored by __restore_flags( flags) at alater time.If the device driver violates this rule while running in a uni-processorenvironment an interrupt might be presented prior to the do_IO() routinereturning to the device driver main path. In this case we will end in adeadlock situation as the interrupt handler will try to obtain the irqlock the device driver still owns (see below) !the driver must assure to hold the device specific lock. This can beaccomplished by(i)  s390irq_spin_lock( irq), or(ii) s390irq_spin_lock_irqsave(irq, flags)Option (i) should be used if the calling routine is running disabled forI/O interrupts (see above) already. Option (ii) obtains the device gate undputs the CPU into I/O disabled state by preserving the current PSW flags.See the descriptions of s390irq_spin_lock() or s390irq_spin_lock_irqsave()for more details.The device driver is allowed to issue the next do_IO() call from within itsinterrupt handler already. It is not required to schedule a bottom-half,unless an non deterministicly long running error recovery procedure orsimilar needs to be scheduled. During I/O processing the Linux/390 genericI/O device driver support has already obtained the IRQ lock, i.e. the handlermust not try to obtain it again when calling do_IO() or we end in a deadlocksituation ! Anyway, the device driver's interrupt handler must only calldo_IO() if the handler itself can be entered recursively if do_IO() e.g. findsa status pending and needs to all the interrupt handler itself.Device drivers shouldn't heavily rely on DOIO_WAIT_FOR_INTERRUPT synchronousI/O request processing. All I/O devices, but the console device are drivenusing a single shared interrupt subclass (ISC). For sync. processing thedevice is temporarily mapped to a special ISC while the calling CPU waits forI/O completion. As this special ISC is gated, all sync. requests in a SMPenvironment are serialized which may cause other CPUs to spin. This serviceis therewith primarily meant to be used during device driver initializationfor ease of device setup.The lpm input parameter might be used for multipath devices shared amongmultiple systems as the Linux/390 CDS isn't grouping channel paths. Thereforeits use might be required if multiple access paths to a device are availableand the device was reserved by means of a reserve device command (for devicessupporting this technique). When issuing this command the device driver needsneeds to extract the dev_id->lpum value and restrict all subsequent channelprograms to this channel path until the device is released by a device releasecommand. Otherwise a deadlock may occur.If a device driver relies on an I/O request to be completed prior to start thenext it can reduce I/O processing overhead by chaining a NoOp I/O commandCCW_CMD_NOOP to the end of the submitted CCW chain. This will force Channel-Endand Device-End status to be presented together, with a single interrupt.However, this should be used with care as it implies the channel will remainbusy, not being able to process I/O requests for other devices on the samechannel. Therefore e.g. read commands should never use this technique, as theresult will be presented by a single interrupt anyway.In order to minimize I/O overhead, a device driver should use theDOIO_REPORT_ALL  only if the device can report intermediate interruptinformation prior to device-end the device driver urgently relies on. In thiscase all I/O interruptions are presented to the device driver until finalstatus is recognized.If a device is able to recover from asynchronosly presented I/O errors, it canperform overlapping I/O using the DOIO_EARLY_NOTIFICATION flag. While somedevices always report channel-end and device-end together, with a singleinterrupt, others present primary status (channel-end) when the channel isready for the next I/O request and secondary status (device-end) when the datatransmission has been completed at the device.Above flag allows to exploit this feature, e.g. for communication devices thatcan handle lost data on the network to allow for enhanced I/O processing.Unless the channel subsystem at any time presents a secondary status interrupt,exploiting this feature will cause only primary status interrups to bepresented to the device driver while overlapping I/O is performed. When asecondary status without error (alert status) is presented, this indicatessuccessful completion for all overlapping do_IO() requests that have beenissued since the last secondary (final) status.During interrupt processing the device specific interrupt handler should avoidbasing its processing decisions on the interruption response block (IRB) thatis part of the dev_id buffer area. The IRB area represents the interruptionparameters from the last interrupt received. Unless the device driver hasspecified DOIO_REPORT_ALL or is called with a pending status(DEVSTAT_STATUS_PENDING), the IRB information may or may not show the completeinterruption status, but the last interrupt only. Therefore the device drivershould usually base its processing decisions on the values of dev_id->cstatand dev_id->dstat that represent the accumulated subchannel and device statusinformation gathered since do_IO() request initiation.halt_IO() - Halt I/O Request ProcessingSometimes a device driver might need a possibility to stop the processing ofa long-running channel program or the device might require to initially issuea halt subchannel (HSCH) I/O command. For those purposes the halt_IO() commandis provided.int halt_IO( int          irq,     /* subchannel number */             int          intparm, /* dummy intparm */             unsigned int flag);   /* operation mode */irq     : irq (subchannel) the halt operation is requested forintparm : interruption parameter; value is only used if no I/O          is outstanding, otherwise the intparm associated with          the I/O request is returnedflag    : 0 (zero) or DOIO_WAIT_FOR_INTERRUPTThe halt_IO() function returns :      0 - successful completion or request successfully initiated-EBUSY  - the device is currently performing a synchronous I/O          operation : do_IO() with flag DOIO_WAIT_FOR_INTERRUPT          or an error was encountered and the device is currently          be sensed-ENODEV - the irq specified doesn't specify a valid subchannel, the          device is not operational (check dev_id.flags) or the irq          is not owned.Usage Notes :A device driver may write a never-ending channel program by writing a channelprogram that at its end loops back to its beginning by means of a transfer inchannel (TIC)   command (CCW_CMD_TIC). Usually this is performed by networkdevice drivers by setting the PCI CCW flag (CCW_FLAG_PCI). Once this CCW isexecuted a program controlled interrupt (PCI) is generated. The device drivercan then perform an appropriate action. Prior to interrupt of an outstandingread to a network device (with or   without PCI flag) a halt_IO() is requiredto end the pending operation.We don't allow to stop sync. I/O requests by means of a halt_IO() call. Thefunction will return -EBUSY instead.Miscellaneous Support RoutinesThis chapter describes various routines to be used in a Linux/390 devicedriver programming environment.s390irq_spin_lock() / s390irq_spin_unlock()Those two macro definitions are required to obtain the device specific IRQlock. The lock needs to be obtained if the device driver intends to calldo_IO() or halt_IO() from anywhere but the device interrupt handler (wherethe lock is already owned). Those routines must only be used if runningdisabled for interrupts already. Otherwise use s390irq_spin_lock_irqsave()and the corresponding unlock routine instead (see below).s390irq_spin_lock( int irq);s390irq_spin_unlock( int irq);s390irq_spin_lock_irqsave() / s390_irq_spin_unlock_irqrestore()Those two macro definitions are required to obtain the device specific IRQlock. The lock needs to be obtained if the device driver intends to calldo_IO() or halt_IO() from anywhere but the device interrupt handler (wherethe lock is already owned). Those routines should only be used if runningenabled for interrupts. If running disabled already, the driver should uses390irq_spin_lock() and the corresponding unlock routine instead (see above).s390irq_spin_lock_irqsave( int irq, unsigned long flags);s390irq_spin_unlock_irqrestore( int irq, unsigned long flags);Special Console Interface RoutinesThis chapter describes the special interface routines required for systemconsole processing. Though they are an extension to the Linux/390 devicedriver interface concept, they base on the same principles. It was necessaryto build those extensions to assure a deterministic behaviour in criticalsituations e.g. printk() messages by other device drivers running disabledfor interrupts during I/O interrupt handling or in case of a panic() messagebeing raised.set_cons_dev - Set Console DeviceThis routine allows to specify the system console device. This is necessaryas the console isn't driven by the same ESA/390 interrupt subclass as areother devices, but it is assigned ist own interrupt subclass. Only one devicecan act as system console. See wait_cons_dev() for details.int set_cons_dev( int irq);irq : subchannel identifying the system console deviceThe set_cons_dev() function returns      0 - successful completion-EIO    - an unhandled interrupt condition is pending for the          specified subchannel (irq) - status pending-ENODEV - irq doesn't specify a valid subchannel or the devive is          not operational-EBUSY  - the console device is already definedreset_cons_dev - Reset Console DeviceThis routine allows for resetting the console device specification. Seeset_cons_dev() for details.int reset_cons_dev( int irq);irq : subchannel identifying the system console deviceThe reset_cons_dev() function returns      0 - successful completion-EIO    - an unhandled interrupt condition is pending for the          specified subchannel (irq) - status pending-ENODEV - irq doesn't specify a valid subchannel or the devive is          not operationalwait_cons_dev - Synchronously Wait for Console ProcessingThe wait_cons_dev() routine is used by the console device driver when itsbuffer pool for intermediate request queuing is exhausted and a new outputrequest is received. In this case the console driver uses the wait_cons_dev()routine to synchronously wait until enough buffer space is gained to enqueuethe current request. Any pending interrupt condition for the console devicefound during wait_cons_dev() processing causes its interrupt handler to becalled.int wait_cons_dev( int irq);irq : subchannel identifying the system console deviceThe wait_cons_dev() function  returns :      0 - successful completion-EINVAL - the irq specified doesn't match the irq configured for          the console device by set_cons_dev()Usage Notes :The function should be used carefully. Especially in a SMP environment thewait_cons_dev() processing requires that all but the special console ISC aredisabled. In a SMP system this requires the other CPUs to be signaled todisable/enable those ISCs.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -