Преглед изворни кода

[pxe] Profile all PXE API calls

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown пре 10 година
родитељ
комит
579337c368
1 измењених фајлова са 49 додато и 0 уклоњено
  1. 49
    0
      src/arch/i386/interface/pxe/pxe_call.c

+ 49
- 0
src/arch/i386/interface/pxe/pxe_call.c Прегледај датотеку

@@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
21 21
 
22 22
 #include <ipxe/uaccess.h>
23 23
 #include <ipxe/init.h>
24
+#include <ipxe/profile.h>
24 25
 #include <setjmp.h>
25 26
 #include <registers.h>
26 27
 #include <biosint.h>
@@ -48,6 +49,26 @@ extern void pxe_int_1a ( void );
48 49
 /** INT 1A hooked flag */
49 50
 static int int_1a_hooked = 0;
50 51
 
52
+/** PXENV_UNDI_TRANSMIT API call profiler */
53
+static struct profiler pxe_api_tx_profiler __profiler =
54
+	{ .name = "pxeapi.tx" };
55
+
56
+/** PXENV_UNDI_ISR API call profiler */
57
+static struct profiler pxe_api_isr_profiler __profiler =
58
+	{ .name = "pxeapi.isr" };
59
+
60
+/** PXE unknown API call profiler
61
+ *
62
+ * This profiler can be used to measure the overhead of a dummy PXE
63
+ * API call.
64
+ */
65
+static struct profiler pxe_api_unknown_profiler __profiler =
66
+	{ .name = "pxeapi.unknown" };
67
+
68
+/** Miscellaneous PXE API call profiler */
69
+static struct profiler pxe_api_misc_profiler __profiler =
70
+	{ .name = "pxeapi.misc" };
71
+
51 72
 /**
52 73
  * Handle an unknown PXE API call
53 74
  *
@@ -80,6 +101,27 @@ static struct pxe_api_call * find_pxe_api_call ( uint16_t opcode ) {
80 101
 	return NULL;
81 102
 }
82 103
 
104
+/**
105
+ * Determine applicable profiler (for debugging)
106
+ *
107
+ * @v opcode		PXE opcode
108
+ * @ret profiler	Profiler
109
+ */
110
+static struct profiler * pxe_api_profiler ( unsigned int opcode ) {
111
+
112
+	/* Determine applicable profiler */
113
+	switch ( opcode ) {
114
+	case PXENV_UNDI_TRANSMIT:
115
+		return &pxe_api_tx_profiler;
116
+	case PXENV_UNDI_ISR:
117
+		return &pxe_api_isr_profiler;
118
+	case PXENV_UNKNOWN:
119
+		return &pxe_api_unknown_profiler;
120
+	default:
121
+		return &pxe_api_misc_profiler;
122
+	}
123
+}
124
+
83 125
 /**
84 126
  * Dispatch PXE API call
85 127
  *
@@ -90,10 +132,14 @@ static struct pxe_api_call * find_pxe_api_call ( uint16_t opcode ) {
90 132
 __asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
91 133
 	uint16_t opcode = ix86->regs.bx;
92 134
 	userptr_t uparams = real_to_user ( ix86->segs.es, ix86->regs.di );
135
+	struct profiler *profiler = pxe_api_profiler ( opcode );
93 136
 	struct pxe_api_call *call;
94 137
 	union u_PXENV_ANY params;
95 138
 	PXENV_EXIT_t ret;
96 139
 
140
+	/* Start profiling */
141
+	profile_start ( profiler );
142
+
97 143
 	/* Locate API call */
98 144
 	call = find_pxe_api_call ( opcode );
99 145
 	if ( ! call ) {
@@ -113,6 +159,9 @@ __asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
113 159
 	/* Copy modified parameter block back to caller and return */
114 160
 	copy_to_user ( uparams, 0, &params, call->params_len );
115 161
 	ix86->regs.ax = ret;
162
+
163
+	/* Stop profiling, if applicable */
164
+	profile_stop ( profiler );
116 165
 }
117 166
 
118 167
 /**

Loading…
Откажи
Сачувај