. let kernel use read_tsc() from sysutil library
. read_tsc() in sysutil library saves edx and eax now . added read_tsc_64() by Antonio Mancina to load tsc into a 64-bit data type directly . deleted read_tsc.h in favour of a prototype in <minix/syslib.h>
This commit is contained in:
		
							parent
							
								
									4148c24393
								
							
						
					
					
						commit
						6d50591226
					
				@ -11,6 +11,8 @@
 | 
			
		||||
#include <minix/ipc.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <minix/u64.h>
 | 
			
		||||
 | 
			
		||||
#ifndef _DEVIO_H
 | 
			
		||||
#include <minix/devio.h>
 | 
			
		||||
#endif
 | 
			
		||||
@ -205,6 +207,9 @@ _PROTOTYPE( int sys_cprof, (int action, int size, int endpt,
 | 
			
		||||
                                       void *ctl_ptr, void *mem_ptr)   );
 | 
			
		||||
_PROTOTYPE( int sys_profbuf, (void *ctl_ptr, void *mem_ptr)            );
 | 
			
		||||
 | 
			
		||||
/* read_tsc() and friends. */
 | 
			
		||||
_PROTOTYPE( void read_tsc_64, (u64_t *t)				);
 | 
			
		||||
_PROTOTYPE( void read_tsc, (u32_t *hi, u32_t *lo)			);
 | 
			
		||||
 | 
			
		||||
#endif /* _SYSLIB_H */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -32,7 +32,6 @@
 | 
			
		||||
.define	_reset		! reset the system
 | 
			
		||||
.define	_idle_task	! task executed when there is no work
 | 
			
		||||
.define	_level0		! call a function at level 0
 | 
			
		||||
.define	_read_tsc	! read the cycle counter (Pentium and up)
 | 
			
		||||
.define	_read_cpu_flags	! read the cpu flags
 | 
			
		||||
.define	_read_cr0	! read cr0
 | 
			
		||||
.define	_write_cr0	! write a value in cr0
 | 
			
		||||
@ -547,24 +546,6 @@ _level0:
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
!*===========================================================================*
 | 
			
		||||
!*			      read_tsc					     *
 | 
			
		||||
!*===========================================================================*
 | 
			
		||||
! PUBLIC void read_tsc(unsigned long *high, unsigned long *low);
 | 
			
		||||
! Read the cycle counter of the CPU. Pentium and up. 
 | 
			
		||||
! This function clobbers edx and eax.
 | 
			
		||||
.align 16
 | 
			
		||||
_read_tsc:
 | 
			
		||||
.data1 0x0f		! this is the RDTSC instruction 
 | 
			
		||||
.data1 0x31		! it places the TSC in EDX:EAX
 | 
			
		||||
	push ebp
 | 
			
		||||
	mov ebp, 8(esp)
 | 
			
		||||
	mov (ebp), edx
 | 
			
		||||
	mov ebp, 12(esp)
 | 
			
		||||
	mov (ebp), eax
 | 
			
		||||
	pop ebp
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
!*===========================================================================*
 | 
			
		||||
!*			      read_flags					     *
 | 
			
		||||
!*===========================================================================*
 | 
			
		||||
 | 
			
		||||
@ -18,6 +18,7 @@ libsysutil_FILES=" \
 | 
			
		||||
	report.c \
 | 
			
		||||
	taskcall.c \
 | 
			
		||||
	read_tsc.s \
 | 
			
		||||
	read_tsc_64.c \
 | 
			
		||||
	profile_extern.c \
 | 
			
		||||
	profile.c"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,6 @@
 | 
			
		||||
#include <minix/profile.h>
 | 
			
		||||
#include <minix/syslib.h>
 | 
			
		||||
#include <minix/u64.h>
 | 
			
		||||
#include "read_tsc.h"
 | 
			
		||||
 | 
			
		||||
#define U64_LO 0
 | 
			
		||||
#define U64_HI 1
 | 
			
		||||
 | 
			
		||||
@ -1,7 +0,0 @@
 | 
			
		||||
#ifndef READ_TSC_H
 | 
			
		||||
#define READ_TSC_H
 | 
			
		||||
 | 
			
		||||
_PROTOTYPE(void read_tsc, (unsigned long *hi, unsigned long *lo) );
 | 
			
		||||
 | 
			
		||||
#endif /* READ_TSC_H */
 | 
			
		||||
 | 
			
		||||
@ -11,13 +11,17 @@
 | 
			
		||||
! Read the cycle counter of the CPU. Pentium and up. 
 | 
			
		||||
.align 16
 | 
			
		||||
_read_tsc:
 | 
			
		||||
	push edx
 | 
			
		||||
	push eax
 | 
			
		||||
.data1 0x0f		! this is the RDTSC instruction 
 | 
			
		||||
.data1 0x31		! it places the TSC in EDX:EAX
 | 
			
		||||
	push ebp
 | 
			
		||||
	mov ebp, 8(esp)
 | 
			
		||||
	mov ebp, 16(esp)
 | 
			
		||||
	mov (ebp), edx
 | 
			
		||||
	mov ebp, 12(esp)
 | 
			
		||||
	mov ebp, 20(esp)
 | 
			
		||||
	mov (ebp), eax
 | 
			
		||||
	pop ebp
 | 
			
		||||
	pop eax
 | 
			
		||||
	pop edx
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										16
									
								
								lib/sysutil/read_tsc_64.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								lib/sysutil/read_tsc_64.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,16 @@
 | 
			
		||||
 | 
			
		||||
#include "sysutil.h"
 | 
			
		||||
#include <minix/u64.h>
 | 
			
		||||
#include <minix/syslib.h>
 | 
			
		||||
 | 
			
		||||
/* Utility function to work directly with u64_t
 | 
			
		||||
 * By Antonio Mancina
 | 
			
		||||
 */
 | 
			
		||||
PUBLIC void read_tsc_64(t)
 | 
			
		||||
u64_t* t;
 | 
			
		||||
{
 | 
			
		||||
    u32_t lo, hi;
 | 
			
		||||
    read_tsc (&hi, &lo);
 | 
			
		||||
    *t = make64 (lo, hi);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user