2006-10-30 16:53:38 +01:00
|
|
|
/* The kernel call that is implemented in this file:
|
|
|
|
* m_type: SYS_SPROFILE
|
|
|
|
*
|
|
|
|
* The parameters for this kernel call are:
|
|
|
|
* m7_i1: PROF_ACTION (start/stop profiling)
|
|
|
|
* m7_i2: PROF_MEM_SIZE (available memory for data)
|
|
|
|
* m7_i3: PROF_FREQ (requested sample frequency)
|
|
|
|
* m7_i4: PROF_ENDPT (endpoint of caller)
|
|
|
|
* m7_p1: PROF_CTL_PTR (location of info struct)
|
|
|
|
* m7_p2: PROF_MEM_PTR (location of memory for data)
|
|
|
|
*
|
|
|
|
* Changes:
|
|
|
|
* 14 Aug, 2006 Created (Rogier Meurs)
|
|
|
|
*/
|
|
|
|
|
2010-04-02 00:22:33 +02:00
|
|
|
#include "kernel/system.h"
|
2006-10-30 16:53:38 +01:00
|
|
|
|
|
|
|
#if SPROFILE
|
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
/* user address to write info struct */
|
|
|
|
PRIVATE vir_bytes sprof_info_addr_vir;
|
|
|
|
|
2006-10-30 16:53:38 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_sprofile *
|
|
|
|
*===========================================================================*/
|
2010-02-03 10:04:48 +01:00
|
|
|
PUBLIC int do_sprofile(struct proc * caller, message * m_ptr)
|
2006-10-30 16:53:38 +01:00
|
|
|
{
|
2010-01-22 23:01:08 +01:00
|
|
|
int proc_nr;
|
2006-10-30 16:53:38 +01:00
|
|
|
|
|
|
|
switch(m_ptr->PROF_ACTION) {
|
|
|
|
|
|
|
|
case PROF_START:
|
|
|
|
/* Starting profiling.
|
|
|
|
*
|
|
|
|
* Check if profiling is not already running. Calculate physical
|
|
|
|
* addresses of user pointers. Reset counters. Start CMOS timer.
|
|
|
|
* Turn on profiling.
|
|
|
|
*/
|
|
|
|
if (sprofiling) {
|
2010-03-03 16:45:01 +01:00
|
|
|
printf("SYSTEM: start s-profiling: already started\n");
|
2006-10-30 16:53:38 +01:00
|
|
|
return EBUSY;
|
|
|
|
}
|
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
/* Test endpoint number. */
|
|
|
|
if(!isokendpt(m_ptr->PROF_ENDPT, &proc_nr))
|
|
|
|
return EINVAL;
|
2006-10-30 16:53:38 +01:00
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
/* Set parameters for statistical profiler. */
|
|
|
|
sprof_ep = m_ptr->PROF_ENDPT;
|
|
|
|
sprof_info_addr_vir = (vir_bytes) m_ptr->PROF_CTL_PTR;
|
|
|
|
sprof_data_addr_vir = (vir_bytes) m_ptr->PROF_MEM_PTR;
|
2006-10-30 16:53:38 +01:00
|
|
|
|
|
|
|
sprof_info.mem_used = 0;
|
|
|
|
sprof_info.total_samples = 0;
|
|
|
|
sprof_info.idle_samples = 0;
|
|
|
|
sprof_info.system_samples = 0;
|
|
|
|
sprof_info.user_samples = 0;
|
|
|
|
|
|
|
|
sprof_mem_size = m_ptr->PROF_MEM_SIZE;
|
|
|
|
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
init_profile_clock(m_ptr->PROF_FREQ);
|
2006-10-30 16:53:38 +01:00
|
|
|
|
|
|
|
sprofiling = 1;
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
|
|
|
|
case PROF_STOP:
|
|
|
|
/* Stopping profiling.
|
|
|
|
*
|
|
|
|
* Check if profiling is indeed running. Turn off profiling.
|
|
|
|
* Stop CMOS timer. Copy info struct to user process.
|
|
|
|
*/
|
|
|
|
if (!sprofiling) {
|
2010-03-03 16:45:01 +01:00
|
|
|
printf("SYSTEM: stop s-profiling: not started\n");
|
2006-10-30 16:53:38 +01:00
|
|
|
return EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprofiling = 0;
|
|
|
|
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
stop_profile_clock();
|
2006-10-30 16:53:38 +01:00
|
|
|
|
2010-02-09 16:20:09 +01:00
|
|
|
data_copy(KERNEL, (vir_bytes) &sprof_info,
|
2008-11-19 13:26:10 +01:00
|
|
|
sprof_ep, sprof_info_addr_vir, sizeof(sprof_info));
|
2006-10-30 16:53:38 +01:00
|
|
|
|
|
|
|
return OK;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* SPROFILE */
|
|
|
|
|