Просмотр исходного кода

[librm] Add profiling self-tests for complete real_call and prot_call cycles

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 лет назад
Родитель
Сommit
be7f35d9c0
1 измененных файлов: 38 добавлений и 0 удалений
  1. 38
    0
      src/arch/i386/transitions/librm_test.c

+ 38
- 0
src/arch/i386/transitions/librm_test.c Просмотреть файл

@@ -45,6 +45,19 @@ static struct profiler p2r_profiler __profiler = { .name = "p2r" };
45 45
 /** Real-to-protected mode transition profiler */
46 46
 static struct profiler r2p_profiler __profiler = { .name = "r2p" };
47 47
 
48
+/** Real-mode call profiler */
49
+static struct profiler real_call_profiler __profiler = { .name = "real_call" };
50
+
51
+/** Protected-mode call profiler */
52
+static struct profiler prot_call_profiler __profiler = { .name = "prot_call" };
53
+
54
+/**
55
+ * Dummy protected-mode function
56
+ */
57
+static void librm_test_prot_call ( void ) {
58
+	/* Do nothing */
59
+}
60
+
48 61
 /**
49 62
  * Perform real mode transition self-tests
50 63
  *
@@ -52,6 +65,8 @@ static struct profiler r2p_profiler __profiler = { .name = "r2p" };
52 65
 static void librm_test_exec ( void ) {
53 66
 	unsigned int i;
54 67
 	unsigned long timestamp;
68
+	unsigned long started;
69
+	unsigned long stopped;
55 70
 	unsigned int discard_d;
56 71
 
57 72
 	/* Profile mode transitions.  We want to profile each
@@ -68,6 +83,29 @@ static void librm_test_exec ( void ) {
68 83
 		profile_stop ( &r2p_profiler );
69 84
 		profile_stop_at ( &p2r_profiler, timestamp );
70 85
 	}
86
+
87
+	/* Profile complete real-mode call cycle */
88
+	for ( i = 0 ; i < PROFILE_COUNT ; i++ ) {
89
+		profile_start ( &real_call_profiler );
90
+		__asm__ __volatile__ ( REAL_CODE ( "" ) : : );
91
+		profile_stop ( &real_call_profiler );
92
+	}
93
+
94
+	/* Profile complete protected-mode call cycle */
95
+	for ( i = 0 ; i < PROFILE_COUNT ; i++ ) {
96
+		__asm__ __volatile__ ( REAL_CODE ( "rdtsc\n\t"
97
+						   "movl %0, %2\n\t"
98
+						   "pushl %3\n\t"
99
+						   "pushw %%cs\n\t"
100
+						   "call prot_call\n\t"
101
+						   "addw $4, %%sp\n\t"
102
+						   "rdtsc\n\t" )
103
+				       : "=a" ( stopped ), "=d" ( discard_d ),
104
+					 "=r" ( started )
105
+				       : "i" ( librm_test_prot_call ) );
106
+		profile_start_at ( &prot_call_profiler, started );
107
+		profile_stop_at ( &prot_call_profiler, stopped );
108
+	}
71 109
 }
72 110
 
73 111
 /** Real mode transition self-test */

Загрузка…
Отмена
Сохранить