2005-10-14 10:58:59 +02:00
|
|
|
/* The kernel call implemented in this file:
|
2005-04-21 16:53:53 +02:00
|
|
|
* m_type: SYS_GETINFO
|
|
|
|
*
|
2005-10-14 10:58:59 +02:00
|
|
|
* The parameters for this kernel call are:
|
2005-04-21 16:53:53 +02:00
|
|
|
* m1_i3: I_REQUEST (what info to get)
|
|
|
|
* m1_p1: I_VAL_PTR (where to put it)
|
|
|
|
* m1_i1: I_VAL_LEN (maximum length expected, optional)
|
2005-07-19 14:21:36 +02:00
|
|
|
* m1_p2: I_VAL_PTR2 (second, optional pointer)
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
* m1_i2: I_VAL_LEN2_E (second length or process nr)
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
|
|
|
|
2005-07-14 17:12:12 +02:00
|
|
|
#include "../system.h"
|
|
|
|
|
2005-07-29 12:21:04 +02:00
|
|
|
static unsigned long bios_buf[1024]; /* 4K, what about alignment */
|
|
|
|
static vir_bytes bios_buf_vir, bios_buf_len;
|
|
|
|
|
2005-07-14 17:12:12 +02:00
|
|
|
#if USE_GETINFO
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_getinfo *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int do_getinfo(m_ptr)
|
|
|
|
register message *m_ptr; /* pointer to request message */
|
|
|
|
{
|
2005-07-21 20:36:40 +02:00
|
|
|
/* Request system information to be copied to caller's address space. This
|
|
|
|
* call simply copies entire data structures to the caller.
|
|
|
|
*/
|
2005-04-21 16:53:53 +02:00
|
|
|
size_t length;
|
|
|
|
phys_bytes src_phys;
|
|
|
|
phys_bytes dst_phys;
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
int proc_nr, nr_e, nr;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-07-19 14:21:36 +02:00
|
|
|
/* Set source address and length based on request type. */
|
2005-04-21 16:53:53 +02:00
|
|
|
switch (m_ptr->I_REQUEST) {
|
2005-04-29 17:36:43 +02:00
|
|
|
case GET_MACHINE: {
|
2005-07-19 14:21:36 +02:00
|
|
|
length = sizeof(struct machine);
|
|
|
|
src_phys = vir2phys(&machine);
|
|
|
|
break;
|
2005-04-29 17:36:43 +02:00
|
|
|
}
|
|
|
|
case GET_KINFO: {
|
2005-07-19 14:21:36 +02:00
|
|
|
length = sizeof(struct kinfo);
|
|
|
|
src_phys = vir2phys(&kinfo);
|
|
|
|
break;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2005-11-14 16:50:46 +01:00
|
|
|
case GET_LOADINFO: {
|
|
|
|
length = sizeof(struct loadinfo);
|
|
|
|
src_phys = vir2phys(&kloadinfo);
|
|
|
|
break;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
case GET_IMAGE: {
|
2005-07-29 17:26:23 +02:00
|
|
|
length = sizeof(struct boot_image) * NR_BOOT_PROCS;
|
2005-07-19 14:21:36 +02:00
|
|
|
src_phys = vir2phys(image);
|
2005-04-21 16:53:53 +02:00
|
|
|
break;
|
|
|
|
}
|
2005-05-02 16:30:04 +02:00
|
|
|
case GET_IRQHOOKS: {
|
2005-07-19 14:21:36 +02:00
|
|
|
length = sizeof(struct irq_hook) * NR_IRQ_HOOKS;
|
|
|
|
src_phys = vir2phys(irq_hooks);
|
2005-04-21 16:53:53 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GET_SCHEDINFO: {
|
|
|
|
/* This is slightly complicated because we need two data structures
|
|
|
|
* at once, otherwise the scheduling information may be incorrect.
|
|
|
|
* Copy the queue heads and fall through to copy the process table.
|
|
|
|
*/
|
|
|
|
length = sizeof(struct proc *) * NR_SCHED_QUEUES;
|
|
|
|
src_phys = vir2phys(rdy_head);
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
okendpt(m_ptr->m_source, &proc_nr);
|
|
|
|
dst_phys = numap_local(proc_nr, (vir_bytes) m_ptr->I_VAL_PTR2,
|
2005-07-19 14:21:36 +02:00
|
|
|
length);
|
2005-04-21 16:53:53 +02:00
|
|
|
if (src_phys == 0 || dst_phys == 0) return(EFAULT);
|
|
|
|
phys_copy(src_phys, dst_phys, length);
|
2005-06-03 15:55:06 +02:00
|
|
|
/* fall through */
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
case GET_PROCTAB: {
|
2005-07-19 14:21:36 +02:00
|
|
|
length = sizeof(struct proc) * (NR_PROCS + NR_TASKS);
|
|
|
|
src_phys = vir2phys(proc);
|
2005-04-21 16:53:53 +02:00
|
|
|
break;
|
|
|
|
}
|
2005-07-14 17:12:12 +02:00
|
|
|
case GET_PRIVTAB: {
|
2005-07-19 14:21:36 +02:00
|
|
|
length = sizeof(struct priv) * (NR_SYS_PROCS);
|
|
|
|
src_phys = vir2phys(priv);
|
2005-07-14 17:12:12 +02:00
|
|
|
break;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
case GET_PROC: {
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
nr_e = (m_ptr->I_VAL_LEN2_E == SELF) ?
|
|
|
|
m_ptr->m_source : m_ptr->I_VAL_LEN2_E;
|
|
|
|
if(!isokendpt(nr_e, &nr)) return EINVAL; /* validate request */
|
2005-07-19 14:21:36 +02:00
|
|
|
length = sizeof(struct proc);
|
|
|
|
src_phys = vir2phys(proc_addr(nr));
|
2005-04-21 16:53:53 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GET_MONPARAMS: {
|
2005-07-19 14:21:36 +02:00
|
|
|
src_phys = kinfo.params_base; /* already is a physical */
|
|
|
|
length = kinfo.params_size;
|
|
|
|
break;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2005-06-03 15:55:06 +02:00
|
|
|
case GET_RANDOMNESS: {
|
2005-07-19 14:21:36 +02:00
|
|
|
static struct randomness copy; /* copy to keep counters */
|
2005-07-18 17:40:24 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
copy = krandom;
|
|
|
|
for (i= 0; i<RANDOM_SOURCES; i++) {
|
|
|
|
krandom.bin[i].r_size = 0; /* invalidate random data */
|
|
|
|
krandom.bin[i].r_next = 0;
|
|
|
|
}
|
2005-06-03 15:55:06 +02:00
|
|
|
length = sizeof(struct randomness);
|
|
|
|
src_phys = vir2phys(©);
|
|
|
|
break;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
case GET_KMESSAGES: {
|
|
|
|
length = sizeof(struct kmessages);
|
|
|
|
src_phys = vir2phys(&kmess);
|
|
|
|
break;
|
|
|
|
}
|
2005-07-14 17:12:12 +02:00
|
|
|
#if DEBUG_TIME_LOCKS
|
2005-06-01 11:37:52 +02:00
|
|
|
case GET_LOCKTIMING: {
|
2005-07-19 14:21:36 +02:00
|
|
|
length = sizeof(timingdata);
|
|
|
|
src_phys = vir2phys(timingdata);
|
|
|
|
break;
|
2005-06-01 11:37:52 +02:00
|
|
|
}
|
|
|
|
#endif
|
2005-07-29 12:21:04 +02:00
|
|
|
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);
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
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);
|
2005-07-29 12:21:04 +02:00
|
|
|
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;
|
|
|
|
|
2006-01-12 15:38:51 +01:00
|
|
|
case GET_IRQACTIDS: {
|
|
|
|
length = sizeof(irq_actids);
|
|
|
|
src_phys = vir2phys(irq_actids);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
default:
|
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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);
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
if(!isokendpt(m_ptr->m_source, &proc_nr))
|
|
|
|
panic("bogus source", m_ptr->m_source);
|
2005-04-21 16:53:53 +02:00
|
|
|
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);
|
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
|
2005-07-14 17:12:12 +02:00
|
|
|
#endif /* USE_GETINFO */
|
2005-04-21 16:53:53 +02:00
|
|
|
|