struct proc *rp;
struct priv *privp;
struct io_range *iorp;
+ int rem;
+ static char zero[4096];
+ vir_bytes addr;
+ struct proc *destproc;
/* Allow safe copies and accesses to SELF */
if ((m_ptr->DIO_REQUEST & _DIO_SAFEMASK) != _DIO_SAFE &&
/* Check for 'safe' variants. */
if((m_ptr->DIO_REQUEST & _DIO_SAFEMASK) == _DIO_SAFE) {
+ vir_bytes newoffset;
+ endpoint_t newep;
/* Map grant address to physical address. */
- if ((phys_buf = umap_verify_grant(proc_addr(proc_nr), who_e,
+ if(verify_grant(proc_nr_e, who_e,
(vir_bytes) m_ptr->DIO_VEC_ADDR,
- (vir_bytes) m_ptr->DIO_OFFSET, count,
- req_dir == _DIO_INPUT ? CPF_WRITE : CPF_READ)) == 0)
- return(EPERM);
+ count,
+ req_dir == _DIO_INPUT ? CPF_WRITE : CPF_READ,
+ (vir_bytes) m_ptr->DIO_OFFSET,
+ &newoffset, &newep) != OK) {
+ printf("do_sdevio: verify_grant failed\n");
+ return EPERM;
+ }
+ if(!isokendpt(newep, &proc_nr))
+ return(EINVAL);
+ destproc = proc_addr(proc_nr);
+ if ((phys_buf = umap_local(destproc, D,
+ (vir_bytes) newoffset, count)) == 0) {
+ printf("do_sdevio: umap_local failed\n");
+ return(EFAULT);
+ }
} else {
if(proc_nr != who_p)
{
if ((phys_buf = umap_local(proc_addr(proc_nr), D,
(vir_bytes) m_ptr->DIO_VEC_ADDR, count)) == 0)
return(EFAULT);
+ destproc = proc_addr(proc_nr);
}
/* current process must be target for phys_* to be OK */
- if(proc_addr(proc_nr) != ptproc) {
- kprintf("do_sdevio: wrong process\n");
- return EIO;
- }
+
+ vm_set_cr3(destproc);
+ rem = count;
+ addr = m_ptr->DIO_VEC_ADDR;
+ while(rem > 0) {
+ int r;
+ int chunk;
+ chunk = rem > sizeof(zero) ? sizeof(zero) : rem;
+ if((r=data_copy_vmcheck(SYSTEM, zero, destproc->p_endpoint,
+ addr, chunk)) != OK) {
+ return r;
+ }
+ addr += chunk;
+ rem -= chunk;
+ }
switch (io_type)
{
#define HASPT(procptr) ((procptr)->p_seg.p_cr3 != 0)
FORWARD _PROTOTYPE( u32_t phys_get32, (vir_bytes v) );
-FORWARD _PROTOTYPE( void vm_set_cr3, (struct proc *pr) );
FORWARD _PROTOTYPE( void set_cr3, (void) );
FORWARD _PROTOTYPE( void vm_enable_paging, (void) );
PRIVATE u32_t vm_cr3; /* temp arg to level0() func */
-PRIVATE void vm_set_cr3(struct proc *newptproc)
+PUBLIC void vm_set_cr3(struct proc *newptproc)
{
int u = 0;
if(!intr_disabled()) { lock; u = 1; }
#define DEBUG_TIME_LOCKS 1
/* Runtime sanity checking. */
-#define DEBUG_VMASSERT 1
-#define DEBUG_SCHED_CHECK 1
-#define DEBUG_STACK_CHECK 1
-#define DEBUG_TRACE 1
+#define DEBUG_VMASSERT 0
+#define DEBUG_SCHED_CHECK 0
+#define DEBUG_STACK_CHECK 0
+#define DEBUG_TRACE 0
#if DEBUG_TRACE