Browse Source

[pxe] Profile all PXE API calls

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
579337c368
1 changed files with 49 additions and 0 deletions
  1. 49
    0
      src/arch/i386/interface/pxe/pxe_call.c

+ 49
- 0
src/arch/i386/interface/pxe/pxe_call.c View File

21
 
21
 
22
 #include <ipxe/uaccess.h>
22
 #include <ipxe/uaccess.h>
23
 #include <ipxe/init.h>
23
 #include <ipxe/init.h>
24
+#include <ipxe/profile.h>
24
 #include <setjmp.h>
25
 #include <setjmp.h>
25
 #include <registers.h>
26
 #include <registers.h>
26
 #include <biosint.h>
27
 #include <biosint.h>
48
 /** INT 1A hooked flag */
49
 /** INT 1A hooked flag */
49
 static int int_1a_hooked = 0;
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
  * Handle an unknown PXE API call
73
  * Handle an unknown PXE API call
53
  *
74
  *
80
 	return NULL;
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
  * Dispatch PXE API call
126
  * Dispatch PXE API call
85
  *
127
  *
90
 __asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
132
 __asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
91
 	uint16_t opcode = ix86->regs.bx;
133
 	uint16_t opcode = ix86->regs.bx;
92
 	userptr_t uparams = real_to_user ( ix86->segs.es, ix86->regs.di );
134
 	userptr_t uparams = real_to_user ( ix86->segs.es, ix86->regs.di );
135
+	struct profiler *profiler = pxe_api_profiler ( opcode );
93
 	struct pxe_api_call *call;
136
 	struct pxe_api_call *call;
94
 	union u_PXENV_ANY params;
137
 	union u_PXENV_ANY params;
95
 	PXENV_EXIT_t ret;
138
 	PXENV_EXIT_t ret;
96
 
139
 
140
+	/* Start profiling */
141
+	profile_start ( profiler );
142
+
97
 	/* Locate API call */
143
 	/* Locate API call */
98
 	call = find_pxe_api_call ( opcode );
144
 	call = find_pxe_api_call ( opcode );
99
 	if ( ! call ) {
145
 	if ( ! call ) {
113
 	/* Copy modified parameter block back to caller and return */
159
 	/* Copy modified parameter block back to caller and return */
114
 	copy_to_user ( uparams, 0, &params, call->params_len );
160
 	copy_to_user ( uparams, 0, &params, call->params_len );
115
 	ix86->regs.ax = ret;
161
 	ix86->regs.ax = ret;
162
+
163
+	/* Stop profiling, if applicable */
164
+	profile_stop ( profiler );
116
 }
165
 }
117
 
166
 
118
 /**
167
 /**

Loading…
Cancel
Save