Unformatted text preview:

Device Drivers The Tempo 32 Operating System Part 8 System Call Implementation Low Level Input Output Subsystem Device drivers are the primary components of the I O subsystem Each device driver is responsible for managing input output on a single type of device at the lowest level by managing the device s controller is not normally called from user mode usually can t be called from user mode frequently presents a normalized interface to the kernel 1 Devices and Device Controllers The distinction between devices and their controllers is sometimes blurred A serial port is usually a single chip e g an 8250 or 16550 A modern IDE or SCSI disk has a built in controller A display has a monitor and a video adapter that usually has many components 2 Controllers and Devices CPU Memory Video Adapter Monitor System Bus PPI Programmable Peripheral Interface Controller Controller IDE Disk IDE Disk Serial Port Keyboard with 8042 chip Serial Device e g a modem A common practice is to allow one controller to support multiple devices The controller in this drive is inactive 3 4 Buses ISA PCI USB AGP Bridges Although simple diagrams as in the previous slide show only one bus with everything connected to it modern systems have many interface buses For example How do all these buses connect in a PC Answer bridges A bridge is essentially a device chip that maps signals between bus formats synchronization data control etc A common PC architecture has a north bridge between the host bus and the PCI and DRAM memory buses the south bridge connects the PCI bus to the ISA USB IDE and AGP buses But many different organizations are possible ISA Industry Standard Architecture found in older PCs PCI Peripheral Component Interconnection modern replacement for ISA USB Universal Serial Bus frequently used to connect external devices AGP Accelerated Graphics Port based on enhancement of PCI for video adapters 5 6 1 USB PCI ATA SATA SCSI CPU 1 North South Bridge Bridge CPU 2 Ethernet Another illustration of the bus bridge configuration of a modern PC from www extremetech com ISA CPU n Firewire Audio etc Memory RAM Video Controller Memory RAM AGP 7 8 Device Classes Normalized Driver Interface 1 Devices are commonly separated into two classes for ease of organization In most UNIX implementations each device in each class has two numbers Block devices those which have addressable blocks of data e g disks CDs DVDs device drivers must be given a block number a read write command and a buffer in each request Character devices everything else device drivers transfer only one or a few bytes at a time but must still have a read write command and know where to get put the data major identifies the controller for all devices of the same type i e all IDE disks will have the same major device number minor identifies an instance of the device i e each individual IDE disk will have a unique minor device number Two arrays of structures bdevsw and cdevsw are indexed by the major device number to locate entry points to device drivers 9 10 Normalized Driver Interface 2 Tempo s Device Drivers Block device driver entry points Tempo doesn t yet use a normalized device driver format Each device driver is represented by a system call for the most common actions Device specific Tempo system calls d open open a device d close close a device d strategy read or write a block d ioctl I O actions other than read or write Character device driver entry points rdc read next keyboard character conout write character to the display diskio read write a disk block asynchio asynchronous disk I O request d open open a device d close close a device d read d write read or write a block d ioctl I O actions other than read or write 11 12 2 rdc basics rdc pseudocode Basic data structures Down on semaphore keysem with specified timeout Return TIMEOUT if down timed out Copy kbdata frstkey to result Increment frstkey modulo NKEYS Return result kbdata circular queue with at most NKEYS entries each containing one character code frstkey is index of first unused character code keysem semaphore with count equal to number of entries in kbdata 13 14 Keyboard Interrupt Handling 1 Keyboard Interrupt Handling 2 Each key press or release generates an interrupt 0x21 IRQ 1 When a keyboard interrupt is handled The kbtoa function is called with the key code as an argument It returns NOCHAR if no character code should be returned If the code indicates a virtual console switch should happen do it by calling setvidpg and return If the keyboard buffer is full the character is ignored Add the character code to the circular queue If no processes are awaiting input increment the keysem semaphore s count Otherwise awaken the first waiting process remove from the delta queue as appropriate if it s priority is higher than that of the running process arrange for a context switch PIC reenabled Keyboard status register read to clear interrupt request Keyboard data register is read and used as argument to kybdisr second level handler When kybdisr returns continue at isr30i normal system call return activity 15 Text Mode Video Display 1 16 Text Mode Video Display 2 Almost every video adapter in every PC ever made supports text in the same way The generic chipset used has only a few significant features Video RAM usually at physical address 0xb8000 is treated as 16 bit values High order 8 bits control foreground background color blinking underling etc Low order 8 bits contain a character code Standard 25 row 80 column screen needs 4000 bytes Most adapters have more than 4000 bytes available so multiple pages can be maintained but only one can be displayed at a time 17 A pair of 8 bit wide adapter registers 12 13 contain the offset of the 16 bit item in video RAM that is to be displayed in the upper left corner of the display Following bytes used to fill remainder of display Another pair of registers 14 15 contain the offset in video RAM of the position where the visible cursor is located 18 3 int setvidpg void pg unsigned int page unsigned int pg unsigned int offset setvidpg select a video page Check requested page number return error if incorrect Save current page s cursor location restore selected page s cursor location Set adapter registers to begin displaying selected page Adjust position of the cursor 19 if page NVPG return NOSUCHVIDPG parameter too large if page vpage return NOERROR no change vidrow vpage vrow save current cursor position vidcol vpage vcol vpage page set new page


View Full Document

UNO CSCI 8530 - The Tempo/32 Operating System

Loading Unlocking...
Login

Join to view The Tempo/32 Operating System and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view The Tempo/32 Operating System and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?