custom message type for SYS_DEVIO

This commit is contained in:
Ben Gras 2014-07-26 13:53:55 +02:00 committed by Lionel Sambuc
parent fce93dad32
commit 3610b3b1a6
5 changed files with 57 additions and 24 deletions

View file

@ -275,7 +275,6 @@
SYS_PROFBUF, SYS_DIAGCTL, SYS_STATECTL, SYS_SAFEMEMSET
/* Field names for SYS_DEVIO, SYS_VDEVIO, SYS_SDEVIO. */
#define DIO_REQUEST m2_i3 /* device in or output */
# define _DIO_INPUT 0x001
# define _DIO_OUTPUT 0x002
# define _DIO_DIRMASK 0x00f
@ -297,8 +296,6 @@
# define DIO_SAFE_OUTPUT_BYTE (_DIO_OUTPUT|_DIO_BYTE|_DIO_SAFE)
# define DIO_SAFE_OUTPUT_WORD (_DIO_OUTPUT|_DIO_WORD|_DIO_SAFE)
# define DIO_SAFE_OUTPUT_LONG (_DIO_OUTPUT|_DIO_LONG|_DIO_SAFE)
#define DIO_PORT m2_l1 /* single port address */
#define DIO_VALUE m2_l2 /* single I/O value */
/* Field names for SYS_IRQCTL. */
# define IRQ_SETPOLICY 1 /* manage a slot of the IRQ table */

View file

@ -844,6 +844,22 @@ typedef struct {
} mess_lsys_krn_sys_privctl;
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_privctl);
typedef struct {
int request;
int port;
uint32_t value;
uint8_t padding[44];
} mess_lsys_krn_sys_devio;
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_devio);
typedef struct {
uint32_t value;
uint8_t padding[52];
} mess_krn_lsys_sys_devio;
_ASSERT_MSG_SIZE(mess_krn_lsys_sys_devio);
typedef struct {
int request;
long int port;
@ -1858,6 +1874,7 @@ typedef struct {
mess_krn_lsys_sys_trace m_krn_lsys_sys_trace;
mess_krn_lsys_sys_umap m_krn_lsys_sys_umap;
mess_krn_lsys_sys_vumap m_krn_lsys_sys_vumap;
mess_krn_lsys_sys_devio m_krn_lsys_sys_devio;
mess_fs_vfs_breadwrite m_fs_vfs_breadwrite;
mess_fs_vfs_chmod m_fs_vfs_chmod;
@ -1938,6 +1955,7 @@ typedef struct {
mess_lsys_fi_ctl m_lsys_fi_ctl;
mess_lsys_fi_reply m_lsys_fi_reply;
mess_lsys_krn_sys_devio m_lsys_krn_sys_devio;
mess_lsys_krn_schedctl m_lsys_krn_schedctl;
mess_lsys_krn_schedule m_lsys_krn_schedule;
mess_lsys_krn_sys_abort m_lsys_krn_sys_abort;

View file

@ -2,9 +2,9 @@
* m_type: SYS_DEVIO
*
* The parameters for this kernel call are:
* m2_i3: DIO_REQUEST (request input or output)
* m2_l1: DIO_PORT (port to read/ write)
* m2_l2: DIO_VALUE (value to write/ return value read)
* m_lsys_krn_sys_devio.request (request input or output)
* m_lsys_krn_sys_devio.port (port to read/ write)
* m_lsys_krn_sys_devio.value (value to write/ return value read)
*/
#include "kernel/system.h"
@ -25,8 +25,8 @@ int do_devio(struct proc * caller, message * m_ptr)
int i, size, nr_io_range;
int io_type, io_dir;
io_type = m_ptr->DIO_REQUEST & _DIO_TYPEMASK;
io_dir = m_ptr->DIO_REQUEST & _DIO_DIRMASK;
io_type = m_ptr->m_lsys_krn_sys_devio.request & _DIO_TYPEMASK;
io_dir = m_ptr->m_lsys_krn_sys_devio.request & _DIO_DIRMASK;
switch (io_type)
{
@ -44,7 +44,7 @@ int do_devio(struct proc * caller, message * m_ptr)
}
if (privp->s_flags & CHECK_IO_PORT)
{
port= m_ptr->DIO_PORT;
port= m_ptr->m_lsys_krn_sys_devio.port;
nr_io_range= privp->s_nr_io_range;
for (i= 0, iorp= privp->s_io_tab; i<nr_io_range; i++, iorp++)
{
@ -54,16 +54,16 @@ int do_devio(struct proc * caller, message * m_ptr)
if (i >= nr_io_range)
{
printf("do_devio: port 0x%x (size %d) not allowed\n",
m_ptr->DIO_PORT, size);
m_ptr->m_lsys_krn_sys_devio.port, size);
return EPERM;
}
}
doit:
if (m_ptr->DIO_PORT & (size-1))
if (m_ptr->m_lsys_krn_sys_devio.port & (size-1))
{
printf("do_devio: unaligned port 0x%x (size %d)\n",
m_ptr->DIO_PORT, size);
m_ptr->m_lsys_krn_sys_devio.port, size);
return EPERM;
}
@ -71,16 +71,34 @@ doit:
if (io_dir == _DIO_INPUT) {
switch (io_type) {
/* maybe "it" should not be called ports */
case _DIO_BYTE: m_ptr->DIO_VALUE = inb(m_ptr->DIO_PORT); break;
case _DIO_WORD: m_ptr->DIO_VALUE = inw(m_ptr->DIO_PORT); break;
case _DIO_LONG: m_ptr->DIO_VALUE = inl(m_ptr->DIO_PORT); break;
case _DIO_BYTE:
m_ptr->m_krn_lsys_sys_devio.value =
inb(m_ptr->m_lsys_krn_sys_devio.port);
break;
case _DIO_WORD:
m_ptr->m_krn_lsys_sys_devio.value =
inw(m_ptr->m_lsys_krn_sys_devio.port);
break;
case _DIO_LONG:
m_ptr->m_krn_lsys_sys_devio.value =
inl(m_ptr->m_lsys_krn_sys_devio.port);
break;
default: return(EINVAL);
}
} else {
switch (io_type) {
case _DIO_BYTE: outb(m_ptr->DIO_PORT, m_ptr->DIO_VALUE); break;
case _DIO_WORD: outw(m_ptr->DIO_PORT, m_ptr->DIO_VALUE); break;
case _DIO_LONG: outl(m_ptr->DIO_PORT, m_ptr->DIO_VALUE); break;
case _DIO_BYTE:
outb(m_ptr->m_lsys_krn_sys_devio.port,
m_ptr->m_lsys_krn_sys_devio.value);
break;
case _DIO_WORD:
outw(m_ptr->m_lsys_krn_sys_devio.port,
m_ptr->m_lsys_krn_sys_devio.value);
break;
case _DIO_LONG:
outl(m_ptr->m_lsys_krn_sys_devio.port,
m_ptr->m_lsys_krn_sys_devio.value);
break;
default: return(EINVAL);
}
}

View file

@ -11,11 +11,11 @@ int type; /* byte, word, long */
message m_io;
int result;
m_io.DIO_REQUEST = _DIO_INPUT | type;
m_io.DIO_PORT = port;
m_io.m_lsys_krn_sys_devio.request = _DIO_INPUT | type;
m_io.m_lsys_krn_sys_devio.port = port;
result = _kernel_call(SYS_DEVIO, &m_io);
*value = m_io.DIO_VALUE;
*value = m_io.m_krn_lsys_sys_devio.value;
return(result);
}

View file

@ -10,9 +10,9 @@ int type; /* byte, word, long */
{
message m_io;
m_io.DIO_REQUEST = _DIO_OUTPUT | type;
m_io.DIO_PORT = port;
m_io.DIO_VALUE = value;
m_io.m_lsys_krn_sys_devio.request = _DIO_OUTPUT | type;
m_io.m_lsys_krn_sys_devio.port = port;
m_io.m_lsys_krn_sys_devio.value = value;
return _kernel_call(SYS_DEVIO, &m_io);
}