These changes are the raw update to qemu-2.6.
[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  * You can also choose to distribute this program under the terms of
20  * the Unmodified Binary Distribution Licence (as given in the file
21  * COPYING.UBDL), provided that you have satisfied its requirements.
22  */
23
24 #include <ipxe/netdevice.h>
25 #include <ipxe/command.h>
26 #include <ipxe/parseopt.h>
27 #include <hci/ifmgmt_cmd.h>
28 #include <pxe_call.h>
29
30 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
31
32 /** @file
33  *
34  * PXE commands
35  *
36  */
37
38 /** "startpxe" options */
39 struct startpxe_options {};
40
41 /** "startpxe" option list */
42 static struct option_descriptor startpxe_opts[] = {};
43
44 /**
45  * "startpxe" payload
46  *
47  * @v netdev            Network device
48  * @v opts              Command options
49  * @ret rc              Return status code
50  */
51 static int startpxe_payload ( struct net_device *netdev,
52                               struct startpxe_options *opts __unused ) {
53
54         if ( netdev_is_open ( netdev ) )
55                 pxe_activate ( netdev );
56
57         return 0;
58 }
59
60 /** "startpxe" command descriptor */
61 static struct ifcommon_command_descriptor startpxe_cmd =
62         IFCOMMON_COMMAND_DESC ( struct startpxe_options, startpxe_opts,
63                                 0, MAX_ARGUMENTS, "[<interface>]",
64                                 startpxe_payload, 0 );
65
66 /**
67  * The "startpxe" command
68  *
69  * @v argc              Argument count
70  * @v argv              Argument list
71  * @ret rc              Return status code
72  */
73 static int startpxe_exec ( int argc, char **argv ) {
74         return ifcommon_exec ( argc, argv, &startpxe_cmd );
75 }
76
77 /** "stoppxe" options */
78 struct stoppxe_options {};
79
80 /** "stoppxe" option list */
81 static struct option_descriptor stoppxe_opts[] = {};
82
83 /** "stoppxe" command descriptor */
84 static struct command_descriptor stoppxe_cmd =
85         COMMAND_DESC ( struct stoppxe_options, stoppxe_opts, 0, 0, NULL );
86
87 /**
88  * The "stoppxe" command
89  *
90  * @v argc              Argument count
91  * @v argv              Argument list
92  * @ret rc              Return status code
93  */
94 static int stoppxe_exec ( int argc __unused, char **argv __unused ) {
95         struct stoppxe_options opts;
96         int rc;
97
98         /* Parse options */
99         if ( ( rc = parse_options ( argc, argv, &stoppxe_cmd, &opts ) ) != 0 )
100                 return rc;
101
102         pxe_deactivate();
103
104         return 0;
105 }
106
107 /** PXE commands */
108 struct command pxe_commands[] __command = {
109         {
110                 .name = "startpxe",
111                 .exec = startpxe_exec,
112         },
113         {
114                 .name = "stoppxe",
115                 .exec = stoppxe_exec,
116         },
117 };