Deleted Added
full compact
boot.c (59408) boot.c (59854)
1/*-
2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/boot/common/boot.c 59408 2000-04-20 00:06:15Z ps $
26 * $FreeBSD: head/sys/boot/common/boot.c 59854 2000-05-01 17:41:25Z bp $
27 */
28
29/*
30 * Loading modules, booting the system
31 */
32
33#include <stand.h>
34#include <string.h>

--- 10 unchanged lines hidden (view full) ---

45/*
46 * The user wants us to boot.
47 */
48COMMAND_SET(boot, "boot", "boot a file or loaded kernel", command_boot);
49
50static int
51command_boot(int argc, char *argv[])
52{
27 */
28
29/*
30 * Loading modules, booting the system
31 */
32
33#include <stand.h>
34#include <string.h>

--- 10 unchanged lines hidden (view full) ---

45/*
46 * The user wants us to boot.
47 */
48COMMAND_SET(boot, "boot", "boot a file or loaded kernel", command_boot);
49
50static int
51command_boot(int argc, char *argv[])
52{
53 struct loaded_module *km;
53 struct preloaded_file *fp;
54 char *cp;
55 int try;
56 int i;
57
58 /*
59 * See if the user has specified an explicit kernel to boot.
60 */
61 if ((argc > 1) && (argv[1][0] != '-')) {
62
63 /* XXX maybe we should discard everything and start again? */
54 char *cp;
55 int try;
56 int i;
57
58 /*
59 * See if the user has specified an explicit kernel to boot.
60 */
61 if ((argc > 1) && (argv[1][0] != '-')) {
62
63 /* XXX maybe we should discard everything and start again? */
64 if (mod_findmodule(NULL, NULL) != NULL) {
64 if (file_findfile(NULL, NULL) != NULL) {
65 sprintf(command_errbuf, "can't boot '%s', kernel module already loaded", argv[1]);
66 return(CMD_ERROR);
67 }
68
69 /* find/load the kernel module */
70 if (mod_load(argv[1], argc - 2, argv + 2) != 0)
71 return(CMD_ERROR);
72 /* we have consumed all arguments */
73 argc = 1;
74 }
75
76 /*
77 * See if there is a kernel module already loaded
78 */
65 sprintf(command_errbuf, "can't boot '%s', kernel module already loaded", argv[1]);
66 return(CMD_ERROR);
67 }
68
69 /* find/load the kernel module */
70 if (mod_load(argv[1], argc - 2, argv + 2) != 0)
71 return(CMD_ERROR);
72 /* we have consumed all arguments */
73 argc = 1;
74 }
75
76 /*
77 * See if there is a kernel module already loaded
78 */
79 if (mod_findmodule(NULL, NULL) == NULL) {
79 if (file_findfile(NULL, NULL) == NULL) {
80 for (try = 0; (cp = getbootfile(try)) != NULL; try++) {
81 if (mod_load(cp, argc - 1, argv + 1) != 0) {
82 printf("can't load '%s'\n", cp);
83 } else {
84 /* we have consumed all arguments */
85 argc = 1;
86 break;
87 }
88 }
89 }
90
91 /*
92 * Loaded anything yet?
93 */
80 for (try = 0; (cp = getbootfile(try)) != NULL; try++) {
81 if (mod_load(cp, argc - 1, argv + 1) != 0) {
82 printf("can't load '%s'\n", cp);
83 } else {
84 /* we have consumed all arguments */
85 argc = 1;
86 break;
87 }
88 }
89 }
90
91 /*
92 * Loaded anything yet?
93 */
94 if ((km = mod_findmodule(NULL, NULL)) == NULL) {
94 if ((fp = file_findfile(NULL, NULL)) == NULL) {
95 command_errmsg = "no bootable kernel";
96 return(CMD_ERROR);
97 }
98
99 /*
100 * If we were given arguments, discard any previous.
101 * XXX should we merge arguments? Hard to DWIM.
102 */
103 if (argc > 1) {
95 command_errmsg = "no bootable kernel";
96 return(CMD_ERROR);
97 }
98
99 /*
100 * If we were given arguments, discard any previous.
101 * XXX should we merge arguments? Hard to DWIM.
102 */
103 if (argc > 1) {
104 if (km->m_args != NULL)
105 free(km->m_args);
106 km->m_args = unargv(argc - 1, argv + 1);
104 if (fp->f_args != NULL)
105 free(fp->f_args);
106 fp->f_args = unargv(argc - 1, argv + 1);
107 }
108
109 /* Hook for platform-specific autoloading of modules */
110 if (archsw.arch_autoload() != 0)
111 return(CMD_ERROR);
112
113 /* Call cleanup routines */
114 for (i = 0; devsw[i] != NULL; ++i)
115 if (devsw[i]->dv_cleanup != NULL)
116 (devsw[i]->dv_cleanup)();
117
118 /* Call the exec handler from the loader matching the kernel */
107 }
108
109 /* Hook for platform-specific autoloading of modules */
110 if (archsw.arch_autoload() != 0)
111 return(CMD_ERROR);
112
113 /* Call cleanup routines */
114 for (i = 0; devsw[i] != NULL; ++i)
115 if (devsw[i]->dv_cleanup != NULL)
116 (devsw[i]->dv_cleanup)();
117
118 /* Call the exec handler from the loader matching the kernel */
119 module_formats[km->m_loader]->l_exec(km);
119 file_formats[fp->f_loader]->l_exec(fp);
120 return(CMD_ERROR);
121}
122
123
124/*
125 * Autoboot after a delay
126 */
127

--- 211 unchanged lines hidden ---
120 return(CMD_ERROR);
121}
122
123
124/*
125 * Autoboot after a delay
126 */
127

--- 211 unchanged lines hidden ---