Message type for SYS_SDEVIO
Change-Id: I2d60a2ccad325236998a7f9af9b4e82fe0c8131f
This commit is contained in:
parent
3ed35f3958
commit
a8c16a502a
4 changed files with 39 additions and 29 deletions
|
@ -301,8 +301,6 @@
|
|||
#define DIO_VALUE m2_l2 /* single I/O value */
|
||||
#define DIO_VEC_ADDR m2_p1 /* address of buffer or (p,v)-pairs */
|
||||
#define DIO_VEC_SIZE m2_l2 /* number of elements in vector */
|
||||
#define DIO_VEC_ENDPT m2_i2 /* number of process where vector is */
|
||||
#define DIO_OFFSET m2_i1 /* offset from grant */
|
||||
|
||||
/* Field names for SYS_SETALARM. */
|
||||
#define ALRM_EXP_TIME m2_l1 /* expire time for the alarm call */
|
||||
|
|
|
@ -700,6 +700,18 @@ typedef struct {
|
|||
} mess_lsys_krn_schedctl;
|
||||
_ASSERT_MSG_SIZE(mess_lsys_krn_schedctl);
|
||||
|
||||
typedef struct {
|
||||
int request;
|
||||
long int port;
|
||||
endpoint_t vec_endpt;
|
||||
phys_bytes vec_addr;
|
||||
vir_bytes vec_size;
|
||||
vir_bytes offset;
|
||||
|
||||
uint8_t padding[32];
|
||||
} mess_lsys_krn_sys_sdevio;
|
||||
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_sdevio);
|
||||
|
||||
typedef struct {
|
||||
phys_bytes base;
|
||||
phys_bytes count;
|
||||
|
@ -1434,6 +1446,7 @@ typedef struct {
|
|||
mess_lsys_krn_schedctl m_lsys_krn_schedctl;
|
||||
mess_lsys_krn_schedule m_lsys_krn_schedule;
|
||||
mess_lsys_krn_sys_memset m_lsys_krn_sys_memset;
|
||||
mess_lsys_krn_sys_sdevio m_lsys_krn_sys_sdevio;
|
||||
|
||||
mess_lsys_pci_busc_get_bar m_lsys_pci_busc_get_bar;
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
* m_type: SYS_SDEVIO
|
||||
*
|
||||
* The parameters for this kernel call are:
|
||||
* m2_i3: DIO_REQUEST (request input or output)
|
||||
* m2_l1: DIO_PORT (port to read/ write)
|
||||
* m2_p1: DIO_VEC_ADDR (virtual address of buffer, or grant ID)
|
||||
* m2_l2: DIO_VEC_SIZE (number of elements)
|
||||
* m2_i2: DIO_VEC_PROC (process where buffer is)
|
||||
* m2_i1: DIO_OFFSET (offset into the grant)
|
||||
* m_lsys_krn_sys_sdevio.request (request input or output)
|
||||
* m_lsys_krn_sys_sdevio.port (port to read/ write)
|
||||
* m_lsys_krn_sys_sdevio.vec_addr (virtual address of buffer, or grant ID)
|
||||
* m_lsys_krn_sys_sdevio.vec_size (number of elements)
|
||||
* m_lsys_krn_sys_sdevio.vec_endpt (process where buffer is)
|
||||
* m_lsys_krn_sys_sdevio.offset (offset into the grant)
|
||||
*/
|
||||
|
||||
#include "kernel/system.h"
|
||||
|
@ -26,9 +26,9 @@ int do_sdevio(struct proc * caller, message *m_ptr)
|
|||
vir_bytes newoffset;
|
||||
endpoint_t newep;
|
||||
int proc_nr;
|
||||
endpoint_t proc_nr_e = m_ptr->DIO_VEC_ENDPT;
|
||||
vir_bytes count = m_ptr->DIO_VEC_SIZE;
|
||||
long port = m_ptr->DIO_PORT;
|
||||
endpoint_t proc_nr_e = m_ptr->m_lsys_krn_sys_sdevio.vec_endpt;
|
||||
vir_bytes count = m_ptr->m_lsys_krn_sys_sdevio.vec_size;
|
||||
long port = m_ptr->m_lsys_krn_sys_sdevio.port;
|
||||
phys_bytes vir_buf;
|
||||
int i, req_type, req_dir, size, nr_io_range;
|
||||
struct priv *privp;
|
||||
|
@ -37,7 +37,7 @@ int do_sdevio(struct proc * caller, message *m_ptr)
|
|||
int retval;
|
||||
|
||||
/* Allow safe copies and accesses to SELF */
|
||||
if ((m_ptr->DIO_REQUEST & _DIO_SAFEMASK) != _DIO_SAFE &&
|
||||
if ((m_ptr->m_lsys_krn_sys_sdevio.request & _DIO_SAFEMASK) != _DIO_SAFE &&
|
||||
proc_nr_e != SELF)
|
||||
{
|
||||
static int first= 1;
|
||||
|
@ -45,7 +45,7 @@ int do_sdevio(struct proc * caller, message *m_ptr)
|
|||
{
|
||||
first= 0;
|
||||
printf("do_sdevio: for %d, req %d\n",
|
||||
m_ptr->m_source, m_ptr->DIO_REQUEST);
|
||||
m_ptr->m_source, m_ptr->m_lsys_krn_sys_sdevio.request);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,18 +61,17 @@ int do_sdevio(struct proc * caller, message *m_ptr)
|
|||
if (iskerneln(proc_nr)) return(EPERM);
|
||||
|
||||
/* Extract direction (in or out) and type (size). */
|
||||
req_dir = m_ptr->DIO_REQUEST & _DIO_DIRMASK;
|
||||
req_type = m_ptr->DIO_REQUEST & _DIO_TYPEMASK;
|
||||
req_dir = m_ptr->m_lsys_krn_sys_sdevio.request & _DIO_DIRMASK;
|
||||
req_type = m_ptr->m_lsys_krn_sys_sdevio.request & _DIO_TYPEMASK;
|
||||
|
||||
/* Check for 'safe' variants. */
|
||||
if((m_ptr->DIO_REQUEST & _DIO_SAFEMASK) == _DIO_SAFE) {
|
||||
if((m_ptr->m_lsys_krn_sys_sdevio.request & _DIO_SAFEMASK) == _DIO_SAFE) {
|
||||
/* Map grant address to physical address. */
|
||||
if(verify_grant(proc_nr_e, caller->p_endpoint,
|
||||
(cp_grant_id_t) m_ptr->DIO_VEC_ADDR,
|
||||
count,
|
||||
m_ptr->m_lsys_krn_sys_sdevio.vec_addr, count,
|
||||
req_dir == _DIO_INPUT ? CPF_WRITE : CPF_READ,
|
||||
(vir_bytes) m_ptr->DIO_OFFSET,
|
||||
&newoffset, &newep, NULL) != OK) {
|
||||
m_ptr->m_lsys_krn_sys_sdevio.offset, &newoffset, &newep,
|
||||
NULL) != OK) {
|
||||
printf("do_sdevio: verify_grant failed\n");
|
||||
return EPERM;
|
||||
}
|
||||
|
@ -88,7 +87,7 @@ int do_sdevio(struct proc * caller, message *m_ptr)
|
|||
return EPERM;
|
||||
}
|
||||
/* Get and check physical address. */
|
||||
vir_buf = (phys_bytes) m_ptr->DIO_VEC_ADDR;
|
||||
vir_buf = m_ptr->m_lsys_krn_sys_sdevio.vec_addr;
|
||||
destproc = proc_addr(proc_nr);
|
||||
}
|
||||
/* current process must be target for phys_* to be OK */
|
||||
|
@ -106,7 +105,7 @@ int do_sdevio(struct proc * caller, message *m_ptr)
|
|||
privp= priv(caller);
|
||||
if (privp && privp->s_flags & CHECK_IO_PORT)
|
||||
{
|
||||
port= m_ptr->DIO_PORT;
|
||||
port= m_ptr->m_lsys_krn_sys_sdevio.port;
|
||||
nr_io_range= privp->s_nr_io_range;
|
||||
for (i= 0, iorp= privp->s_io_tab; i<nr_io_range; i++, iorp++)
|
||||
{
|
||||
|
|
|
@ -13,12 +13,12 @@ vir_bytes offset; /* offset from grant */
|
|||
{
|
||||
message m_io;
|
||||
|
||||
m_io.DIO_REQUEST = req;
|
||||
m_io.DIO_PORT = port;
|
||||
m_io.DIO_VEC_ENDPT = proc_nr;
|
||||
m_io.DIO_VEC_ADDR = buffer;
|
||||
m_io.DIO_VEC_SIZE = count;
|
||||
m_io.DIO_OFFSET = offset;
|
||||
m_io.m_lsys_krn_sys_sdevio.request = req;
|
||||
m_io.m_lsys_krn_sys_sdevio.port = port;
|
||||
m_io.m_lsys_krn_sys_sdevio.vec_endpt = proc_nr;
|
||||
m_io.m_lsys_krn_sys_sdevio.vec_addr = buffer;
|
||||
m_io.m_lsys_krn_sys_sdevio.vec_size = count;
|
||||
m_io.m_lsys_krn_sys_sdevio.offset = offset;
|
||||
|
||||
return(_kernel_call(SYS_SDEVIO, &m_io));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue