Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / common / boot / grub2 / commands / i386 / pc / pxecmd.c
blob2a2aadcdd1e7999bed0fdab3705acb47782fd397
1 /* pxe.c - command to control the pxe driver */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2008 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 #include <grub/normal.h>
21 #include <grub/dl.h>
22 #include <grub/arg.h>
23 #include <grub/err.h>
24 #include <grub/misc.h>
25 #include <grub/machine/pxe.h>
27 static const struct grub_arg_option options[] =
29 {"info", 'i', 0, "show PXE information.", 0, 0},
30 {"bsize", 'b', 0, "set PXE block size", 0, ARG_TYPE_INT},
31 {"unload", 'u', 0, "unload PXE stack.", 0, 0},
32 {0, 0, 0, 0, 0, 0}
35 static void
36 print_ip (grub_uint32_t ip)
38 int i;
40 for (i = 0; i < 3; i++)
42 grub_printf ("%d.", ip & 0xFF);
43 ip >>= 8;
45 grub_printf ("%d", ip);
48 static grub_err_t
49 grub_cmd_pxe (struct grub_arg_list *state, int argc __attribute__ ((unused)),
50 char **args __attribute__ ((unused)))
52 if (! grub_pxe_pxenv)
53 return grub_error (GRUB_ERR_FILE_NOT_FOUND, "no pxe environment");
55 if (state[1].set)
57 int size;
59 size = grub_strtoul (state[1].arg, 0, 0);
60 if (size < GRUB_PXE_MIN_BLKSIZE)
61 size = GRUB_PXE_MIN_BLKSIZE;
62 else if (size > GRUB_PXE_MAX_BLKSIZE)
63 size = GRUB_PXE_MAX_BLKSIZE;
65 grub_pxe_blksize = size;
68 if (state[0].set)
70 grub_printf ("blksize : %d\n", grub_pxe_blksize);
71 grub_printf ("client ip : ");
72 print_ip (grub_pxe_your_ip);
73 grub_printf ("\nserver ip : ");
74 print_ip (grub_pxe_server_ip);
75 grub_printf ("\ngateway ip : ");
76 print_ip (grub_pxe_gateway_ip);
77 grub_printf ("\n");
80 if (state[2].set)
81 grub_pxe_unload ();
83 return 0;
86 GRUB_MOD_INIT(pxecmd)
88 (void) mod; /* To stop warning. */
89 grub_register_command ("pxe", grub_cmd_pxe, GRUB_COMMAND_FLAG_BOTH,
90 "pxe [-i|-b|-u]",
91 "Command to control the PXE device.", options);
94 GRUB_MOD_FINI(pxecmd)
96 grub_unregister_command ("pxe");