Direct Port I/O and Windows NT Undocumented features for direct control of hardware devices. 


Мы поможем в написании ваших работ!



ЗНАЕТЕ ЛИ ВЫ?

Direct Port I/O and Windows NT Undocumented features for direct control of hardware devices.



By Dale Roberts. Dale works with data acquisition and control software at the Vestibular Laboratory of the Johns Hopkins University School of Medicine. He can be reached at roberts@ishtar.med.jhu.edu.

Port I/O instructions allow all 80x86 CPUs to commu­nicate with other hardware devices in the system. For low-level, direct control of a hardware device, the C functions _inp() and _out() (implemented using the 80x86 processor's IN and OUT instructions let you read from or write to and I/O port. However, inserting _inp() or _out() in a Windows NT application gives you a privi­leged-instruction exception message and the option of terminating or debugging the offending app. If you at­tempt port I/O from a 16-bit DOS app in an NT console window, the I/O is either ignored or emulated by NT's virtual device drivers — you don't get an exception. But you don't get the direct I/O either.

This isn't a bug, NT is supposed to work this way. The NT architects decided that it would be too risky to allow applications to directly access the system hard­ware. With unrestricted I/O access an application could turn off all interrupts, take over the system, and trash the display or the hard drive. A buggy program could unintentionally do the same. NT's architecture requires that all hardware be accessed via kernel-mode device drivers - special, trusted pieces of software that essentially become part of the operating system when loaded. These device drivers have complete access to entire system memory, all hardware devices, and all privileged processor instructions. In contrast, ap­plications run in user mode, where they have restrict­ed access to memory — and where the CPU can't execute certain privileged operating-system instructions, in­cluding I/O instructions.

The restriction on I/O port access is both a blessing and a curse. On one hand, it makes NT exceptionally stable. Generally, application programmers can write and crash and debug programs all day long without shak­ing NT. Several applications can run without adversely affecting one another. On the other hand, I/O restric­tions prevent you from communicating directly and quick­ly with the hardware without taking the relatively large amount of time required for a call to a device driver. Whenever you want to communicate with a device driver, you must send a request through NT's I/O subsystem. This can take about 30 clock cycles.

Why would you ever need to put I/O instructions in user mode code? When writing a device driver, it might make things easier if you could write a quick program to interact with the device, sprinkling printt()s and getchar ()s among port I/O instructions so that you could verify that you are driving the device correctly before you put the code into an actual device driver and chance a system lockup. Or you may want to write a portion of a driver in a user-mode DLL (as with video drivers, for instance) to achieve a desired level of performance. One of my favorite uses of I/O is for using an oscilloscope to debug programs and time sec­tions of code. To do this, you need to set and clear a bit in a digital output port and monitor the voltage on a scope.

Since direct, user-mode port I/O in NT seems so use­ful, you'd think there would be an accepted way to achieve it. A quick look through the sample source code in the Windows NT Device Driver Kit (DDK) reveals a program called «PORTIO». Initially, I thought this would provide direct port I/O from an app. However, PORTIO is merely an example showing how to use Win32 Devicel Control() calls to kernel-mode device driver, which imple­ments the actual I/O. Using PORTIO, each I/O operation requires a costly, time-consuming call to the device driver. This was useless for my oscilloscope timings. I needed a better way.

 

Список слов к текстам урока

Прочтите вслух слова и допишите перевод однокоренных слов, используя знания суффиксов

 


Feature – черта

Acquisition – приобретение, сбор

To allow – позволять

To implement – воплощать, реализовывать, вводить

Implementation - __________

To insert – вводить, вставлять

Insertion -_______

Exception – исключение

Exceptionally - ______

To terminate – завершать, выходить (из цикла)

Terminal - ________

Terminating - _________

To debug – налаживать, отлаживать, устранять (неполадки)

Debugging - ______

Bug ---___________

To attempt – пытаться, пробовать, делать попытку

Attempt - ______

To restrict – ограничивать

Interrupt – прерывать, прерывание

Trash- хлам, мусор, отбросы

To trash - ____

Intention – намерение

Unintentionally - _____

Via – через

To trust – доверять, полагаться

Trusted - проверенный

Piece – кусок, участок

Entire – целый, весь

Blessing – благо, благословение

Curse – проклятие, ругательство. Бич

Generally – в целом

To shake – трястись, колебать

Adversely – враждебно, неблагоприятно, вредно

Adverse - ____

To prevent – препятствовать, предотвращать

Sprinkling - разбрасывающий

To verify – контролировать, проверять. Сличать

To consume – потреблять

Consuming – затратный

Costly time-consuming – дорогостоящий по затратам времени


 

Упражнение 2. Найдите все существительные в и наречия в тексте. Переведите их. Поставьте существительные во множественное число.

 

Упражнение 3. Переведите словосочетания, обращая внимание на выражение падежных отношений с помощью предлогов.

 

Features for direct control of hardware devices; the Vestibular laboratory of the John Hopkins University School of Medicine; for low-level, direct control of a hardware devise; a port I\O instruction; to debug programs and time sections of code

 

Упражнение 15. Просмотрите Текст, подчеркните и отметьте цифрами перевод данных словосочетаний, которые могут использоваться в профессиональном разroворе:

­1) позволяют вам читать из или записывать в

2) вы не получаете исключения

З) работать таким (подобным) образом

4) (это) было бы слишком рискованно позволить

5) вся системная память

6) с одной стороны

7) с друrой стороны

8) целый (весь) день напролет

9) без неблаrоприятноrо воздействия одноrо на друrое

10) предохраняет (обереrает) вас от

11) относительно большое количество времени

12) Korдa бы вы ни захотели (сделать что­то)

1 З) это может занять

14) зачем вам вообще нужно (делать что­то)

15) это моrло бы облеrчить дело

16) один из моих любимых

­

 

Упражнение 5. Это упражнение для тренировки «быстрого», просмотровочного чтения. Просмотрите параграфы и поставьте их в нужном порядке, обращая внимание на подчеркнутые слова

(Look through the paragraphs and arrange them in proper order paying attention to the un­derlined words):

Welcome to the Official Red Hat Linux Getting Started Guide!

A. Inside, you'll find valuable tips which will help you get acquainted
with GNOME, your new default desktop environment. You'll also learn
the fundamentals of navigating and managing files and directories from
the shell prompt, or console. Among the new features of Red Hat Linux 6.1
you'll find the RH PPP Dialer, also called RP3; inside, you'll learn how to
use this application to get online quickly and easily.

B. If you count yourself among the many who are discovering Red Hat
Linux for the first time, this book is for you!

C. But first, a little background...

D. In short this guide picks up where the Official Red Hat Linux Instal­lation Guide leaves off: helping you understand a bit about your new

operating system.

E. At Red Hat, we believe we offer the best Linux distribution on the
market. We hope you'll agree that the time and the money you spent to
install and work with Red Hat Linux was well spent, indeed.

 

Упражнение 6. Переведите и сформулируйте правило о месте апострофа:

­ programmer, programmers, programmer's error, programmers' error.

 

АРТИКЛИ

­ Упражнение 3. Поставьте к словам артикль а или ап:

­ book; ­ woman; ­ year; ­ apple; ­ еуе; ­ hour.

­

Упражнение 6. Поставьте артикль там, rде он нужен:

а) Do you have ___ match? ___ match that you gave me didn’t light.

We’re having ___ rice for dinner. There were ___ books on the shelves.

There’s ____ man waiting to see you. I told ____man waiting to see you to come back tomorrow.

I heard ___ train approaching. ____ train that I heard approaching was going very fast.

b) ___ Prince of Wales; ___ Prince Charles; ___ Douglas Hall; ____ Vatican; ___sea of Azov; _____Potomas River; once ___ month; ____President of ____ United States; ___ President Bush; ____Witness Jones; ____ chapter 2.

 

Список слов к тексту урока

­Прочтите вслух и допишите перевод однокоренных слов, используя знание суффиксов.

­

to figure out вычислять, постиrать, разrадывать

to trap захватывать

to define определять

definition

defining

level ypoвень, степень

current ток; текущая запись, текущий

to store запоминать, хранить

storage

sigпifiсапt значительный, СУlЦественный

significance

value ценность, стоимость, оценка, значение

free свободный, вольный, добровольный

freely

to set устанавливать, монтировать

set, subset

offset

t1exibIe rибкий

flexibility

task задача

to accomplish совершать, выполнять, достиrать

bitmask битовая маска

array матрица, массив, таблица

to correspond to... соответствовать, быть аналоrичным чему­л.

particular специфический, особый, частный, детальный, ТlЦательный

to encompass окружать, заключать

to hold удерживать; выполняться (об условии)

to provide обеспечивать, снабжать

to choose выбирать, избирать, предпочитать

to assume принимать (на себя); предполаrать

permission разрешение

main rлавный, основной

integer целое число

­



Поделиться:


Последнее изменение этой страницы: 2017-02-10; просмотров: 319; Нарушение авторского права страницы; Мы поможем в написании вашей работы!

infopedia.su Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. Обратная связь - 3.145.42.94 (0.017 с.)