Add memtest support.
[syslinux-debian/hramrach.git] / com32 / modules / gpxecmd.c
blobd2d90a2fe7aa08a6d1557a37cd5ffb997c14b943
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2008 H. Peter Anvin - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
8 * Boston MA 02110-1301, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
14 * gpxecmd.c
16 * Invoke an arbitrary gPXE command, if available.
19 #include <alloca.h>
20 #include <inttypes.h>
21 #include <stdio.h>
22 #include <console.h>
23 #include <com32.h>
24 #include <string.h>
26 #include <sys/gpxe.h>
27 #include <syslinux/pxe_api.h>
29 struct segoff16 {
30 uint16_t offs, seg;
33 struct s_PXENV_FILE_EXEC {
34 uint16_t Status;
35 struct segoff16 Command;
38 static void gpxecmd(const char **args)
40 char *q;
41 struct s_PXENV_FILE_EXEC *fx;
43 fx = lmalloc(sizeof *fx);
44 if (!fx)
45 return;
47 q = (char *)(fx + 1);
49 fx->Status = 1;
50 fx->Command.offs = OFFS(q);
51 fx->Command.seg = SEG(q);
53 while (*args) {
54 q = stpcpy(q, *args);
55 *q++ = ' ';
56 args++;
58 *--q = '\0';
60 pxe_call(PXENV_FILE_EXEC, fx);
62 /* This should not return... */
65 int main(int argc, const char *argv[])
67 if (argc < 2) {
68 printf("Usage: gpxecmd command...\n");
69 return 1;
72 if (!is_gpxe()) {
73 printf("gpxecmd: gPXE API not detected\n");
74 return 1;
77 gpxecmd(argv + 1);
79 return 0;