1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#include <alloca.h>
20#include <inttypes.h>
21#include <stdio.h>
22#include <console.h>
23#include <com32.h>
24#include <string.h>
25#include <sys/gpxe.h>
26
27struct segoff16 {
28 uint16_t offs, seg;
29};
30
31struct s_PXENV_FILE_EXEC {
32 uint16_t Status;
33 struct segoff16 Command;
34};
35
36static void gpxecmd(const char **args)
37{
38 char *q;
39 struct s_PXENV_FILE_EXEC *fx;
40 com32sys_t reg;
41
42 memset(®, 0, sizeof reg);
43
44 fx = __com32.cs_bounce;
45 q = (char *)(fx + 1);
46
47 fx->Status = 1;
48 fx->Command.offs = OFFS(q);
49 fx->Command.seg = SEG(q);
50
51 while (*args) {
52 q = stpcpy(q, *args);
53 *q++ = ' ';
54 args++;
55 }
56 *--q = '\0';
57
58 memset(®, 0, sizeof reg);
59 reg.eax.w[0] = 0x0009;
60 reg.ebx.w[0] = 0x00e5;
61 reg.edi.w[0] = OFFS(fx);
62 reg.es = SEG(fx);
63
64 __intcall(0x22, ®, ®);
65
66
67}
68
69int main(int argc, const char *argv[])
70{
71 openconsole(&dev_null_r, &dev_stdcon_w);
72
73 if (argc < 2) {
74 printf("Usage: gpxecmd command...\n");
75 return 1;
76 }
77
78 if (!is_gpxe()) {
79 printf("gpxecmd: gPXE API not detected\n");
80 return 1;
81 }
82
83 gpxecmd(argv + 1);
84
85 return 0;
86}
87