Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / arch / i386 / hci / commands / pxe_cmd.c
1 /*
2  * Copyright (C) 2010 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  */
19
20 #include <ipxe/netdevice.h>
21 #include <ipxe/command.h>
22 #include <ipxe/parseopt.h>
23 #include <hci/ifmgmt_cmd.h>
24 #include <pxe_call.h>
25
26 FILE_LICENCE ( GPL2_OR_LATER );
27
28 /** @file
29  *
30  * PXE commands
31  *
32  */
33
34 /** "startpxe" options */
35 struct startpxe_options {};
36
37 /** "startpxe" option list */
38 static struct option_descriptor startpxe_opts[] = {};
39
40 /**
41  * "startpxe" payload
42  *
43  * @v netdev            Network device
44  * @v opts              Command options
45  * @ret rc              Return status code
46  */
47 static int startpxe_payload ( struct net_device *netdev,
48                               struct startpxe_options *opts __unused ) {
49
50         if ( netdev_is_open ( netdev ) )
51                 pxe_activate ( netdev );
52
53         return 0;
54 }
55
56 /** "startpxe" command descriptor */
57 static struct ifcommon_command_descriptor startpxe_cmd =
58         IFCOMMON_COMMAND_DESC ( struct startpxe_options, startpxe_opts,
59                                 0, MAX_ARGUMENTS, "[<interface>]",
60                                 startpxe_payload, 0 );
61
62 /**
63  * The "startpxe" command
64  *
65  * @v argc              Argument count
66  * @v argv              Argument list
67  * @ret rc              Return status code
68  */
69 static int startpxe_exec ( int argc, char **argv ) {
70         return ifcommon_exec ( argc, argv, &startpxe_cmd );
71 }
72
73 /** "stoppxe" options */
74 struct stoppxe_options {};
75
76 /** "stoppxe" option list */
77 static struct option_descriptor stoppxe_opts[] = {};
78
79 /** "stoppxe" command descriptor */
80 static struct command_descriptor stoppxe_cmd =
81         COMMAND_DESC ( struct stoppxe_options, stoppxe_opts, 0, 0, NULL );
82
83 /**
84  * The "stoppxe" command
85  *
86  * @v argc              Argument count
87  * @v argv              Argument list
88  * @ret rc              Return status code
89  */
90 static int stoppxe_exec ( int argc __unused, char **argv __unused ) {
91         struct stoppxe_options opts;
92         int rc;
93
94         /* Parse options */
95         if ( ( rc = parse_options ( argc, argv, &stoppxe_cmd, &opts ) ) != 0 )
96                 return rc;
97
98         pxe_deactivate();
99
100         return 0;
101 }
102
103 /** PXE commands */
104 struct command pxe_commands[] __command = {
105         {
106                 .name = "startpxe",
107                 .exec = startpxe_exec,
108         },
109         {
110                 .name = "stoppxe",
111                 .exec = stoppxe_exec,
112         },
113 };