Basic VM and other minor improvements.
Not complete, probably not fully debugged or optimized.
This commit is contained in:
+47
-56
@@ -10,13 +10,7 @@
|
||||
*/
|
||||
|
||||
#include "../system.h"
|
||||
|
||||
#if !( POWERPC )
|
||||
|
||||
static unsigned long bios_buf[1024]; /* 4K, what about alignment */
|
||||
static vir_bytes bios_buf_vir, bios_buf_len;
|
||||
|
||||
#endif /* #if !( POWERPC ) */
|
||||
#include "../vm.h"
|
||||
|
||||
|
||||
#if USE_GETINFO
|
||||
@@ -31,35 +25,44 @@ register message *m_ptr; /* pointer to request message */
|
||||
* call simply copies entire data structures to the caller.
|
||||
*/
|
||||
size_t length;
|
||||
phys_bytes src_phys;
|
||||
phys_bytes dst_phys;
|
||||
int proc_nr, nr_e, nr;
|
||||
vir_bytes src_vir;
|
||||
int proc_nr, nr_e, nr, hz;
|
||||
struct proc *caller;
|
||||
phys_bytes ph;
|
||||
|
||||
caller = proc_addr(who_p);
|
||||
|
||||
/* Set source address and length based on request type. */
|
||||
switch (m_ptr->I_REQUEST) {
|
||||
case GET_MACHINE: {
|
||||
length = sizeof(struct machine);
|
||||
src_phys = vir2phys(&machine);
|
||||
src_vir = (vir_bytes) &machine;
|
||||
break;
|
||||
}
|
||||
case GET_KINFO: {
|
||||
length = sizeof(struct kinfo);
|
||||
src_phys = vir2phys(&kinfo);
|
||||
src_vir = (vir_bytes) &kinfo;
|
||||
break;
|
||||
}
|
||||
case GET_LOADINFO: {
|
||||
length = sizeof(struct loadinfo);
|
||||
src_phys = vir2phys(&kloadinfo);
|
||||
src_vir = (vir_bytes) &kloadinfo;
|
||||
break;
|
||||
}
|
||||
case GET_HZ: {
|
||||
length = sizeof(hz);
|
||||
src_vir = (vir_bytes) &hz;
|
||||
hz = HZ;
|
||||
break;
|
||||
}
|
||||
case GET_IMAGE: {
|
||||
length = sizeof(struct boot_image) * NR_BOOT_PROCS;
|
||||
src_phys = vir2phys(image);
|
||||
src_vir = (vir_bytes) image;
|
||||
break;
|
||||
}
|
||||
case GET_IRQHOOKS: {
|
||||
length = sizeof(struct irq_hook) * NR_IRQ_HOOKS;
|
||||
src_phys = vir2phys(irq_hooks);
|
||||
src_vir = (vir_bytes) irq_hooks;
|
||||
break;
|
||||
}
|
||||
case GET_SCHEDINFO: {
|
||||
@@ -67,36 +70,44 @@ register message *m_ptr; /* pointer to request message */
|
||||
* at once, otherwise the scheduling information may be incorrect.
|
||||
* Copy the queue heads and fall through to copy the process table.
|
||||
*/
|
||||
if((ph=umap_local(caller, D, (vir_bytes) m_ptr->I_VAL_PTR2,length)) == 0)
|
||||
return EFAULT;
|
||||
length = sizeof(struct proc *) * NR_SCHED_QUEUES;
|
||||
src_phys = vir2phys(rdy_head);
|
||||
okendpt(m_ptr->m_source, &proc_nr);
|
||||
dst_phys = numap_local(proc_nr, (vir_bytes) m_ptr->I_VAL_PTR2,
|
||||
length);
|
||||
if (src_phys == 0 || dst_phys == 0) return(EFAULT);
|
||||
phys_copy(src_phys, dst_phys, length);
|
||||
/* fall through */
|
||||
CHECKRANGE_OR_SUSPEND(proc_addr(who_p), ph, length, 1);
|
||||
data_copy(SYSTEM, (vir_bytes) rdy_head,
|
||||
who_e, (vir_bytes) m_ptr->I_VAL_PTR2, length);
|
||||
/* fall through to GET_PROCTAB */
|
||||
}
|
||||
case GET_PROCTAB: {
|
||||
length = sizeof(struct proc) * (NR_PROCS + NR_TASKS);
|
||||
src_phys = vir2phys(proc);
|
||||
src_vir = (vir_bytes) proc;
|
||||
break;
|
||||
}
|
||||
case GET_PRIVTAB: {
|
||||
length = sizeof(struct priv) * (NR_SYS_PROCS);
|
||||
src_phys = vir2phys(priv);
|
||||
src_vir = (vir_bytes) priv;
|
||||
break;
|
||||
}
|
||||
case GET_PROC: {
|
||||
nr_e = (m_ptr->I_VAL_LEN2_E == SELF) ?
|
||||
m_ptr->m_source : m_ptr->I_VAL_LEN2_E;
|
||||
who_e : m_ptr->I_VAL_LEN2_E;
|
||||
if(!isokendpt(nr_e, &nr)) return EINVAL; /* validate request */
|
||||
length = sizeof(struct proc);
|
||||
src_phys = vir2phys(proc_addr(nr));
|
||||
src_vir = (vir_bytes) proc_addr(nr);
|
||||
break;
|
||||
}
|
||||
case GET_WHOAMI: {
|
||||
int len;
|
||||
/* GET_WHOAMI uses m3 and only uses the message contents for info. */
|
||||
m_ptr->GIWHO_EP = who_e;
|
||||
len = MIN(sizeof(m_ptr->GIWHO_NAME), sizeof(caller->p_name))-1;
|
||||
strncpy(m_ptr->GIWHO_NAME, caller->p_name, len);
|
||||
m_ptr->GIWHO_NAME[len] = '\0';
|
||||
return OK;
|
||||
}
|
||||
case GET_MONPARAMS: {
|
||||
src_phys = kinfo.params_base; /* already is a physical */
|
||||
length = kinfo.params_size;
|
||||
src_vir = (vir_bytes) params_buffer;
|
||||
length = sizeof(params_buffer);
|
||||
break;
|
||||
}
|
||||
case GET_RANDOMNESS: {
|
||||
@@ -109,44 +120,25 @@ register message *m_ptr; /* pointer to request message */
|
||||
krandom.bin[i].r_next = 0;
|
||||
}
|
||||
length = sizeof(struct randomness);
|
||||
src_phys = vir2phys(©);
|
||||
src_vir = (vir_bytes) ©
|
||||
break;
|
||||
}
|
||||
case GET_KMESSAGES: {
|
||||
length = sizeof(struct kmessages);
|
||||
src_phys = vir2phys(&kmess);
|
||||
src_vir = (vir_bytes) &kmess;
|
||||
break;
|
||||
}
|
||||
#if DEBUG_TIME_LOCKS
|
||||
case GET_LOCKTIMING: {
|
||||
length = sizeof(timingdata);
|
||||
src_phys = vir2phys(timingdata);
|
||||
src_vir = (vir_bytes) timingdata;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !( POWERPC )
|
||||
case GET_BIOSBUFFER:
|
||||
bios_buf_vir = (vir_bytes)bios_buf;
|
||||
bios_buf_len = sizeof(bios_buf);
|
||||
|
||||
length = sizeof(bios_buf_len);
|
||||
src_phys = vir2phys(&bios_buf_len);
|
||||
if (length != m_ptr->I_VAL_LEN2_E) return (EINVAL);
|
||||
if(!isokendpt(m_ptr->m_source, &proc_nr))
|
||||
panic("bogus source", m_ptr->m_source);
|
||||
dst_phys = numap_local(proc_nr, (vir_bytes) m_ptr->I_VAL_PTR2, length);
|
||||
if (src_phys == 0 || dst_phys == 0) return(EFAULT);
|
||||
phys_copy(src_phys, dst_phys, length);
|
||||
|
||||
length = sizeof(bios_buf_vir);
|
||||
src_phys = vir2phys(&bios_buf_vir);
|
||||
break;
|
||||
#endif /* #if !( POWERPC ) */
|
||||
|
||||
case GET_IRQACTIDS: {
|
||||
length = sizeof(irq_actids);
|
||||
src_phys = vir2phys(irq_actids);
|
||||
src_vir = (vir_bytes) irq_actids;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -162,11 +154,10 @@ register message *m_ptr; /* pointer to request message */
|
||||
|
||||
/* Try to make the actual copy for the requested data. */
|
||||
if (m_ptr->I_VAL_LEN > 0 && length > m_ptr->I_VAL_LEN) return (E2BIG);
|
||||
if(!isokendpt(m_ptr->m_source, &proc_nr))
|
||||
panic("bogus source", m_ptr->m_source);
|
||||
dst_phys = numap_local(proc_nr, (vir_bytes) m_ptr->I_VAL_PTR, length);
|
||||
if (src_phys == 0 || dst_phys == 0) return(EFAULT);
|
||||
phys_copy(src_phys, dst_phys, length);
|
||||
if((ph=umap_local(caller, D, (vir_bytes) m_ptr->I_VAL_PTR,length)) == 0)
|
||||
return EFAULT;
|
||||
CHECKRANGE_OR_SUSPEND(caller, ph, length, 1);
|
||||
data_copy(SYSTEM, src_vir, who_e, (vir_bytes) m_ptr->I_VAL_PTR, length);
|
||||
return(OK);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user