source: branches/minix3-book/kernel/system/do_devio.c

Last change on this file was 4, checked in by Mattia Monga, 14 years ago

Importazione sorgenti libro

File size: 1.4 KB
Line 
1/* The kernel call implemented in this file:
2 * m_type: SYS_DEVIO
3 *
4 * The parameters for this kernel call are:
5 * m2_i3: DIO_REQUEST (request input or output)
6 * m2_i1: DIO_TYPE (flag indicating byte, word, or long)
7 * m2_l1: DIO_PORT (port to read/ write)
8 * m2_l2: DIO_VALUE (value to write/ return value read)
9 */
10
11#include "../system.h"
12#include <minix/devio.h>
13
14#if USE_DEVIO
15
16/*===========================================================================*
17 * do_devio *
18 *===========================================================================*/
19PUBLIC int do_devio(m_ptr)
20register message *m_ptr; /* pointer to request message */
21{
22/* Process a single I/O request for byte, word, and long values. */
23 if (m_ptr->DIO_REQUEST == DIO_INPUT) {
24 switch (m_ptr->DIO_TYPE) {
25 case DIO_BYTE: m_ptr->DIO_VALUE = inb(m_ptr->DIO_PORT); break;
26 case DIO_WORD: m_ptr->DIO_VALUE = inw(m_ptr->DIO_PORT); break;
27 case DIO_LONG: m_ptr->DIO_VALUE = inl(m_ptr->DIO_PORT); break;
28 default: return(EINVAL);
29 }
30 } else {
31 switch (m_ptr->DIO_TYPE) {
32 case DIO_BYTE: outb(m_ptr->DIO_PORT, m_ptr->DIO_VALUE); break;
33 case DIO_WORD: outw(m_ptr->DIO_PORT, m_ptr->DIO_VALUE); break;
34 case DIO_LONG: outl(m_ptr->DIO_PORT, m_ptr->DIO_VALUE); break;
35 default: return(EINVAL);
36 }
37 }
38 return(OK);
39}
40
41#endif /* USE_DEVIO */
Note: See TracBrowser for help on using the repository browser.